From 3b7d5a8a405e4a2e5fbb0e7cd89d50306db17c27 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 10 Oct 2013 12:58:35 +0000 Subject: [PATCH] Change to node output socket drawing: Instead of always drawing only the socket label for outputs, leave this check up to the socket type draw function. This gives custom node scripts more flexibility in how to draw socket values by allowing buttons on output sockets as well. http://wiki.blender.org/index.php/Extensions:2.6/Py/API_Changes#Python_Node_Output_Drawing --- release/scripts/templates_py/custom_nodes.py | 2 +- source/blender/editors/space_node/drawnode.c | 22 +++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py index 5f002f37161..975ae1881f2 100644 --- a/release/scripts/templates_py/custom_nodes.py +++ b/release/scripts/templates_py/custom_nodes.py @@ -40,7 +40,7 @@ class MyCustomSocket(NodeSocket): # Optional function for drawing the socket input value def draw(self, context, layout, node, text): - if self.is_linked: + if self.is_output or self.is_linked: layout.label(text) else: layout.prop(self, "myEnumProperty", text=text) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b348156bc1f..ae2fed91131 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -86,18 +86,12 @@ static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin uiItemL(layout, text, 0); } -static void node_draw_input_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) +static void node_draw_socket_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) { bNodeSocket *sock = (bNodeSocket *)ptr->data; sock->typeinfo->draw(C, layout, ptr, node_ptr, IFACE_(sock->name)); } -static void node_draw_output_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) -{ - bNodeSocket *sock = ptr->data; - node_socket_button_label(C, layout, ptr, node_ptr, IFACE_(sock->name)); -} - /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ @@ -2752,8 +2746,8 @@ void ED_node_init_butfuncs(void) NodeTypeUndefined.tweak_area_func = node_tweak_area_default; NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; - NodeTypeUndefined.draw_input = node_draw_input_default; - NodeTypeUndefined.draw_output = node_draw_output_default; + NodeTypeUndefined.draw_input = node_draw_socket_default; + NodeTypeUndefined.draw_output = node_draw_socket_default; NodeTypeUndefined.resize_area_func = node_resize_area_default; NodeSocketTypeUndefined.draw = node_socket_undefined_draw; @@ -2770,8 +2764,8 @@ void ED_node_init_butfuncs(void) ntype->tweak_area_func = node_tweak_area_default; ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; - ntype->draw_input = node_draw_input_default; - ntype->draw_output = node_draw_output_default; + ntype->draw_input = node_draw_socket_default; + ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; node_common_set_butfunc(ntype); @@ -2795,8 +2789,8 @@ void ED_init_custom_node_type(bNodeType *ntype) /* default ui functions */ ntype->draw_nodetype = node_draw_default; ntype->draw_nodetype_prepare = node_update_default; - ntype->draw_input = node_draw_input_default; - ntype->draw_output = node_draw_output_default; + ntype->draw_input = node_draw_socket_default; + ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; ntype->select_area_func = node_select_area_default; ntype->tweak_area_func = node_tweak_area_default; @@ -2840,7 +2834,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - if ((sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) { + if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) { node_socket_button_label(C, layout, ptr, node_ptr, text); return; }