Blender  V3.3
Classes
view2d_ops.cc File Reference
#include <cmath>
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "UI_interface.h"
#include "UI_view2d.h"
#include "PIL_time.h"

Go to the source code of this file.

Classes

struct  v2dViewPanData
 
struct  v2dViewZoomData
 
struct  SmoothView2DStore
 
struct  v2dScrollerMove
 
struct  View2DScrollers
 

Functions

Internal Utilities
static bool view2d_poll (bContext *C)
 
View Pan Shared Utilities
static bool view_pan_poll (bContext *C)
 
static void view_pan_init (bContext *C, wmOperator *op)
 
static void view_pan_apply_ex (bContext *C, v2dViewPanData *vpd, float dx, float dy)
 
static void view_pan_apply (bContext *C, wmOperator *op)
 
static void view_pan_exit (wmOperator *op)
 
View Pan Operator (modal drag-pan)
static int view_pan_exec (bContext *C, wmOperator *op)
 
static int view_pan_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int view_pan_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void view_pan_cancel (bContext *UNUSED(C), wmOperator *op)
 
static void VIEW2D_OT_pan (wmOperatorType *ot)
 
View Edge Pan Operator (modal)

Scroll the region if the mouse is dragged to an edge. "Invisible" operator that always passes through.

static int view_edge_pan_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
static int view_edge_pan_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void view_edge_pan_cancel (bContext *UNUSED(C), wmOperator *op)
 
static void VIEW2D_OT_edge_pan (wmOperatorType *ot)
 
View Pan Operator (single step)
static int view_scrollright_exec (bContext *C, wmOperator *op)
 
static void VIEW2D_OT_scroll_right (wmOperatorType *ot)
 
static int view_scrollleft_exec (bContext *C, wmOperator *op)
 
static void VIEW2D_OT_scroll_left (wmOperatorType *ot)
 
static int view_scrolldown_exec (bContext *C, wmOperator *op)
 
static void VIEW2D_OT_scroll_down (wmOperatorType *ot)
 
static int view_scrollup_exec (bContext *C, wmOperator *op)
 
static void VIEW2D_OT_scroll_up (wmOperatorType *ot)
 
View Zoom Shared Utilities
static void view_zoom_axis_lock_defaults (bContext *C, bool r_do_zoom_xy[2])
 
static bool view_zoom_poll (bContext *C)
 
static void view_zoomdrag_init (bContext *C, wmOperator *op)
 
static void view_zoomstep_apply_ex (bContext *C, v2dViewZoomData *vzd, const float facx, const float facy)
 
static void view_zoomstep_apply (bContext *C, wmOperator *op)
 
View Zoom Operator (single step)
static void view_zoomstep_exit (wmOperator *op)
 
static int view_zoomin_exec (bContext *C, wmOperator *op)
 
static int view_zoomin_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void VIEW2D_OT_zoom_in (wmOperatorType *ot)
 
static int view_zoomout_exec (bContext *C, wmOperator *op)
 
static int view_zoomout_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void VIEW2D_OT_zoom_out (wmOperatorType *ot)
 
View Zoom Operator (modal drag-zoom)
static void view_zoomdrag_apply (bContext *C, wmOperator *op)
 
static void view_zoomdrag_exit (bContext *C, wmOperator *op)
 
static void view_zoomdrag_cancel (bContext *C, wmOperator *op)
 
static int view_zoomdrag_exec (bContext *C, wmOperator *op)
 
static int view_zoomdrag_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int view_zoomdrag_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void VIEW2D_OT_zoom (wmOperatorType *ot)
 
Border Zoom Operator
static int view_borderzoom_exec (bContext *C, wmOperator *op)
 
static void VIEW2D_OT_zoom_border (wmOperatorType *ot)
 
Smooth View Operator
static float smooth_view_rect_to_fac (const rctf *rect_a, const rctf *rect_b)
 
void UI_view2d_smooth_view (const bContext *C, ARegion *region, const rctf *cur, const int smooth_viewtx)
 
static int view2d_smoothview_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
static void VIEW2D_OT_smoothview (wmOperatorType *ot)
 
View Reset Operator
static int reset_exec (bContext *C, wmOperator *UNUSED(op))
 
static void VIEW2D_OT_reset (wmOperatorType *ot)
 
Registration
void ED_operatortypes_view2d (void)
 
void ED_keymap_view2d (wmKeyConfig *keyconf)
 

Scroll Bar Move Operator

enum  {
  SCROLLHANDLE_MIN = -1 , SCROLLHANDLE_BAR , SCROLLHANDLE_MAX , SCROLLHANDLE_MIN_OUTSIDE ,
  SCROLLHANDLE_MAX_OUTSIDE
}
 
static short mouse_in_scroller_handle (int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
 
static bool scroller_activate_poll (bContext *C)
 
static void scroller_activate_init (bContext *C, wmOperator *op, const wmEvent *event, const char in_scroller)
 
static void scroller_activate_exit (bContext *C, wmOperator *op)
 
static void scroller_activate_cancel (bContext *C, wmOperator *op)
 
static void scroller_activate_apply (bContext *C, wmOperator *op)
 
static int scroller_activate_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static int scroller_activate_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void VIEW2D_OT_scroller_activate (wmOperatorType *ot)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SCROLLHANDLE_MIN 
SCROLLHANDLE_BAR 
SCROLLHANDLE_MAX 
SCROLLHANDLE_MIN_OUTSIDE 
SCROLLHANDLE_MAX_OUTSIDE 

Definition at line 1749 of file view2d_ops.cc.

Function Documentation

◆ ED_keymap_view2d()

void ED_keymap_view2d ( wmKeyConfig keyconf)

Definition at line 2277 of file view2d_ops.cc.

References WM_keymap_ensure().

Referenced by ED_spacetypes_keymap().

◆ ED_operatortypes_view2d()

void ED_operatortypes_view2d ( void  )

◆ mouse_in_scroller_handle()

static short mouse_in_scroller_handle ( int  mouse,
int  sc_min,
int  sc_max,
int  sh_min,
int  sh_max 
)
static

Check if mouse is within scroller handle.

Parameters
mouserelevant mouse coordinate in region space.
sc_min,sc_maxextents of scroller 'groove' (potential available space for scroller).
sh_min,sh_maxpositions of scrollbar handles.

Definition at line 1764 of file view2d_ops.cc.

References SCROLLHANDLE_BAR, SCROLLHANDLE_MAX, SCROLLHANDLE_MAX_OUTSIDE, SCROLLHANDLE_MIN, SCROLLHANDLE_MIN_OUTSIDE, and V2D_SCROLL_HANDLE_SIZE_HOTSPOT.

Referenced by scroller_activate_init().

◆ reset_exec()

static int reset_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ scroller_activate_apply()

static void scroller_activate_apply ( bContext C,
wmOperator op 
)
static

◆ scroller_activate_cancel()

static void scroller_activate_cancel ( bContext C,
wmOperator op 
)
static

Definition at line 1927 of file view2d_ops.cc.

References C, and scroller_activate_exit().

Referenced by VIEW2D_OT_scroller_activate().

◆ scroller_activate_exit()

static void scroller_activate_exit ( bContext C,
wmOperator op 
)
static

◆ scroller_activate_init()

static void scroller_activate_init ( bContext C,
wmOperator op,
const wmEvent event,
const char  in_scroller 
)
static

◆ scroller_activate_invoke()

static int scroller_activate_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ scroller_activate_modal()

static int scroller_activate_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ scroller_activate_poll()

static bool scroller_activate_poll ( bContext C)
static

◆ smooth_view_rect_to_fac()

static float smooth_view_rect_to_fac ( const rctf rect_a,
const rctf rect_b 
)
static

function to get a factor out of a rectangle

NOTE: this doesn't always work as well as it might because the target size may not be reached because of clamping the desired rect, we could attempt to clamp the rect before working out the zoom factor but its not really worthwhile for the few cases this happens.

Definition at line 1522 of file view2d_ops.cc.

References BLI_rctf_cent_x(), BLI_rctf_cent_y(), BLI_rctf_size_x(), BLI_rctf_size_y(), fabsf, max_ff(), and min_ff().

Referenced by UI_view2d_smooth_view().

◆ UI_view2d_smooth_view()

void UI_view2d_smooth_view ( const bContext C,
ARegion region,
const rctf cur,
const int  smooth_viewtx 
)

◆ VIEW2D_OT_edge_pan()

static void VIEW2D_OT_edge_pan ( wmOperatorType ot)
static

◆ VIEW2D_OT_pan()

static void VIEW2D_OT_pan ( wmOperatorType ot)
static

◆ VIEW2D_OT_reset()

static void VIEW2D_OT_reset ( wmOperatorType ot)
static

◆ VIEW2D_OT_scroll_down()

static void VIEW2D_OT_scroll_down ( wmOperatorType ot)
static

◆ VIEW2D_OT_scroll_left()

static void VIEW2D_OT_scroll_left ( wmOperatorType ot)
static

◆ VIEW2D_OT_scroll_right()

static void VIEW2D_OT_scroll_right ( wmOperatorType ot)
static

◆ VIEW2D_OT_scroll_up()

static void VIEW2D_OT_scroll_up ( wmOperatorType ot)
static

◆ VIEW2D_OT_scroller_activate()

static void VIEW2D_OT_scroller_activate ( wmOperatorType ot)
static

◆ VIEW2D_OT_smoothview()

static void VIEW2D_OT_smoothview ( wmOperatorType ot)
static

◆ VIEW2D_OT_zoom()

static void VIEW2D_OT_zoom ( wmOperatorType ot)
static

◆ VIEW2D_OT_zoom_border()

static void VIEW2D_OT_zoom_border ( wmOperatorType ot)
static

◆ VIEW2D_OT_zoom_in()

static void VIEW2D_OT_zoom_in ( wmOperatorType ot)
static

◆ VIEW2D_OT_zoom_out()

static void VIEW2D_OT_zoom_out ( wmOperatorType ot)
static

◆ view2d_poll()

static bool view2d_poll ( bContext C)
static

◆ view2d_smoothview_invoke()

static int view2d_smoothview_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ view_borderzoom_exec()

static int view_borderzoom_exec ( bContext C,
wmOperator op 
)
static

The user defines a rect using standard box select tools, and we use this rect to define the new zoom-level of the view in the following ways:

  1. LEFTMOUSE - zoom in to view
  2. RIGHTMOUSE - zoom out of view

Currently, these key mappings are hardcoded, but it shouldn't be too important to have custom keymappings for this...

Definition at line 1344 of file view2d_ops.cc.

References BLI_rctf_cent_x(), BLI_rctf_cent_y(), BLI_rctf_size_x(), BLI_rctf_size_y(), C, center, CTX_wm_region(), View2D::cur, View2D::keepzoom, OPERATOR_FINISHED, wmOperator::ptr, RNA_boolean_get(), size(), UI_view2d_region_to_view_rctf(), UI_view2d_smooth_view(), ARegion::v2d, V2D_LOCKZOOM_X, V2D_LOCKZOOM_Y, WM_operator_properties_border_to_rctf(), WM_operator_smooth_viewtx_get(), rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by VIEW2D_OT_zoom_border().

◆ view_edge_pan_cancel()

static void view_edge_pan_cancel ( bContext UNUSEDC,
wmOperator op 
)
static

◆ view_edge_pan_invoke()

static int view_edge_pan_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ view_edge_pan_modal()

static int view_edge_pan_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_pan_apply()

static void view_pan_apply ( bContext C,
wmOperator op 
)
static

◆ view_pan_apply_ex()

static void view_pan_apply_ex ( bContext C,
v2dViewPanData vpd,
float  dx,
float  dy 
)
static

◆ view_pan_cancel()

static void view_pan_cancel ( bContext UNUSEDC,
wmOperator op 
)
static

Definition at line 296 of file view2d_ops.cc.

References view_pan_exit().

Referenced by VIEW2D_OT_pan().

◆ view_pan_exec()

static int view_pan_exec ( bContext C,
wmOperator op 
)
static

Definition at line 191 of file view2d_ops.cc.

References C, OPERATOR_FINISHED, view_pan_apply(), view_pan_exit(), and view_pan_init().

Referenced by VIEW2D_OT_pan().

◆ view_pan_exit()

static void view_pan_exit ( wmOperator op)
static

◆ view_pan_init()

static void view_pan_init ( bContext C,
wmOperator op 
)
static

◆ view_pan_invoke()

static int view_pan_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_pan_modal()

static int view_pan_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_pan_poll()

static bool view_pan_poll ( bContext C)
static

◆ view_scrolldown_exec()

static int view_scrolldown_exec ( bContext C,
wmOperator op 
)
static

◆ view_scrollleft_exec()

static int view_scrollleft_exec ( bContext C,
wmOperator op 
)
static

◆ view_scrollright_exec()

static int view_scrollright_exec ( bContext C,
wmOperator op 
)
static

◆ view_scrollup_exec()

static int view_scrollup_exec ( bContext C,
wmOperator op 
)
static

◆ view_zoom_axis_lock_defaults()

static void view_zoom_axis_lock_defaults ( bContext C,
bool  r_do_zoom_xy[2] 
)
static

Clamp by convention rather than locking flags, for ndof and +/- keys

Definition at line 608 of file view2d_ops.cc.

References blender::compositor::area(), C, CTX_wm_area(), CTX_wm_region(), ARegion::regiontype, RGN_TYPE_WINDOW, and SPACE_SEQ.

Referenced by view_zoomin_exec(), and view_zoomout_exec().

◆ view_zoom_poll()

static bool view_zoom_poll ( bContext C)
static

◆ view_zoomdrag_apply()

static void view_zoomdrag_apply ( bContext C,
wmOperator op 
)
static

◆ view_zoomdrag_cancel()

static void view_zoomdrag_cancel ( bContext C,
wmOperator op 
)
static

Definition at line 1041 of file view2d_ops.cc.

References C, and view_zoomdrag_exit().

Referenced by VIEW2D_OT_zoom().

◆ view_zoomdrag_exec()

static int view_zoomdrag_exec ( bContext C,
wmOperator op 
)
static

◆ view_zoomdrag_exit()

static void view_zoomdrag_exit ( bContext C,
wmOperator op 
)
static

◆ view_zoomdrag_init()

static void view_zoomdrag_init ( bContext C,
wmOperator op 
)
static

◆ view_zoomdrag_invoke()

static int view_zoomdrag_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_zoomdrag_modal()

static int view_zoomdrag_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_zoomin_exec()

static int view_zoomin_exec ( bContext C,
wmOperator op 
)
static

◆ view_zoomin_invoke()

static int view_zoomin_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_zoomout_exec()

static int view_zoomout_exec ( bContext C,
wmOperator op 
)
static

◆ view_zoomout_invoke()

static int view_zoomout_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ view_zoomstep_apply()

static void view_zoomstep_apply ( bContext C,
wmOperator op 
)
static

◆ view_zoomstep_apply_ex()

static void view_zoomstep_apply_ex ( bContext C,
v2dViewZoomData vzd,
const float  facx,
const float  facy 
)
static

◆ view_zoomstep_exit()

static void view_zoomstep_exit ( wmOperator op)
static