From e83ef85576a04c41b719176f7797596fe9866a2c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 14 Aug 2012 17:56:33 +0000 Subject: Python node operator for combined node collapsing and hiding unused sockets. Socket hide flag is added to RNA as well, but can only be set when the socket is not connected, to avoid dangling links in editor drawing. Currently this operator has no default hotkey, but can be called from the Node menu. --- source/blender/makesrna/intern/rna_nodetree.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 9e4d29eca52..27201ea6389 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -324,6 +324,20 @@ static char *rna_NodeSocket_path(PointerRNA *ptr) return NULL; } +static void rna_NodeSocket_hide_set(PointerRNA *ptr, int value) +{ + bNodeSocket *sock = (bNodeSocket *)ptr->data; + + /* don't hide linked sockets */ + if (sock->flag & SOCK_IN_USE) + return; + + if (value) + sock->flag |= SOCK_HIDDEN; + else + sock->flag &= ~SOCK_HIDDEN; +} + /* Button Set Funcs for Matte Nodes */ static void rna_Matte_t1_set(PointerRNA *ptr, float value) { @@ -4106,6 +4120,17 @@ static void rna_def_node_socket(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Group Socket", "For group nodes, the group input or output socket this corresponds to"); + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_HIDDEN); + RNA_def_property_boolean_funcs(prop, NULL, "rna_NodeSocket_hide_set"); + RNA_def_property_ui_text(prop, "Hide", "Hide the socket"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "is_linked", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_IN_USE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Linked", "True if the socket is connected"); + prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SOCK_COLLAPSED); RNA_def_property_ui_text(prop, "Expanded", "Socket links are expanded in the user interface"); -- cgit v1.2.3