Page MenuHome

bone-group-move-sort.patch

Authored By
Torsten Rupp (rupp)
Nov 13 2013, 2:32 PM
Size
5 KB
Subscribers
None

bone-group-move-sort.patch

Index: release/scripts/ui/properties_data_armature.py
===================================================================
--- release/scripts/ui/properties_data_armature.py (revision 31748)
+++ release/scripts/ui/properties_data_armature.py (working copy)
@@ -105,6 +105,16 @@
col.prop(arm, "use_deform_delay", text="Delay Refresh")
+class DATA_PT_bone_group_specials(bpy.types.Menu):
+ bl_label = "Bone Group Specials"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator("pose.group_sort", icon='SORTALPHA')
+
+
class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Bone Groups"
@@ -117,16 +127,25 @@
ob = context.object
pose = ob.pose
+ group = pose.bone_groups.active
row = layout.row()
- row.template_list(pose, "bone_groups", pose.bone_groups, "active_index", rows=2)
+ rows = 2
+ if group:
+ rows = 5
+ row.template_list(pose, "bone_groups", pose.bone_groups, "active_index", rows=rows)
+
col = row.column(align=True)
col.active = (ob.proxy is None)
col.operator("pose.group_add", icon='ZOOMIN', text="")
col.operator("pose.group_remove", icon='ZOOMOUT', text="")
+ col.menu("DATA_PT_bone_group_specials", icon='DOWNARROW_HLT', text="")
+ if group:
+ col.separator()
+ col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
+ col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
- group = pose.bone_groups.active
if group:
col = layout.column()
col.active = (ob.proxy is None)
Index: source/blender/editors/armature/armature_ops.c
===================================================================
--- source/blender/editors/armature/armature_ops.c (revision 31748)
+++ source/blender/editors/armature/armature_ops.c (working copy)
@@ -120,6 +120,8 @@
WM_operatortype_append(POSE_OT_group_add);
WM_operatortype_append(POSE_OT_group_remove);
+ WM_operatortype_append(POSE_OT_group_move);
+ WM_operatortype_append(POSE_OT_group_sort);
WM_operatortype_append(POSE_OT_group_assign);
WM_operatortype_append(POSE_OT_group_unassign);
WM_operatortype_append(POSE_OT_group_select);
Index: source/blender/editors/armature/armature_intern.h
===================================================================
--- source/blender/editors/armature/armature_intern.h (revision 31748)
+++ source/blender/editors/armature/armature_intern.h (working copy)
@@ -104,7 +104,8 @@
void POSE_OT_group_add(struct wmOperatorType *ot);
void POSE_OT_group_remove(struct wmOperatorType *ot);
-void POSE_OT_group_remove(struct wmOperatorType *ot);
+void POSE_OT_group_move(struct wmOperatorType *ot);
+void POSE_OT_group_sort(struct wmOperatorType *ot);
void POSE_OT_group_assign(struct wmOperatorType *ot);
void POSE_OT_group_unassign(struct wmOperatorType *ot);
void POSE_OT_group_select(struct wmOperatorType *ot);
Index: source/blender/editors/armature/poseobject.c
===================================================================
--- source/blender/editors/armature/poseobject.c (revision 31748)
+++ source/blender/editors/armature/poseobject.c (working copy)
@@ -1147,6 +1147,109 @@
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
+static int group_move_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ bPose *pose= (ob) ? ob->pose : NULL;
+ bActionGroup *grp = NULL;
+ int dir= RNA_enum_get(op->ptr, "direction"), ret;
+
+ if (ELEM(NULL, ob, pose))
+ return OPERATOR_CANCELLED;
+ if (pose->active_group <= 0)
+ return OPERATOR_CANCELLED;
+
+ /* get group to move */
+ grp= BLI_findlink(&pose->agroups, pose->active_group-1);
+ if (!grp)
+ return OPERATOR_CANCELLED;
+
+ if (dir == 1) { /* up */
+ void *prev = grp->prev;
+ if (prev) {
+ BLI_remlink(&pose->agroups, grp);
+ BLI_insertlinkbefore(&pose->agroups, prev, grp);
+ pose->active_group--;
+ }
+ } else { /* down */
+ void *next = grp->next;
+ if (next) {
+ BLI_remlink(&pose->agroups, grp);
+ BLI_insertlinkafter(&pose->agroups, next, grp);
+ pose->active_group++;
+ }
+ }
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_move(wmOperatorType *ot)
+{
+ static EnumPropertyItem group_slot_move[] = {
+ {1, "UP", 0, "Up", ""},
+ {-1, "DOWN", 0, "Down", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name= "Move Bone Group";
+ ot->idname= "POSE_OT_group_move";
+
+ /* api callbacks */
+ ot->exec= group_move_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_enum(ot->srna, "direction", group_slot_move, 0, "Direction", "Direction to move, UP or DOWN");
+}
+
+/* compare bone groups by name */
+static int group_sort(void *grp_a_ptr, void *grp_b_ptr)
+{
+ bActionGroup *grp_a= (bActionGroup *)grp_a_ptr;
+ bActionGroup *grp_b= (bActionGroup *)grp_b_ptr;
+
+ return strcmp(grp_a->name, grp_b->name);
+}
+
+static int group_sort_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ bPose *pose= (ob) ? ob->pose : NULL;
+
+ if (ELEM(NULL, ob, pose))
+ return OPERATOR_CANCELLED;
+ if (pose->active_group <= 0)
+ return OPERATOR_CANCELLED;
+
+ /* sort bone group names */
+ BLI_sortlist(&pose->agroups, group_sort);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_sort(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Sort Bone Groups";
+ ot->idname= "POSE_OT_group_sort";
+
+ /* api callbacks */
+ ot->exec= group_sort_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ------------ */
/* invoke callback which presents a list of bone-groups for the user to choose from */

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6b/a6/f8b120239c6eb80ccd7596ca1a38

Event Timeline