[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48767] trunk/blender/source/blender/ editors/space_node: style cleanup: node drawing

Campbell Barton ideasman42 at gmail.com
Mon Jul 9 21:58:37 CEST 2012


Revision: 48767
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48767
Author:   campbellbarton
Date:     2012-07-09 19:58:36 +0000 (Mon, 09 Jul 2012)
Log Message:
-----------
style cleanup: node drawing

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_draw.c

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2012-07-09 19:50:43 UTC (rev 48766)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2012-07-09 19:58:36 UTC (rev 48767)
@@ -994,7 +994,7 @@
 	float alpha;
 	
 	UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
-	alpha = (float)(color[3])/255.0f;
+	alpha = (float)(color[3]) / 255.0f;
 	
 	/* skip if out of view */
 	if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
@@ -1074,7 +1074,7 @@
 }
 
 
-#define NODE_REROUTE_SIZE	8.0f
+#define NODE_REROUTE_SIZE  8.0f
 
 static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
 {
@@ -1086,36 +1086,36 @@
 	nodeToView(node, 0.0f, 0.0f, &locx, &locy);
 	
 	/* reroute node has exactly one input and one output, both in the same place */
-	nsock= node->outputs.first;
-	nsock->locx= locx;
-	nsock->locy= locy;
+	nsock = node->outputs.first;
+	nsock->locx = locx;
+	nsock->locy = locy;
 
-	nsock= node->inputs.first;
-	nsock->locx= locx;
-	nsock->locy= locy;
-	
-	node->width = size*2;
-	node->totr.xmin= locx - size;
-	node->totr.xmax= locx + size;
-	node->totr.ymax= locy + size;
-	node->totr.ymin= locy - size;
+	nsock = node->inputs.first;
+	nsock->locx = locx;
+	nsock->locy = locy;
+
+	node->width = size * 2.0f;
+	node->totr.xmin = locx - size;
+	node->totr.xmax = locx + size;
+	node->totr.ymax = locy + size;
+	node->totr.ymin = locy - size;
 }
 
 static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode),  bNodeTree *ntree, bNode *node)
 {
 	bNodeSocket *sock;
-	#if 0	/* UNUSED */
-	rctf *rct= &node->totr;
+	#if 0   /* UNUSED */
+	rctf *rct = &node->totr;
 	float size = NODE_REROUTE_SIZE;
 	#endif
-	float socket_size= NODE_SOCKSIZE;
+	float socket_size = NODE_SOCKSIZE;
 
 	/* skip if out of view */
 	if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
-			node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
-
+	    node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
+	{
 		uiEndBlock(C, node->block);
-		node->block= NULL;
+		node->block = NULL;
 		return;
 	}
 
@@ -1134,12 +1134,12 @@
 	if (node->flag & (NODE_ACTIVE | SELECT)) {
 		glEnable(GL_BLEND);
 		glEnable(GL_LINE_SMOOTH);
-			/* using different shades of TH_TEXT_HI for the empasis, like triangle */
-			if (node->flag & NODE_ACTIVE)
-				UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
-			else
-				UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
-			uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
+		/* using different shades of TH_TEXT_HI for the empasis, like triangle */
+		if (node->flag & NODE_ACTIVE)
+			UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
+		else
+			UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
+		uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
 
 		glDisable(GL_LINE_SMOOTH);
 		glDisable(GL_BLEND);
@@ -1149,13 +1149,13 @@
 	/* only draw input socket. as they all are placed on the same position.
 	 * highlight also if node itself is selected, since we don't display the node body separately!
 	 */
-	for (sock= node->inputs.first; sock; sock= sock->next) {
+	for (sock = node->inputs.first; sock; sock = sock->next) {
 		node_socket_circle_draw(ntree, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT));
 	}
 
 	uiEndBlock(C, node->block);
 	uiDrawBlock(C, node->block);
-	node->block= NULL;
+	node->block = NULL;
 }
 
 /* Special tweak area for reroute node.
@@ -1164,12 +1164,12 @@
 static int node_tweak_area_reroute(bNode *node, int x, int y)
 {
 	/* square of tweak radius */
-	static const float tweak_radius_sq = 576;	/* 24*24 */
+	static const float tweak_radius_sq = 576;   /* 24*24 */
 	
 	bNodeSocket *sock = node->inputs.first;
 	float dx = sock->locx - x;
 	float dy = sock->locy - y;
-	return (dx*dx + dy*dy <= tweak_radius_sq);
+	return (dx * dx + dy * dy <= tweak_radius_sq);
 }
 
 static void node_common_set_butfunc(bNodeType *ntype)
@@ -1197,9 +1197,9 @@
 			ntype->resize_area_func = node_resize_area_frame;
 			break;
 		case NODE_REROUTE:
-			ntype->drawfunc= node_draw_reroute;
-			ntype->drawupdatefunc= node_update_reroute;
-			ntype->tweak_area_func= node_tweak_area_reroute;
+			ntype->drawfunc = node_draw_reroute;
+			ntype->drawupdatefunc = node_update_reroute;
+			ntype->tweak_area_func = node_tweak_area_reroute;
 			break;
 	}
 }
@@ -2468,7 +2468,7 @@
 
 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
-	bNode *node= ptr->data;
+	bNode *node = ptr->data;
 
 	uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
 
@@ -2691,7 +2691,7 @@
 			ntype->uibackdropfunc = node_composit_backdrop_viewer;
 			break;
 		case CMP_NODE_MASK:
-			ntype->uifunc= node_composit_buts_mask;
+			ntype->uifunc = node_composit_buts_mask;
 			break;
 		case CMP_NODE_KEYINGSCREEN:
 			ntype->uifunc = node_composit_buts_keyingscreen;
@@ -3123,27 +3123,31 @@
 	deltay = vec[3][1] - vec[0][1];
 	/* check direction later, for top sockets */
 	if (fromreroute) {
-		if (ABS(deltax)>ABS(deltay)) {
-			vec[1][1]= vec[0][1];
-			vec[1][0]= vec[0][0]+(deltax>0?dist:-dist);
-		} else {
-			vec[1][0]= vec[0][0];
-			vec[1][1]= vec[0][1]+(deltay>0?dist:-dist);
+		if (ABS(deltax) > ABS(deltay)) {
+			vec[1][1] = vec[0][1];
+			vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist);
 		}
-	} else {
+		else {
+			vec[1][0] = vec[0][0];
+			vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist);
+		}
+	}
+	else {
 		vec[1][0] = vec[0][0] + dist;
 		vec[1][1] = vec[0][1];
 	}
 	if (toreroute) {
-		if (ABS(deltax)>ABS(deltay)) {
-			vec[2][1]= vec[3][1];
-			vec[2][0]= vec[3][0]+ (deltax>0?-dist:dist);
-		} else {
-			vec[2][0]= vec[3][0];
-			vec[2][1]= vec[3][1]+(deltay>0?-dist:dist);
+		if (ABS(deltax) > ABS(deltay)) {
+			vec[2][1] = vec[3][1];
+			vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist);
 		}
+		else {
+			vec[2][0] = vec[3][0];
+			vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist);
+		}
 
-	} else {
+	}
+	else {
 		vec[2][0] = vec[3][0] - dist;
 		vec[2][1] = vec[3][1];
 	}
@@ -3161,8 +3165,8 @@
 }
 
 #define LINK_RESOL  24
-#define LINK_ARROW	12	/* position of arrow on the link, LINK_RESOL/2 */
-#define ARROW_SIZE 7
+#define LINK_ARROW  12  /* position of arrow on the link, LINK_RESOL/2 */
+#define ARROW_SIZE  7
 void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
 {
 	float coord_array[LINK_RESOL + 1][2];

Modified: trunk/blender/source/blender/editors/space_node/node_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_draw.c	2012-07-09 19:50:43 UTC (rev 48766)
+++ trunk/blender/source/blender/editors/space_node/node_draw.c	2012-07-09 19:58:36 UTC (rev 48767)
@@ -82,7 +82,7 @@
 #include "node_intern.h"
 
 /* width of socket columns in group display */
-#define NODE_GROUP_FRAME		120
+#define NODE_GROUP_FRAME  120
 // XXX interface.h
 extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
 
@@ -91,8 +91,8 @@
 {
 	snode_set_context(snode, scene);
 	
-	if (snode->nodetree && snode->nodetree->id.us==0)
-		snode->nodetree->id.us= 1;
+	if (snode->nodetree && snode->nodetree->id.us == 0)
+		snode->nodetree->id.us = 1;
 }
 
 void ED_node_changed_update(ID *id, bNode *node)
@@ -102,30 +102,30 @@
 
 	node_tree_from_ID(id, &nodetree, &edittree, &treetype);
 
-	if (treetype==NTREE_SHADER) {
+	if (treetype == NTREE_SHADER) {
 		DAG_id_tag_update(id, 0);
 
 		if (GS(id->name) == ID_MA)
-			WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, id);
+			WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, id);
 		else if (GS(id->name) == ID_LA)
-			WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, id);
+			WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, id);
 		else if (GS(id->name) == ID_WO)
-			WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id);
+			WM_main_add_notifier(NC_WORLD | ND_WORLD_DRAW, id);
 	}
-	else if (treetype==NTREE_COMPOSIT) {
+	else if (treetype == NTREE_COMPOSIT) {
 		if (node)
 			nodeUpdate(edittree, node);
 		/* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */
 			
-		node= node_tree_get_editgroup(nodetree);
+		node = node_tree_get_editgroup(nodetree);
 		if (node)
 			nodeUpdateID(nodetree, node->id);
 
-		WM_main_add_notifier(NC_SCENE|ND_NODES, id);
+		WM_main_add_notifier(NC_SCENE | ND_NODES, id);
 	}			
-	else if (treetype==NTREE_TEXTURE) {
+	else if (treetype == NTREE_TEXTURE) {
 		DAG_id_tag_update(id, 0);
-		WM_main_add_notifier(NC_TEXTURE|ND_NODES, id);
+		WM_main_add_notifier(NC_TEXTURE | ND_NODES, id);
 	}
 }
 
@@ -136,9 +136,9 @@
 	if (ntree == lookup)
 		return 1;
 	
-	for (node=ntree->nodes.first; node; node=node->next)
+	for (node = ntree->nodes.first; node; node = node->next)
 		if (node->type == NODE_GROUP && node->id)
-			if (has_nodetree((bNodeTree*)node->id, lookup))
+			if (has_nodetree((bNodeTree *)node->id, lookup))
 				return 1;
 	
 	return 0;
@@ -150,14 +150,14 @@
 } NodeUpdateCalldata;
 static void node_generic_update_cb(void *calldata, ID *owner_id, bNodeTree *ntree)
 {
-	NodeUpdateCalldata *cd= (NodeUpdateCalldata*)calldata;
+	NodeUpdateCalldata *cd = (NodeUpdateCalldata *)calldata;
 	/* check if nodetree uses the group stored in calldata */
 	if (has_nodetree(ntree, cd->ntree))
 		ED_node_changed_update(owner_id, cd->node);
 }
 void ED_node_generic_update(Main *bmain, bNodeTree *ntree, bNode *node)
 {
-	bNodeTreeType *tti= ntreeGetType(ntree->type);
+	bNodeTreeType *tti = ntreeGetType(ntree->type);
 	NodeUpdateCalldata cd;
 	cd.ntree = ntree;
 	cd.node = node;
@@ -174,14 +174,14 @@
 	/* These tell if either the node or any of the parent nodes is selected.
 	 * A selected parent means an unselected node is also in foreground!
 	 */
-	int a_select=(a->flag & NODE_SELECT), b_select=(b->flag & NODE_SELECT);
-	int a_active=(a->flag & NODE_ACTIVE), b_active=(b->flag & NODE_ACTIVE);
+	int a_select = (a->flag & NODE_SELECT), b_select = (b->flag & NODE_SELECT);
+	int a_active = (a->flag & NODE_ACTIVE), b_active = (b->flag & NODE_ACTIVE);
 	
 	/* if one is an ancestor of the other */
 	/* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list