Anim: move 'solo bone collection' operator to menu and add 'show all'

Move operators that act on the active bone collection to a 'specials'
context menu, just like other UILists.

The menu now contains:
- Solo the active bone collection (i.e. make it visible and hide others).
- Show all bone collections.
This commit is contained in:
Sybren A. Stüvel
2023-09-28 14:38:54 +02:00
parent 85b62251a6
commit f2bda4ab3a
3 changed files with 44 additions and 7 deletions

View File

@@ -506,9 +506,9 @@ class ARMATURE_OT_sync_bone_color_to_selected(Operator):
return {'FINISHED'}
class ARMATURE_OT_bone_collection_solo_visibility(Operator):
class ARMATURE_OT_collection_solo_visibility(Operator):
"""Hide all other bone collections and show the active one"""
bl_idname = "armature.bone_collection_solo_visibility"
bl_idname = "armature.collection_solo_visibility"
bl_label = "Solo Visibility"
bl_options = {'REGISTER', 'UNDO'}
@@ -520,9 +520,25 @@ class ARMATURE_OT_bone_collection_solo_visibility(Operator):
def execute(self, context):
arm = context.object.data
active_bcoll = arm.collections.active
for bcoll in arm.collections:
bcoll.is_visible = bcoll == active_bcoll
bcoll.is_visible = bcoll.name == self.name
return {'FINISHED'}
class ARMATURE_OT_collection_show_all(Operator):
"""Show all bone collections"""
bl_idname = "armature.collection_show_all"
bl_label = "Show All"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.object and context.object.type == 'ARMATURE' and context.object.data
def execute(self, context):
arm = context.object.data
for bcoll in arm.collections:
bcoll.is_visible = True
return {'FINISHED'}
@@ -532,5 +548,6 @@ classes = (
ClearUselessActions,
UpdateAnimatedTransformConstraint,
ARMATURE_OT_sync_bone_color_to_selected,
ARMATURE_OT_bone_collection_solo_visibility,
ARMATURE_OT_collection_solo_visibility,
ARMATURE_OT_collection_show_all,
)

View File

@@ -135,8 +135,9 @@ class DATA_PT_bone_collections(ArmatureButtonsPanel, Panel):
col.separator()
col.operator("armature.collection_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("armature.collection_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
props = col.operator("armature.bone_collection_solo_visibility", text="", icon='SOLO_ON')
props.name = active_bcoll.name
col.separator()
col.menu("ARMATURE_MT_collection_context_menu", icon='DOWNARROW_HLT', text="")
row = layout.row()
@@ -149,6 +150,20 @@ class DATA_PT_bone_collections(ArmatureButtonsPanel, Panel):
sub.operator("armature.collection_deselect", text="Deselect")
class ARMATURE_MT_collection_context_menu(Menu):
bl_label = "Bone Collection Specials"
def draw(self, context):
layout = self.layout
arm = context.armature
active_bcoll = arm.collections.active
props = layout.operator("armature.collection_solo_visibility")
props.name = active_bcoll.name if active_bcoll else ""
layout.operator("armature.collection_show_all")
class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
bl_label = "Inverse Kinematics"
bl_options = {'DEFAULT_CLOSED'}
@@ -275,6 +290,7 @@ classes = (
DATA_PT_skeleton,
DATA_PT_bone_collections,
DATA_UL_bone_collections,
ARMATURE_MT_collection_context_menu,
DATA_PT_motion_paths,
DATA_PT_motion_paths_display,
DATA_PT_display,

View File

@@ -3989,8 +3989,12 @@ class VIEW3D_MT_bone_collections(Menu):
layout.label(text="- select bones to operate on first -")
return
layout.operator("armature.collection_show_all")
layout.separator()
arm = context.object.data
bone = context.active_bone
found_editable_bcoll = False
for bcoll in arm.collections:
if not bcoll.is_editable: