Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInes Almeida <britalmeida@gmail.com>2016-03-31 01:14:42 +0300
committerInes Almeida <britalmeida@gmail.com>2016-03-31 01:14:42 +0300
commitab058bc492b490d7c72d131f569076889ba3d2a5 (patch)
treedc8d68c4baae12dda7a1a4a2a7d22d420ba221fa /bone_selection_sets.py
parentc24359d93a4d2862e185f73814eff9213a98dc46 (diff)
[Selection Sets] Fix broken Assign operator, add functionality to move sets up/down the list
Diffstat (limited to 'bone_selection_sets.py')
-rw-r--r--bone_selection_sets.py54
1 files changed, 48 insertions, 6 deletions
diff --git a/bone_selection_sets.py b/bone_selection_sets.py
index fc25404e..904793ab 100644
--- a/bone_selection_sets.py
+++ b/bone_selection_sets.py
@@ -40,13 +40,9 @@ from bpy.types import (
from bpy.props import (
StringProperty,
- BoolProperty,
IntProperty,
- FloatProperty,
EnumProperty,
CollectionProperty,
- BoolVectorProperty,
- FloatVectorProperty,
)
# Data Structure ##############################################################
@@ -111,7 +107,11 @@ class POSE_PT_selection_sets(Panel):
# TODO specials like sorting
#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
row = layout.row()
@@ -154,10 +154,49 @@ class NeedSelSetPluginOperator(PluginOperator):
def poll(self, context):
if super().poll(context):
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
+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):
bl_idname = "pose.selection_set_add"
bl_label = "Create Selection Set"
@@ -226,6 +265,8 @@ class POSE_OT_selection_set_assign(PluginOperator):
if not (arm.active_selection_set < len(arm.selection_sets)):
bpy.ops.wm.call_menu("INVOKE_DEFAULT",
name="pose.selection_set_create_new_popup")
+ else:
+ bpy.ops.pose.selection_set_assign('EXEC_DEFAULT')
return {'FINISHED'}
@@ -316,6 +357,7 @@ classes = (
POSE_UL_selection_set,
SelectionEntry,
SelectionSet,
+ POSE_OT_selection_set_move,
POSE_OT_selection_set_add,
POSE_OT_selection_set_remove,
POSE_OT_selection_set_assign,