Blender V4.5
view2d_ops.cc File Reference
#include <cmath>
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_math_base.h"
#include "BLI_math_vector.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_screen.hh"
#include "UI_interface.hh"
#include "UI_view2d.hh"
#include "view2d_intern.hh"

Go to the source code of this file.

Classes

struct  v2dViewPanData
struct  v2dViewZoomData
struct  SmoothView2DStore
struct  v2dScrollerMove

Functions

Internal Utilities
static bool view2d_poll (bContext *C)
static float view2d_scroll_delta_y_snap_page_size (const View2D &v2d, const float delta_y)
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 wmOperatorStatus view_pan_exec (bContext *C, wmOperator *op)
static wmOperatorStatus view_pan_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus view_pan_modal (bContext *C, wmOperator *op, const wmEvent *event)
static void view_pan_cancel (bContext *, 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 wmOperatorStatus view_edge_pan_invoke (bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus view_edge_pan_modal (bContext *C, wmOperator *op, const wmEvent *event)
static void view_edge_pan_cancel (bContext *, wmOperator *op)
static void VIEW2D_OT_edge_pan (wmOperatorType *ot)
View Pan Operator (single step)
static wmOperatorStatus view_scrollright_exec (bContext *C, wmOperator *op)
static void VIEW2D_OT_scroll_right (wmOperatorType *ot)
static wmOperatorStatus view_scrollleft_exec (bContext *C, wmOperator *op)
static void VIEW2D_OT_scroll_left (wmOperatorType *ot)
static wmOperatorStatus view_scrolldown_exec (bContext *C, wmOperator *op)
static void VIEW2D_OT_scroll_down (wmOperatorType *ot)
static wmOperatorStatus 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 (bContext *C, wmOperator *op)
static wmOperatorStatus view_zoomin_exec (bContext *C, wmOperator *op)
static wmOperatorStatus view_zoomin_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static void VIEW2D_OT_zoom_in (wmOperatorType *ot)
static wmOperatorStatus view_zoomout_exec (bContext *C, wmOperator *op)
static wmOperatorStatus 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 wmOperatorStatus view_zoomdrag_exec (bContext *C, wmOperator *op)
static wmOperatorStatus view_zoomdrag_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus view_zoomdrag_modal (bContext *C, wmOperator *op, const wmEvent *event)
static void VIEW2D_OT_zoom (wmOperatorType *ot)
Border Zoom Operator

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 key-mappings for this.

static wmOperatorStatus 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 wmOperatorStatus view2d_smoothview_invoke (bContext *C, wmOperator *, const wmEvent *event)
static void VIEW2D_OT_smoothview (wmOperatorType *ot)
View Reset Operator
static wmOperatorStatus reset_exec (bContext *C, wmOperator *)
static void VIEW2D_OT_reset (wmOperatorType *ot)
Registration
void ED_operatortypes_view2d ()
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 scrollbar_zone_get (int mouse, 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 wmOperatorStatus scroller_activate_modal (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus 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 1810 of file view2d_ops.cc.

Function Documentation

◆ ED_keymap_view2d()

void ED_keymap_view2d ( wmKeyConfig * keyconf)

◆ ED_operatortypes_view2d()

◆ reset_exec()

◆ scrollbar_zone_get()

short scrollbar_zone_get ( int mouse,
int sh_min,
int sh_max )
static

Get the part of the scrollbar that the mouse is in.

Parameters
mouseRelevant mouse coordinate in region space.
sh_min,sh_maxExtents of the "scroller handle" part of the scrollbar in region space.

Definition at line 1824 of file view2d_ops.cc.

References scrollbar_zone_get(), SCROLLHANDLE_BAR, SCROLLHANDLE_MAX, SCROLLHANDLE_MAX_OUTSIDE, SCROLLHANDLE_MIN, SCROLLHANDLE_MIN_OUTSIDE, and V2D_SCROLL_HANDLE_SIZE_HOTSPOT.

Referenced by scrollbar_zone_get(), and scroller_activate_init().

◆ scroller_activate_apply()

◆ scroller_activate_cancel()

void scroller_activate_cancel ( bContext * C,
wmOperator * op )
static

◆ scroller_activate_exit()

◆ scroller_activate_init()

◆ scroller_activate_invoke()

◆ scroller_activate_modal()

◆ scroller_activate_poll()

◆ smooth_view_rect_to_fac()

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 1598 of file view2d_ops.cc.

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

Referenced by smooth_view_rect_to_fac(), and UI_view2d_smooth_view().

◆ UI_view2d_smooth_view()

◆ VIEW2D_OT_edge_pan()

◆ VIEW2D_OT_pan()

◆ VIEW2D_OT_reset()

◆ VIEW2D_OT_scroll_down()

◆ VIEW2D_OT_scroll_left()

◆ VIEW2D_OT_scroll_right()

◆ VIEW2D_OT_scroll_up()

◆ VIEW2D_OT_scroller_activate()

◆ VIEW2D_OT_smoothview()

◆ VIEW2D_OT_zoom()

◆ VIEW2D_OT_zoom_border()

◆ VIEW2D_OT_zoom_in()

◆ VIEW2D_OT_zoom_out()

◆ view2d_poll()

bool view2d_poll ( bContext * C)
static

◆ view2d_scroll_delta_y_snap_page_size()

float view2d_scroll_delta_y_snap_page_size ( const View2D & v2d,
const float delta_y )
static

Calculate a scrolling delta that is the closest to a multiple of the page size (as returned by view2d_page_size_y). So when scrolling for more than half a page size, a delta to the next page is returned. No scrolling change should be applied when this returns 0.

Definition at line 52 of file view2d_ops.cc.

References abs, view2d_page_size_y(), and view2d_scroll_delta_y_snap_page_size().

Referenced by scroller_activate_modal(), view2d_scroll_delta_y_snap_page_size(), and view_pan_modal().

◆ view2d_smoothview_invoke()

◆ view_borderzoom_exec()

◆ view_edge_pan_cancel()

void view_edge_pan_cancel ( bContext * ,
wmOperator * op )
static

◆ view_edge_pan_invoke()

◆ view_edge_pan_modal()

◆ view_pan_apply()

◆ view_pan_apply_ex()

◆ view_pan_cancel()

void view_pan_cancel ( bContext * ,
wmOperator * op )
static

◆ view_pan_exec()

◆ view_pan_exit()

◆ view_pan_init()

◆ view_pan_invoke()

◆ view_pan_modal()

◆ view_pan_poll()

◆ view_scrolldown_exec()

◆ view_scrollleft_exec()

◆ view_scrollright_exec()

◆ view_scrollup_exec()

◆ view_zoom_axis_lock_defaults()

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 682 of file view2d_ops.cc.

References C, CTX_wm_area(), CTX_wm_region(), ARegion::regiontype, RGN_TYPE_WINDOW, SPACE_SEQ, ScrArea::spacetype, and view_zoom_axis_lock_defaults().

Referenced by view_zoom_axis_lock_defaults(), view_zoomin_exec(), and view_zoomout_exec().

◆ view_zoom_poll()

◆ view_zoomdrag_apply()

◆ view_zoomdrag_cancel()

void view_zoomdrag_cancel ( bContext * C,
wmOperator * op )
static

Definition at line 1124 of file view2d_ops.cc.

References C, view_zoomdrag_cancel(), and view_zoomdrag_exit().

Referenced by VIEW2D_OT_zoom(), and view_zoomdrag_cancel().

◆ view_zoomdrag_exec()

wmOperatorStatus view_zoomdrag_exec ( bContext * C,
wmOperator * op )
static

◆ view_zoomdrag_exit()

◆ view_zoomdrag_init()

◆ view_zoomdrag_invoke()

◆ view_zoomdrag_modal()

◆ view_zoomin_exec()

◆ view_zoomin_invoke()

◆ view_zoomout_exec()

◆ view_zoomout_invoke()

◆ view_zoomstep_apply()

void view_zoomstep_apply ( bContext * C,
wmOperator * op )
static

◆ view_zoomstep_apply_ex()

◆ view_zoomstep_exit()