Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/view2d_ops.c
| Context not available. | |||||
| { | { | ||||
| v2dViewZoomData *vzd = op->customdata; | v2dViewZoomData *vzd = op->customdata; | ||||
| View2D *v2d = vzd->v2d; | View2D *v2d = vzd->v2d; | ||||
| const rctf cur_old = v2d->cur; | |||||
| float dx, dy; | float dx, dy; | ||||
| const int snap_test = ED_region_snap_size_test(vzd->region); | const int snap_test = ED_region_snap_size_test(vzd->region); | ||||
| Context not available. | |||||
| vzd->timer_lastdraw = time; | vzd->timer_lastdraw = time; | ||||
| } | } | ||||
| /* only move view on an axis if change is allowed */ | /* Only move view on an axis if change is allowed. */ | ||||
| if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { | if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { | ||||
| if (v2d->keepofs & V2D_LOCKOFS_X) { | if (v2d->keepofs & V2D_LOCKOFS_X) { | ||||
| v2d->cur.xmax -= 2 * dx; | v2d->cur.xmax -= 2 * dx; | ||||
| } | } | ||||
| else { | else { | ||||
| v2d->cur.xmin += dx; | |||||
| v2d->cur.xmax -= dx; | |||||
| if (zoom_to_pos) { | if (zoom_to_pos) { | ||||
| float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); | /* Get zoom fac the same way as in | ||||
| float mval_faci = 1.0f - mval_fac; | * ui_view2d_curRect_validate_resize - better keep in sync! */ | ||||
| float ofs = (mval_fac * dx) - (mval_faci * dx); | const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); | ||||
| v2d->cur.xmin += ofs + dx; | /* Only move view to mouse if zoom fac is inside minzoom/maxzoom. */ | ||||
| v2d->cur.xmax += ofs - dx; | if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || | ||||
| } | IN_RANGE_INCL(zoomx, v2d->minzoom, v2d->maxzoom)) { | ||||
| else { | float mval_fac = (vzd->mx_2d - cur_old.xmin) / BLI_rctf_size_x(&cur_old); | ||||
| v2d->cur.xmin += dx; | float mval_faci = 1.0f - mval_fac; | ||||
| v2d->cur.xmax -= dx; | float ofs = (mval_fac * dx) - (mval_faci * dx); | ||||
| v2d->cur.xmin += ofs; | |||||
| v2d->cur.xmax += ofs; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| v2d->cur.ymax -= 2 * dy; | v2d->cur.ymax -= 2 * dy; | ||||
| } | } | ||||
| else { | else { | ||||
| v2d->cur.ymin += dy; | |||||
| v2d->cur.ymax -= dy; | |||||
| if (zoom_to_pos) { | if (zoom_to_pos) { | ||||
| float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); | /* Get zoom fac the same way as in | ||||
| float mval_faci = 1.0f - mval_fac; | * ui_view2d_curRect_validate_resize - better keep in sync! */ | ||||
| float ofs = (mval_fac * dy) - (mval_faci * dy); | const float zoomy = (float)(BLI_rcti_size_y(&v2d->mask) + 1) / BLI_rctf_size_y(&v2d->cur); | ||||
| v2d->cur.ymin += ofs + dy; | /* Only move view to mouse if zoom fac is inside minzoom/maxzoom. */ | ||||
| v2d->cur.ymax += ofs - dy; | if (((v2d->keepzoom & V2D_LIMITZOOM) == 0) || | ||||
| } | IN_RANGE_INCL(zoomy, v2d->minzoom, v2d->maxzoom)) { | ||||
| else { | float mval_fac = (vzd->my_2d - cur_old.ymin) / BLI_rctf_size_y(&cur_old); | ||||
| v2d->cur.ymin += dy; | float mval_faci = 1.0f - mval_fac; | ||||
| v2d->cur.ymax -= dy; | float ofs = (mval_fac * dy) - (mval_faci * dy); | ||||
| v2d->cur.ymin += ofs; | |||||
| v2d->cur.ymax += ofs; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||