mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Nodes: support searching for frame/seconds to find Scene Time node
Previously, one had to search for "Time" to get the Scene Time node which provides access to the current frame and second. Intuitively I often start searching for "frame" or "seconds" instead and only later remember what I actually have to search for. This patch improves the UX by allowing to create a Scene Time node by searching for "frame" or "seconds" directly. This works in Geometry Nodes and the compositor. Pull Request: https://projects.blender.org/blender/blender/pulls/138927
This commit is contained in:
parent
578f935170
commit
c157fecc4e
3 changed files with 17 additions and 3 deletions
|
|
@ -25,6 +25,20 @@ def add_node_type(layout, node_type, *, label=None, poll=None, search_weight=0.0
|
|||
return props
|
||||
|
||||
|
||||
def add_node_type_with_subnames(context, layout, node_type, subnames, *, label=None, search_weight=0.0):
|
||||
bl_rna = bpy.types.Node.bl_rna_get_subclass(node_type)
|
||||
if not label:
|
||||
label = bl_rna.name if bl_rna else "Unknown"
|
||||
|
||||
props = []
|
||||
props.append(add_node_type(layout, node_type, label=label, search_weight=search_weight))
|
||||
if getattr(context, "is_menu_search", False):
|
||||
for subname in subnames:
|
||||
sublabel = "{} ▸ {}".format(iface_(label), iface_(subname))
|
||||
props.append(add_node_type(layout, node_type, label=sublabel, search_weight=search_weight))
|
||||
return props
|
||||
|
||||
|
||||
def draw_node_group_add_menu(context, layout):
|
||||
"""Add items to the layout used for interacting with node groups."""
|
||||
space_node = context.space_data
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ class NODE_MT_category_compositor_input_scene(Menu):
|
|||
bl_idname = "NODE_MT_category_compositor_input_scene"
|
||||
bl_label = "Scene"
|
||||
|
||||
def draw(self, _context):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
node_add_menu.add_node_type(layout, "CompositorNodeRLayers")
|
||||
node_add_menu.add_node_type(layout, "CompositorNodeSceneTime")
|
||||
node_add_menu.add_node_type_with_subnames(context, layout, "CompositorNodeSceneTime", ["Frame", "Seconds"])
|
||||
node_add_menu.add_node_type(layout, "CompositorNodeTime")
|
||||
|
||||
node_add_menu.draw_assets_for_catalog(layout, "Input/Scene")
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ class NODE_MT_geometry_node_GEO_INPUT_SCENE(Menu):
|
|||
if context.space_data.geometry_nodes_type == 'TOOL':
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeToolMousePosition")
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeObjectInfo")
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeInputSceneTime")
|
||||
node_add_menu.add_node_type_with_subnames(context, layout, "GeometryNodeInputSceneTime", ["Frame", "Seconds"])
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeSelfObject")
|
||||
if context.space_data.geometry_nodes_type == 'TOOL':
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeViewportTransform")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue