diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2016-09-18 22:36:34 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2016-09-18 22:44:42 +0300 |
commit | 572bc1364ca9d978edf5aee991849dd4f8e56a52 (patch) | |
tree | 61e965068f2d6bc835ecb8bd0ffe29709c9f5c1d /source/blender/editors/armature/pose_lib.c | |
parent | 6c28d3bac26b22049768824bef6ae9d0e82bb71f (diff) |
BLI_listbase: Add/use utility to move link (BLI_listbase_link_move)
We were calling BLI_remlink and then BLI_insertlinkbefore/after quite often. BLI_listbase_link_move simplifies code a bit and makes it easier to follow. It also returns if link position has changed which can be used to avoid unnecessary updates.
Added it to a number of list reorder operators for now and made use of return value. Behavior shouldn't be changed.
Also some minor cleanup.
Diffstat (limited to 'source/blender/editors/armature/pose_lib.c')
-rw-r--r-- | source/blender/editors/armature/pose_lib.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index b200aa2401b..4af7f3f8727 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -766,32 +766,18 @@ static int poselib_move_exec(bContext *C, wmOperator *op) dir = RNA_enum_get(op->ptr, "direction"); /* move pose */ - if (dir == 1) { /* up */ - void *prev = marker->prev; + if (BLI_listbase_link_move(&act->markers, marker, dir)) { + act->active_marker = marker_index + dir + 1; - if (prev == NULL) - return OPERATOR_CANCELLED; - - BLI_remlink(&act->markers, marker); - BLI_insertlinkbefore(&act->markers, prev, marker); + /* 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); } - else { /* down */ - void *next = marker->next; - - if (next == NULL) - return OPERATOR_CANCELLED; - - BLI_remlink(&act->markers, marker); - BLI_insertlinkafter(&act->markers, next, marker); + else { + return OPERATOR_CANCELLED; } - 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; } @@ -800,8 +786,8 @@ void POSELIB_OT_pose_move(wmOperatorType *ot) { PropertyRNA *prop; static EnumPropertyItem pose_lib_pose_move[] = { - {1, "UP", 0, "Up", ""}, - {-1, "DOWN", 0, "Down", ""}, + {-1, "UP", 0, "Up", ""}, + {1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} }; |