UI: Shape key right click context menu

Invoke context menu for shape key with right click.
Added `MESH_MT_shape_key_tree_context_menu`, this include operators
that takes action on selected/active tree items:
- Make Basis
- Duplicate
- Move to Top -> Move After Basis
- Move to Bottom -> Move to Last

See Video in PR description

Pull Request: https://projects.blender.org/blender/blender/pulls/143444
This commit is contained in:
Pratik Borhade
2025-08-07 12:41:26 +02:00
committed by Pratik Borhade
parent 2f68e7e4b4
commit 0f8f9057a9
2 changed files with 22 additions and 0 deletions

View File

@@ -84,6 +84,18 @@ class MESH_MT_shape_key_context_menu(Menu):
layout.operator("object.shape_key_move", icon='TRIA_DOWN_BAR', text="Move to Bottom").type = 'BOTTOM'
class MESH_MT_shape_key_tree_context_menu(Menu):
bl_label = "Shape Key context menu"
def draw(self, _context):
layout = self.layout
layout.operator("object.shape_key_make_basis", text="Make Basis")
layout.operator("object.shape_key_copy", icon='DUPLICATE', text="Duplicate")
layout.separator()
layout.operator("object.shape_key_move", icon='TRIA_UP_BAR', text="Move After Basis").type = 'TOP'
layout.operator("object.shape_key_move", icon='TRIA_DOWN_BAR', text="Move to Last").type = 'BOTTOM'
class MESH_MT_color_attribute_context_menu(Menu):
bl_label = "Color Attribute Specials"
@@ -690,6 +702,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
classes = (
MESH_MT_vertex_group_context_menu,
MESH_MT_shape_key_context_menu,
MESH_MT_shape_key_tree_context_menu,
MESH_MT_color_attribute_context_menu,
MESH_MT_attribute_context_menu,
MESH_UL_vgroups,

View File

@@ -230,6 +230,15 @@ class ShapeKeyItem : public ui::AbstractTreeViewItem {
return label_;
}
void build_context_menu(bContext &C, uiLayout &layout) const override
{
MenuType *mt = WM_menutype_find("MESH_MT_shape_key_tree_context_menu", true);
if (!mt) {
return;
}
UI_menutype_draw(&C, mt, &layout);
}
std::unique_ptr<ui::AbstractViewItemDragController> create_drag_controller() const override
{
return std::make_unique<ShapeKeyDragController>(