Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/view2d_ops.c
| Context not available. | |||||
| const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); | const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); | ||||
| const bool zoom_to_pos = use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS); | const bool zoom_to_pos = use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS); | ||||
| /* get amount to move view by */ | /* Get amount to move view by. */ | ||||
| dx = RNA_float_get(op->ptr, "deltax") / U.dpi_fac; | dx = RNA_float_get(op->ptr, "deltax"); | ||||
| dy = RNA_float_get(op->ptr, "deltay") / U.dpi_fac; | dy = RNA_float_get(op->ptr, "deltay"); | ||||
| if (U.uiflag & USER_ZOOM_INVERT) { | |||||
| dx *= -1; | |||||
| dy *= -1; | |||||
| } | |||||
| /* Continuous zoom method, must be skipped for zooming with a trackpad, | /* Continuous zoom method, must be skipped for zooming with a trackpad, | ||||
| * it's not used for trackpads and the 'timer' is not initialized before. */ | * it's not used for trackpads and the 'timer' is not initialized before. */ | ||||
| Context not available. | |||||
| } | } | ||||
| if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { | if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { | ||||
| float dx, dy, fac; | float facx, facy, dx, dy; | ||||
| float zoomfac = 0.01f; | |||||
| /* Some view2d's (graph) don't have min/max zoom, or extreme ones. */ | |||||
| if (v2d->maxzoom > 0.0f) { | |||||
| zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); | |||||
| } | |||||
| vzd->lastx = event->prevx; | vzd->lastx = event->prevx; | ||||
| vzd->lasty = event->prevy; | vzd->lasty = event->prevy; | ||||
| /* As we have only 1D information (magnify value), feed both axes | facx = zoomfac * (event->prevx - event->x); | ||||
| * with magnify information that is stored in x axis | |||||
| */ | |||||
| fac = 0.01f * (event->prevx - event->x); | |||||
| dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f; | |||||
| if (event->type == MOUSEPAN) { | if (event->type == MOUSEPAN) { | ||||
| fac = 0.01f * (event->prevy - event->y); | facy = zoomfac * (event->prevy - event->y); | ||||
| } | |||||
| else { | |||||
| /* Set to equal as MOUSEZOOM uses only X axis to pass magnification value. */ | |||||
| facy = facx; | |||||
| } | } | ||||
| dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f; | |||||
| /* Support zoom to always zoom entirely. Only respect Zoom Axis user setting | /* Support zoom to always zoom entirely. Only respect Zoom Axis user setting | ||||
| * if the view does not have any zoom restrictions any will be scaled uniformly. */ | * if the view does not have any zoom restrictions any will be scaled uniformly. */ | ||||
| if (v2d->keepzoom & V2D_KEEPASPECT) { | if (v2d->keepzoom & V2D_KEEPASPECT) { | ||||
| if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { | if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { | ||||
| if (U.uiflag & USER_ZOOM_HORIZ) { | if (U.uiflag & USER_ZOOM_HORIZ) { | ||||
| dy = 0; | facy = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| dx = 0; | facx = 0; | ||||
| } | } | ||||
| } | } | ||||
| if (fabsf(dx) > fabsf(dy)) { | if (fabsf(facx) > fabsf(facy)) { | ||||
| dy = dx; | facy = facx; | ||||
| } | } | ||||
| else { | else { | ||||
| dx = dy; | facx = facy; | ||||
| } | |||||
| } | |||||
| dx = facx * BLI_rctf_size_x(&v2d->cur); | |||||
| dy = facy * BLI_rctf_size_y(&v2d->cur); | |||||
| if (event->type == MOUSEPAN) { | |||||
| const bool user_zoom_invert = (U.uiflag & USER_ZOOM_INVERT) != 0; | |||||
| const bool user_trackpad_natural = (U.uiflag2 & USER_TRACKPAD_NATURAL) != 0; | |||||
| if (user_zoom_invert != user_trackpad_natural) { | |||||
| dx *= -1; | |||||
| dy *= -1; | |||||
| } | } | ||||
| } | } | ||||
| RNA_float_set(op->ptr, "deltax", dx); | RNA_float_set(op->ptr, "deltax", dx); | ||||
| RNA_float_set(op->ptr, "deltay", dy); | RNA_float_set(op->ptr, "deltay", dy); | ||||
| Context not available. | |||||
| view_zoomdrag_apply(C, op); | view_zoomdrag_apply(C, op); | ||||
| } | } | ||||
| else if (event->type == MOUSEMOVE) { | else if (event->type == MOUSEMOVE) { | ||||
| float dx, dy; | float facx, facy, dx, dy; | ||||
| float zoomfac = 0.01f; | float zoomfac = 0.01f; | ||||
| /* some view2d's (graph) don't have min/max zoom, or extreme ones */ | /* some view2d's (graph) don't have min/max zoom, or extreme ones */ | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* 'continuous' or 'dolly' */ | /* "Continue" or "Dolly" zoom style. */ | ||||
| float fac; | facx = zoomfac * (event->x - vzd->lastx) / U.dpi_fac; | ||||
| /* x-axis transform */ | facy = zoomfac * (event->y - vzd->lasty) / U.dpi_fac; | ||||
| fac = zoomfac * (event->x - vzd->lastx); | |||||
| dx = fac * BLI_rctf_size_x(&v2d->cur); | |||||
| /* y-axis transform */ | |||||
| fac = zoomfac * (event->y - vzd->lasty); | |||||
| dy = fac * BLI_rctf_size_y(&v2d->cur); | |||||
| /* Support zoom to always zoom entirely. Only respect Zoom Axis user setting | /* Support zoom to always zoom entirely. Only respect Zoom Axis user setting | ||||
| * if the view does not have any zoom restrictions any will be scaled uniformly. */ | * if the view does not have any zoom restrictions any will be scaled uniformly. */ | ||||
| if (v2d->keepzoom & V2D_KEEPASPECT) { | if (v2d->keepzoom & V2D_KEEPASPECT) { | ||||
| if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { | if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) { | ||||
| if (U.uiflag & USER_ZOOM_HORIZ) { | if (U.uiflag & USER_ZOOM_HORIZ) { | ||||
| dy = 0; | facy = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| dx = 0; | facx = 0; | ||||
| } | } | ||||
| } | } | ||||
| if (fabsf(dx) > fabsf(dy)) { | if (fabsf(facx) > fabsf(facy)) { | ||||
| dy = dx; | facy = facx; | ||||
| } | } | ||||
| else { | else { | ||||
| dx = dy; | facx = facy; | ||||
| } | } | ||||
| } | } | ||||
| dx = facx * BLI_rctf_size_x(&v2d->cur); | |||||
| dy = facy * BLI_rctf_size_y(&v2d->cur); | |||||
| } | |||||
| if (U.uiflag & USER_ZOOM_INVERT) { | |||||
| dx *= -1; | |||||
| dy *= -1; | |||||
| } | } | ||||
| /* set transform amount, and add current deltas to stored total delta (for redo) */ | /* set transform amount, and add current deltas to stored total delta (for redo) */ | ||||
| Context not available. | |||||