diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-22 17:22:28 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-22 17:22:28 +0400 |
commit | 44eb9cc2721463ee302dc3a74d45092bd10c12ac (patch) | |
tree | 63410f62967e0c9760eb72372f0448940e7fdd77 /source/blender/editors | |
parent | 5cf739c2dad6002f4716f0ccf514bd2544e0698d (diff) |
Fix #30491: Not Updating Scene Length
(also fixes special request from Ian for Mango)
Added operator to update actual content length of all selected strips.
Can be useful for scenes and movies as well after doing making changes to
scene/movie.
Can be improved further to deal better with cases when strip has got effect
and it's get reshuffled because of overlapping after changing it's length.
Diffstat (limited to 'source/blender/editors')
3 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index cd16b35ea25..8d04edd0c7f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -55,6 +55,7 @@ #include "BKE_sequencer.h" #include "BKE_report.h" #include "BKE_sound.h" +#include "BKE_movieclip.h" #include "IMB_imbuf.h" @@ -3055,3 +3056,65 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); } + +static int sequencer_update_strip_length_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + Editing *ed = seq_give_editing(scene, FALSE); + Sequence *seq; + int update = FALSE; + + SEQP_BEGIN(ed, seq) { + if ((seq->flag & SELECT)) { + int changed = FALSE; + + switch (seq->type) { + case SEQ_SCENE: + seq->len = seq->scene->r.efra - seq->scene->r.sfra + 1; + changed = TRUE; + break; + case SEQ_MOVIECLIP: + seq->len = BKE_movieclip_get_duration(seq->clip); + changed = TRUE; + break; + case SEQ_MOVIE: + seq->len = IMB_anim_get_duration(seq->anim, IMB_TC_RECORD_RUN); + changed = TRUE; + break; + } + + if (changed) { + calc_sequence_disp(scene, seq); + + if (seq_test_overlap(ed->seqbasep, seq)) + shuffle_seq(ed->seqbasep, seq, scene); + + update = TRUE; + } + } + } + SEQ_END + + if (update) { + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + } + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_update_strip_length(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Strip Length"; + ot->idname = "SEQUENCER_OT_update_strip_length"; + ot->description = "Update actual content length for selected strips"; + + /* api callbacks */ + ot->exec = sequencer_update_strip_length_exec; + ot->poll = ED_operator_sequencer_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index ef782832f13..7acaaf76c62 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -117,6 +117,8 @@ void SEQUENCER_OT_paste(struct wmOperatorType *ot); void SEQUENCER_OT_rebuild_proxy(struct wmOperatorType *ot); +void SEQUENCER_OT_update_strip_length(struct wmOperatorType *ot); + /* preview specific operators */ void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 1ebb8af321c..88b9c61a033 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -113,6 +113,8 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_copy); WM_operatortype_append(SEQUENCER_OT_paste); + + WM_operatortype_append(SEQUENCER_OT_update_strip_length); } |