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

[Selection Sets] Fix broken Assign operator, add functionality to move sets up/down the list

parent c24359d9
No related branches found
No related tags found
No related merge requests found
...@@ -40,13 +40,9 @@ from bpy.types import ( ...@@ -40,13 +40,9 @@ from bpy.types import (
from bpy.props import ( from bpy.props import (
StringProperty, StringProperty,
BoolProperty,
IntProperty, IntProperty,
FloatProperty,
EnumProperty, EnumProperty,
CollectionProperty, CollectionProperty,
BoolVectorProperty,
FloatVectorProperty,
) )
# Data Structure ############################################################## # Data Structure ##############################################################
...@@ -111,7 +107,11 @@ class POSE_PT_selection_sets(Panel): ...@@ -111,7 +107,11 @@ class POSE_PT_selection_sets(Panel):
# TODO specials like sorting # TODO specials like sorting
#col.menu("POSE_MT_selection_sets_specials", icon='DOWNARROW_HLT', text="") #col.menu("POSE_MT_selection_sets_specials", icon='DOWNARROW_HLT', text="")
# TODO move up/down arrows # move up/down arrows
if len(arm.selection_sets) > 0:
col.separator()
col.operator("pose.selection_set_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("pose.selection_set_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
# buttons # buttons
row = layout.row() row = layout.row()
...@@ -154,10 +154,49 @@ class NeedSelSetPluginOperator(PluginOperator): ...@@ -154,10 +154,49 @@ class NeedSelSetPluginOperator(PluginOperator):
def poll(self, context): def poll(self, context):
if super().poll(context): if super().poll(context):
arm = context.object arm = context.object
return (arm.active_selection_set < len(arm.selection_sets)) return (arm.active_selection_set < len(arm.selection_sets)
and arm.active_selection_set >= 0)
return False return False
class POSE_OT_selection_set_move(NeedSelSetPluginOperator):
bl_idname = "pose.selection_set_move"
bl_label = "Move Selection Set in List"
bl_description = "Move the active Selection Set up/down the list of sets"
bl_options = {'UNDO', 'REGISTER'}
direction = EnumProperty(
name="Move Direction",
description="Direction to move the active Selection Set: UP (default) or DOWN",
items=[
('UP', "Up", "", -1),
('DOWN', "Down", "", 1),
],
default='UP'
)
@classmethod
def poll(self, context):
if super().poll(context):
arm = context.object
return len(arm.selection_sets) > 1
return False
def execute(self, context):
arm = context.object
active_idx = arm.active_selection_set
new_idx = active_idx + (-1 if self.direction == 'UP' else 1)
if new_idx < 0 or new_idx >= len(arm.selection_sets):
return {'FINISHED'}
arm.selection_sets.move(active_idx, new_idx)
arm.active_selection_set = new_idx
return {'FINISHED'}
class POSE_OT_selection_set_add(PluginOperator): class POSE_OT_selection_set_add(PluginOperator):
bl_idname = "pose.selection_set_add" bl_idname = "pose.selection_set_add"
bl_label = "Create Selection Set" bl_label = "Create Selection Set"
...@@ -226,6 +265,8 @@ class POSE_OT_selection_set_assign(PluginOperator): ...@@ -226,6 +265,8 @@ class POSE_OT_selection_set_assign(PluginOperator):
if not (arm.active_selection_set < len(arm.selection_sets)): if not (arm.active_selection_set < len(arm.selection_sets)):
bpy.ops.wm.call_menu("INVOKE_DEFAULT", bpy.ops.wm.call_menu("INVOKE_DEFAULT",
name="pose.selection_set_create_new_popup") name="pose.selection_set_create_new_popup")
else:
bpy.ops.pose.selection_set_assign('EXEC_DEFAULT')
return {'FINISHED'} return {'FINISHED'}
...@@ -316,6 +357,7 @@ classes = ( ...@@ -316,6 +357,7 @@ classes = (
POSE_UL_selection_set, POSE_UL_selection_set,
SelectionEntry, SelectionEntry,
SelectionSet, SelectionSet,
POSE_OT_selection_set_move,
POSE_OT_selection_set_add, POSE_OT_selection_set_add,
POSE_OT_selection_set_remove, POSE_OT_selection_set_remove,
POSE_OT_selection_set_assign, POSE_OT_selection_set_assign,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment