Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_ops.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { | if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| float delta, factor, location[2]; | float delta, factor, location[2]; | ||||
| UI_view2d_region_to_view( | UI_view2d_region_to_view( | ||||
| ®ion->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); | ®ion->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); | ||||
| delta = event->prev_xy[0] - event->xy[0] + event->prev_xy[1] - event->xy[1]; | if (event->type == MOUSEPAN) { | ||||
| if (U.uiflag & USER_ZOOM_HORIZ) { | |||||
| delta = WM_event_absolute_delta_x(event); | |||||
| } | |||||
| else { | |||||
| delta = WM_event_absolute_delta_y(event); | |||||
| } | |||||
| if (U.uiflag & USER_ZOOM_INVERT) { | if (U.uiflag & USER_ZOOM_INVERT) { | ||||
| delta *= -1; | delta *= -1.0f; | ||||
| } | |||||
| factor = 1.0f + delta / 300.0f; | |||||
| } | |||||
| else { /* MOUSEZOOM */ | |||||
| factor = 1.0f + event->factor; | |||||
| } | } | ||||
| factor = 1.0f + delta / 300.0f; | |||||
| RNA_float_set(op->ptr, "factor", factor); | RNA_float_set(op->ptr, "factor", factor); | ||||
| 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"); | ||||
| sima_zoom_set(sima, | sima_zoom_set(sima, | ||||
| region, | region, | ||||
| sima->zoom * factor, | sima->zoom * factor, | ||||
| location, | location, | ||||
| (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); | (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); | ||||
| ED_region_tag_redraw(region); | ED_region_tag_redraw(region); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||