Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_operators/node.py31
-rw-r--r--release/scripts/startup/bl_ui/space_node.py1
-rw-r--r--source/blender/makesdna/DNA_node_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c25
4 files changed, 58 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 2f7fc359864..ddbd46df04f 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -134,3 +134,34 @@ class NODE_OT_add_search(Operator):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
+
+
+class NODE_OT_collapse_hide_unused_toggle(Operator):
+ '''Toggle collapsed nodes and hide unused sockets'''
+ bl_idname = "node.collapse_hide_unused_toggle"
+ bl_label = "Collapse and Hide Unused Sockets"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ # needs active node editor and a tree
+ return space.type == 'NODE_EDITOR' and space.edit_tree
+
+ def execute(self, context):
+ space = context.space_data
+ tree = space.edit_tree
+
+ for node in tree.nodes:
+ if node.select:
+ hide = not node.hide
+
+ node.hide = hide
+ # Note: connected sockets are ignored internally
+ for socket in node.inputs:
+ socket.hide = hide
+ for socket in node.outputs:
+ socket.hide = hide
+
+ return {'FINISHED'}
+
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 46baef9b043..5b7ecbfb618 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -182,6 +182,7 @@ class NODE_MT_node(Menu):
layout.operator("node.preview_toggle")
layout.operator("node.hide_socket_toggle")
layout.operator("node.options_toggle")
+ layout.operator("node.collapse_hide_unused_toggle")
layout.separator()
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");