Fix #30491: Not Updating Scene Length
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 22 Mar 2012 13:22:28 +0000 (13:22 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 22 Mar 2012 13:22:28 +0000 (13:22 +0000)
(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.

release/scripts/startup/bl_ui/space_sequencer.py
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/sequencer_ops.c

index 2848b49ef2b55ff54a63eff8dfca2ce35f93bc34..4640e82b53f19323059b17dbc4da77284feb4ca6 100644 (file)
@@ -242,6 +242,7 @@ class SEQUENCER_MT_strip(Menu):
         layout.operator("sequencer.offset_clear")
         layout.operator("sequencer.deinterlace_selected_movies")
         layout.operator("sequencer.rebuild_proxy")
+        layout.operator("sequencer.update_strip_length")
         layout.separator()
 
         layout.operator("sequencer.duplicate")
index cd16b35ea259d5f1a45c1d8ed2911e984dd5fd54..8d04edd0c7f83e74651207e344ab253a0e250403 100644 (file)
@@ -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;
+}
index ef782832f134c0d3cac98a32e531829f7070c06f..7acaaf76c6271186e09c4f623151c4165e3fb6b5 100644 (file)
@@ -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);
 
index 1ebb8af321cd498bbdde79078ae8195663dbdd7a..88b9c61a033a314ea11e9bdb7de1ca0ac8ba50ad 100644 (file)
@@ -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);
 }