114 if (region ==
NULL) {
262 switch (event->
type) {
268 vpd->
lastx =
event->x;
269 vpd->
lasty =
event->y;
331 RNA_def_int(
ot->
srna,
"deltax", 0, INT_MIN, INT_MAX,
"Delta X",
"", INT_MIN, INT_MAX);
332 RNA_def_int(
ot->
srna,
"deltay", 0, INT_MIN, INT_MAX,
"Delta Y",
"", INT_MIN, INT_MAX);
345 #define EDGE_PAN_REGION_PAD (U.widget_unit)
347 #define EDGE_PAN_SPEED_PER_PIXEL (25.0f * (float)U.dpi_fac)
349 #define EDGE_PAN_DELAY 1.0f
375 const double current_time)
377 if (pan_dir_x == 0) {
383 if (pan_dir_y == 0) {
400 return x *
x *
x * (
x * (
x * 6.0 - 15.0) + 10.0);
406 const double current_time)
414 if (event_loc >
max) {
417 else if (event_loc <
min) {
421 BLI_assert(!
"Calculating speed outside of pan zones");
452 if (outside_padding != 0) {
453 padding_rect = region->
winrct;
454 BLI_rcti_pad(&padding_rect, outside_padding, outside_padding);
480 float dx = 0.0f, dy = 0.0f;
481 if (pan_dir_x != 0) {
483 dx = dtime * speed * (
float)pan_dir_x;
485 if (pan_dir_y != 0) {
486 const float speed =
edge_pan_speed(vpd, event->
y,
false, current_time);
487 dy = dtime * speed * (
float)pan_dir_y;
494 return success_retval;
505 ot->
name =
"View Edge Pan";
506 ot->
description =
"Pan the view when the mouse is held at an edge";
523 "Padding around the region in UI units within which panning is activated (0 to "
529 #undef EDGE_PAN_REGION_PAD
530 #undef EDGE_PAN_SPEED_PER_PIXEL
531 #undef EDGE_PAN_DELAY
568 ot->
name =
"Scroll Right";
570 ot->
idname =
"VIEW2D_OT_scroll_right";
577 RNA_def_int(
ot->
srna,
"deltax", 0, INT_MIN, INT_MAX,
"Delta X",
"", INT_MIN, INT_MAX);
578 RNA_def_int(
ot->
srna,
"deltay", 0, INT_MIN, INT_MAX,
"Delta Y",
"", INT_MIN, INT_MAX);
612 ot->
idname =
"VIEW2D_OT_scroll_left";
619 RNA_def_int(
ot->
srna,
"deltax", 0, INT_MIN, INT_MAX,
"Delta X",
"", INT_MIN, INT_MAX);
620 RNA_def_int(
ot->
srna,
"deltay", 0, INT_MIN, INT_MAX,
"Delta Y",
"", INT_MIN, INT_MAX);
660 ot->
idname =
"VIEW2D_OT_scroll_down";
667 RNA_def_int(
ot->
srna,
"deltax", 0, INT_MIN, INT_MAX,
"Delta X",
"", INT_MIN, INT_MAX);
668 RNA_def_int(
ot->
srna,
"deltay", 0, INT_MIN, INT_MAX,
"Delta Y",
"", INT_MIN, INT_MAX);
716 RNA_def_int(
ot->
srna,
"deltax", 0, INT_MIN, INT_MAX,
"Delta X",
"", INT_MIN, INT_MAX);
717 RNA_def_int(
ot->
srna,
"deltay", 0, INT_MIN, INT_MAX,
"Delta Y",
"", INT_MIN, INT_MAX);
767 r_do_zoom_xy[0] =
true;
768 r_do_zoom_xy[1] =
true;
775 r_do_zoom_xy[1] =
false;
786 if (region ==
NULL) {
874 const float mval_faci = 1.0f - mval_fac;
875 const float ofs = (mval_fac * dx) - (mval_faci * dx);
909 const float mval_faci = 1.0f - mval_fac;
910 const float ofs = (mval_fac * dy) - (mval_faci * dy);
1010 ot->
srna,
"zoomfacx", 0, -FLT_MAX, FLT_MAX,
"Zoom Factor X",
"", -FLT_MAX, FLT_MAX);
1013 ot->
srna,
"zoomfacy", 0, -FLT_MAX, FLT_MAX,
"Zoom Factor Y",
"", -FLT_MAX, FLT_MAX);
1075 ot->
srna,
"zoomfacx", 0, -FLT_MAX, FLT_MAX,
"Zoom Factor X",
"", -FLT_MAX, FLT_MAX);
1078 ot->
srna,
"zoomfacy", 0, -FLT_MAX, FLT_MAX,
"Zoom Factor Y",
"", -FLT_MAX, FLT_MAX);
1115 dx *= time_step * 0.5f;
1116 dy *= time_step * 0.5f;
1129 const float mval_faci = 1.0f - mval_fac;
1130 const float ofs = (mval_fac * dx) - (mval_faci * dx);
1148 const float mval_faci = 1.0f - mval_fac;
1149 const float ofs = (mval_fac * dy) - (mval_faci * dy);
1227 vzd->
lastx =
event->prevx;
1228 vzd->
lasty =
event->prevy;
1231 float zoomfac = 0.01f;
1286 vzd->
lastx =
event->x;
1287 vzd->
lasty =
event->y;
1329 float zoomfac = 0.01f;
1359 dx = len_new[0] - len_old[0];
1360 dy = len_new[1] - len_old[1];
1367 float facx = zoomfac * (
event->x - vzd->
lastx);
1368 float facy = zoomfac * (
event->y - vzd->
lasty);
1414 vzd->
lastx =
event->x;
1415 vzd->
lasty =
event->y;
1454 ot->
name =
"Zoom 2D View";
1470 prop =
RNA_def_float(
ot->
srna,
"deltax", 0, -FLT_MAX, FLT_MAX,
"Delta X",
"", -FLT_MAX, FLT_MAX);
1472 prop =
RNA_def_float(
ot->
srna,
"deltay", 0, -FLT_MAX, FLT_MAX,
"Delta Y",
"", -FLT_MAX, FLT_MAX);
1561 ot->
name =
"Zoom to Border";
1562 ot->
description =
"Zoom in the view to the nearest item contained in the border";
1563 ot->
idname =
"VIEW2D_OT_zoom_border";
1583 #ifdef WITH_INPUT_NDOF
1590 const wmNDOFMotionData *ndof =
event->customdata;
1593 const float zoom_sensitivity = 0.5f;
1594 const float speed = 10.0f;
1595 const bool has_translate = (ndof->tvec[0] && ndof->tvec[1]) &&
view_pan_poll(
C);
1598 if (has_translate) {
1601 WM_event_ndof_pan_get(ndof, pan_vec,
false);
1603 pan_vec[0] *= speed;
1604 pan_vec[1] *= speed;
1615 float zoom_factor = zoom_sensitivity * ndof->dt * -ndof->tvec[2];
1620 zoom_factor = -zoom_factor;
1629 C, vzd, do_zoom_xy[0] ? zoom_factor : 0.0f, do_zoom_xy[1] ? zoom_factor : 0.0f);
1640 ot->
name =
"NDOF Pan/Zoom";
1642 ot->
description =
"Use a 3D mouse device to pan/zoom the view";
1680 float fac_max = 0.0f;
1682 for (
int i = 0; i < 2; i++) {
1684 float tfac =
fabsf(cent_a[i] - cent_b[i]) /
min_ff(size_a[i], size_b[i]);
1685 fac_max =
max_ff(fac_max, tfac);
1686 if (fac_max >= 1.0f) {
1691 tfac = (1.0f - (
min_ff(size_a[i], size_b[i]) /
max_ff(size_a[i], size_b[i]))) * 2.0f;
1692 fac_max =
max_ff(fac_max, tfac);
1693 if (fac_max >= 1.0f) {
1697 return min_ff(fac_max, 1.0f);
1724 if (smooth_viewtx && fac > FLT_EPSILON) {
1725 bool changed =
false;
1802 step = (3.0f * step * step - 2.0f * step * step * step);
1821 ot->
name =
"Smooth View 2D";
1822 ot->
idname =
"VIEW2D_OT_smoothview";
1921 bool in_view =
true;
1922 if (sh_min <= sc_min && sc_max <= sh_max) {
1925 else if (sh_max <= sc_min || sc_max <= sh_min) {
1983 const char in_scroller)
1998 vsm->
lastx =
event->x;
1999 vsm->
lasty =
event->y;
2008 rctf tot_cur_union = v2d->
tot;
2011 if (in_scroller ==
'h') {
2082 float temp = vsm->
fac * vsm->
delta;
2088 switch (vsm->
zone) {
2143 switch (event->
type) {
2174 vsm->
lastx =
event->x;
2175 vsm->
lasty =
event->y;
2299 ot->
name =
"Scroller Activate";
2301 ot->
idname =
"VIEW2D_OT_scroller_activate";
2409 #ifdef WITH_INPUT_NDOF
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct bScreen * CTX_wm_screen(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float min_ff(float a, float b)
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y)
bool BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void BLI_rctf_union(struct rctf *rct1, const struct rctf *rct2)
#define IN_RANGE_INCL(a, b, c)
typedef double(DMatrix)[4][4]
@ V2D_SCROLL_HORIZONTAL_FULLR
@ V2D_SCROLL_VERTICAL_FULLR
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_HORIZONTAL_HANDLES
void ED_area_tag_redraw(ScrArea *area)
int ED_region_snap_size_test(const struct ARegion *region)
void ED_region_tag_redraw_no_rebuild(struct ARegion *region)
bool ED_region_snap_size_apply(struct ARegion *region, int snap_flag)
void ED_region_tag_redraw(struct ARegion *region)
NSNotificationCenter * center
Read Guarded memory(de)allocation.
Platform independent time functions.
const struct uiStyle * UI_style_get(void)
char UI_view2d_mouse_in_scrollers(const struct ARegion *region, const struct View2D *v2d, int x, int y)
void UI_view2d_region_to_view_rctf(const struct View2D *v2d, const struct rctf *rect_src, struct rctf *rect_dst) ATTR_NONNULL()
#define V2D_SCROLL_HANDLE_SIZE_HOTSPOT
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
void UI_view2d_zoom_cache_reset(void)
void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D *v2dcur, int flag)
void UI_view2d_curRect_changed(const struct bContext *C, struct View2D *v2d)
void UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom, struct View2DScrollers *r_scrollers)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
struct SmoothView2DStore * sms
struct wmTimer * smooth_timer
double edge_pan_last_time
double edge_pan_start_time_x
double edge_pan_start_time_y
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct wmEvent * eventstate
double PIL_check_seconds_timer(void)
ccl_device_inline float distance(const float2 &a, const float2 &b)
static void VIEW2D_OT_scroll_up(wmOperatorType *ot)
static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
struct v2dViewZoomData v2dViewZoomData
static int view_scrollup_exec(bContext *C, wmOperator *op)
static void VIEW2D_OT_scroll_left(wmOperatorType *ot)
struct v2dViewPanData v2dViewPanData
static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
static void scroller_activate_apply(bContext *C, wmOperator *op)
static bool view_zoom_poll(bContext *C)
static int view_scrolldown_exec(bContext *C, wmOperator *op)
static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
struct v2dScrollerMove v2dScrollerMove
static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int view_scrollleft_exec(bContext *C, wmOperator *op)
static void VIEW2D_OT_scroll_down(wmOperatorType *ot)
static void edge_pan_manage_delay_timers(v2dViewPanData *vpd, int pan_dir_x, int pan_dir_y, const double current_time)
static void view_zoomstep_apply(bContext *C, wmOperator *op)
static void VIEW2D_OT_pan(wmOperatorType *ot)
static void view_zoomstep_apply_ex(bContext *C, v2dViewZoomData *vzd, const float facx, const float facy)
static void VIEW2D_OT_zoom_out(wmOperatorType *ot)
static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float dy)
static void scroller_activate_exit(bContext *C, wmOperator *op)
static int view_zoomin_exec(bContext *C, wmOperator *op)
static int view_pan_exec(bContext *C, wmOperator *op)
#define EDGE_PAN_REGION_PAD
static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
static void view_pan_exit(wmOperator *op)
static int view_scrollright_exec(bContext *C, wmOperator *op)
static void VIEW2D_OT_zoom(wmOperatorType *ot)
static bool view2d_poll(bContext *C)
static void view_zoomdrag_exit(bContext *C, wmOperator *op)
static float smootherstep(const float domain_max, float x)
static void VIEW2D_OT_zoom_in(wmOperatorType *ot)
static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void view_zoomdrag_apply(bContext *C, wmOperator *op)
#define EDGE_PAN_SPEED_PER_PIXEL
@ SCROLLHANDLE_MIN_OUTSIDE
@ SCROLLHANDLE_MAX_OUTSIDE
static void scroller_activate_cancel(bContext *C, wmOperator *op)
void ED_keymap_view2d(wmKeyConfig *keyconf)
static void view_edge_pan_cancel(bContext *UNUSED(C), wmOperator *op)
static int view_zoomout_exec(bContext *C, wmOperator *op)
static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
static int view_borderzoom_exec(bContext *C, wmOperator *op)
void UI_view2d_smooth_view(bContext *C, ARegion *region, const rctf *cur, const int smooth_viewtx)
static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void view_pan_init(bContext *C, wmOperator *op)
static int view_edge_pan_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static float edge_pan_speed(v2dViewPanData *vpd, int event_loc, bool x_dir, const double current_time)
static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_operatortypes_view2d(void)
static void VIEW2D_OT_scroll_right(wmOperatorType *ot)
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
static void view_pan_apply(bContext *C, wmOperator *op)
static bool view_pan_poll(bContext *C)
static void VIEW2D_OT_edge_pan(wmOperatorType *ot)
static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
static void VIEW2D_OT_reset(wmOperatorType *ot)
static int view_zoomdrag_exec(bContext *C, wmOperator *op)
static bool scroller_activate_poll(bContext *C)
static void VIEW2D_OT_smoothview(wmOperatorType *ot)
static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int reset_exec(bContext *C, wmOperator *UNUSED(op))
static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, const char in_scroller)
static void view_zoomdrag_init(bContext *C, wmOperator *op)
static void view_zoomstep_exit(wmOperator *op)
static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2])
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
int WM_event_absolute_delta_y(const struct wmEvent *event)
int WM_event_absolute_delta_x(const struct wmEvent *event)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_name_call(bContext *C, const char *opstring, short context, PointerRNA *properties)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_add_mousemove(wmWindow *win)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
void WM_operator_properties_use_cursor_init(wmOperatorType *ot)
void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
void WM_operator_properties_gesture_box_zoom(wmOperatorType *ot)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int WM_operator_smooth_viewtx_get(const wmOperator *op)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)