Nodes: support searching for color blend modes in Add menu

This is a follow up to #138534. It adds support for searching for all color blend
operations. It's supported in Geometry Nodes, Compositor and Shader Nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138581
This commit is contained in:
Jacques Lucke
2025-05-09 04:02:50 +02:00
parent f9d3235291
commit fb86bf0367
4 changed files with 24 additions and 15 deletions

View File

@@ -78,6 +78,24 @@ def add_node_type_with_searchable_enum(context, layout, node_idname, property_na
prop.value = repr(item.identifier)
def add_color_mix_node(context, layout):
label = iface_("Mix Color")
props = node_add_menu.add_node_type(layout, "ShaderNodeMix", label=label)
ops = props.settings.add()
ops.name = "data_type"
ops.value = "'RGBA'"
if getattr(context, "is_menu_search", False):
for item in bpy.types.ShaderNodeMix.bl_rna.properties["blend_type"].enum_items_static:
props = node_add_menu.add_node_type(layout, "ShaderNodeMix", label=label + "" + item.name)
prop = props.settings.add()
prop.name = "data_type"
prop.value = "'RGBA'"
prop = props.settings.add()
prop.name = "blend_type"
prop.value = repr(item.identifier)
def add_simulation_zone(layout, label):
"""Add simulation zone to a menu."""
props = layout.operator("node.add_simulation_zone", text=label, text_ctxt=i18n_contexts.default)

View File

@@ -128,17 +128,14 @@ class NODE_MT_category_compositor_color_mix(Menu):
bl_idname = "NODE_MT_category_compositor_color_mix"
bl_label = "Mix"
def draw(self, _context):
def draw(self, context):
layout = self.layout
node_add_menu.add_node_type(layout, "CompositorNodeAlphaOver")
layout.separator()
node_add_menu.add_node_type(layout, "CompositorNodeCombineColor")
node_add_menu.add_node_type(layout, "CompositorNodeSeparateColor")
layout.separator()
props = node_add_menu.add_node_type(layout, "ShaderNodeMix", label=iface_("Mix Color"))
ops = props.settings.add()
ops.name = "data_type"
ops.value = "'RGBA'"
node_add_menu.add_color_mix_node(context, layout)
node_add_menu.add_node_type(layout, "CompositorNodeZcombine")
node_add_menu.draw_assets_for_catalog(layout, "Color/Mix")

View File

@@ -31,17 +31,14 @@ class NODE_MT_geometry_node_GEO_COLOR(Menu):
bl_idname = "NODE_MT_geometry_node_GEO_COLOR"
bl_label = "Color"
def draw(self, _context):
def draw(self, context):
layout = self.layout
node_add_menu.add_node_type(layout, "ShaderNodeBlackbody")
node_add_menu.add_node_type(layout, "ShaderNodeValToRGB")
node_add_menu.add_node_type(layout, "ShaderNodeRGBCurve")
layout.separator()
node_add_menu.add_node_type(layout, "FunctionNodeCombineColor")
props = node_add_menu.add_node_type(layout, "ShaderNodeMix", label=iface_("Mix Color"))
ops = props.settings.add()
ops.name = "data_type"
ops.value = "'RGBA'"
node_add_menu.add_color_mix_node(context, layout)
node_add_menu.add_node_type(layout, "FunctionNodeSeparateColor")
node_add_menu.draw_assets_for_catalog(layout, "Utilities/Color")

View File

@@ -244,7 +244,7 @@ class NODE_MT_category_shader_color(Menu):
bl_idname = "NODE_MT_category_shader_color"
bl_label = "Color"
def draw(self, _context):
def draw(self, context):
layout = self.layout
node_add_menu.add_node_type(layout, "ShaderNodeBrightContrast")
@@ -252,10 +252,7 @@ class NODE_MT_category_shader_color(Menu):
node_add_menu.add_node_type(layout, "ShaderNodeHueSaturation")
node_add_menu.add_node_type(layout, "ShaderNodeInvert")
node_add_menu.add_node_type(layout, "ShaderNodeLightFalloff")
props = node_add_menu.add_node_type(layout, "ShaderNodeMix", label=iface_("Mix Color"))
ops = props.settings.add()
ops.name = "data_type"
ops.value = "'RGBA'"
node_add_menu.add_color_mix_node(context, layout)
node_add_menu.add_node_type(layout, "ShaderNodeRGBCurve")
node_add_menu.draw_assets_for_catalog(layout, self.bl_label)