Fix #128589: allow disabling node group interface UI for custom node tree types
This adds a new `bl_use_group_interface` property that can be set on custom node group types. By default it is `true` to avoid this being a breaking change. If it's set to `false` some UI elements related to the built-in node group interface are hidden. Pull Request: https://projects.blender.org/blender/blender/pulls/131877
This commit is contained in:
@@ -336,6 +336,7 @@ class NODE_MT_node(Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
snode = context.space_data
|
||||
group = snode.edit_tree
|
||||
is_compositor = snode.tree_type == 'CompositorNodeTree'
|
||||
|
||||
layout.operator("transform.translate").view2d_edge_pan = True
|
||||
@@ -372,11 +373,12 @@ class NODE_MT_node(Menu):
|
||||
layout.operator("node.links_detach")
|
||||
layout.operator("node.links_mute")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("node.group_make", icon='NODETREE')
|
||||
layout.operator("node.group_insert", text="Insert Into Group")
|
||||
layout.operator("node.group_edit").exit = False
|
||||
layout.operator("node.group_ungroup")
|
||||
if not group or group.bl_use_group_interface:
|
||||
layout.separator()
|
||||
layout.operator("node.group_make", icon='NODETREE')
|
||||
layout.operator("node.group_insert", text="Insert Into Group")
|
||||
layout.operator("node.group_edit").exit = False
|
||||
layout.operator("node.group_ungroup")
|
||||
|
||||
layout.separator()
|
||||
layout.menu("NODE_MT_context_menu_show_hide_menu")
|
||||
@@ -581,6 +583,7 @@ class NODE_MT_context_menu(Menu):
|
||||
snode = context.space_data
|
||||
is_nested = (len(snode.path) > 1)
|
||||
is_geometrynodes = snode.tree_type == 'GeometryNodeTree'
|
||||
group = snode.edit_tree
|
||||
|
||||
selected_nodes_len = len(context.selected_nodes)
|
||||
active_node = context.active_node
|
||||
@@ -640,17 +643,18 @@ class NODE_MT_context_menu(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("node.group_make", text="Make Group", icon='NODETREE')
|
||||
layout.operator("node.group_insert", text="Insert Into Group")
|
||||
if group and group.bl_use_group_interface:
|
||||
layout.operator("node.group_make", text="Make Group", icon='NODETREE')
|
||||
layout.operator("node.group_insert", text="Insert Into Group")
|
||||
|
||||
if active_node and active_node.type == 'GROUP':
|
||||
layout.operator("node.group_edit").exit = False
|
||||
layout.operator("node.group_ungroup", text="Ungroup")
|
||||
if active_node and active_node.type == 'GROUP':
|
||||
layout.operator("node.group_edit").exit = False
|
||||
layout.operator("node.group_ungroup", text="Ungroup")
|
||||
|
||||
if is_nested:
|
||||
layout.operator("node.tree_path_parent", text="Exit Group", icon='FILE_PARENT')
|
||||
if is_nested:
|
||||
layout.operator("node.tree_path_parent", text="Exit Group", icon='FILE_PARENT')
|
||||
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
|
||||
layout.operator("node.join", text="Join in New Frame")
|
||||
layout.operator("node.detach", text="Remove from Frame")
|
||||
@@ -921,6 +925,8 @@ class NODE_PT_node_tree_interface(Panel):
|
||||
return False
|
||||
if tree.is_embedded_data:
|
||||
return False
|
||||
if not tree.bl_use_group_interface:
|
||||
return False
|
||||
return True
|
||||
|
||||
def draw(self, context):
|
||||
@@ -1003,6 +1009,9 @@ class NODE_PT_node_tree_properties(Panel):
|
||||
else:
|
||||
layout.prop(group, "description", text="Description")
|
||||
|
||||
if not group.bl_use_group_interface:
|
||||
return
|
||||
|
||||
layout.prop(group, "color_tag")
|
||||
row = layout.row(align=True)
|
||||
row.prop(group, "default_group_node_width", text="Node Width")
|
||||
|
||||
@@ -482,6 +482,12 @@ struct bNodeTreeType {
|
||||
/* Check if the socket type is valid for this tree type. */
|
||||
bool (*valid_socket_type)(bNodeTreeType *ntreetype, bNodeSocketType *socket_type);
|
||||
|
||||
/**
|
||||
* If true, then some UI elements related to building node groups will be hidden.
|
||||
* This can be used by Python-defined custom node tree types.
|
||||
*/
|
||||
bool no_group_interface;
|
||||
|
||||
/* RNA integration */
|
||||
ExtensionRNA rna_ext;
|
||||
};
|
||||
|
||||
@@ -11463,6 +11463,14 @@ static void rna_def_nodetree(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_REGISTER);
|
||||
RNA_def_property_ui_text(prop, "Icon", "The node tree icon");
|
||||
|
||||
prop = RNA_def_property(srna, "bl_use_group_interface", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, nullptr, "typeinfo->no_group_interface", 1);
|
||||
RNA_def_property_boolean_default(prop, true);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Use Group Interface",
|
||||
"Determines the visibility of some UI elements related to node groups");
|
||||
|
||||
/* poll */
|
||||
func = RNA_def_function(srna, "poll", nullptr);
|
||||
RNA_def_function_ui_description(func, "Check visibility in the editor");
|
||||
|
||||
Reference in New Issue
Block a user