Added buttons to move a pose in a pose library up/down.
This will break the pose library preview add-on, since that add-on uses file indices rather than pose names.
This commit is contained in:
parent
661a316c72
commit
19268fbad3
|
@ -201,6 +201,10 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
|
|||
|
||||
col.operator("poselib.action_sanitize", icon='HELP', text="") # XXX: put in menu?
|
||||
|
||||
if pose_marker_active is not None:
|
||||
col.operator("poselib.pose_move", icon='TRIA_UP', text="").direction = 'UP'
|
||||
col.operator("poselib.pose_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
|
||||
|
||||
# TODO: this panel will soon be deprecated too
|
||||
class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
|
||||
|
|
|
@ -201,6 +201,7 @@ void POSELIB_OT_action_sanitize(struct wmOperatorType *ot);
|
|||
void POSELIB_OT_pose_add(struct wmOperatorType *ot);
|
||||
void POSELIB_OT_pose_remove(struct wmOperatorType *ot);
|
||||
void POSELIB_OT_pose_rename(struct wmOperatorType *ot);
|
||||
void POSELIB_OT_pose_move(struct wmOperatorType *ot);
|
||||
|
||||
void POSELIB_OT_browse_interactive(struct wmOperatorType *ot);
|
||||
void POSELIB_OT_apply_pose(struct wmOperatorType *ot);
|
||||
|
|
|
@ -151,6 +151,7 @@ void ED_operatortypes_armature(void)
|
|||
WM_operatortype_append(POSELIB_OT_pose_add);
|
||||
WM_operatortype_append(POSELIB_OT_pose_remove);
|
||||
WM_operatortype_append(POSELIB_OT_pose_rename);
|
||||
WM_operatortype_append(POSELIB_OT_pose_move);
|
||||
|
||||
WM_operatortype_append(POSELIB_OT_new);
|
||||
WM_operatortype_append(POSELIB_OT_unlink);
|
||||
|
|
|
@ -733,6 +733,102 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
|
|||
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
||||
}
|
||||
|
||||
static int poselib_move_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
TimeMarker *marker;
|
||||
int marker_index;
|
||||
int dir;
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* check if valid poselib */
|
||||
if (act == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
prop = RNA_struct_find_property(op->ptr, "pose");
|
||||
if (RNA_property_is_set(op->ptr, prop)) {
|
||||
marker_index = RNA_property_enum_get(op->ptr, prop);
|
||||
}
|
||||
else {
|
||||
marker_index = act->active_marker - 1;
|
||||
}
|
||||
|
||||
/* get index (and pointer) of pose to remove */
|
||||
marker = BLI_findlink(&act->markers, marker_index);
|
||||
if (marker == NULL) {
|
||||
BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
dir = RNA_enum_get(op->ptr, "direction");
|
||||
|
||||
/* move pose */
|
||||
if (dir == 1) { /* up */
|
||||
void *prev = marker->prev;
|
||||
|
||||
if (prev == NULL)
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
BLI_remlink(&act->markers, marker);
|
||||
BLI_insertlinkbefore(&act->markers, prev, marker);
|
||||
}
|
||||
else { /* down */
|
||||
void *next = marker->next;
|
||||
|
||||
if (next == NULL)
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
BLI_remlink(&act->markers, marker);
|
||||
BLI_insertlinkafter(&act->markers, next, marker);
|
||||
}
|
||||
|
||||
act->active_marker = marker_index - dir + 1;
|
||||
|
||||
/* send notifiers for this - using keyframe editing notifiers, since action
|
||||
* may be being shown in anim editors as active action
|
||||
*/
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSELIB_OT_pose_move(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
static EnumPropertyItem pose_lib_pose_move[] = {
|
||||
{1, "UP", 0, "Up", ""},
|
||||
{-1, "DOWN", 0, "Down", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "PoseLib Move Pose";
|
||||
ot->idname = "POSELIB_OT_pose_move";
|
||||
ot->description = "Move the pose up or down in the active Pose Library";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
ot->exec = poselib_move_exec;
|
||||
ot->poll = has_poselib_pose_data_for_editing_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to move");
|
||||
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
|
||||
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
||||
ot->prop = prop;
|
||||
|
||||
RNA_def_enum(ot->srna, "direction", pose_lib_pose_move, 0, "Direction", "Direction to move, UP or DOWN");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************************************************************* */
|
||||
/* Pose-Lib Browsing/Previewing Operator */
|
||||
|
||||
|
|
Loading…
Reference in New Issue