[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25917] trunk/blender/source/blender/ editors/space_node/node_draw.c: Partial fix for [#19926] clicks " fall through" when stacking nodes

Matt Ebb matt at mke3.net
Tue Jan 12 08:07:51 CET 2010


Revision: 25917
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25917
Author:   broken
Date:     2010-01-12 08:07:51 +0100 (Tue, 12 Jan 2010)

Log Message:
-----------
Partial fix for [#19926] clicks "fall through" when stacking nodes

This still isn't ideal, but a bit better than before, it just tweaks the order of 
block processing so that at least the buttons on top of other buttons get processed first.

The actual fix will be quite tricky, not sure about how best to do that so far..

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

Modified: trunk/blender/source/blender/editors/space_node/node_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_draw.c	2010-01-12 05:54:15 UTC (rev 25916)
+++ trunk/blender/source/blender/editors/space_node/node_draw.c	2010-01-12 07:07:51 UTC (rev 25917)
@@ -161,6 +161,36 @@
 	fdrawline(xmin+dx, ymin+aspect, xmax, ymax-dy+aspect);
 }
 
+static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
+{
+	bNode *node;
+	char str[32];
+	
+	/* add node uiBlocks in reverse order - prevents events going to overlapping nodes */
+	
+	/* process selected nodes first so they're at the start of the uiblocks list */
+	for(node= ntree->nodes.last; node; node= node->prev) {
+		
+		if (node->flag & NODE_SELECT) {
+			/* ui block */
+			sprintf(str, "node buttons %p", node);
+			node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
+			uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
+		}
+	}
+	
+	/* then the rest */
+	for(node= ntree->nodes.last; node; node= node->prev) {
+		
+		if (!(node->flag & (NODE_GROUP_EDIT|NODE_SELECT))) {
+			/* ui block */
+			sprintf(str, "node buttons %p", node);
+			node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
+			uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
+		}
+	}
+}
+
 /* based on settings in node, sets drawing rect info. each redraw! */
 static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
 {
@@ -169,7 +199,6 @@
 	bNodeSocket *nsock;
 	float dy= node->locy;
 	int buty;
-	char str[32];
 	
 	/* header */
 	dy-= NODE_DY;
@@ -237,11 +266,6 @@
 	/* XXX ugly hack, typeinfo for group is generated */
 	if(node->type == NODE_GROUP)
 		; // XXX node->typeinfo->uifunc= node_buts_group;
-
-	/* ui block */
-	sprintf(str, "node buttons %p", node);
-	node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
-	uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
 	
 	/* buttons rect? */
 	if((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) {
@@ -290,7 +314,6 @@
 	bNodeSocket *nsock;
 	float rad, drad, hiddenrad= HIDDEN_RAD;
 	int totin=0, totout=0, tot;
-	char str[32];
 	
 	/* calculate minimal radius */
 	for(nsock= node->inputs.first; nsock; nsock= nsock->next)
@@ -331,11 +354,6 @@
 			rad+= drad;
 		}
 	}
-
-	/* ui block */
-	sprintf(str, "node buttons %p", node);
-	node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
-	uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
 }
 
 static int node_get_colorid(bNode *node)
@@ -368,10 +386,14 @@
 	rctf *rect= &gnode->totr;
 	int counter;
 	
+	/* init ui blocks for sub-nodetrees */
+	node_uiblocks_init(C, ngroup);
+	
 	/* center them, is a bit of abuse of locx and locy though */
 	for(node= ngroup->nodes.first; node; node= node->next) {
 		node->locx+= gnode->locx;
 		node->locy+= gnode->locy;
+		
 		if(node->flag & NODE_HIDDEN)
 			node_update_hidden(C, node);
 		else
@@ -504,29 +526,21 @@
 {
 	int col[3];
 	
-	/* choose color based on sock flags */
-	if(sock->flag & SELECT) {
-		if(sock->type==SOCK_VALUE) {
-			col[0]= 200; col[1]= 200; col[2]= 200;}
-		else if(sock->type==SOCK_VECTOR) {
-			col[0]= 140; col[1]= 140; col[2]= 240;}
-		else if(sock->type==SOCK_RGBA) {
-			col[0]= 240; col[1]= 240; col[2]= 100;}
-		else {
-			col[0]= 140; col[1]= 240; col[2]= 140;}
+	if(sock->type==-1) {
+		col[0]= 0; col[1]= 0; col[2]= 0;
 	}
-	else {
-		if(sock->type==-1) {
-			col[0]= 0; col[1]= 0; col[2]= 0;}
-		else if(sock->type==SOCK_VALUE) {
-			col[0]= 160; col[1]= 160; col[2]= 160;}
-		else if(sock->type==SOCK_VECTOR) {
-			col[0]= 100; col[1]= 100; col[2]= 200;}
-		else if(sock->type==SOCK_RGBA) {
-			col[0]= 200; col[1]= 200; col[2]= 40;}
-		else { 
-			col[0]= 100; col[1]= 200; col[2]= 100;}
+	else if(sock->type==SOCK_VALUE) {
+		col[0]= 160; col[1]= 160; col[2]= 160;
 	}
+	else if(sock->type==SOCK_VECTOR) {
+		col[0]= 100; col[1]= 100; col[2]= 200;
+	}
+	else if(sock->type==SOCK_RGBA) {
+		col[0]= 200; col[1]= 200; col[2]= 40;
+	}
+	else { 
+		col[0]= 100; col[1]= 200; col[2]= 100;
+	}
 	
 	circle_draw(sock->locx, sock->locy, size, sock->type, col);
 }
@@ -1079,6 +1093,8 @@
 	if(snode->nodetree) {
 		bNode *node;
 		
+		node_uiblocks_init(C, snode->nodetree);
+		
 		/* for now, we set drawing coordinates on each redraw */
 		for(node= snode->nodetree->nodes.first; node; node= node->next) {
 			if(node->flag & NODE_GROUP_EDIT)





More information about the Bf-blender-cvs mailing list