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-12-18 16:51:50 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2011-12-18 16:51:50 +0400
commita885d8aee6eeaf9e202abf147ed769929f859cf3 (patch)
tree18a94bacc4e05a4d8237aa9964f4695ac5b7d245 /source/blender/editors/space_node/node_draw.c
parent8ed5fdde1d0ffd11cfd0df6d1d54b768e7ac4127 (diff)
Fix for toggle buttons in node headers.
The buttons for "hiding" (collapsing) a node, hiding unlinked sockets, additional options, the preview and for opening a node group were all using a custom mouse test function, which was broken. They now use actual buttons instead of just displaying icons. Before executing the respective operators the button's node has to be selected and activated, so the buttons use an intermediate handle function, which selects the node and then calls the operator.
Diffstat (limited to 'source/blender/editors/space_node/node_draw.c')
-rw-r--r--source/blender/editors/space_node/node_draw.c99
1 files changed, 75 insertions, 24 deletions
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 67b4c43343e..7c3e4ad5c54 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -562,6 +562,18 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
}
+/* common handle function for operator buttons that need to select the node first */
+static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv)
+{
+ bNode *node = (bNode*)node_argv;
+ const char *opname = (const char *)op_argv;
+
+ /* select & activate only the button's node */
+ node_select_single(C, node);
+
+ WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL);
+}
+
static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock;
@@ -601,39 +613,54 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
- /* show/hide icons, note this sequence is copied in do_header_node() node_state.c */
+ /* show/hide icons */
iconofs= rct->xmax - 7.0f;
+ /* preview */
if(node->typeinfo->flag & NODE_PREVIEW) {
- float alpha = (node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))? 1.0f: 0.5f;
-
+ uiBut *but;
iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_MATERIAL, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, alpha, "");
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_MATERIAL,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_preview_toggle");
+ /* XXX this does not work when node is activated and the operator called right afterwards,
+ * since active ID is not updated yet (needs to process the notifier).
+ * This can only work as visual indicator!
+ */
+// if (!(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)))
+// uiButSetFlag(but, UI_BUT_DISABLED);
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
}
+ /* group edit */
if(node->type == NODE_GROUP) {
-
+ uiBut *but;
iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_NODETREE, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_NODETREE,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_group_edit");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
}
+ /* option buttons */
if(node->typeinfo->flag & NODE_OPTIONS) {
+ uiBut *but;
iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_BUTS, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
- }
- { /* always hide/reveal unused sockets */
- // XXX re-enable
- /* int shade;
- if(node_has_hidden_sockets(node))
- shade= -40;
- else
- shade= -90; */
-
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_BUTS,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_options_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
+ }
+ /* hide unused sockets */
+ {
+ uiBut *but;
iconofs-=iconbutw;
-
- uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefIconBut(node->block, TOGBUT, B_REDR, ICON_PLUS,
+ iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_socket_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
}
/* title */
@@ -643,7 +670,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
/* open/close entirely? */
- UI_DrawTriIcon(rct->xmin+10.0f, rct->ymax-NODE_DY/2.0f, 'v');
+ {
+ uiBut *but;
+ int but_size = UI_UNIT_X *0.6f;
+ /* XXX button uses a custom triangle draw below, so make it invisible without icon */
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefBut(node->block, TOGBUT, B_REDR, "",
+ rct->xmin+10.0f-but_size/2, rct->ymax-NODE_DY/2.0f-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
+
+ /* custom draw function for this button */
+ UI_DrawTriIcon(rct->xmin+10.0f, rct->ymax-NODE_DY/2.0f, 'v');
+ }
/* this isn't doing anything for the label, so commenting out
if(node->flag & SELECT)
@@ -789,7 +828,19 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
/* open entirely icon */
- UI_DrawTriIcon(rct->xmin+10.0f, centy, 'h');
+ {
+ uiBut *but;
+ int but_size = UI_UNIT_X *0.6f;
+ /* XXX button uses a custom triangle draw below, so make it invisible without icon */
+ uiBlockSetEmboss(node->block, UI_EMBOSSN);
+ but = uiDefBut(node->block, TOGBUT, B_REDR, "",
+ rct->xmin+10.0f-but_size/2, centy-but_size/2, but_size, but_size, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(but, node_toggle_button_cb, node, (void*)"NODE_OT_hide_toggle");
+ uiBlockSetEmboss(node->block, UI_EMBOSS);
+
+ /* custom draw function for this button */
+ UI_DrawTriIcon(rct->xmin+10.0f, centy, 'h');
+ }
/* disable lines */
if(node->flag & NODE_MUTED)