Sequencer: Implement zoom-to-fit view mode
In this mode the preview image is always using the most of the preview area space: it is scaled to fit, preserving aspect ratio. This makes it possible to always have maximum of the preview region even after resize of other areas. This mode is enabled by default, is available in the View -> Zoom to Fit menu. It is enabled when View All (Home key) is used, and is disabled when manual navigation ([panning, zooming) is performed. There is no versioning code, which means existing files will open as-is, but new projects will have this option enabled. Ref T78987 Maniphest Tasks: T78987 Differential Revision: https://developer.blender.org/D8549
This commit is contained in:
@@ -327,6 +327,7 @@ class SEQUENCER_MT_view(Menu):
|
||||
if is_preview:
|
||||
layout.separator()
|
||||
if st.display_mode == 'IMAGE':
|
||||
layout.prop(st, "zoom_to_fit")
|
||||
layout.prop(ed, "show_overlay", text="Show Frame Overlay")
|
||||
layout.prop(st, "show_safe_areas", text="Show Safe Areas")
|
||||
layout.prop(st, "show_metadata", text="Show Metadata")
|
||||
|
||||
@@ -174,7 +174,7 @@ static void blo_update_defaults_screen(bScreen *screen,
|
||||
}
|
||||
else if (area->spacetype == SPACE_SEQ) {
|
||||
SpaceSeq *seq = area->spacedata.first;
|
||||
seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES;
|
||||
seq->flag |= SEQ_SHOW_MARKERS | SEQ_SHOW_FCURVES | SEQ_ZOOM_TO_FIT;
|
||||
}
|
||||
else if (area->spacetype == SPACE_TEXT) {
|
||||
/* Show syntax and line numbers in Script workspace text editor. */
|
||||
|
||||
@@ -144,11 +144,11 @@ 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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -612,6 +612,7 @@ typedef enum eSpaceSeq_Flag {
|
||||
SEQ_SHOW_SAFE_CENTER = (1 << 9),
|
||||
SEQ_SHOW_METADATA = (1 << 10),
|
||||
SEQ_SHOW_MARKERS = (1 << 11), /* show markers region */
|
||||
SEQ_ZOOM_TO_FIT = (1 << 12),
|
||||
} eSpaceSeq_Flag;
|
||||
|
||||
/* SpaceSeq.view */
|
||||
|
||||
@@ -4796,6 +4796,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Waveform Displaying", "How Waveforms are drawn");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "zoom_to_fit", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_ZOOM_TO_FIT);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Zoom to Fit", "Automatically zoom preview image to make it fully fit the region");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_overexposed", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "zebra");
|
||||
RNA_def_property_ui_text(prop, "Show Overexposed", "Show overexposed areas with zebra stripes");
|
||||
|
||||
Reference in New Issue
Block a user