Blender V5.0
view3d_navigate_view_zoom.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_math_vector.h"
10#include "BLI_rect.h"
11#include "BLI_time.h"
12
13#include "BKE_context.hh"
14#include "BKE_screen.hh"
15
16#include "WM_api.hh"
17
18#include "RNA_access.hh"
19
20#include "ED_screen.hh"
21
22#include "view3d_intern.hh"
23#include "view3d_navigate.hh" /* own include */
24
25/* -------------------------------------------------------------------- */
28
30{
31 /* NOTE: #viewdolly_modal_keymap has an exact copy of this, apply fixes to both. */
32
33 static const EnumPropertyItem modal_items[] = {
34 {VIEW_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
35 {VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
36
37 {VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
38 {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
39
40 {0, nullptr, 0, nullptr, nullptr},
41 };
42
43 wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Zoom Modal");
44
45 /* This function is called for each space-type, only needs to add map once. */
46 if (keymap && keymap->modal_items) {
47 return;
48 }
49
50 keymap = WM_modalkeymap_ensure(keyconf, "View3D Zoom Modal", modal_items);
51
52 /* assign map to operators */
53 WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom");
54}
55
61 const Depsgraph *depsgraph,
62 View3D *v3d,
63 ARegion *region,
64 float dfac,
65 const int zoom_xy[2])
66{
67 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
68 const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
69 const float zoomfac_new = clamp_f(
70 zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR);
71 const float camzoom_new = BKE_screen_view3d_zoom_from_fac(zoomfac_new);
72
73 if (zoom_xy != nullptr) {
74 float zoomfac_px;
75 rctf camera_frame_old;
76 rctf camera_frame_new;
77
78 const float pt_src[2] = {float(zoom_xy[0]), float(zoom_xy[1])};
79 float pt_dst[2];
80 float delta_px[2];
81
82 ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, false, &camera_frame_old);
83 BLI_rctf_translate(&camera_frame_old, region->winrct.xmin, region->winrct.ymin);
84
85 rv3d->camzoom = camzoom_new;
87
88 ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, false, &camera_frame_new);
89 BLI_rctf_translate(&camera_frame_new, region->winrct.xmin, region->winrct.ymin);
90
91 BLI_rctf_transform_pt_v(&camera_frame_new, &camera_frame_old, pt_dst, pt_src);
92 sub_v2_v2v2(delta_px, pt_dst, pt_src);
93
94 /* translate the camera offset using pixel space delta
95 * mapped back to the camera (same logic as panning in camera view) */
96 zoomfac_px = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom) * 2.0f;
97
98 rv3d->camdx += delta_px[0] / (region->winx * zoomfac_px);
99 rv3d->camdy += delta_px[1] / (region->winy * zoomfac_px);
100 CLAMP(rv3d->camdx, -1.0f, 1.0f);
101 CLAMP(rv3d->camdy, -1.0f, 1.0f);
102 }
103 else {
104 rv3d->camzoom = camzoom_new;
106 }
107}
108
113static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2])
114{
115 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
116 const float dist_new = rv3d->dist * dfac;
117
118 if (zoom_xy != nullptr) {
119 float dvec[3];
120 float tvec[3];
121 float tpos[3];
122 float xy_delta[2];
123
124 float zfac;
125
126 negate_v3_v3(tpos, rv3d->ofs);
127
128 xy_delta[0] = float(((zoom_xy[0] - region->winrct.xmin) * 2) - region->winx) / 2.0f;
129 xy_delta[1] = float(((zoom_xy[1] - region->winrct.ymin) * 2) - region->winy) / 2.0f;
130
131 /* Project cursor position into 3D space */
132 zfac = ED_view3d_calc_zfac(rv3d, tpos);
133 ED_view3d_win_to_delta(region, xy_delta, zfac, dvec);
134
135 /* Calculate view target position for dolly */
136 add_v3_v3v3(tvec, tpos, dvec);
137 negate_v3(tvec);
138
139 /* Offset to target position and dolly */
140 copy_v3_v3(rv3d->ofs, tvec);
141 rv3d->dist = dist_new;
142
143 /* Calculate final offset */
144 madd_v3_v3v3fl(rv3d->ofs, tvec, dvec, dfac);
145 }
146 else {
147 rv3d->dist = dist_new;
148 }
149}
150
151static float viewzoom_scale_value(const rcti *winrct,
152 const eViewZoom_Style viewzoom,
153 const bool zoom_invert,
154 const bool zoom_invert_force,
155 const int xy_curr[2],
156 const int xy_init[2],
157 const float val,
158 const float val_orig,
159 double *r_timer_lastdraw)
160{
161 float zfac;
162
163 if (viewzoom == USER_ZOOM_CONTINUE) {
164 double time = BLI_time_now_seconds();
165 float time_step = float(time - *r_timer_lastdraw);
166 float fac;
167
168 if (U.uiflag & USER_ZOOM_HORIZ) {
169 fac = float(xy_init[0] - xy_curr[0]);
170 }
171 else {
172 fac = float(xy_init[1] - xy_curr[1]);
173 }
174
175 fac /= UI_SCALE_FAC;
176
177 if (zoom_invert != zoom_invert_force) {
178 fac = -fac;
179 }
180
181 zfac = 1.0f + ((fac / 20.0f) * time_step);
182 *r_timer_lastdraw = time;
183 }
184 else if (viewzoom == USER_ZOOM_SCALE) {
185 /* method which zooms based on how far you move the mouse */
186
187 const int ctr[2] = {
188 BLI_rcti_cent_x(winrct),
189 BLI_rcti_cent_y(winrct),
190 };
191 float len_new = (5 * UI_SCALE_FAC) + (len_v2v2_int(ctr, xy_curr) / UI_SCALE_FAC);
192 float len_old = (5 * UI_SCALE_FAC) + (len_v2v2_int(ctr, xy_init) / UI_SCALE_FAC);
193
194 /* intentionally ignore 'zoom_invert' for scale */
195 if (zoom_invert_force) {
196 std::swap(len_new, len_old);
197 }
198
199 zfac = val_orig * (len_old / max_ff(len_new, 1.0f)) / val;
200 }
201 else { /* USER_ZOOM_DOLLY */
202 float len_new = 5 * UI_SCALE_FAC;
203 float len_old = 5 * UI_SCALE_FAC;
204
205 if (U.uiflag & USER_ZOOM_HORIZ) {
206 len_new += (winrct->xmax - (xy_curr[0])) / UI_SCALE_FAC;
207 len_old += (winrct->xmax - (xy_init[0])) / UI_SCALE_FAC;
208 }
209 else {
210 len_new += (winrct->ymax - (xy_curr[1])) / UI_SCALE_FAC;
211 len_old += (winrct->ymax - (xy_init[1])) / UI_SCALE_FAC;
212 }
213
214 if (zoom_invert != zoom_invert_force) {
215 std::swap(len_new, len_old);
216 }
217
218 zfac = val_orig * (2.0f * ((len_new / max_ff(len_old, 1.0f)) - 1.0f) + 1.0f) / val;
219 }
220
221 return zfac;
222}
223
224static float viewzoom_scale_value_offset(const rcti *winrct,
225 const eViewZoom_Style viewzoom,
226 const bool zoom_invert,
227 const bool zoom_invert_force,
228 const int xy_curr[2],
229 const int xy_init[2],
230 const int xy_offset[2],
231 const float val,
232 const float val_orig,
233 double *r_timer_lastdraw)
234{
235 const int xy_curr_offset[2] = {
236 xy_curr[0] + xy_offset[0],
237 xy_curr[1] + xy_offset[1],
238 };
239 const int xy_init_offset[2] = {
240 xy_init[0] + xy_offset[0],
241 xy_init[1] + xy_offset[1],
242 };
243 return viewzoom_scale_value(winrct,
244 viewzoom,
245 zoom_invert,
246 zoom_invert_force,
247 xy_curr_offset,
248 xy_init_offset,
249 val,
250 val_orig,
251 r_timer_lastdraw);
252}
253
255 const int xy[2],
256 const eViewZoom_Style viewzoom,
257 const bool zoom_invert,
258 const bool zoom_to_pos)
259{
260 float zfac;
261 float zoomfac_prev = BKE_screen_view3d_zoom_to_fac(vod->init.camzoom) * 2.0f;
262 float zoomfac = BKE_screen_view3d_zoom_to_fac(vod->rv3d->camzoom) * 2.0f;
263
265 viewzoom,
266 zoom_invert,
267 true,
268 xy,
269 vod->init.event_xy,
271 zoomfac,
272 zoomfac_prev,
273 &vod->prev.time);
274
275 if (!ELEM(zfac, 1.0f, 0.0f)) {
276 /* calculate inverted, then invert again (needed because of camera zoom scaling) */
277 zfac = 1.0f / zfac;
279 vod->depsgraph,
280 vod->v3d,
281 vod->region,
282 zfac,
283 zoom_to_pos ? vod->prev.event_xy : nullptr);
284 }
285
287}
288
290 const int xy[2],
291 const eViewZoom_Style viewzoom,
292 const bool zoom_invert,
293 const bool zoom_to_pos)
294{
295 const blender::Bounds<float> dist_range = ED_view3d_dist_soft_range_get(vod->v3d, false);
296 float zfac = viewzoom_scale_value_offset(&vod->region->winrct,
297 viewzoom,
298 zoom_invert,
299 false,
300 xy,
301 vod->init.event_xy,
303 vod->rv3d->dist,
304 vod->init.dist,
305 &vod->prev.time);
306
307 if (zfac != 1.0f) {
308 const float zfac_min = dist_range.min / vod->rv3d->dist;
309 const float zfac_max = dist_range.max / vod->rv3d->dist;
310 CLAMP(zfac, zfac_min, zfac_max);
311
312 view_zoom_to_window_xy_3d(vod->region, zfac, zoom_to_pos ? vod->prev.event_xy : nullptr);
313 }
314
315 /* these limits were in old code too */
316 CLAMP(vod->rv3d->dist, dist_range.min, dist_range.max);
317
318 if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
319 view3d_boxview_sync(vod->area, vod->region);
320 }
321
323
325}
326
328 const int xy[2],
329 const eViewZoom_Style viewzoom,
330 const bool zoom_invert)
331{
332 const bool zoom_to_pos = (vod->viewops_flag & VIEWOPS_FLAG_ZOOM_TO_MOUSE) != 0;
333
334 if ((vod->rv3d->persp == RV3D_CAMOB) &&
335 (vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) == 0)
336 {
337 viewzoom_apply_camera(vod, xy, viewzoom, zoom_invert, zoom_to_pos);
338 }
339 else {
340 viewzoom_apply_3d(vod, xy, viewzoom, zoom_invert, zoom_to_pos);
341 }
342}
343
345 ViewOpsData *vod,
346 const eV3D_OpEvent event_code,
347 const int xy[2])
348{
349 bool use_autokey = false;
351
352 switch (event_code) {
353 case VIEW_APPLY: {
354 viewzoom_apply(vod, xy, (eViewZoom_Style)U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0);
356 use_autokey = true;
357 }
358 break;
359 }
360 case VIEW_CONFIRM: {
361 use_autokey = true;
363 break;
364 }
365 case VIEW_CANCEL: {
366 vod->state_restore();
368 break;
369 }
370 case VIEW_PASS:
371 break;
372 }
373
374 if (use_autokey) {
375 ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
376 }
377
378 return ret;
379}
380
382 const Depsgraph *depsgraph,
383 Scene *scene,
384 ScrArea *area,
385 ARegion *region,
386 const int delta,
387 const int zoom_xy[2])
388{
389 View3D *v3d = static_cast<View3D *>(area->spacedata.first);
390 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
391 bool use_cam_zoom;
392
393 use_cam_zoom = (rv3d->persp == RV3D_CAMOB) &&
394 !(rv3d->is_persp && ED_view3d_camera_lock_check(v3d, rv3d));
395
396 const blender::Bounds<float> dist_range = ED_view3d_dist_soft_range_get(v3d, false);
397
398 if (delta < 0) {
399 const float step = 1.2f;
400 if (use_cam_zoom) {
401 view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy);
402 }
403 else {
404 if (rv3d->dist < dist_range.max) {
405 view_zoom_to_window_xy_3d(region, step, zoom_xy);
406 }
407 }
408 }
409 else {
410 const float step = 1.0f / 1.2f;
411 if (use_cam_zoom) {
412 view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy);
413 }
414 else {
415 if (rv3d->dist > dist_range.min) {
416 view_zoom_to_window_xy_3d(region, step, zoom_xy);
417 }
418 }
419 }
420
421 if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
422 view3d_boxview_sync(area, region);
423 }
424
426 ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true);
427
428 ED_region_tag_redraw(region);
429}
430
432{
433 BLI_assert(op->customdata == nullptr);
434
436 Scene *scene = CTX_data_scene(C);
437 ScrArea *area = CTX_wm_area(C);
438 ARegion *region = CTX_wm_region(C);
439 View3D *v3d = static_cast<View3D *>(area->spacedata.first);
440 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
441
442 const int delta = RNA_int_get(op->ptr, "delta");
443 const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init");
444
445 int zoom_xy_buf[2];
446 const int *zoom_xy = nullptr;
447 const bool do_zoom_to_mouse_pos = (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS));
448 if (do_zoom_to_mouse_pos) {
449 zoom_xy_buf[0] = RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") :
450 region->winx / 2;
451 zoom_xy_buf[1] = RNA_struct_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") :
452 region->winy / 2;
453 zoom_xy = zoom_xy_buf;
454 }
455
456 view_zoom_apply_step(C, depsgraph, scene, area, region, delta, zoom_xy);
458
459 return OPERATOR_FINISHED;
460}
461
463 ViewOpsData *vod,
464 const wmEvent *event,
466{
467 int xy[2];
468
469 PropertyRNA *prop;
470 prop = RNA_struct_find_property(ptr, "mx");
471 xy[0] = RNA_property_is_set(ptr, prop) ? RNA_property_int_get(ptr, prop) : event->xy[0];
472
473 prop = RNA_struct_find_property(ptr, "my");
474 xy[1] = RNA_property_is_set(ptr, prop) ? RNA_property_int_get(ptr, prop) : event->xy[1];
475
476 prop = RNA_struct_find_property(ptr, "delta");
477 const int delta = RNA_property_is_set(ptr, prop) ? RNA_property_int_get(ptr, prop) : 0;
478
479 if (delta) {
480 const bool do_zoom_to_mouse_pos = (vod->viewops_flag & VIEWOPS_FLAG_ZOOM_TO_MOUSE) != 0;
482 vod->depsgraph,
483 vod->scene,
484 vod->area,
485 vod->region,
486 delta,
487 do_zoom_to_mouse_pos ? xy : nullptr);
488
489 return OPERATOR_FINISHED;
490 }
491
492 eV3D_OpEvent event_code = ELEM(event->type, MOUSEZOOM, MOUSEPAN) ? VIEW_CONFIRM : VIEW_PASS;
493 if (event_code == VIEW_CONFIRM) {
494 if (U.uiflag & USER_ZOOM_HORIZ) {
495 vod->init.event_xy[0] = vod->prev.event_xy[0] = xy[0];
496 }
497 else {
498 /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */
499 vod->init.event_xy[1] = vod->prev.event_xy[1] = vod->init.event_xy[1] + xy[0] -
500 event->prev_xy[0];
501 }
502 viewzoom_apply(vod, event->prev_xy, USER_ZOOM_DOLLY, (U.uiflag & USER_ZOOM_INVERT) != 0);
503 ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
504
505 return OPERATOR_FINISHED;
506 }
507
508 if (U.viewzoom == USER_ZOOM_CONTINUE) {
509 /* needs a timer to continue redrawing */
512 }
513
515}
516
518{
519 /* Near duplicate logic in #viewdolly_invoke(), changes here may apply there too. */
521}
522
524{
525 /* identifiers */
526 ot->name = "Zoom View";
527 ot->description = "Zoom in/out in the view";
528 ot->idname = ViewOpsType_zoom.idname;
529
530 /* API callbacks. */
531 ot->invoke = viewzoom_invoke;
532 ot->exec = viewzoom_exec;
536
537 /* flags */
539
540 /* properties */
543}
544
546
549 /*idname*/ "VIEW3D_OT_zoom",
550 /*poll_fn*/ view3d_zoom_or_dolly_poll,
551 /*init_fn*/ viewzoom_invoke_impl,
552 /*apply_fn*/ viewzoom_modal_impl,
553};
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
Definition screen.cc:1044
float BKE_screen_view3d_zoom_to_fac(float camzoom)
Definition screen.cc:1039
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float len_v2v2_int(const int v1[2], const int v2[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:573
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
Definition rct.cc:526
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition BLI_rect.h:181
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition BLI_rect.h:177
Platform independent time functions.
double BLI_time_now_seconds(void)
Definition time.cc:113
#define CLAMP(a, b, c)
#define ELEM(...)
#define UI_SCALE_FAC
@ USER_ZOOM_INVERT
@ USER_ZOOM_TO_MOUSEPOS
@ USER_ZOOM_HORIZ
eViewZoom_Style
@ USER_ZOOM_SCALE
@ USER_ZOOM_CONTINUE
@ USER_ZOOM_DOLLY
#define RV3D_CAMZOOM_MAX
#define RV3D_CAMZOOM_MIN_FACTOR
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CAMZOOM_MAX_FACTOR
@ RV3D_CAMOB
#define RV3D_CAMZOOM_MIN
@ RV3D_BOXVIEW
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:618
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[3], bool precise=false)
bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionView3D *rv3d)
blender::Bounds< float > ED_view3d_dist_soft_range_get(const View3D *v3d, bool use_persp_range)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
void ED_view3d_calc_camera_border(const Scene *scene, const Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, bool no_shift, rctf *r_viewborder)
bool ED_view3d_camera_lock_autokey(View3D *v3d, RegionView3D *rv3d, bContext *C, bool do_rotate, bool do_translate)
bool ED_view3d_camera_lock_undo_grouped_push(const char *str, const View3D *v3d, const RegionView3D *rv3d, bContext *C)
#define C
Definition RandGen.cpp:29
@ OPTYPE_BLOCKING
Definition WM_types.hh:184
@ OPTYPE_GRAB_CURSOR_XY
Definition WM_types.hh:188
#define U
BPy_StructRNA * depsgraph
nullptr float
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
@ VIEW_CONFIRM
Definition image_ops.cc:601
@ VIEW_PASS
Definition image_ops.cc:599
@ VIEW_APPLY
Definition image_ops.cc:600
return ret
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void * regiondata
void * first
ListBase spacedata
eViewOpsFlag viewops_flag
Depsgraph * depsgraph
blender::int2 event_xy
blender::int2 event_xy_offset
struct ViewOpsData::@244345216304223004112237167211144027240265370072 prev
RegionView3D * rv3d
struct ViewOpsData::@010113264246165170144271002355152266226235365232 init
int ymin
int ymax
int xmin
int xmax
wmEventType type
Definition WM_types.hh:757
int prev_xy[2]
Definition WM_types.hh:820
const void * modal_items
const char * name
Definition WM_types.hh:1033
struct wmOperatorType * type
struct PointerRNA * ptr
void view3d_boxview_sync(ScrArea *area, ARegion *region)
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
wmOperatorStatus view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3D_OpPropFlag flag)
wmOperatorStatus view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
bool view3d_zoom_or_dolly_poll(bContext *C)
const ViewOpsType ViewOpsType_zoom
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_ZOOM_TO_MOUSE
eV3D_OpEvent
@ VIEW_CANCEL
@ V3D_OP_PROP_USE_MOUSE_INIT
@ V3D_OP_PROP_DELTA
@ V3D_OP_PROP_MOUSE_CO
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEW_MODAL_CANCEL
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEW_MODAL_CONFIRM
static void viewzoom_apply(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert)
static wmOperatorStatus viewzoom_modal_impl(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])
static void view_zoom_apply_step(bContext *C, const Depsgraph *depsgraph, Scene *scene, ScrArea *area, ARegion *region, const int delta, const int zoom_xy[2])
static void viewzoom_apply_3d(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_to_pos)
static void view_zoom_to_window_xy_camera(Scene *scene, const Depsgraph *depsgraph, View3D *v3d, ARegion *region, float dfac, const int zoom_xy[2])
static float viewzoom_scale_value(const rcti *winrct, const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_invert_force, const int xy_curr[2], const int xy_init[2], const float val, const float val_orig, double *r_timer_lastdraw)
static wmOperatorStatus viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
static void viewzoom_apply_camera(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_to_pos)
static float viewzoom_scale_value_offset(const rcti *winrct, const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_invert_force, const int xy_curr[2], const int xy_init[2], const int xy_offset[2], const float val, const float val_orig, double *r_timer_lastdraw)
void VIEW3D_OT_zoom(wmOperatorType *ot)
static wmOperatorStatus viewzoom_invoke_impl(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
static wmOperatorStatus viewzoom_exec(bContext *C, wmOperator *op)
static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2])
int xy[2]
Definition wm_draw.cc:178
@ MOUSEPAN
@ TIMER
@ MOUSEZOOM
PointerRNA * ptr
Definition wm_files.cc:4238
wmOperatorType * ot
Definition wm_files.cc:4237
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition wm_keymap.cc:932
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
Definition wm_keymap.cc:959
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)