Sequencer:

* Sound strips now respect metastrips for muting. That means they
  are muted if the metastrip is muted, and don't play when located
  outside of the current metastrip.
* Operators now use notifiers instead of redraw tagging, added a
  separate notifier for selection as well, but that is not used to
  do less redraws yet.
This commit is contained in:
Brecht Van Lommel 2009-12-08 13:57:51 +00:00
parent 0151be0210
commit f2452c1fd6
9 changed files with 133 additions and 71 deletions

@ -186,6 +186,7 @@ int shuffle_seq_time(ListBase * seqbasep);
void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage);
void seq_update_sound(struct Sequence *seq);
void seq_update_muting(struct Editing *ed);
void clear_scene_in_allseqs(struct Scene *sce);

@ -3477,16 +3477,55 @@ int shuffle_seq_time(ListBase * seqbasep)
return offset? 0:1;
}
void seq_update_sound(struct Sequence *seq)
void seq_update_sound(Sequence *seq)
{
if(seq->type == SEQ_SOUND)
if(seq->type == SEQ_SOUND && seq->sound_handle)
{
seq->sound_handle->startframe = seq->startdisp;
seq->sound_handle->endframe = seq->enddisp;
seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs;
seq->sound_handle->mute = seq->flag & SEQ_MUTE ? 1 : 0;
seq->sound_handle->changed = -1;
/* mute is set in seq_update_muting_recursive */
}
}
static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
{
Sequence *seq;
int seqmute;
/* for sound we go over full meta tree to update muted state,
since sound is played outside of evaluating the imbufs, */
for(seq=seqbasep->first; seq; seq=seq->next) {
seqmute= (mute || (seq->flag & SEQ_MUTE));
if(seq->type == SEQ_META) {
/* if this is the current meta sequence, unmute because
all sequences above this were set to mute */
if(seq == metaseq)
seqmute= 0;
seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
}
else if(seq->type == SEQ_SOUND) {
if(seq->sound_handle && seqmute != seq->sound_handle->mute) {
seq->sound_handle->mute = seqmute;
seq->sound_handle->changed = -1;
}
}
}
}
void seq_update_muting(Editing *ed)
{
if(ed) {
/* mute all sounds up to current metastack list */
MetaStack *ms= ed->metastack.last;
if(ms)
seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
else
seq_update_muting_recursive(&ed->seqbase, NULL, 0);
}
}

@ -4234,6 +4234,9 @@ static void lib_link_scene(FileData *fd, Main *main)
seq->anim= 0;
}
SEQ_END
if(sce->ed)
seq_update_muting(sce->ed);
if(sce->nodetree) {
lib_link_ntree(fd, &sce->id, sce->nodetree);

@ -218,7 +218,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
seq->flag |= SELECT;
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -297,8 +297,9 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
}
sort_seq(scene);
seq_update_muting(ed);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -425,7 +426,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
/* last active name */
strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR-1);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -557,7 +558,8 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
seq->flag |= SELECT;
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}

@ -1399,7 +1399,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
/* as last: */
sort_seq(scene);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1451,21 +1451,18 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
if ((seq->flag & SEQ_LOCK)==0) {
if(selected){ /* mute unselected */
if (seq->flag & SELECT) {
if(seq->flag & SELECT)
seq->flag |= SEQ_MUTE;
seq_update_sound(seq);
}
}
else {
if ((seq->flag & SELECT)==0) {
if((seq->flag & SELECT)==0)
seq->flag |= SEQ_MUTE;
seq_update_sound(seq);
}
}
}
}
ED_area_tag_redraw(CTX_wm_area(C));
seq_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1505,21 +1502,18 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
for(seq= ed->seqbasep->first; seq; seq= seq->next) {
if ((seq->flag & SEQ_LOCK)==0) {
if(selected){ /* unmute unselected */
if (seq->flag & SELECT) {
if(seq->flag & SELECT)
seq->flag &= ~SEQ_MUTE;
seq_update_sound(seq);
}
}
else {
if ((seq->flag & SELECT)==0) {
if((seq->flag & SELECT)==0)
seq->flag &= ~SEQ_MUTE;
seq_update_sound(seq);
}
}
}
}
ED_area_tag_redraw(CTX_wm_area(C));
seq_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1559,7 +1553,7 @@ static int sequencer_lock_exec(bContext *C, wmOperator *op)
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1596,7 +1590,7 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *op)
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1633,7 +1627,7 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op)
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1665,7 +1659,7 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *op)
free_imbuf_seq(scene, &ed->seqbase, FALSE);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1741,9 +1735,7 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op)
sort_seq(scene);
}
if (changed) {
ED_area_tag_redraw(CTX_wm_area(C));
}
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1803,7 +1795,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *op)
recurs_dupli_seq(scene, ed->seqbasep, &new);
addlisttolist(ed->seqbasep, &new);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1894,8 +1886,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op)
ms= ms->prev;
}
//ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL); /* redraw other sequencer views */
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -1986,7 +1977,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
/* as last: */
sort_seq(scene);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -2063,7 +2054,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op)
}
ED_area_tag_redraw(CTX_wm_area(C));
seq_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -2164,7 +2157,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm);
ED_area_tag_redraw(CTX_wm_area(C));
seq_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
@ -2233,8 +2228,10 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op)
SEQ_END;
sort_seq(scene);
seq_update_muting(ed);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
@ -2459,16 +2456,16 @@ static int next_prev_edit_internal(Scene *scene, int side)
return change;
}
/* select less operator */
/* move frame to next edit point operator */
static int sequencer_next_edit_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
if (next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) {
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
}
if(!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
return OPERATOR_FINISHED;
}
@ -2494,9 +2491,10 @@ static int sequencer_previous_edit_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
if (next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) {
ED_area_tag_redraw(CTX_wm_area(C));
}
if(!next_prev_edit_internal(scene, SEQ_SIDE_LEFT))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
return OPERATOR_FINISHED;
}
@ -2578,10 +2576,13 @@ static int sequencer_swap_internal_exec(bContext *C, int side)
swap_sequence(active_seq, seq);
break;
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
return OPERATOR_FINISHED;
return OPERATOR_CANCELLED;
}
static int sequencer_swap_right_exec(bContext *C, wmOperator *op)

@ -256,7 +256,8 @@ static int sequencer_deselect_exec(bContext *C, wmOperator *op)
seq->flag |= SELECT;
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -297,7 +298,8 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *op)
seq->flag |= SELECT;
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -508,7 +510,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
#endif
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
/* allowing tweaks */
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
}
@ -594,9 +597,10 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
if (select_more_less_seq__internal(scene, 0, 0)) {
ED_area_tag_redraw(CTX_wm_area(C));
}
if(!select_more_less_seq__internal(scene, 0, 0))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -624,9 +628,10 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
if (select_more_less_seq__internal(scene, 1, 0)) {
ED_area_tag_redraw(CTX_wm_area(C));
}
if(!select_more_less_seq__internal(scene, 1, 0))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -681,7 +686,7 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEv
selected = select_more_less_seq__internal(scene, 1, 1);
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -716,7 +721,7 @@ static int sequencer_select_linked_exec(bContext *C, wmOperator *op)
selected = select_more_less_seq__internal(scene, 1, 1);
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -768,7 +773,7 @@ static int sequencer_select_handles_exec(bContext *C, wmOperator *op)
}
}
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}
@ -805,7 +810,7 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
select_active_side(ed->seqbasep, RNA_enum_get(op->ptr, "side"), seq_act->machine, seq_act->startdisp);
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER_SELECT, scene);
return OPERATOR_FINISHED;
}

@ -232,6 +232,7 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn)
case ND_FRAME:
case ND_MARKERS:
case ND_SEQUENCER:
case ND_SEQUENCER_SELECT:
ED_region_tag_redraw(ar);
break;
}
@ -266,6 +267,7 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->data) {
case ND_FRAME:
case ND_SEQUENCER:
case ND_SEQUENCER_SELECT:
ED_region_tag_redraw(ar);
break;
}

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <limits.h>
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_types.h"
@ -269,11 +270,18 @@ static void rna_Sequence_update(bContext *C, PointerRNA *ptr)
Editing *ed= seq_give_editing(scene, FALSE);
free_imbuf_seq(scene, &ed->seqbase, FALSE);
if(RNA_struct_is_a(ptr->type, &RNA_SoundSequence))
seq_update_sound(ptr->data);
}
static void rna_Sequence_sound_update(bContext *C, PointerRNA *ptr)
static void rna_Sequence_mute_update(bContext *C, PointerRNA *ptr)
{
/* TODO */
Scene *scene= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
seq_update_muting(ed);
rna_Sequence_update(C, ptr);
}
#else
@ -480,22 +488,22 @@ static void rna_def_sequence(BlenderRNA *brna)
prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Selected", "");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER_SELECT, NULL);
prop= RNA_def_property(srna, "left_handle_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LEFTSEL);
RNA_def_property_ui_text(prop, "Left Handle Selected", "");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER_SELECT, NULL);
prop= RNA_def_property(srna, "right_handle_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_RIGHTSEL);
RNA_def_property_ui_text(prop, "Right Handle Selected", "");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER_SELECT, NULL);
prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE);
RNA_def_property_ui_text(prop, "Mute", "");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_mute_update");
prop= RNA_def_property(srna, "frame_locked", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_IPO_FRAME_LOCKED);
@ -834,18 +842,18 @@ static void rna_def_sound(BlenderRNA *brna)
prop= RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Sound");
RNA_def_property_ui_text(prop, "Sound", "Sound datablock used by this sequence.");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_sound_update");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "strip->stripdata->name");
RNA_def_property_ui_text(prop, "Filename", "");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SoundSequence_filename_set");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_sound_update");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
prop= RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "strip->dir");
RNA_def_property_ui_text(prop, "Directory", "");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_sound_update");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
rna_def_input(srna);
@ -855,7 +863,7 @@ static void rna_def_sound(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "volume");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Volume", "Playback volume of the sound");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_sound_update");
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
}
static void rna_def_effect(BlenderRNA *brna)

@ -168,6 +168,7 @@ typedef struct wmNotifier {
#define ND_KEYINGSET (12<<16)
#define ND_SCENEDELETE (13<<16)
#define ND_LAYER (14<<16)
#define ND_SEQUENCER_SELECT (15<<16)
/* NC_OBJECT Object */
#define ND_TRANSFORM (16<<16)