Fix #138018: VSE zooming left aligned
Create an option in `View2D.flag` that allows us to have separate behavior for area resizing (left aligned with `V2D_KEEPOFS_X`) and zooming (centered with the keepofs flags disabled). Add this to the versioning code. Pull Request: https://projects.blender.org/blender/blender/pulls/138041
This commit is contained in:
committed by
John Kiril Swenson
parent
600380cd98
commit
8b36cf3eac
@@ -9773,6 +9773,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
region->v2d.keepzoom |= V2D_KEEPZOOM;
|
||||
region->v2d.keepofs |= V2D_KEEPOFS_X | V2D_KEEPOFS_Y;
|
||||
region->v2d.flag |= V2D_ZOOM_IGNORE_KEEPOFS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,18 +765,21 @@ static void view_zoomstep_apply_ex(bContext *C,
|
||||
dy = (BLI_rctf_size_y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
|
||||
}
|
||||
|
||||
/* only resize view on an axis if change is allowed */
|
||||
/* Only resize view on an axis if change is allowed. */
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
|
||||
if (v2d->keepofs & V2D_LOCKOFS_X) {
|
||||
v2d->cur.xmax -= 2 * dx;
|
||||
}
|
||||
else if (v2d->keepofs & V2D_KEEPOFS_X) {
|
||||
if (v2d->align & V2D_ALIGN_NO_POS_X) {
|
||||
v2d->cur.xmin += 2 * dx;
|
||||
}
|
||||
else {
|
||||
/* Only consider keepofs flags if it is not forbidden. */
|
||||
if ((v2d->flag & V2D_ZOOM_IGNORE_KEEPOFS) == 0) {
|
||||
if (v2d->keepofs & V2D_LOCKOFS_X) {
|
||||
v2d->cur.xmax -= 2 * dx;
|
||||
}
|
||||
else if (v2d->keepofs & V2D_KEEPOFS_X) {
|
||||
if (v2d->align & V2D_ALIGN_NO_POS_X) {
|
||||
v2d->cur.xmin += 2 * dx;
|
||||
}
|
||||
else {
|
||||
v2d->cur.xmax -= 2 * dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -803,16 +806,18 @@ static void view_zoomstep_apply_ex(bContext *C,
|
||||
}
|
||||
}
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
|
||||
if (v2d->keepofs & V2D_LOCKOFS_Y) {
|
||||
v2d->cur.ymax -= 2 * dy;
|
||||
}
|
||||
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
|
||||
if (v2d->align & V2D_ALIGN_NO_POS_Y) {
|
||||
v2d->cur.ymin += 2 * dy;
|
||||
}
|
||||
else {
|
||||
if ((v2d->flag & V2D_ZOOM_IGNORE_KEEPOFS) == 0) {
|
||||
if (v2d->keepofs & V2D_LOCKOFS_Y) {
|
||||
v2d->cur.ymax -= 2 * dy;
|
||||
}
|
||||
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
|
||||
if (v2d->align & V2D_ALIGN_NO_POS_Y) {
|
||||
v2d->cur.ymin += 2 * dy;
|
||||
}
|
||||
else {
|
||||
v2d->cur.ymax -= 2 * dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene)
|
||||
region->v2d.keepzoom = V2D_KEEPZOOM;
|
||||
region->v2d.keepofs = V2D_KEEPOFS_X | V2D_KEEPOFS_Y;
|
||||
region->v2d.keeptot = V2D_KEEPTOT_FREE;
|
||||
region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL | V2D_ZOOM_IGNORE_KEEPOFS;
|
||||
region->v2d.align = V2D_ALIGN_NO_NEG_Y;
|
||||
|
||||
return (SpaceLink *)sseq;
|
||||
|
||||
@@ -124,6 +124,9 @@ enum {
|
||||
/* Ensure scrolling always snaps to multiples of #View2D.page_size_y or the #View2D.mask height
|
||||
* if this is 0. Zooming doesn't respect this. */
|
||||
V2D_SNAP_TO_PAGESIZE_Y = (1 << 11),
|
||||
/* Ignore keepofs flags only during zoom.
|
||||
* Allows for different behavior between zooming and area resize. */
|
||||
V2D_ZOOM_IGNORE_KEEPOFS = (1 << 12),
|
||||
};
|
||||
|
||||
/** Scroller flags for View2D (#View2D.scroll). */
|
||||
|
||||
Reference in New Issue
Block a user