diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2012-10-07 15:55:49 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2012-10-07 15:55:49 +0400 |
commit | e4c70deee87290363d02942ecbbf39216a3620a8 (patch) | |
tree | b98b5477e6ce7c43e6aafac5cda851c3d95cbfaf /source/blender/editors/space_sequencer | |
parent | 39d020da482c8859f1a9229c392145f904973387 (diff) | |
parent | 7748133bf2d0a99f37b2a0b0ce438b6726db36fa (diff) |
Merge w/ trunk: r50097-r51140 (also, I got ahead of myself and fixed a lot of warnings before committing)
Diffstat (limited to 'source/blender/editors/space_sequencer')
11 files changed, 758 insertions, 226 deletions
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 91ed9da17bc..3563cc96861 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -45,6 +45,7 @@ set(SRC sequencer_ops.c sequencer_scopes.c sequencer_select.c + sequencer_view.c space_sequencer.c sequencer_intern.h diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 7b7170d99e0..ff895c06d57 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -242,7 +242,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) strip->us = 1; BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2); - BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq); + BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); @@ -343,7 +343,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) strip->us = 1; BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2); - BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq); + BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); BKE_sequence_calc_disp(scene, seq); BKE_sequencer_sort(scene); @@ -439,7 +439,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) strip->us = 1; BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2); - BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq); + BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); BKE_sequence_calc_disp(scene, seq); BKE_sequencer_sort(scene); @@ -820,7 +820,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->type = type; BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2); - BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq); + BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); sh = BKE_sequence_get_effect(seq); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index c3d74667349..c0f96052d81 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -52,6 +52,7 @@ #include "BKE_sound.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "GPU_colors.h" @@ -70,6 +71,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "WM_api.h" +#include "WM_types.h" + /* own include */ #include "sequencer_intern.h" @@ -437,7 +441,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask); + pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); if (pixely <= 0) return; /* can happen when the view is split/resized */ @@ -736,7 +740,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline /* draw sound wave */ if (seq->type == SEQ_TYPE_SOUND_RAM) { - drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx); + drawseqwave(scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx); } /* draw lock */ @@ -758,7 +762,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline glDisable(GL_BLEND); } - if (!BKE_seqence_is_valid_check(seq)) { + if (!BKE_sequence_is_valid_check(seq)) { glEnable(GL_POLYGON_STIPPLE); /* panic! */ @@ -826,20 +830,103 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) else special_seq_update = NULL; } +ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs) +{ + SeqRenderData context; + ImBuf *ibuf; + int rectx, recty; + float render_size = 0.0; + float proxy_size = 100.0; + + render_size = sseq->render_size; + if (render_size == 0) { + render_size = scene->r.size; + } + else { + proxy_size = render_size; + } + + if (render_size < 0) { + return NULL; + } + + rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f; + recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f; + + context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); + + if (special_seq_update) + ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); + else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { + ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); + else + ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + + return ibuf; +} + +static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf) +{ + if (scopes->reference_ibuf != ibuf) { + if (scopes->zebra_ibuf) { + IMB_freeImBuf(scopes->zebra_ibuf); + scopes->zebra_ibuf = NULL; + } + + if (scopes->waveform_ibuf) { + IMB_freeImBuf(scopes->waveform_ibuf); + scopes->waveform_ibuf = NULL; + } + + if (scopes->sep_waveform_ibuf) { + IMB_freeImBuf(scopes->sep_waveform_ibuf); + scopes->sep_waveform_ibuf = NULL; + } + + if (scopes->vector_ibuf) { + IMB_freeImBuf(scopes->vector_ibuf); + scopes->vector_ibuf = NULL; + } + + if (scopes->histogram_ibuf) { + IMB_freeImBuf(scopes->histogram_ibuf); + scopes->histogram_ibuf = NULL; + } + } +} + +static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf)) +{ + ImBuf *display_ibuf = IMB_dupImBuf(ibuf); + ImBuf *scope; + + if (display_ibuf->rect_float) { + IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, + &scene->display_settings); + } + + scope = make_scope_cb(display_ibuf); + + IMB_freeImBuf(display_ibuf); + + return scope; +} + void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay) { struct Main *bmain = CTX_data_main(C); struct ImBuf *ibuf = NULL; struct ImBuf *scope = NULL; struct View2D *v2d = &ar->v2d; - int rectx, recty; + /* int rectx, recty; */ /* UNUSED */ float viewrectx, viewrecty; float render_size = 0.0; float proxy_size = 100.0; float col[3]; GLuint texid; GLuint last_texid; - SeqRenderData context; + unsigned char *display_buffer; + void *cache_handle = NULL; render_size = sseq->render_size; if (render_size == 0) { @@ -855,8 +942,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq viewrectx = (render_size * (float)scene->r.xsch) / 100.0f; viewrecty = (render_size * (float)scene->r.ysch) / 100.0f; - rectx = viewrectx + 0.5f; - recty = viewrecty + 0.5f; + /* rectx = viewrectx + 0.5f; */ /* UNUSED */ + /* recty = viewrecty + 0.5f; */ /* UNUSED */ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { viewrectx *= scene->r.xasp / scene->r.yasp; @@ -879,52 +966,74 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (G.is_rendering) return; - context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size); - - if (special_seq_update) - ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update); - else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown); - else - ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown); + ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs); if (ibuf == NULL) return; if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; - - switch (sseq->mainb) { - case SEQ_DRAW_IMG_IMBUF: - if (sseq->zebra != 0) { - scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra); - } - break; - case SEQ_DRAW_IMG_WAVEFORM: - if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { - scope = make_sep_waveform_view_from_ibuf(ibuf); - } - else { - scope = make_waveform_view_from_ibuf(ibuf); - } - break; - case SEQ_DRAW_IMG_VECTORSCOPE: - scope = make_vectorscope_view_from_ibuf(ibuf); - break; - case SEQ_DRAW_IMG_HISTOGRAM: - scope = make_histogram_view_from_ibuf(ibuf); - break; + + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) { + SequencerScopes *scopes = &sseq->scopes; + + sequencer_check_scopes(scopes, ibuf); + + switch (sseq->mainb) { + case SEQ_DRAW_IMG_IMBUF: + if (!scopes->zebra_ibuf) { + ImBuf *display_ibuf = IMB_dupImBuf(ibuf); + + if (display_ibuf->rect_float) { + IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, + &scene->display_settings); + } + scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra); + IMB_freeImBuf(display_ibuf); + } + scope = scopes->zebra_ibuf; + break; + case SEQ_DRAW_IMG_WAVEFORM: + if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { + if (!scopes->sep_waveform_ibuf) + scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf); + scope = scopes->sep_waveform_ibuf; + } + else { + if (!scopes->waveform_ibuf) + scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf); + scope = scopes->waveform_ibuf; + } + break; + case SEQ_DRAW_IMG_VECTORSCOPE: + if (!scopes->vector_ibuf) + scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf); + scope = scopes->vector_ibuf; + break; + case SEQ_DRAW_IMG_HISTOGRAM: + if (!scopes->histogram_ibuf) + scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf); + scope = scopes->histogram_ibuf; + break; + } + + scopes->reference_ibuf = ibuf; } if (scope) { IMB_freeImBuf(ibuf); ibuf = scope; - } - if (ibuf->rect_float && ibuf->rect == NULL) { - IMB_rect_from_float(ibuf); + if (ibuf->rect_float && ibuf->rect == NULL) { + IMB_rect_from_float(ibuf); + } + + display_buffer = (unsigned char *)ibuf->rect; } - + else { + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + } + /* setting up the view - actual drawing starts here */ UI_view2d_view_ortho(v2d); @@ -937,16 +1046,16 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); gpuBegin(GL_QUADS); if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { rctf tot_clip; - tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin); - tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin); - tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax); - tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax); + tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin); + tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin); + tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax); + tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax); gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); gpuVertex2f(tot_clip.xmin, tot_clip.ymin); gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); gpuVertex2f(tot_clip.xmin, tot_clip.ymax); @@ -1017,7 +1126,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq /* draw grease-pencil (image aligned) */ draw_gpencil_2dimage(C); - IMB_freeImBuf(ibuf); + if (!scope) + IMB_freeImBuf(ibuf); /* ortho at pixel level */ UI_view2d_view_restore(C); @@ -1036,6 +1146,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (mask) { int width, height; + float aspx = 1.0f, aspy = 1.0f; // ED_mask_get_size(C, &width, &height); //Scene *scene = CTX_data_scene(C); @@ -1045,11 +1156,14 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq ED_mask_draw_region(mask, ar, 0, 0, /* TODO */ width, height, + aspx, aspy, FALSE, TRUE, NULL, C); } } + if (cache_handle) + IMB_display_buffer_release(cache_handle); } #if 0 @@ -1132,7 +1246,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) View2D *v2d = &ar->v2d; Sequence *last_seq = BKE_sequencer_active_get(scene); int sel = 0, j; - float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); /* loop through twice, first unselected, then selected */ for (j = 0; j < 2; j++) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 2dc26a9d5b8..204930e82a6 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -170,7 +170,7 @@ static void proxy_endjob(void *pjv) BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop); } - BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, FALSE, FALSE); + BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, FALSE); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene); } @@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ if (ed == NULL) return NULL; - pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask); + pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -381,8 +381,8 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ while (seq) { if (seq->machine == (int)y) { /* check for both normal strips, and strips that have been flipped horizontally */ - if ( ((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) || - ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) ) + if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) || + ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) ) { if (BKE_sequence_tx_test(seq)) { @@ -1141,12 +1141,16 @@ 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; + BKE_sequence_invalidate_dependent(scene, seq); + } } else { - if ((seq->flag & SELECT) == 0) + if ((seq->flag & SELECT) == 0) { seq->flag |= SEQ_MUTE; + BKE_sequence_invalidate_dependent(scene, seq); + } } } } @@ -1188,12 +1192,16 @@ 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; + BKE_sequence_invalidate_dependent(scene, seq); + } } else { - if ((seq->flag & SELECT) == 0) + if ((seq->flag & SELECT) == 0) { seq->flag &= ~SEQ_MUTE; + BKE_sequence_invalidate_dependent(scene, seq); + } } } } @@ -1340,7 +1348,7 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE); + BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1565,7 +1573,7 @@ static int apply_unique_name_cb(Sequence *seq, void *arg_pt) char name[sizeof(seq->name) - 2]; strcpy(name, seq->name + 2); - BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq); + BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq); BKE_sequencer_dupe_animdata(scene, name, seq->name + 2); return 1; @@ -1668,6 +1676,20 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +static int sequencer_delete_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + + if (ar->regiontype == RGN_TYPE_WINDOW) { + /* bounding box of 30 pixels is used for markers shortcuts, + * prevent conflict with markers shortcurts here + */ + if (event->mval[1] <= 30) + return OPERATOR_PASS_THROUGH; + } + + return WM_operator_confirm(C, op, event); +} void SEQUENCER_OT_delete(wmOperatorType *ot) { @@ -1678,7 +1700,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) ot->description = "Erase selected strips from the sequencer"; /* api callbacks */ - ot->invoke = WM_operator_confirm; + ot->invoke = sequencer_delete_invoke; ot->exec = sequencer_delete_exec; ot->poll = sequencer_edit_poll; @@ -1946,7 +1968,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) BKE_sequencer_update_muting(ed); - BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seqm); + BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2142,8 +2164,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) float winx = (int)(rd->size * rd->xsch) / 100; float winy = (int)(rd->size * rd->ysch) / 100; - float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx; - float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy; + float facx = BLI_rcti_size_x(&v2d->mask) / winx; + float facy = BLI_rcti_size_y(&v2d->mask) / winy; BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1); @@ -2246,7 +2268,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) ymax += ymargin; ymin -= ymargin; - orig_height = cur_new.ymax - cur_new.ymin; + orig_height = BLI_rctf_size_y(&cur_new); cur_new.xmin = xmin; cur_new.xmax = xmax; @@ -2255,8 +2277,8 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) cur_new.ymax = ymax; /* only zoom out vertically */ - if (orig_height > cur_new.ymax - cur_new.ymin) { - ymid = BLI_RCT_CENTER_Y(&cur_new); + if (orig_height > BLI_rctf_size_y(&cur_new)) { + ymid = BLI_rctf_cent_y(&cur_new); cur_new.ymin = ymid - (orig_height / 2); cur_new.ymax = ymid + (orig_height / 2); @@ -2288,7 +2310,9 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) } -static int find_next_prev_edit(Scene *scene, int cfra, int side) +static int find_next_prev_edit(Scene *scene, int cfra, + const short side, + const short do_skip_mute, const short do_center) { Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL, *frame_seq = NULL; @@ -2299,19 +2323,32 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) if (ed == NULL) return cfra; for (seq = ed->seqbasep->first; seq; seq = seq->next) { + int seq_frame; + + if (do_skip_mute && (seq->flag & SEQ_MUTE)) { + continue; + } + + if (do_center) { + seq_frame = (seq->startdisp + seq->enddisp) / 2; + } + else { + seq_frame = seq->startdisp; + } + dist = MAXFRAME * 2; switch (side) { case SEQ_SIDE_LEFT: - if (seq->startdisp < cfra) { - dist = cfra - seq->startdisp; + if (seq_frame < cfra) { + dist = cfra - seq_frame; } break; case SEQ_SIDE_RIGHT: - if (seq->startdisp > cfra) { - dist = seq->startdisp - cfra; + if (seq_frame > cfra) { + dist = seq_frame - cfra; } - else if (seq->startdisp == cfra) { + else if (seq_frame == cfra) { frame_seq = seq; } break; @@ -2326,83 +2363,77 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) /* if no sequence to the right is found and the * frame is on the start of the last sequence, * move to the end of the last sequence */ - if (frame_seq) cfra = frame_seq->enddisp; + if (frame_seq) { + if (do_center) { + cfra = (frame_seq->startdisp + frame_seq->enddisp) / 2; + } + else { + cfra = frame_seq->enddisp; + } + } + + if (best_seq) { + if (do_center) { + cfra = (best_seq->startdisp + best_seq->enddisp) / 2; + } + else { + cfra = best_seq->startdisp; + } + } - return best_seq ? best_seq->startdisp : cfra; + return cfra; } -static int next_prev_edit_internal(Scene *scene, int side) +static int strip_jump_internal(Scene *scene, + const short side, + const short do_skip_mute, const short do_center) { - int change = 0; + int change = FALSE; int cfra = CFRA; - int nfra = find_next_prev_edit(scene, cfra, side); + int nfra = find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center); if (nfra != cfra) { CFRA = nfra; - change = 1; + change = TRUE; } return change; } -/* move frame to next edit point operator */ -static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op)) +/* jump frame to edit point operator */ +static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - - 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; -} + short next = RNA_boolean_get(op->ptr, "next"); + short center = RNA_boolean_get(op->ptr, "center"); -void SEQUENCER_OT_next_edit(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Next Edit"; - ot->idname = "SEQUENCER_OT_next_edit"; - ot->description = "Move frame to next edit point"; - - /* api callbacks */ - ot->exec = sequencer_next_edit_exec; - ot->poll = sequencer_edit_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ -} - -/* move frame to previous edit point operator */ -static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Scene *scene = CTX_data_scene(C); - - if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) + /* currently do_skip_mute is always TRUE */ + if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, TRUE, center)) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -void SEQUENCER_OT_previous_edit(wmOperatorType *ot) +void SEQUENCER_OT_strip_jump(wmOperatorType *ot) { /* identifiers */ - ot->name = "Previous Edit"; - ot->idname = "SEQUENCER_OT_previous_edit"; + ot->name = "Jump to Strip"; + ot->idname = "SEQUENCER_OT_strip_jump"; ot->description = "Move frame to previous edit point"; - + /* api callbacks */ - ot->exec = sequencer_previous_edit_exec; + ot->exec = sequencer_strip_jump_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Strip", ""); + RNA_def_boolean(ot->srna, "center", TRUE, "Use strip center", ""); } static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) @@ -2424,7 +2455,7 @@ static Sequence *sequence_find_parent(Scene *scene, Sequence *child) if (ed == NULL) return NULL; for (seq = ed->seqbasep->first; seq; seq = seq->next) { - if ( (seq != child) && seq_is_parent(seq, child) ) { + if ((seq != child) && seq_is_parent(seq, child)) { parent = seq; break; } @@ -2540,7 +2571,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) if (se) { // prevent setting the render size if sequence values aren't initialized - if ( (se->orig_width > 0) && (se->orig_height > 0) ) { + if ((se->orig_width > 0) && (se->orig_height > 0)) { scene->r.xsch = se->orig_width; scene->r.ysch = se->orig_height; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); @@ -2769,11 +2800,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) if (ed == NULL) return OPERATOR_CANCELLED; - rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); - rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); + rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot)); + rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot)); - rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot))); - rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot))); + rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot)); + rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot)); rect.xmin += 0.5f; rect.xmax += 0.5f; @@ -2880,7 +2911,7 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1); /* important else we don't get the imbuf cache flushed */ - BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE); + BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2940,7 +2971,7 @@ static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1); /* important else we don't get the imbuf cache flushed */ - BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE); + BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -3013,7 +3044,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) BKE_sequence_calc(scene, seq); /* important else we don't get the imbuf cache flushed */ - BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE); + BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE); } else { /* lame, set rna filepath */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index bad4fcf9135..935bd13fcfc 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -44,6 +44,7 @@ struct ScrArea; struct ARegion; struct ARegionType; struct Scene; +struct Main; /* space_sequencer.c */ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); @@ -51,10 +52,12 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa); /* sequencer_draw.c */ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar); -void draw_image_seq(const struct bContext* C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); +void draw_image_seq(const struct bContext *C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay); void seq_reset_imageofs(struct SpaceSeq *sseq); +struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs); + /* sequencer_edit.c */ struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); @@ -95,8 +98,7 @@ void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot); void SEQUENCER_OT_snap(struct wmOperatorType *ot); -void SEQUENCER_OT_previous_edit(struct wmOperatorType *ot); -void SEQUENCER_OT_next_edit(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_jump(struct wmOperatorType *ot); void SEQUENCER_OT_swap(struct wmOperatorType *ot); void SEQUENCER_OT_swap_data(struct wmOperatorType *ot); void SEQUENCER_OT_rendersize(struct wmOperatorType *ot); @@ -116,8 +118,6 @@ 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); @@ -180,6 +180,10 @@ void SEQUENCER_OT_properties(struct wmOperatorType *ot); /* sequencer_modifiers.c */ void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot); void SEQUENCER_OT_strip_modifier_remove(struct wmOperatorType *ot); +void SEQUENCER_OT_strip_modifier_move(struct wmOperatorType *ot); + +/* sequencer_view.c */ +void SEQUENCER_OT_sample(struct wmOperatorType *ot); #endif /* __SEQUENCER_INTERN_H__ */ 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", ""); +} diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 45ffc997172..70b288a59e6 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -43,6 +43,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_sequencer.h" #include "ED_markers.h" #include "ED_transform.h" /* transform keymap */ @@ -72,12 +73,14 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); WM_operatortype_append(SEQUENCER_OT_snap); - WM_operatortype_append(SEQUENCER_OT_next_edit); - WM_operatortype_append(SEQUENCER_OT_previous_edit); + WM_operatortype_append(SEQUENCER_OT_strip_jump); WM_operatortype_append(SEQUENCER_OT_swap); WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); + WM_operatortype_append(SEQUENCER_OT_copy); + WM_operatortype_append(SEQUENCER_OT_paste); + WM_operatortype_append(SEQUENCER_OT_view_all); WM_operatortype_append(SEQUENCER_OT_view_selected); WM_operatortype_append(SEQUENCER_OT_view_all_preview); @@ -110,14 +113,17 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_sound_strip_add); WM_operatortype_append(SEQUENCER_OT_image_strip_add); WM_operatortype_append(SEQUENCER_OT_effect_strip_add); - WM_operatortype_append(SEQUENCER_OT_properties); - WM_operatortype_append(SEQUENCER_OT_copy); - WM_operatortype_append(SEQUENCER_OT_paste); + /* sequencer_buttons.c */ + WM_operatortype_append(SEQUENCER_OT_properties); /* sequencer_modifiers.c */ WM_operatortype_append(SEQUENCER_OT_strip_modifier_add); WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove); + WM_operatortype_append(SEQUENCER_OT_strip_modifier_move); + + /* sequencer_view.h */ + WM_operatortype_append(SEQUENCER_OT_sample); } @@ -128,7 +134,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Common items ------------------------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0); - + + WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.show_overlay"); @@ -137,9 +145,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) /* Strips Region --------------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0); - - WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); @@ -149,12 +155,12 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "type", SEQ_CUT_SOFT); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", TRUE); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "unselected", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); @@ -175,7 +181,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -189,12 +195,24 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", FALSE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, 0, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", FALSE); + + /* alt for center */ + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEUPKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + RNA_boolean_set(kmi->ptr, "center", TRUE); + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_strip_jump", PAGEDOWNKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + RNA_boolean_set(kmi->ptr, "center", TRUE); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0); @@ -229,7 +247,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "linked_left", TRUE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "linked_right", TRUE); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "linked_left", TRUE); RNA_boolean_set(kmi->ptr, "linked_right", TRUE); @@ -277,14 +295,14 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -292,37 +310,39 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame"); RNA_int_set(kmi->ptr, "value", 0); transform_keymap_for_space(keyconf, keymap, SPACE_SEQ); - + /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); - - + + /* Preview Region ----------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0); /* would prefer to use numpad keys for job */ RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f); - + /* Setting zoom levels is not that useful, except for back to zoom level 1, removing keymap because of conflicts for now */ #if 0 RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f); - + RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f); RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f); #endif + + /* sample */ + WM_keymap_add_item(keymap, "SEQUENCER_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0); } void ED_operatormacros_sequencer(void) diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 5debeaf79ae..6ed34a79510 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -60,16 +60,14 @@ static void scope_put_pixel(unsigned char *table, unsigned char *pos) pos[3] = 255; } -static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, - int col) +static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, int col) { char newval = table[pos[col]]; pos[col] = newval; pos[3] = 255; } -static void wform_put_line(int w, - unsigned char *last_pos, unsigned char *new_pos) +static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_pos) { if (last_pos > new_pos) { unsigned char *temp = new_pos; @@ -86,8 +84,7 @@ static void wform_put_line(int w, } } -static void wform_put_line_single( - int w, unsigned char *last_pos, unsigned char *new_pos, int col) +static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char *new_pos, int col) { if (last_pos > new_pos) { unsigned char *temp = new_pos; @@ -161,8 +158,7 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -204,8 +200,7 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -249,8 +244,7 @@ ImBuf *make_waveform_view_from_ibuf(ImBuf *ibuf) static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) { - ImBuf *rval = IMB_allocImBuf( - ibuf->x + 3, 515, 32, IB_rect); + ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect); int x, y; unsigned char *src = (unsigned char *) ibuf->rect; unsigned char *tgt = (unsigned char *) rval->rect; @@ -263,8 +257,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -275,16 +268,14 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) unsigned char *rgb = src + 4 * (ibuf->x * y + x); for (c = 0; c < 3; c++) { unsigned char *p = tgt; - p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + - c * sw + x / 3 + 1); + p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; scope_put_pixel_single(wtable, p, c); if (last_p[c] != NULL) { - wform_put_line_single( - w, last_p[c], p, c); + wform_put_line_single(w, last_p[c], p, c); } last_p[c] = p; } @@ -311,8 +302,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) wform_put_grid(tgt, w, h); for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - waveform_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } for (y = 0; y < ibuf->y; y++) { @@ -327,16 +317,14 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) CLAMP(v, 0.0f, 1.0f); - p += 4 * (w * ((int) (v * (h - 3)) + 1) + - c * sw + x / 3 + 1); + p += 4 * (w * ((int) (v * (h - 3)) + 1) + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; scope_put_pixel_single(wtable, p, c); if (last_p[c] != NULL) { - wform_put_line_single( - w, last_p[c], p, c); + wform_put_line_single(w, last_p[c], p, c); } last_p[c] = p; } @@ -461,6 +449,8 @@ static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col) } } +#define HIS_STEPS 512 + static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) { ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect); @@ -468,22 +458,38 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) unsigned int n; unsigned char *src = (unsigned char *) ibuf->rect; - unsigned int bins[3][256]; + unsigned int bins[3][HIS_STEPS]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); + #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256) for (y = 0; y < ibuf->y; y++) { + unsigned int cur_bins[3][HIS_STEPS]; + + memset(cur_bins, 0, sizeof(cur_bins)); + for (x = 0; x < ibuf->x; x++) { - bins[0][*src++]++; - bins[1][*src++]++; - bins[2][*src++]++; - src++; + unsigned char *pixel = src + (y * ibuf->x + x) * 4; + + cur_bins[0][pixel[0]]++; + cur_bins[1][pixel[1]]++; + cur_bins[2][pixel[2]]++; + } + + #pragma omp critical + { + int i; + for (i = 0; i < HIS_STEPS; i++) { + bins[0][i] += cur_bins[0][i]; + bins[1][i] += cur_bins[1][i]; + bins[2][i] += cur_bins[2][i]; + } } } n = 0; for (c = 0; c < 3; c++) { - for (x = 0; x < 256; x++) { + for (x = 0; x < HIS_STEPS; x++) { if (bins[c][x] > n) { n = bins[c][x]; } @@ -491,11 +497,9 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) } for (c = 0; c < 3; c++) { - for (x = 0; x < 256; x++) { - draw_histogram_bar(rval, x * 2 + 1, - ((float) bins[c][x]) / n, c); - draw_histogram_bar(rval, x * 2 + 2, - ((float) bins[c][x]) / n, c); + for (x = 0; x < HIS_STEPS; x++) { + draw_histogram_bar(rval, x * 2 + 1, ((float) bins[c][x]) / n, c); + draw_histogram_bar(rval, x * 2 + 2, ((float) bins[c][x]) / n, c); } } @@ -504,13 +508,13 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) return rval; } -static int get_bin_float(float f) +BLI_INLINE int get_bin_float(float f) { if (f < -0.25f) { - f = -0.25f; + return 0; } - else if (f > 1.25f) { - f = 1.25f; + else if (f >= 1.25f) { + return 511; } return (int) (((f + 0.25f) / 1.5f) * 512); @@ -522,16 +526,32 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) int n, c, x, y; float *src = ibuf->rect_float; - unsigned int bins[3][512]; + unsigned int bins[3][HIS_STEPS]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); + #pragma omp parallel for shared(bins, src, ibuf) private(x, y) if (ibuf->y >= 256) for (y = 0; y < ibuf->y; y++) { + unsigned int cur_bins[3][HIS_STEPS]; + + memset(cur_bins, 0, sizeof(cur_bins)); + for (x = 0; x < ibuf->x; x++) { - bins[0][get_bin_float(*src++)]++; - bins[1][get_bin_float(*src++)]++; - bins[2][get_bin_float(*src++)]++; - src++; + float *pixel = src + (y * ibuf->x + x) * 4; + + cur_bins[0][get_bin_float(pixel[0])]++; + cur_bins[1][get_bin_float(pixel[1])]++; + cur_bins[2][get_bin_float(pixel[2])]++; + } + + #pragma omp critical + { + int i; + for (i = 0; i < HIS_STEPS; i++) { + bins[0][i] += cur_bins[0][i]; + bins[1][i] += cur_bins[1][i]; + bins[2][i] += cur_bins[2][i]; + } } } @@ -540,14 +560,14 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) n = 0; for (c = 0; c < 3; c++) { - for (x = 0; x < 512; x++) { + for (x = 0; x < HIS_STEPS; x++) { if (bins[c][x] > n) { n = bins[c][x]; } } } for (c = 0; c < 3; c++) { - for (x = 0; x < 512; x++) { + for (x = 0; x < HIS_STEPS; x++) { draw_histogram_bar(rval, x + 1, (float) bins[c][x] / n, c); } } @@ -557,6 +577,8 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) return rval; } +#undef HIS_STEPS + ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf) { if (ibuf->rect_float) { @@ -567,9 +589,7 @@ ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf) } } -static void vectorscope_put_cross(unsigned char r, unsigned char g, - unsigned char b, - char *tgt, int w, int h, int size) +static void vectorscope_put_cross(unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size) { float rgb[3], yuv[3]; char *p; @@ -609,8 +629,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) unsigned char wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - scope_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255); } for (x = 0; x <= 255; x++) { @@ -656,8 +675,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) unsigned char wtable[256]; for (x = 0; x < 256; x++) { - wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, - scope_gamma) * 255); + wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255); } for (x = 0; x <= 255; x++) { diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 3d57f2f88ed..be33b782fdf 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -1109,7 +1109,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) actseq->tmp = SET_INT_IN_POINTER(TRUE); - for (BKE_seqence_iterator_begin(ed, &iter, TRUE); iter.valid; BKE_seqence_iterator_next(&iter)) { + for (BKE_sequence_iterator_begin(ed, &iter, TRUE); iter.valid; BKE_sequence_iterator_next(&iter)) { seq = iter.seq; /* Ignore all seqs already selected! */ @@ -1137,8 +1137,8 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) changed = TRUE; /* Unfortunately, we must restart checks from the beginning. */ - BKE_seqence_iterator_end(&iter); - BKE_seqence_iterator_begin(ed, &iter, TRUE); + BKE_sequence_iterator_end(&iter); + BKE_sequence_iterator_begin(ed, &iter, TRUE); } /* Video strips bellow active one, or any strip for audio (order do no matters here!). */ @@ -1147,7 +1147,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) changed = TRUE; } } - BKE_seqence_iterator_end(&iter); + BKE_sequence_iterator_end(&iter); return changed; } diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c new file mode 100644 index 00000000000..92b17393114 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -0,0 +1,234 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +/** \file blender/editors/space_sequencer/sequencer_view.c + * \ingroup spseq + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" + +#include "DNA_scene_types.h" + +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_sequencer.h" +#include "BKE_screen.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_image.h" +#include "ED_screen.h" +#include "ED_space_api.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" + +#include "UI_view2d.h" + +/* own include */ +#include "sequencer_intern.h" + +/******************** sample backdrop operator ********************/ + +typedef struct ImageSampleInfo { + ARegionType *art; + void *draw_handle; + int x, y; + int channels; + + unsigned char col[4]; + float colf[4]; + + unsigned char *colp; + float *colfp; + + int draw; +int color_manage; +} ImageSampleInfo; + +static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) +{ + Scene *scene = CTX_data_scene(C); + ImageSampleInfo *info = arg_info; + + if (info->draw) { + ED_image_draw_info(scene, ar, info->color_manage, FALSE, info->channels, + info->x, info->y, info->colp, info->colfp, NULL, NULL); + } +} + +static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); + ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0); + ImageSampleInfo *info = op->customdata; + float fx, fy; + + if (ibuf == NULL) { + IMB_freeImBuf(ibuf); + info->draw = 0; + return; + } + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); + + fx += (float) ibuf->x / 2.0f; + fy += (float) ibuf->y / 2.0f; + + if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { + float *fp; + unsigned char *cp; + int x = (int) fx, y = (int) fy; + + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; + + info->colp = NULL; + info->colfp = NULL; + + if (ibuf->rect) { + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; + info->colp = info->col; + + info->colf[0] = (float)cp[0] / 255.0f; + info->colf[1] = (float)cp[1] / 255.0f; + info->colf[2] = (float)cp[2] / 255.0f; + info->colf[3] = (float)cp[3] / 255.0f; + info->colfp = info->colf; + + info->color_manage = FALSE; + } + if (ibuf->rect_float) { + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); + + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; + info->colfp = info->colf; + + /* sequencer's image buffers are in non-linear space, need to make them linear */ + BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->colf); + + info->color_manage = TRUE; + } + } + else { + info->draw = 0; + } + + IMB_freeImBuf(ibuf); + ED_area_tag_redraw(CTX_wm_area(C)); +} + +static void sample_exit(bContext *C, wmOperator *op) +{ + ImageSampleInfo *info = op->customdata; + + ED_region_draw_cb_exit(info->art, info->draw_handle); + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(info); +} + +static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + SpaceSeq *sseq = CTX_wm_space_seq(C); + ImageSampleInfo *info; + + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) + return OPERATOR_CANCELLED; + + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; + info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); + op->customdata = info; + + sample_apply(C, op, event); + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + switch (event->type) { + case LEFTMOUSE: + case RIGHTMOUSE: /* XXX hardcoded */ + sample_exit(C, op); + return OPERATOR_CANCELLED; + case MOUSEMOVE: + sample_apply(C, op, event); + break; + } + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_cancel(bContext *C, wmOperator *op) +{ + sample_exit(C, op); + + return OPERATOR_CANCELLED; +} + +static int sample_poll(bContext *C) +{ + return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; +} + +void SEQUENCER_OT_sample(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Sample Color"; + ot->idname = "SEQUENCER_OT_sample"; + ot->description = "Use mouse to sample color in current frame"; + + /* api callbacks */ + ot->invoke = sample_invoke; + ot->modal = sample_modal; + ot->cancel = sample_cancel; + ot->poll = sample_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING; +} diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index f7362aab7aa..7bfe58cb50a 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -57,8 +57,19 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "IMB_imbuf.h" + #include "sequencer_intern.h" // own include +/**************************** common state *****************************/ + +static void sequencer_scopes_tag_refresh(ScrArea *sa) +{ + SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; + + sseq->scopes.reference_ibuf = NULL; +} + /* ******************** manage regions ********************* */ ARegion *sequencer_has_buttons_region(ScrArea *sa) @@ -183,12 +194,27 @@ static SpaceLink *sequencer_new(const bContext *C) } /* not spacelink itself */ -static void sequencer_free(SpaceLink *UNUSED(sl)) +static void sequencer_free(SpaceLink *sl) { -// SpaceSeq *sseq= (SpaceSequencer*) sl; - + SpaceSeq *sseq = (SpaceSeq *) sl; + SequencerScopes *scopes = &sseq->scopes; + // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); + if (scopes->zebra_ibuf) + IMB_freeImBuf(scopes->zebra_ibuf); + + if (scopes->waveform_ibuf) + IMB_freeImBuf(scopes->waveform_ibuf); + + if (scopes->sep_waveform_ibuf) + IMB_freeImBuf(scopes->sep_waveform_ibuf); + + if (scopes->vector_ibuf) + IMB_freeImBuf(scopes->vector_ibuf); + + if (scopes->histogram_ibuf) + IMB_freeImBuf(scopes->histogram_ibuf); } @@ -290,7 +316,24 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) return (SpaceLink *)sseqn; } - +static void sequencer_listener(ScrArea *sa, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_SCENE: + switch (wmn->data) { + case ND_FRAME: + case ND_SEQUENCER: + sequencer_scopes_tag_refresh(sa); + break; + } + break; + case NC_SPACE: + if (wmn->data == ND_SPACE_SEQUENCER) + sequencer_scopes_tag_refresh(sa); + break; + } +} /* *********************** sequencer (main) region ************************ */ /* add handlers, stuff you only do once or on area/region changes */ @@ -513,8 +556,8 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); } break; @@ -567,8 +610,8 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->data == ND_DATA) { ED_region_tag_redraw(ar); } break; @@ -610,6 +653,7 @@ void ED_spacetype_sequencer(void) st->context = sequencer_context; st->dropboxes = sequencer_dropboxes; st->refresh = sequencer_refresh; + st->listener = sequencer_listener; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); |