diff options
Diffstat (limited to 'source/blender/editors/space_sequencer')
8 files changed, 192 insertions, 117 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index dce8aa16985..79f30423bf2 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -78,6 +78,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel) struct Main *bmain = CTX_data_main(C); struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); struct Scene *scene = CTX_data_scene(C); + ARegion *region = CTX_wm_region(C); SpaceSeq *space_sequencer = CTX_wm_space_seq(C); /* NOTE: We can only reliably show metadata for the original (current) * frame when split view is used. */ @@ -88,7 +89,8 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel) } /* NOTE: We disable multiview for drawing, since we don't know what is the * from the panel (is kind of all the views?). */ - ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, space_sequencer, scene->r.cfra, 0, ""); + ImBuf *ibuf = sequencer_ibuf_get( + bmain, region, depsgraph, scene, space_sequencer, scene->r.cfra, 0, ""); if (ibuf != NULL) { ED_region_image_metadata_panel_draw(ibuf, panel->layout); IMB_freeImBuf(ibuf); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 0f4690c11d5..cdc7ada8c84 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -56,6 +56,7 @@ #include "GPU_matrix.h" #include "GPU_state.h" #include "GPU_vertex_buffer.h" +#include "GPU_viewport.h" #include "ED_anim_api.h" #include "ED_gpencil.h" @@ -88,11 +89,12 @@ #define SEQ_SCROLLER_TEXT_OFFSET 8 #define MUTE_ALPHA 120 -/* Note, Don't use SEQ_BEGIN/SEQ_END while drawing! +/* Note, Don't use SEQ_ALL_BEGIN/SEQ_ALL_END while drawing! * it messes up transform. */ -#undef SEQ_BEGIN -#undef SEQP_BEGIN -#undef SEQ_END +#undef SEQ_ALL_BEGIN +#undef SEQ_ALL_END +#undef SEQ_CURRENT_BEGIN +#undef SEQ_CURRENT_END static Sequence *special_seq_update = NULL; @@ -294,7 +296,7 @@ static void draw_seq_waveform(View2D *v2d, /* Fcurve lookup is quite expensive, so do this after precondition. */ FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, NULL); - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); @@ -350,13 +352,13 @@ static void draw_seq_waveform(View2D *v2d, immEnd(); immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2) { - /* Don't use SEQ_BEGIN/SEQ_END here, + /* Don't use SEQ_ALL_BEGIN/SEQ_ALL_END here, * because it changes seq->depth, which is needed for transform. */ Sequence *seq; uchar col[4]; @@ -381,9 +383,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, offset = 0; } - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); for (seq = seqbase->first; seq; seq = seq->next) { chan_min = min_ii(chan_min, seq->machine); @@ -443,7 +443,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } /* Get handle width in pixels. */ @@ -489,10 +489,9 @@ static void draw_seq_handle(View2D *v2d, } if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) { - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); if (seq->flag & whichsel) { if (seq_active) { @@ -511,7 +510,7 @@ static void draw_seq_handle(View2D *v2d, } immRectf(pos, rx1, y1, rx2, y2); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } /* Draw numbers for start and end of the strip next to its handles. */ @@ -753,9 +752,7 @@ static void draw_sequence_extensions(Scene *scene, Sequence *seq, uint pos, floa y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); color3ubv_from_seq(scene, seq, col); if (seq->flag & SELECT) { @@ -781,7 +778,7 @@ static void draw_sequence_extensions(Scene *scene, Sequence *seq, uint pos, floa imm_draw_box_wire_2d( pos, x2, y2 + pixely, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); } - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } static void draw_color_strip_band(Sequence *seq, uint pos, float text_margin_y, float y1) @@ -791,7 +788,7 @@ static void draw_color_strip_band(Sequence *seq, uint pos, float text_margin_y, rgb_float_to_uchar(col, colvars->col); if (seq->flag & SEQ_MUTE) { - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); col[3] = MUTE_ALPHA; } else { @@ -812,7 +809,7 @@ static void draw_color_strip_band(Sequence *seq, uint pos, float text_margin_y, immEnd(); if (seq->flag & SEQ_MUTE) { - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } @@ -843,9 +840,7 @@ static void draw_seq_background(Scene *scene, } if (seq->flag & SEQ_MUTE) { - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); col[3] = MUTE_ALPHA; } @@ -910,13 +905,13 @@ static void draw_seq_background(Scene *scene, } if (seq->flag & SEQ_MUTE) { - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } static void draw_seq_locked(float x1, float y1, float x2, float y2) { - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); @@ -930,12 +925,12 @@ static void draw_seq_locked(float x1, float y1, float x2, float y2) immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } static void draw_seq_invalid(float x1, float x2, float y2, float text_margin_y) { - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -943,7 +938,7 @@ static void draw_seq_invalid(float x1, float x2, float y2, float text_margin_y) immRectf(pos, x1, y2, x2, text_margin_y); immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } static void calculate_seq_text_offsets( @@ -1056,13 +1051,13 @@ static void draw_seq_fcurve( GPU_vertbuf_data_len_set(vbo, vert_count); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); GPU_batch_uniform_4f(batch, "color", 0.0f, 0.0f, 0.0f, 0.15f); - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); if (vert_count > 0) { GPU_batch_draw(batch); } - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); GPU_batch_discard(batch); } } @@ -1180,7 +1175,7 @@ static void draw_effect_inputs_highlight(Sequence *seq) Sequence *seq1 = seq->seq1; Sequence *seq2 = seq->seq2; Sequence *seq3 = seq->seq3; - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1207,7 +1202,7 @@ static void draw_effect_inputs_highlight(Sequence *seq) seq3->machine + SEQ_STRIP_OFSTOP); } immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } void sequencer_special_update_set(Sequence *seq) @@ -1235,7 +1230,14 @@ void ED_sequencer_special_preview_clear(void) sequencer_special_update_set(NULL); } +/** + * Rendering using opengl will change the current viewport/context. + * This is why we need the ARegion, to set back the render area. + * TODO do not rely on such hack and just update the ibuf ouside of + * the UI drawing code. + **/ ImBuf *sequencer_ibuf_get(struct Main *bmain, + ARegion *region, struct Depsgraph *depsgraph, Scene *scene, SpaceSeq *sseq, @@ -1271,9 +1273,16 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, * by Escape pressed somewhere in the past. */ G.is_break = false; - /* Rendering can change OGL context. Save & Restore framebuffer. */ + GPUViewport *viewport = WM_draw_region_get_bound_viewport(region); GPUFrameBuffer *fb = GPU_framebuffer_active_get(); - GPU_framebuffer_restore(); + if (viewport) { + /* Unbind viewport to release the DRW context. */ + GPU_viewport_unbind(viewport); + } + else { + /* Rendering can change OGL context. Save & Restore framebuffer. */ + GPU_framebuffer_restore(); + } if (special_seq_update) { ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update); @@ -1282,7 +1291,12 @@ ImBuf *sequencer_ibuf_get(struct Main *bmain, ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown); } - if (fb) { + if (viewport) { + /* Follows same logic as wm_draw_window_offscreen to make sure to restore the same viewport. */ + int view = (sseq->multiview_eye == STEREO_RIGHT_ID) ? 1 : 0; + GPU_viewport_bind(viewport, view, ®ion->winrct); + } + else if (fb) { GPU_framebuffer_bind(fb); } @@ -1534,11 +1548,7 @@ static void sequencer_stop_running_jobs(const bContext *C, Scene *scene) static void sequencer_preview_clear(void) { - float col[3]; - - UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); - GPU_clear_color(col[0], col[1], col[2], 0.0); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_SEQ_PREVIEW); } static void sequencer_preview_get_rect(rctf *preview, @@ -1594,9 +1604,7 @@ static void sequencer_draw_display_buffer(const bContext *C, void *display_buffer; if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) { - GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(GPU_BLEND_ALPHA); } /* Format needs to be created prior to any immBindShader call. @@ -1681,7 +1689,7 @@ static void sequencer_draw_display_buffer(const bContext *C, } if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) { - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } if (draw_backdrop) { @@ -1775,6 +1783,16 @@ void sequencer_draw_preview(const bContext *C, return; } + /* Get image. */ + ibuf = sequencer_ibuf_get( + bmain, region, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]); + + /* Setup offscreen buffers. */ + GPUViewport *viewport = WM_draw_region_get_viewport(region); + GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); + GPU_framebuffer_bind_no_srgb(framebuffer_overlay); + GPU_depth_test(GPU_DEPTH_NONE); + if (sseq->render_size == SEQ_PROXY_RENDER_SIZE_NONE) { sequencer_preview_clear(); return; @@ -1794,9 +1812,6 @@ void sequencer_draw_preview(const bContext *C, imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); } } - /* Get image. */ - ibuf = sequencer_ibuf_get( - bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]); if (ibuf) { scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop); @@ -1928,7 +1943,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) else if (last_seq->type == SEQ_TYPE_MULTICAM) { int channel = last_seq->multicam_source; if (channel != 0) { - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1937,7 +1952,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) immRectf(pos, v2d->cur.xmin, channel, v2d->cur.xmax, channel + 1); immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } } @@ -1945,7 +1960,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) /* Draw highlight if "solo preview" is used. */ if (special_seq_update) { const Sequence *seq = special_seq_update; - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1959,7 +1974,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } } @@ -1969,7 +1984,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) const int frame_sta = scene->r.sfra; const int frame_end = scene->r.efra + 1; - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2030,7 +2045,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUnbindProgram(); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } typedef struct CacheDrawData { @@ -2154,7 +2169,7 @@ static void draw_cache_view(const bContext *C) return; } - GPU_blend(true); + GPU_blend(GPU_BLEND_ALPHA); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2241,7 +2256,7 @@ static void draw_cache_view(const bContext *C) draw_cache_view_batch( userdata.final_out_vbo, userdata.final_out_vert_count, 1.0f, 0.4f, 0.2f, 0.4f); - GPU_blend(false); + GPU_blend(GPU_BLEND_NONE); } /* Draw sequencer timeline. */ @@ -2256,6 +2271,11 @@ void draw_timeline_seq(const bContext *C, ARegion *region) seq_prefetch_wm_notify(C, scene); + GPUViewport *viewport = WM_draw_region_get_viewport(region); + GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); + GPU_framebuffer_bind_no_srgb(framebuffer_overlay); + GPU_depth_test(GPU_DEPTH_NONE); + UI_GetThemeColor3fv(TH_BACK, col); if (ed && ed->metastack.first) { GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f); @@ -2263,7 +2283,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region) else { GPU_clear_color(col[0], col[1], col[2], 0.0f); } - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); /* Get timeline boundbox, needed for the scrollers. */ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 99d4c2d9f1a..f175c2a7419 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -58,6 +58,7 @@ #include "ED_sequencer.h" #include "UI_interface.h" +#include "UI_resources.h" #include "UI_view2d.h" #include "DEG_depsgraph.h" @@ -216,7 +217,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports) file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); bool selected = false; /* Check for no selected strips */ - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_META) || (seq->flag & SELECT) == 0) { continue; @@ -239,7 +240,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports) BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name); } } - SEQ_END; + SEQ_CURRENT_END; if (!selected) { BKE_reportf(reports, RPT_WARNING, "Select movie or image strips"); @@ -482,10 +483,10 @@ void ED_sequencer_deselect_all(Scene *scene) return; } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { seq->flag &= ~SEQ_ALLSEL; } - SEQ_END; + SEQ_CURRENT_END; } void recurs_sel_seq(Sequence *seqm) @@ -1030,7 +1031,7 @@ static void set_filter_seq(Scene *scene) return; } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->flag & SELECT) { if (seq->type == SEQ_TYPE_MOVIE) { seq->flag |= SEQ_FILTERY; @@ -1039,7 +1040,7 @@ static void set_filter_seq(Scene *scene) } } } - SEQ_END; + SEQ_CURRENT_END; } #endif @@ -1065,7 +1066,7 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene) return; } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->flag & SELECT) { if (STREQLEN(seq->strip->dir, from, strlen(from))) { printf("found %s\n", seq->strip->dir); @@ -1080,7 +1081,7 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene) } } } - SEQ_END; + SEQ_CURRENT_END; } /** \} */ @@ -1308,7 +1309,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } /* Test for effects and overlap. - * Don't use SEQP_BEGIN since that would be recursive. */ + * Don't use SEQ_CURRENT_BEGIN since that would be recursive. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) { seq->flag &= ~SEQ_OVERLAP; @@ -2294,25 +2295,25 @@ static int sequencer_split_exec(bContext *C, wmOperator *op) Sequence *seq; if (ignore_selection) { if (use_cursor_position) { - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->enddisp == split_frame && seq->machine == split_channel) { seq_selected = seq->flag & SEQ_ALLSEL; } } - SEQ_END; + SEQ_CURRENT_END; if (!seq_selected) { - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->startdisp == split_frame && seq->machine == split_channel) { seq->flag &= ~SEQ_ALLSEL; } } - SEQ_END; + SEQ_CURRENT_END; } } } else { if (split_side != SEQ_SIDE_BOTH) { - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (split_side == SEQ_SIDE_LEFT) { if (seq->startdisp >= split_frame) { seq->flag &= ~SEQ_ALLSEL; @@ -2324,15 +2325,15 @@ static int sequencer_split_exec(bContext *C, wmOperator *op) } } } - SEQ_END; + SEQ_CURRENT_END; } } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->seq1 || seq->seq2 || seq->seq3) { BKE_sequence_calc(scene, seq); } } - SEQ_END; + SEQ_CURRENT_END; BKE_sequencer_sort(scene); } @@ -2376,6 +2377,28 @@ static int sequencer_split_invoke(bContext *C, wmOperator *op, const wmEvent *ev return sequencer_split_exec(C, op); } +static void sequencer_split_ui(bContext *UNUSED(C), wmOperator *op) +{ + uiLayout *layout = op->layout; + uiLayoutSetPropSep(layout, true); + uiLayoutSetPropDecorate(layout, false); + + PointerRNA ptr; + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + + uiLayout *row = uiLayoutRow(layout, false); + uiItemR(row, &ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, &ptr, "frame", 0, NULL, ICON_NONE); + uiItemR(layout, &ptr, "side", 0, NULL, ICON_NONE); + + uiItemS(layout); + + uiItemR(layout, &ptr, "use_cursor_position", 0, NULL, ICON_NONE); + if (RNA_boolean_get(&ptr, "use_cursor_position")) { + uiItemR(layout, &ptr, "channel", 0, NULL, ICON_NONE); + } +} + void SEQUENCER_OT_split(struct wmOperatorType *ot) { /* Identifiers. */ @@ -2387,6 +2410,7 @@ void SEQUENCER_OT_split(struct wmOperatorType *ot) ot->invoke = sequencer_split_invoke; ot->exec = sequencer_split_exec; ot->poll = sequencer_edit_poll; + ot->ui = sequencer_split_ui; /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2521,12 +2545,12 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) BKE_sequencer_prefetch_stop(scene); - SEQP_BEGIN (scene->ed, seq) { + SEQ_CURRENT_BEGIN (scene->ed, seq) { if (seq->flag & SELECT) { BKE_sequencer_flag_for_removal(scene, ed->seqbasep, seq); } } - SEQ_END; + SEQ_CURRENT_END; BKE_sequencer_remove_flagged_sequences(scene, ed->seqbasep); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); @@ -2642,6 +2666,8 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) seq = ed->seqbasep->first; /* Poll checks this is valid. */ + BKE_sequencer_prefetch_stop(scene); + while (seq) { if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) { Sequence *seq_next; @@ -2837,6 +2863,8 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + BKE_sequencer_prefetch_stop(scene); + /* Remove all selected from main list, and put in meta. */ seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1, SEQ_TYPE_META); /* Channel number set later. */ @@ -2922,6 +2950,8 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } + BKE_sequencer_prefetch_stop(scene); + for (seq = last_seq->seqbase.first; seq != NULL; seq = seq->next) { BKE_sequence_invalidate_cache_composite(scene, seq); } @@ -2946,7 +2976,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0); /* Test for effects and overlap - * don't use SEQP_BEGIN since that would be recursive. */ + * don't use SEQ_CURRENT_BEGIN since that would be recursive. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_OVERLAP; @@ -3470,7 +3500,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if ((seq->flag & SELECT)) { ListBase queue = {NULL, NULL}; LinkData *link; @@ -3487,7 +3517,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); } } - SEQ_END; + SEQ_CURRENT_END; BLI_gset_free(file_list, MEM_freeN); @@ -3538,7 +3568,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) turnon = false; } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if ((seq->flag & SELECT)) { if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_META)) { BKE_sequencer_proxy_set(seq, turnon); @@ -3583,7 +3613,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) } } } - SEQ_END; + SEQ_CURRENT_END; WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -3960,12 +3990,12 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - SEQ_BEGIN (ed, seq) { + SEQ_ALL_BEGIN (ed, seq) { if (seq->type == SEQ_TYPE_TEXT) { BLI_addtail(&text_seq, MEM_dupallocN(seq)); } } - SEQ_END; + SEQ_ALL_END; if (BLI_listbase_is_empty(&text_seq)) { BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export"); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 1d168866e7c..df36453bd2e 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -60,6 +60,7 @@ float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx) /* void seq_reset_imageofs(struct SpaceSeq *sseq); */ struct ImBuf *sequencer_ibuf_get(struct Main *bmain, + struct ARegion *region, struct Depsgraph *depsgraph, struct Scene *scene, struct SpaceSeq *sseq, diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index e0f7179c3f9..50f2a5084ef 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -232,7 +232,7 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - SEQP_BEGIN (ed, seq_iter) { + SEQ_CURRENT_BEGIN (ed, seq_iter) { if (seq_iter->flag & SELECT) { if (seq_iter == seq) { continue; @@ -254,7 +254,7 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op) BKE_sequence_modifier_list_copy(seq_iter, seq); } } - SEQ_END; + SEQ_CURRENT_END; BKE_sequence_invalidate_cache_preprocessed(scene, seq); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 85b70354ab3..955b4dba5e8 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -415,14 +415,14 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) const float x = UI_view2d_region_to_view_x(v2d, mval[0]); - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (((x < CFRA) && (seq->enddisp <= CFRA)) || ((x >= CFRA) && (seq->startdisp >= CFRA))) { /* Select left or right. */ seq->flag |= SELECT; recurs_sel_seq(seq); } } - SEQ_END; + SEQ_CURRENT_END; { SpaceSeq *sseq = CTX_wm_space_seq(C); @@ -975,7 +975,7 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op) ED_sequencer_deselect_all(scene); } const int cfra = CFRA; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { bool test = false; switch (side) { case -1: @@ -994,7 +994,7 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op) recurs_sel_seq(seq); } } - SEQ_END; + SEQ_CURRENT_END; ED_outliner_select_sync_from_sequence_tag(C); @@ -1282,13 +1282,13 @@ static bool select_grouped_type(Editing *ed, Sequence *actseq, const int channel Sequence *seq; bool changed = false; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == actseq->type) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; return changed; } @@ -1299,13 +1299,13 @@ static bool select_grouped_type_basic(Editing *ed, Sequence *actseq, const int c bool changed = false; const bool is_sound = SEQ_IS_SOUND(actseq); - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && (is_sound ? SEQ_IS_SOUND(seq) : !SEQ_IS_SOUND(seq))) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; return changed; } @@ -1316,14 +1316,14 @@ static bool select_grouped_type_effect(Editing *ed, Sequence *actseq, const int bool changed = false; const bool is_effect = SEQ_IS_EFFECT(actseq); - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && (is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; return changed; } @@ -1339,45 +1339,45 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel } if (SEQ_HAS_PATH(actseq) && dir) { - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && SEQ_HAS_PATH(seq) && seq->strip && STREQ(seq->strip->dir, dir)) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; } else if (actseq->type == SEQ_TYPE_SCENE) { Scene *sce = actseq->scene; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_SCENE && seq->scene == sce) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; } else if (actseq->type == SEQ_TYPE_MOVIECLIP) { MovieClip *clip = actseq->clip; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP && seq->clip == clip) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; } else if (actseq->type == SEQ_TYPE_MASK) { struct Mask *mask = actseq->mask; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MASK && seq->mask == mask) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; } return changed; @@ -1394,15 +1394,15 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann effects[i] = false; } - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && (seq->type & SEQ_TYPE_EFFECT) && ELEM(actseq, seq->seq1, seq->seq2, seq->seq3)) { effects[seq->type] = true; } } - SEQ_END; + SEQ_CURRENT_END; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) { if (seq->seq1) { seq->seq1->flag |= SELECT; @@ -1416,7 +1416,7 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann changed = true; } } - SEQ_END; + SEQ_CURRENT_END; return changed; } @@ -1426,13 +1426,13 @@ static bool select_grouped_time_overlap(Editing *ed, Sequence *actseq) Sequence *seq; bool changed = false; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { if (seq->startdisp < actseq->enddisp && seq->enddisp > actseq->startdisp) { seq->flag |= SELECT; changed = true; } } - SEQ_END; + SEQ_CURRENT_END; return changed; } @@ -1447,10 +1447,10 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int int machine = actseq->machine; SeqIterator iter; - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { seq->tmp = NULL; } - SEQ_END; + SEQ_CURRENT_END; actseq->tmp = POINTER_FROM_INT(true); @@ -1523,11 +1523,11 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) bool changed = false; if (!extend) { - SEQP_BEGIN (ed, seq) { + SEQ_CURRENT_BEGIN (ed, seq) { seq->flag &= ~SELECT; changed = true; } - SEQ_END; + SEQ_CURRENT_END; } switch (type) { diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index c1dac30bcb6..491c475b596 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -144,17 +144,17 @@ void SEQUENCER_OT_view_frame(wmOperatorType *ot) static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) { + SpaceSeq *sseq = CTX_wm_space_seq(C); bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); #if 0 ARegion *region = CTX_wm_region(C); - SpaceSeq *sseq = area->spacedata.first; Scene *scene = CTX_data_scene(C); #endif View2D *v2d = UI_view2d_fromcontext(C); v2d->cur = v2d->tot; - UI_view2d_curRect_validate(v2d); + UI_view2d_curRect_changed(C, v2d); UI_view2d_sync(screen, area, v2d, V2D_LOCK_COPY); #if 0 @@ -186,6 +186,8 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) } #endif + sseq->flag |= SEQ_ZOOM_TO_FIT; + ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; } @@ -228,6 +230,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op) ED_region_tag_redraw(CTX_wm_region(C)); + UI_view2d_curRect_changed(C, v2d); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index b8bb3e4d43b..4a6bd0de60c 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -96,7 +96,8 @@ static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *sce sseq->chanshown = 0; sseq->view = SEQ_VIEW_SEQUENCE; sseq->mainb = SEQ_DRAW_IMG_IMBUF; - sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES; + sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | + SEQ_ZOOM_TO_FIT; /* Tool header. */ region = MEM_callocN(sizeof(ARegion), "tool header for sequencer"); @@ -679,6 +680,22 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *region) WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); } +static void sequencer_preview_region_layout(const bContext *C, ARegion *region) +{ + SpaceSeq *sseq = CTX_wm_space_seq(C); + + if (sseq->flag & SEQ_ZOOM_TO_FIT) { + View2D *v2d = ®ion->v2d; + v2d->cur = v2d->tot; + } +} + +static void sequencer_preview_region_view2d_changed(const bContext *C, ARegion *UNUSED(region)) +{ + SpaceSeq *sseq = CTX_wm_space_seq(C); + sseq->flag &= ~SEQ_ZOOM_TO_FIT; +} + static void sequencer_preview_region_draw(const bContext *C, ARegion *region) { ScrArea *area = CTX_wm_area(C); @@ -881,6 +898,8 @@ void ED_spacetype_sequencer(void) art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); art->regionid = RGN_TYPE_PREVIEW; art->init = sequencer_preview_region_init; + art->layout = sequencer_preview_region_layout; + art->on_view2d_changed = sequencer_preview_region_view2d_changed; art->draw = sequencer_preview_region_draw; art->listener = sequencer_preview_region_listener; art->keymapflag = ED_KEYMAP_TOOL | ED_KEYMAP_GIZMO | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | |