Revision: 60662 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60662 Author: lukastoenne Date: 2013-10-10 13:07:09 +0000 (Thu, 10 Oct 2013) Log Message: ----------- Get rid of the draw_input/draw_output callbacks for nodes. These are pretty useless wrappers around socket draw functions. Only use-case is the File Output node, which draws socket format type instead of an input value. This is now a special case in the standard socket type drawing, but should eventually become a socket type of its own for the File Output node.
Modified Paths: -------------- trunk/blender/source/blender/blenkernel/BKE_node.h trunk/blender/source/blender/editors/space_node/drawnode.c trunk/blender/source/blender/editors/space_node/node_draw.c Modified: trunk/blender/source/blender/blenkernel/BKE_node.h =================================================================== --- trunk/blender/source/blender/blenkernel/BKE_node.h 2013-10-10 12:58:35 UTC (rev 60661) +++ trunk/blender/source/blender/blenkernel/BKE_node.h 2013-10-10 13:07:09 UTC (rev 60662) @@ -131,8 +131,6 @@ int type, subtype; } bNodeSocketType; -typedef void (*NodeSocketDrawFunction)(struct bContext *C, struct uiLayout *layout, struct PointerRNA *ptr, struct PointerRNA *node_ptr); - typedef void *(*NodeInitExecFunction)(struct bNodeExecContext *context, struct bNode *node, bNodeInstanceKey key); typedef void (*NodeFreeExecFunction)(struct bNode *node, void *nodedata); typedef void (*NodeExecFunction)(void *data, int thread, struct bNode *, struct bNodeExecData *execdata, struct bNodeStack **in, struct bNodeStack **out); @@ -176,13 +174,6 @@ /* Additional drawing on backdrop */ void (*draw_backdrop)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); - /* Draw a node socket. Default draws the input value button. */ - /* XXX deprecated, only used for the OutputFile node, - * should be removed at some point. - */ - NodeSocketDrawFunction draw_input; - NodeSocketDrawFunction draw_output; - /// Optional custom label function for the node header. const char *(*labelfunc)(struct bNode *); /// Optional custom resize handle polling. Modified: trunk/blender/source/blender/editors/space_node/drawnode.c =================================================================== --- trunk/blender/source/blender/editors/space_node/drawnode.c 2013-10-10 12:58:35 UTC (rev 60661) +++ trunk/blender/source/blender/editors/space_node/drawnode.c 2013-10-10 13:07:09 UTC (rev 60662) @@ -86,13 +86,7 @@ uiItemL(layout, text, 0); } -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)); -} - /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ #if 0 /* UNUSED */ @@ -1572,46 +1566,6 @@ uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); } -/* draw function for file output node sockets, displays only sub-path and format, no value button */ -static void node_draw_input_file_output(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) -{ - bNodeTree *ntree = ptr->id.data; - bNodeSocket *sock = ptr->data; - uiLayout *row; - PointerRNA inputptr, imfptr; - int imtype; - - row = uiLayoutRow(layout, FALSE); - - imfptr = RNA_pointer_get(node_ptr, "format"); - imtype = RNA_enum_get(&imfptr, "file_format"); - if (imtype == R_IMF_IMTYPE_MULTILAYER) { - NodeImageMultiFileSocket *input = sock->storage; - RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); - - uiItemL(row, input->layer, ICON_NONE); - } - else { - NodeImageMultiFileSocket *input = sock->storage; - PropertyRNA *imtype_prop; - const char *imtype_name; - uiBlock *block; - RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); - - uiItemL(row, input->path, ICON_NONE); - - if (!RNA_boolean_get(&inputptr, "use_node_format")) - imfptr = RNA_pointer_get(&inputptr, "format"); - - imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); - RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, - RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); - block = uiLayoutGetBlock(row); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiItemL(row, imtype_name, ICON_NONE); - uiBlockSetEmboss(block, UI_EMBOSSN); - } -} static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { PointerRNA imfptr = RNA_pointer_get(ptr, "format"); @@ -2382,7 +2336,6 @@ case CMP_NODE_OUTPUT_FILE: ntype->draw_buttons = node_composit_buts_file_output; ntype->draw_buttons_ex = node_composit_buts_file_output_ex; - ntype->draw_input = node_draw_input_file_output; break; case CMP_NODE_DIFF_MATTE: ntype->draw_buttons = node_composit_buts_diff_matte; @@ -2746,8 +2699,6 @@ NodeTypeUndefined.tweak_area_func = node_tweak_area_default; NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; - 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; @@ -2764,8 +2715,6 @@ ntype->tweak_area_func = node_tweak_area_default; ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; - 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); @@ -2789,8 +2738,6 @@ /* default ui functions */ ntype->draw_nodetype = node_draw_default; ntype->draw_nodetype_prepare = node_update_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; @@ -2828,12 +2775,59 @@ copy_v4_v4(r_color, std_node_socket_colors[type]); } +/* draw function for file output node sockets, displays only sub-path and format, no value button */ +static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) +{ + bNodeTree *ntree = ptr->id.data; + bNodeSocket *sock = ptr->data; + uiLayout *row; + PointerRNA inputptr, imfptr; + int imtype; + + row = uiLayoutRow(layout, FALSE); + + imfptr = RNA_pointer_get(node_ptr, "format"); + imtype = RNA_enum_get(&imfptr, "file_format"); + if (imtype == R_IMF_IMTYPE_MULTILAYER) { + NodeImageMultiFileSocket *input = sock->storage; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); + + uiItemL(row, input->layer, ICON_NONE); + } + else { + NodeImageMultiFileSocket *input = sock->storage; + PropertyRNA *imtype_prop; + const char *imtype_name; + uiBlock *block; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); + + uiItemL(row, input->path, ICON_NONE); + + if (!RNA_boolean_get(&inputptr, "use_node_format")) + imfptr = RNA_pointer_get(&inputptr, "format"); + + imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); + RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, + RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); + block = uiLayoutGetBlock(row); + uiBlockSetEmboss(block, UI_EMBOSSP); + uiItemL(row, imtype_name, ICON_NONE); + uiBlockSetEmboss(block, UI_EMBOSSN); + } +} + static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text) { + bNode *node = node_ptr->data; bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ + /* XXX not nice, eventually give this node its own socket type ... */ + if (node->type == CMP_NODE_OUTPUT_FILE) { + node_file_output_socket_draw(C, layout, ptr, node_ptr); + } + 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; Modified: trunk/blender/source/blender/editors/space_node/node_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_node/node_draw.c 2013-10-10 12:58:35 UTC (rev 60661) +++ trunk/blender/source/blender/editors/space_node/node_draw.c 2013-10-10 13:07:09 UTC (rev 60662) @@ -351,7 +351,7 @@ row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - node->typeinfo->draw_output((bContext *)C, row, &sockptr, &nodeptr); + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); @@ -437,8 +437,10 @@ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - node->typeinfo->draw_input((bContext *)C, layout, &sockptr, &nodeptr); + row = uiLayoutRow(layout, 1); + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); + uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs