diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-08-14 21:56:33 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-08-14 21:56:33 +0400 |
commit | e83ef85576a04c41b719176f7797596fe9866a2c (patch) | |
tree | 460f2db930a31524e1678b423f7937e740caa0d9 /source/blender | |
parent | 3220ef9d952b71c397849ea64abb882ea65b4d48 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 4ff344d94d1..ffb16b96b55 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -127,7 +127,7 @@ typedef struct bNodeSocket { /* sock->flag, first bit is select */ /* hidden is user defined, to hide unused */ #define SOCK_HIDDEN 2 - /* only used now for groups... */ + /* for quick check if socket is linked */ #define SOCK_IN_USE 4 /* XXX deprecated */ /* unavailable is for dynamic sockets */ #define SOCK_UNAVAIL 8 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"); |