Nodes: Panel declarations for grouping sockets #108649

Merged
Lukas Tönne merged 27 commits from LukasTonne/blender:node-socket-categories into main 2023-06-14 18:02:46 +02:00
2 changed files with 32 additions and 32 deletions
Showing only changes of commit 5e1c8395c9 - Show all commits

View File

@ -244,7 +244,7 @@ class NODE_OT_tree_path_parent(Operator):
return {'FINISHED'}
class NodeSocketPanelOperator():
class NodePanelOperator():
@classmethod
def poll(cls, context):
snode = context.space_data
@ -258,16 +258,16 @@ class NodeSocketPanelOperator():
return True
class NODE_OT_socket_panel_add(NodeSocketPanelOperator, Operator):
'''Add a new socket panel to the tree'''
bl_idname = "node.socket_panel_add"
bl_label = "Add Socket Panel"
class NODE_OT_panel_add(NodePanelOperator, Operator):
'''Add a new panel to the tree'''
bl_idname = "node.panel_add"
bl_label = "Add Panel"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
snode = context.space_data
tree = snode.edit_tree
panels = tree.socket_panels
panels = tree.panels
# Remember index to move the item.
LukasTonne marked this conversation as resolved Outdated

Period at the end of the comment.

Period at the end of the comment.
dst_index = min(panels.active_index + 1, len(panels))
@ -278,16 +278,16 @@ class NODE_OT_socket_panel_add(NodeSocketPanelOperator, Operator):
return {'FINISHED'}
class NODE_OT_socket_panel_remove(NodeSocketPanelOperator, Operator):
'''Remove a socket panel from the tree'''
bl_idname = "node.socket_panel_remove"
bl_label = "Remove Socket Panel"
class NODE_OT_panel_remove(NodePanelOperator, Operator):
'''Remove a panel from the tree'''
bl_idname = "node.panel_remove"
bl_label = "Remove Panel"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
snode = context.space_data
tree = snode.edit_tree
panels = tree.socket_panels
panels = tree.panels
if panels.active:
panels.remove(panels.active)
@ -296,10 +296,10 @@ class NODE_OT_socket_panel_remove(NodeSocketPanelOperator, Operator):
return {'FINISHED'}
class NODE_OT_socket_panel_move(NodeSocketPanelOperator, Operator):
'''Move a socket panel to another position'''
bl_idname = "node.socket_panel_move"
bl_label = "Move Socket Panel"
class NODE_OT_panel_move(NodePanelOperator, Operator):
'''Move a panel to another position'''
bl_idname = "node.panel_move"
bl_label = "Move Panel"
bl_options = {'REGISTER', 'UNDO'}
direction: EnumProperty(
@ -311,7 +311,7 @@ class NODE_OT_socket_panel_move(NodeSocketPanelOperator, Operator):
def execute(self, context):
snode = context.space_data
tree = snode.edit_tree
panels = tree.socket_panels
panels = tree.panels
if self.direction == 'UP' and panels.active_index > 0:
panels.move(panels.active_index, panels.active_index - 1)
@ -329,8 +329,8 @@ classes = (
NODE_OT_add_node,
NODE_OT_add_simulation_zone,
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_socket_panel_add,
NODE_OT_socket_panel_remove,
NODE_OT_socket_panel_move,
NODE_OT_panel_add,
NODE_OT_panel_remove,
NODE_OT_panel_move,
NODE_OT_tree_path_parent,
)

View File

@ -960,17 +960,17 @@ class NODE_PT_node_tree_interface_outputs(NodeTreeInterfacePanel):
self.draw_socket_list(context, "OUT", "outputs", "active_output")
class NODE_UL_socket_panels(bpy.types.UIList):
class NODE_UL_panels(bpy.types.UIList):
def draw_item(self, context, layout, _data, item, icon, _active_data, _active_propname, _index):
row = layout.row(align=True)
row.prop(item, "name", text="", emboss=False, icon_value=icon)
class NODE_PT_socket_panels(Panel):
class NODE_PT_panels(Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
bl_category = "Group"
bl_label = "Socket Panels"
bl_label = "Node Panels"
@classmethod
def poll(cls, context):
@ -995,28 +995,28 @@ class NODE_PT_socket_panels(Panel):
split = layout.row()
split.template_list(
"NODE_UL_socket_panels",
"NODE_UL_panels",
"",
tree,
"socket_panels",
tree.socket_panels,
"panels",
tree.panels,
"active_index")
ops_col = split.column()
add_remove_col = ops_col.column(align=True)
add_remove_col.operator("node.socket_panel_add", icon='ADD', text="")
add_remove_col.operator("node.socket_panel_remove", icon='REMOVE', text="")
add_remove_col.operator("node.panel_add", icon='ADD', text="")
add_remove_col.operator("node.panel_remove", icon='REMOVE', text="")
ops_col.separator()

I know I started this with the socket list, but I'm regretting it now. Maybe we can skip exposing the name property separate from the list. It should be clear that you can rename in the list.

I know I started this with the socket list, but I'm regretting it now. Maybe we can skip exposing the name property separate from the list. It should be clear that you can rename in the list.

Not sure, we may want to add more settings to categories, such as options to close categories by default, doc strings, etc.

Not sure, we may want to add more settings to categories, such as options to close categories by default, doc strings, etc.

Ideally i'd like to display the node tree declarations in a way that resembles the final node output, to make it more intuitive. The vertical UI layout of the node editor sidebar makes that a bit challenging. But lets say we could arrange it any way we like, then you'd have inputs on the left and outputs on the right. Categories would show in a kind of tree view matching the panels in modifiers. Socket details and category details would be displayed close to active element.

Ideally i'd like to display the node tree declarations in a way that resembles the final node output, to make it more intuitive. The vertical UI layout of the node editor sidebar makes that a bit challenging. But lets say we could arrange it any way we like, then you'd have inputs on the left and outputs on the right. Categories would show in a kind of tree view matching the panels in modifiers. Socket details and category details would be displayed close to active element. ![](/attachments/b3fb4846-83b0-4d4b-b172-097ff3be0091)

Hmm, all I mean is that there's no need to have the separate name property outside of the list. Not that displaying more options doesn't make sense.

For he other stuff, the inputs and outputs used to be side-by-side, but it doesn't work well with Blender's single-column UI layout paradigm. But that can be discussed more later.

Hmm, all I mean is that there's no need to have the separate name property outside of the list. Not that displaying more options doesn't make sense. For he other stuff, the inputs and outputs used to be side-by-side, but it doesn't work well with Blender's single-column UI layout paradigm. But that can be discussed more later.
up_down_col = ops_col.column(align=True)
props = up_down_col.operator("node.socket_panel_move", icon='TRIA_UP', text="")
props = up_down_col.operator("node.panel_move", icon='TRIA_UP', text="")
props.direction = 'UP'
props = up_down_col.operator("node.socket_panel_move", icon='TRIA_DOWN', text="")
props = up_down_col.operator("node.panel_move", icon='TRIA_DOWN', text="")
props.direction = 'DOWN'
active_panel = tree.socket_panels.active
active_panel = tree.panels.active
if active_panel is not None:
layout.prop(active_panel, "name")
@ -1164,8 +1164,8 @@ classes = (
NODE_UL_interface_sockets,
NODE_PT_node_tree_interface_inputs,
NODE_PT_node_tree_interface_outputs,
NODE_UL_socket_panels,
NODE_PT_socket_panels,
NODE_UL_panels,
NODE_PT_panels,
NODE_UL_simulation_zone_items,
NODE_PT_simulation_zone_items,