Clean-up logic of behavior of refresh/reload operators in sequencer

After discussion with Campbell we found much nicer solution which
keeps operation with data much more clear:

- Refresh Sequencer is totally harmless, do not touch actual data
  and just removes everything from cache
- Reload Strip will reload data and adjust it's length for all
  selected strips without affecting on length of strip itself
- Reload Strip and Adjust length will do the same but will also
  adjust length of strip itself.
This commit is contained in:
Sergey Sharybin
2012-03-26 22:26:30 +00:00
parent 83e83e5eff
commit 40c667e75e
5 changed files with 20 additions and 43 deletions

View File

@@ -348,6 +348,4 @@ extern SequencerDrawView sequencer_view3d_cb;
extern ListBase seqbase_clipboard;
extern int seqbase_clipboard_frame;
void seq_update_sequence_length(struct Scene *scene, struct Editing *ed, struct Sequence *seq);
#endif // __BKE_SEQUENCER_H__

View File

@@ -4007,31 +4007,3 @@ void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase,
}
}
}
void seq_update_sequence_length(Scene *scene, Editing *ed, Sequence *seq)
{
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_open_anim_file(seq);
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);
}
}

View File

@@ -1273,15 +1273,22 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
}
/* reload operator */
static int sequencer_reload_exec(bContext *C, wmOperator *UNUSED(op))
static int sequencer_reload_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq;
int adjust_length= RNA_boolean_get(op->ptr, "adjust_length");
for (seq= ed->seqbasep->first; seq; seq= seq->next) {
if (seq->flag & SELECT) {
update_changed_seq_and_deps(scene, seq, 0, 1);
reload_sequence_new_file(scene, seq, !adjust_length);
if (adjust_length) {
if (seq_test_overlap(ed->seqbasep, seq))
shuffle_seq(ed->seqbasep, seq, scene);
}
}
}
@@ -1292,6 +1299,8 @@ static int sequencer_reload_exec(bContext *C, wmOperator *UNUSED(op))
void SEQUENCER_OT_reload(struct wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Reload Strips";
ot->idname = "SEQUENCER_OT_reload";
@@ -1303,26 +1312,18 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
prop = RNA_def_boolean(ot->srna, "adjust_length", 0, "Adjust Length", "Adjust lenght of strips to their data length");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* reload operator */
static void sequencer_refresh_all_length(Scene *scene, Editing *ed)
{
Sequence *seq;
SEQP_BEGIN(ed, seq) {
seq_update_sequence_length(scene, ed, seq);
}
SEQ_END
}
static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(scene, FALSE);
free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE);
sequencer_refresh_all_length(scene, ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);

View File

@@ -159,7 +159,10 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", LKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_reassign_inputs", RKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "adjust_length", TRUE);
WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0);