diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-08-23 13:04:30 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-08-23 13:04:30 +0400 |
commit | 9bae78ed5d2261c9d61c854d405286741fcb39b2 (patch) | |
tree | b6d63943f9dd2081f857530eb5ac8173ed14f728 /source/blender/editors/space_sequencer/sequencer_modifier.c | |
parent | 40db82e31482361a9cda585e3eb396e81859cf31 (diff) |
Sequencer: move up/down operators for modifiers
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_modifier.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_modifier.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index b19d92d67a0..a4a485b34c6 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -154,3 +154,69 @@ void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); } + +/*********************** Move operator *************************/ + +enum { + SEQ_MODIFIER_MOVE_UP = 0, + SEQ_MODIFIER_MOVE_DOWN +}; + +static int strip_modifier_move_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Sequence *seq = BKE_sequencer_active_get(scene); + char name[MAX_NAME]; + int direction; + SequenceModifierData *smd; + + RNA_string_get(op->ptr, "name", name); + direction = RNA_enum_get(op->ptr, "direction"); + + smd = BKE_sequence_modifier_find_by_name(seq, name); + if (!smd) + return OPERATOR_CANCELLED; + + if (direction == SEQ_MODIFIER_MOVE_UP) { + if (smd->prev) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->prev->prev, smd); + } + } + else if (direction == SEQ_MODIFIER_MOVE_DOWN) { + if (smd->next) { + BLI_remlink(&seq->modifiers, smd); + BLI_insertlink(&seq->modifiers, smd->next, smd); + } + } + + BKE_sequence_invalidate_cache(scene, seq); + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) +{ + static EnumPropertyItem direction_items[] = { + {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"}, + {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"}, + {0, NULL, 0, NULL, NULL} + }; + + /* identifiers */ + ot->name = "Move Strip Modifier"; + ot->idname = "SEQUENCER_OT_strip_modifier_move"; + ot->description = "Move modifier up and down in the stack"; + + /* api callbacks */ + ot->exec = strip_modifier_move_exec; + ot->poll = strip_modifier_active_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove"); + RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", ""); +} |