diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-05-29 16:43:37 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-05-29 16:43:37 +0400 |
commit | 902dbbe301b1a27f672a2dca441bf9c09babe3af (patch) | |
tree | fecb60b76bcbb761dfbb7cf55a6070f92ee0bb9a | |
parent | 9eb93a9d9c775f950f43dab61653f6365e0f3123 (diff) |
Replacement for the "Active Node" panel in node editor properties sidebar. This panel is now defined in space_node.py instead of node_buttons.c. The properties have been split up into generic properties
(name, label), custom colors (closed by default) and input parameters (extra options + unlinked input socket values).
-rw-r--r-- | release/scripts/startup/bl_ui/space_node.py | 117 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_buttons.c | 104 |
2 files changed, 99 insertions, 122 deletions
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index b54162a0cb4..6072774538f 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -231,8 +231,106 @@ class NODE_MT_node(Menu): layout.operator("node.read_fullsamplelayers") +class NODE_MT_node_color_presets(Menu): + """Predefined node color""" + bl_label = "Color Presets" + preset_subdir = "node_color" + preset_operator = "script.execute_preset" + draw = Menu.draw_preset + + +class NODE_MT_node_color_specials(Menu): + bl_label = "Node Color Specials" + + def draw(self, context): + layout = self.layout + + layout.operator("node.node_copy_color", icon='COPY_ID') + + +class NODE_PT_active_node_generic(Panel): + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'UI' + bl_label = "Node" +# bl_options = {'HIDE_HEADER'} + + @classmethod + def poll(cls, context): + space = context.space_data + return context.active_node is not None + + def draw(self, context): + layout = self.layout + node = context.active_node + + layout.prop(node, "name", icon='NODE') + layout.prop(node, "label", icon='NODE') + + +class NODE_PT_active_node_color(Panel): + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'UI' + bl_label = "Color" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + space = context.space_data + return context.active_node is not None + + def draw_header(self, context): + node = context.active_node + self.layout.prop(node, "use_custom_color", text="") + + def draw(self, context): + layout = self.layout + node = context.active_node + + layout.enabled = node.use_custom_color + + row = layout.row() + col = row.column() + col.menu("NODE_MT_node_color_presets") + col.prop(node, "color", text="") + col = row.column(align=True) + col.operator("node.node_color_preset_add", text="", icon='ZOOMIN').remove_active = False + col.operator("node.node_color_preset_add", text="", icon='ZOOMOUT').remove_active = True + col.menu("NODE_MT_node_color_specials", text="", icon='DOWNARROW_HLT') + + +class NODE_PT_active_node_properties(Panel): + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'UI' + bl_label = "Properties" + + @classmethod + def poll(cls, context): + space = context.space_data + return context.active_node is not None + + def draw(self, context): + layout = self.layout + node = context.active_node + # set "node" context pointer for the panel layout + layout.context_pointer_set("node", node) + + if hasattr(node, "draw_buttons_ext"): + node.draw_buttons_ext(context, layout) + elif hasattr(node, "draw_buttons"): + node.draw_buttons(context, layout) + + # XXX this could be filtered further to exclude socket types which don't have meaningful input values (e.g. cycles shader) + value_inputs = [socket for socket in node.inputs if socket.enabled and not socket.hide and not socket.is_linked] + if value_inputs: + layout.separator() + layout.label("Inputs:") + for socket in value_inputs: + row = layout.row() + socket.draw(context, row, node, socket.name) + + # Node Backdrop options -class NODE_PT_properties(Panel): +class NODE_PT_backdrop(Panel): bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' bl_label = "Backdrop" @@ -291,23 +389,6 @@ class NODE_PT_quality(bpy.types.Panel): col.prop(snode, "use_hidden_preview") -class NODE_MT_node_color_presets(Menu): - """Predefined node color""" - bl_label = "Color Presets" - preset_subdir = "node_color" - preset_operator = "script.execute_preset" - draw = Menu.draw_preset - - -class NODE_MT_node_color_specials(Menu): - bl_label = "Node Color Specials" - - def draw(self, context): - layout = self.layout - - layout.operator("node.node_copy_color", icon='COPY_ID') - - class NODE_UL_interface_sockets(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): socket = item diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 2860bc93892..7068973b2bf 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -65,102 +65,6 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) return (snode && snode->nodetree); } -/* poll callback for active node */ -static int active_node_poll(const bContext *C, PanelType *UNUSED(pt)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - return (snode && snode->edittree && nodeGetActive(snode->edittree)); -} - -/* active node */ -static void active_node_panel(const bContext *C, Panel *pa) -{ - SpaceNode *snode = CTX_wm_space_node(C); - bNodeTree *ntree = (snode) ? snode->edittree : NULL; - bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; // xxx... for editing group nodes - bNodeSocket *sock; - uiLayout *layout, *row, *col, *sub; - PointerRNA ptr, opptr; - bool show_inputs; - - /* verify pointers, and create RNA pointer for the node */ - if (ELEM(NULL, ntree, node)) - return; - //if (node->id) /* for group nodes */ - // RNA_pointer_create(node->id, &RNA_Node, node, &ptr); - //else - RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - - layout = uiLayoutColumn(pa->layout, FALSE); - uiLayoutSetContextPointer(layout, "node", &ptr); - - /* draw this node's name, etc. */ - uiItemR(layout, &ptr, "label", 0, NULL, ICON_NODE); - uiItemS(layout); - uiItemR(layout, &ptr, "name", 0, NULL, ICON_NODE); - uiItemS(layout); - - uiItemO(layout, NULL, 0, "NODE_OT_hide_socket_toggle"); - uiItemS(layout); - uiItemS(layout); - - row = uiLayoutRow(layout, FALSE); - - col = uiLayoutColumn(row, TRUE); - uiItemM(col, (bContext *)C, "NODE_MT_node_color_presets", NULL, 0); - uiItemR(col, &ptr, "use_custom_color", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); - sub = uiLayoutRow(col, FALSE); - if (!(node->flag & NODE_CUSTOM_COLOR)) - uiLayoutSetEnabled(sub, FALSE); - uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); - - col = uiLayoutColumn(row, TRUE); - uiItemO(col, "", ICON_ZOOMIN, "node.node_color_preset_add"); - opptr = uiItemFullO(col, "node.node_color_preset_add", "", ICON_ZOOMOUT, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); - RNA_boolean_set(&opptr, "remove_active", 1); - uiItemM(col, (bContext *)C, "NODE_MT_node_color_specials", "", ICON_DOWNARROW_HLT); - - /* draw this node's settings */ - if (node->typeinfo && node->typeinfo->uifuncbut) { - uiItemS(layout); - uiItemS(layout); - node->typeinfo->uifuncbut(layout, (bContext *)C, &ptr); - } - else if (node->typeinfo && node->typeinfo->uifunc) { - uiItemS(layout); - uiItemS(layout); - node->typeinfo->uifunc(layout, (bContext *)C, &ptr); - } - - uiItemS(layout); - - /* socket input values */ - /* XXX this is not quite perfect yet, it still shows sockets without meaningful input values - * and does not yet use the socket link template - but better than nothing. - * Eventually could move this panel to python - * and leave it up to the individual node system implementation. - */ - show_inputs = false; - for (sock = node->inputs.first; sock; sock = sock->next) { - if (!nodeSocketIsHidden(sock) && !(sock->flag & SOCK_IN_USE)) { - show_inputs = true; - break; - } - } - if (show_inputs) { - uiItemL(layout, "Inputs:", 0); - for (sock = node->inputs.first; sock; sock = sock->next) { - if (!nodeSocketIsHidden(sock) && !(sock->flag & SOCK_IN_USE)) { - uiLayout *row = uiLayoutRow(layout, false); - PointerRNA sock_ptr; - RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sock_ptr); - sock->typeinfo->draw((bContext *)C, row, &sock_ptr, &ptr, sock->name); - } - } - } -} - static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); @@ -275,14 +179,6 @@ void node_buttons_register(ARegionType *art) { PanelType *pt; - pt = MEM_callocN(sizeof(PanelType), "spacetype node panel active node"); - strcpy(pt->idname, "NODE_PT_item"); - strcpy(pt->label, N_("Active Node")); - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = active_node_panel; - pt->poll = active_node_poll; - BLI_addtail(&art->paneltypes, pt); - pt = MEM_callocN(sizeof(PanelType), "spacetype node panel node sockets"); strcpy(pt->idname, "NODE_PT_sockets"); strcpy(pt->label, N_("Sockets")); |