Skip to content
Snippets Groups Projects
Commit 21466a9e authored by Ines Almeida's avatar Ines Almeida
Browse files

Bone Selection Sets: minor refactoring and improvements.

- hide properties of operators so they don't show in the last action panel if unneeded.
- menu registration was not being unregistered.
- minor comments and renaming (Select > Bone Selection Set instead of Select > Select Selection Set)
parent 464aaced
No related branches found
No related tags found
No related merge requests found
...@@ -126,8 +126,8 @@ class POSE_PT_selection_sets(Panel): ...@@ -126,8 +126,8 @@ class POSE_PT_selection_sets(Panel):
class POSE_UL_selection_set(UIList): class POSE_UL_selection_set(UIList):
def draw_item(self, context, layout, data, set, icon, active_data, active_propname, index): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
layout.prop(set, "name", text="", icon='GROUP_BONE', emboss=False) layout.prop(item, "name", text="", icon='GROUP_BONE', emboss=False)
class POSE_MT_selection_set_create(Menu): class POSE_MT_selection_set_create(Menu):
...@@ -139,7 +139,7 @@ class POSE_MT_selection_set_create(Menu): ...@@ -139,7 +139,7 @@ class POSE_MT_selection_set_create(Menu):
text="New Selection Set") text="New Selection Set")
class POSE_MT_selection_sets(Menu): class POSE_MT_selection_sets_select(Menu):
bl_label = 'Select Selection Set' bl_label = 'Select Selection Set'
@classmethod @classmethod
...@@ -217,7 +217,8 @@ class POSE_OT_selection_set_move(NeedSelSetPluginOperator): ...@@ -217,7 +217,8 @@ class POSE_OT_selection_set_move(NeedSelSetPluginOperator):
('UP', "Up", "", -1), ('UP', "Up", "", -1),
('DOWN', "Down", "", 1), ('DOWN', "Down", "", 1),
], ],
default='UP' default='UP',
options={'HIDDEN'},
) )
@classmethod @classmethod
...@@ -338,6 +339,7 @@ class POSE_OT_selection_set_select(NeedSelSetPluginOperator): ...@@ -338,6 +339,7 @@ class POSE_OT_selection_set_select(NeedSelSetPluginOperator):
name='Selection Set Index', name='Selection Set Index',
default=-1, default=-1,
description='Which Selection Set to select; -1 uses the active Selection Set', description='Which Selection Set to select; -1 uses the active Selection Set',
options={'HIDDEN'},
) )
def execute(self, context): def execute(self, context):
...@@ -419,8 +421,8 @@ class POSE_OT_selection_set_paste(PluginOperator): ...@@ -419,8 +421,8 @@ class POSE_OT_selection_set_paste(PluginOperator):
# Helper Functions ############################################################ # Helper Functions ############################################################
def add_sss_button(self, context): def menu_func_select_selection_set(self, context):
self.layout.menu('POSE_MT_selection_sets') self.layout.menu('POSE_MT_selection_sets_select', text="Bone Selection Set")
def to_json(context) -> str: def to_json(context) -> str:
...@@ -499,7 +501,7 @@ def uniqify(name: str, other_names: list) -> str: ...@@ -499,7 +501,7 @@ def uniqify(name: str, other_names: list) -> str:
classes = ( classes = (
POSE_MT_selection_set_create, POSE_MT_selection_set_create,
POSE_MT_selection_sets_specials, POSE_MT_selection_sets_specials,
POSE_MT_selection_sets, POSE_MT_selection_sets_select,
POSE_PT_selection_sets, POSE_PT_selection_sets,
POSE_UL_selection_set, POSE_UL_selection_set,
SelectionEntry, SelectionEntry,
...@@ -519,7 +521,7 @@ classes = ( ...@@ -519,7 +521,7 @@ classes = (
) )
# store keymaps here to access after registration # Store keymaps here to access after registration.
addon_keymaps = [] addon_keymaps = []
...@@ -527,6 +529,7 @@ def register(): ...@@ -527,6 +529,7 @@ def register():
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
# Add properties.
bpy.types.Object.selection_sets = CollectionProperty( bpy.types.Object.selection_sets = CollectionProperty(
type=SelectionSet, type=SelectionSet,
name="Selection Sets", name="Selection Sets",
...@@ -538,28 +541,34 @@ def register(): ...@@ -538,28 +541,34 @@ def register():
default=0 default=0
) )
# Add shortcuts to the keymap.
wm = bpy.context.window_manager wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Pose') km = wm.keyconfigs.addon.keymaps.new(name='Pose')
kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True, shift=True) kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', alt=True, shift=True)
kmi.properties.name = 'POSE_MT_selection_sets' kmi.properties.name = 'POSE_MT_selection_sets'
addon_keymaps.append((km, kmi)) addon_keymaps.append((km, kmi))
bpy.types.VIEW3D_MT_select_pose.append(add_sss_button) # Add entries to menus.
bpy.types.VIEW3D_MT_select_pose.append(menu_func_select_selection_set)
def unregister(): def unregister():
for cls in classes: for cls in classes:
bpy.utils.unregister_class(cls) bpy.utils.unregister_class(cls)
# Clear properties.
del bpy.types.Object.selection_sets del bpy.types.Object.selection_sets
del bpy.types.Object.active_selection_set del bpy.types.Object.active_selection_set
# handle the keymap # Clear shortcuts from the keymap.
for km, kmi in addon_keymaps: for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi) km.keymap_items.remove(kmi)
addon_keymaps.clear() addon_keymaps.clear()
# Clear entries from menus.
bpy.types.VIEW3D_MT_select_pose.remove(menu_func_select_selection_set)
if __name__ == "__main__": if __name__ == "__main__":
import doctest import doctest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment