Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-11-22 21:49:06 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2011-11-22 21:49:06 +0400
commitb450d3c3b6585cefe52d007c0088c4dc7b2e78ec (patch)
treefc4cb80a0b3c3940b8529b8620dd7bff49a10467 /source/blender/editors/space_node
parent470cfd4aeb010b4a674d27ace3cfffad2ca6c4f0 (diff)
Fix for long-standing TODO item: Clicking on overlapping nodes would activate buttons below.
This patch adds a new CLIP_EVENTS flag for uiBlock, which will prevent the ui_but_find_mouse_over search function from looking into "lower" uiBlocks (i.e. those further back in the list). The order of block creation for nodes has also been updated to use the z-ordering (just the nodetree->nodes list). In order for this to work, the bounding box values of the uiBlocks have to be set explicitely to fit the node size, those are usually either zero or calculated from the internal buttons.
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/drawnode.c10
-rw-r--r--source/blender/editors/space_node/node_draw.c40
2 files changed, 33 insertions, 17 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 29f67844827..4e9ac08d8c8 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -471,6 +471,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
float locx, locy;
rctf *rect= &gnode->totr;
float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
+ float group_header= 26*U.dpi/72;
int counter;
int dy;
@@ -594,6 +595,15 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
gsock = gsock->next;
}
}
+
+ /* Set the block bounds to clip mouse events from underlying nodes.
+ * Add margin for header and input/output columns.
+ */
+ uiExplicitBoundsBlock(gnode->block,
+ rect->xmin - node_group_frame,
+ rect->ymin,
+ rect->xmax + node_group_frame,
+ rect->ymax + group_header);
}
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index c4a7f2cb473..024db35a084 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -197,28 +197,16 @@ 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 */
+ /* add node uiBlocks in drawing 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) {
+ for(node= ntree->nodes.first; node; node=node->next) {
/* ui block */
sprintf(str, "node buttons %p", (void *)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", (void *)node);
- node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS);
- uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node);
- }
+
+ /* this cancels events for background nodes */
+ uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS);
}
}
@@ -339,6 +327,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->totr.xmax= locx + node->width;
node->totr.ymax= locy;
node->totr.ymin= MIN2(dy, locy-2*NODE_DY);
+
+ /* Set the block bounds to clip mouse events from underlying nodes.
+ * Add a margin for sockets on each side.
+ */
+ uiExplicitBoundsBlock(node->block,
+ node->totr.xmin - NODE_SOCKSIZE,
+ node->totr.ymin,
+ node->totr.xmax + NODE_SOCKSIZE,
+ node->totr.ymax);
}
/* based on settings in node, sets drawing rect info. each redraw! */
@@ -391,6 +388,15 @@ static void node_update_hidden(bNode *node)
rad+= drad;
}
}
+
+ /* Set the block bounds to clip mouse events from underlying nodes.
+ * Add a margin for sockets on each side.
+ */
+ uiExplicitBoundsBlock(node->block,
+ node->totr.xmin - NODE_SOCKSIZE,
+ node->totr.ymin,
+ node->totr.xmax + NODE_SOCKSIZE,
+ node->totr.ymax);
}
void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node)