UI: Interleave essentials modifiers in "Generate" menu
Hardocde the position of the essentials assets in the menu, for consistent alphabetical order and a clearer indication of the different between the nodes and builtin "Array" modifiers (the old one is now called "Array (Legacy)"). Pull Request: https://projects.blender.org/blender/blender/pulls/146887
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
|
||||
import bpy
|
||||
from bpy.types import Panel, Menu, Operator
|
||||
from bpy.app.translations import (
|
||||
pgettext_n as n_,
|
||||
)
|
||||
|
||||
|
||||
class ModifierButtonsPanel:
|
||||
@@ -25,16 +28,29 @@ class ModifierAddMenu:
|
||||
MODIFIER_TYPES_I18N_CONTEXT = bpy.types.Modifier.bl_rna.properties["type"].translation_context
|
||||
|
||||
@classmethod
|
||||
def operator_modifier_add(cls, layout, mod_type):
|
||||
def operator_modifier_add(cls, layout, mod_type, text=None, no_icon=False):
|
||||
label = text if text else cls.MODIFIER_TYPES_TO_LABELS[mod_type]
|
||||
layout.operator(
|
||||
"object.modifier_add",
|
||||
text=cls.MODIFIER_TYPES_TO_LABELS[mod_type],
|
||||
text=label,
|
||||
# Although these are operators, the label actually comes from an (enum) property,
|
||||
# so the property's translation context must be used here.
|
||||
text_ctxt=cls.MODIFIER_TYPES_I18N_CONTEXT,
|
||||
icon=cls.MODIFIER_TYPES_TO_ICONS[mod_type],
|
||||
icon='NONE' if no_icon else cls.MODIFIER_TYPES_TO_ICONS[mod_type],
|
||||
).type = mod_type
|
||||
|
||||
@classmethod
|
||||
def operator_modifier_add_asset(cls, layout, name, icon='NONE'):
|
||||
props = layout.operator(
|
||||
"object.modifier_add_node_group",
|
||||
text=name,
|
||||
text_ctxt=cls.MODIFIER_TYPES_I18N_CONTEXT,
|
||||
icon=icon,
|
||||
)
|
||||
props.asset_library_type = 'ESSENTIALS'
|
||||
props.asset_library_identifier = ""
|
||||
props.relative_asset_identifier = "geometry_nodes/geometry_nodes_essentials.blend/NodeTree/" + name
|
||||
|
||||
|
||||
class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
bl_label = "Modifiers"
|
||||
@@ -132,12 +148,14 @@ class OBJECT_MT_modifier_add_generate(ModifierAddMenu, Menu):
|
||||
layout = self.layout
|
||||
ob_type = context.object.type
|
||||
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE'}:
|
||||
self.operator_modifier_add(layout, 'ARRAY')
|
||||
self.operator_modifier_add_asset(layout, 'Array', icon='MOD_ARRAY')
|
||||
self.operator_modifier_add(layout, 'ARRAY', text=n_("Array (Legacy)"), no_icon=True)
|
||||
self.operator_modifier_add(layout, 'BEVEL')
|
||||
if ob_type == 'MESH':
|
||||
self.operator_modifier_add(layout, 'BOOLEAN')
|
||||
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE'}:
|
||||
self.operator_modifier_add(layout, 'BUILD')
|
||||
self.operator_modifier_add_asset(layout, n_('Curve to Tube'))
|
||||
self.operator_modifier_add(layout, 'DECIMATE')
|
||||
self.operator_modifier_add(layout, 'EDGE_SPLIT')
|
||||
if ob_type == 'MESH':
|
||||
@@ -150,6 +168,7 @@ class OBJECT_MT_modifier_add_generate(ModifierAddMenu, Menu):
|
||||
self.operator_modifier_add(layout, 'MULTIRES')
|
||||
if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE'}:
|
||||
self.operator_modifier_add(layout, 'REMESH')
|
||||
self.operator_modifier_add_asset(layout, n_('Scatter on Surface'))
|
||||
self.operator_modifier_add(layout, 'SCREW')
|
||||
if ob_type == 'MESH':
|
||||
self.operator_modifier_add(layout, 'SKIN')
|
||||
@@ -175,7 +194,7 @@ class OBJECT_MT_modifier_add_generate(ModifierAddMenu, Menu):
|
||||
self.operator_modifier_add(layout, 'GREASE_PENCIL_OUTLINE')
|
||||
self.operator_modifier_add(layout, 'GREASE_PENCIL_SIMPLIFY')
|
||||
self.operator_modifier_add(layout, 'GREASE_PENCIL_SUBDIV')
|
||||
layout.template_modifier_asset_menu_items(catalog_path=self.bl_label)
|
||||
layout.template_modifier_asset_menu_items(catalog_path=self.bl_label, skip_essentials=True)
|
||||
|
||||
|
||||
class OBJECT_MT_modifier_add_deform(ModifierAddMenu, Menu):
|
||||
|
||||
Reference in New Issue
Block a user