Blender  V3.3
wm_gesture_ops.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_windowmanager_types.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BKE_context.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm.h"
#include "wm_event_system.h"
#include "wm_event_types.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "UI_interface.h"
#include "RNA_access.h"
#include "RNA_define.h"

Go to the source code of this file.

Functions

Internal Gesture Utilities

Border gesture has two types:

  1. WM_GESTURE_CROSS_RECT: starts a cross, on mouse click it changes to border.
  2. WM_GESTURE_RECT: starts immediate as a border, on mouse click or release it ends.

It stores 4 values (xmin, xmax, ymin, ymax) and event it ended with (event_type).

static void gesture_modal_end (bContext *C, wmOperator *op)
 
static void gesture_modal_state_to_operator (wmOperator *op, int modal_state)
 
static int UNUSED_FUNCTION() gesture_modal_state_from_operator (wmOperator *op)
 
Border Gesture

Border gesture has two types:

  1. WM_GESTURE_CROSS_RECT: starts a cross, on mouse click it changes to border.
  2. WM_GESTURE_RECT: starts immediate as a border, on mouse click or release it ends.

It stores 4 values (xmin, xmax, ymin, ymax) and event it ended with (event_type).

static bool gesture_box_apply_rect (wmOperator *op)
 
static bool gesture_box_apply (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)
 
void WM_gesture_box_cancel (bContext *C, wmOperator *op)
 
Circle Gesture

Currently only used for selection or modal paint stuff, calls wmOperatorType.exec while hold mouse, exits on release (with no difference between cancel and confirm).

static void gesture_circle_apply (bContext *C, wmOperator *op)
 
int WM_gesture_circle_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
int WM_gesture_circle_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void WM_gesture_circle_cancel (bContext *C, wmOperator *op)
 
Lasso Gesture
int WM_gesture_lasso_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
int WM_gesture_lines_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int gesture_lasso_apply (bContext *C, wmOperator *op)
 
int WM_gesture_lasso_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
int WM_gesture_lines_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void WM_gesture_lasso_cancel (bContext *C, wmOperator *op)
 
void WM_gesture_lines_cancel (bContext *C, wmOperator *op)
 
const int(* WM_gesture_lasso_path_to_array (bContext *UNUSED(C), wmOperator *op, int *r_mcoords_len))[2]
 

Straight Line Gesture

Gesture defined by the start and end points of a line that is created between the position of the initial event and the position of the current event.

Straight Line Gesture has two modal callbacks depending on the tool that is being implemented: a regular modal callback intended to update the data during the execution of the gesture and a one-shot callback that only updates the data once when the gesture finishes.

It stores 4 values: xstart, ystart, xend, yend.

#define STRAIGHTLINE_SNAP_DEG   15.0f
 
static bool gesture_straightline_apply (bContext *C, wmOperator *op)
 
int WM_gesture_straightline_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
int WM_gesture_straightline_active_side_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static void wm_gesture_straightline_do_angle_snap (rcti *rect)
 
int WM_gesture_straightline_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
int WM_gesture_straightline_oneshot_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void WM_gesture_straightline_cancel (bContext *C, wmOperator *op)
 

Detailed Description

Default operator callbacks for use with gestures (border/circle/lasso/straightline). Operators themselves are defined elsewhere.

Definition in file wm_gesture_ops.c.

Macro Definition Documentation

◆ STRAIGHTLINE_SNAP_DEG

#define STRAIGHTLINE_SNAP_DEG   15.0f

Definition at line 768 of file wm_gesture_ops.c.

Function Documentation

◆ gesture_box_apply()

static bool gesture_box_apply ( bContext C,
wmOperator op 
)
static

◆ gesture_box_apply_rect()

static bool gesture_box_apply_rect ( wmOperator op)
static

◆ gesture_circle_apply()

static void gesture_circle_apply ( bContext C,
wmOperator op 
)
static

◆ gesture_lasso_apply()

static int gesture_lasso_apply ( bContext C,
wmOperator op 
)
static

◆ gesture_modal_end()

static void gesture_modal_end ( bContext C,
wmOperator op 
)
static

◆ gesture_modal_state_from_operator()

static int UNUSED_FUNCTION() gesture_modal_state_from_operator ( wmOperator op)
static

◆ gesture_modal_state_to_operator()

static void gesture_modal_state_to_operator ( wmOperator op,
int  modal_state 
)
static

◆ gesture_straightline_apply()

static bool gesture_straightline_apply ( bContext C,
wmOperator op 
)
static

◆ WM_gesture_box_cancel()

void WM_gesture_box_cancel ( bContext C,
wmOperator op 
)

◆ WM_gesture_box_invoke()

int WM_gesture_box_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_box_modal()

int WM_gesture_box_modal ( bContext C,
wmOperator op,
const wmEvent event 
)

Definition at line 190 of file wm_gesture_ops.c.

References BLI_rcti_translate(), C, CTX_wm_window(), wmOperator::customdata, wmGesture::customdata, EVT_MODAL_MAP, gesture_box_apply(), gesture_box_apply_rect(), GESTURE_MODAL_BEGIN, GESTURE_MODAL_CANCEL, GESTURE_MODAL_DESELECT, gesture_modal_end(), GESTURE_MODAL_IN, GESTURE_MODAL_MOVE, GESTURE_MODAL_OUT, GESTURE_MODAL_SELECT, wmGesture::is_active, wmGesture::is_active_prev, wmGesture::modal_state, MOUSEMOVE, wmGesture::move, NDOF_MOTION, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, OPERATOR_RUNNING_MODAL, wmGesture::type, wmEvent::type, wmEvent::val, wmGesture::wait_for_input, wmGesture::winrct, WM_GESTURE_CROSS_RECT, wm_gesture_tag_redraw(), rcti::xmax, rcti::xmin, wmEvent::xy, rcti::ymax, and rcti::ymin.

Referenced by ACTION_OT_select_box(), ANIM_OT_channels_select_box(), ANIM_OT_previewrange_set(), CLIP_OT_graph_select_box(), CLIP_OT_select_box(), file_box_select_modal(), GPENCIL_OT_select_box(), GRAPH_OT_select_box(), IMAGE_OT_render_border(), IMAGE_OT_view_zoom_border(), INFO_OT_select_box(), MARKER_OT_select_box(), MASK_OT_select_box(), NLA_OT_select_box(), blender::ed::space_node::NODE_OT_select_box(), blender::ed::space_node::NODE_OT_viewer_border(), OUTLINER_OT_select_box(), PAINT_OT_hide_show(), PAINT_OT_mask_box_gesture(), SCULPT_OT_face_set_box_gesture(), SCULPT_OT_trim_box_gesture(), SEQUENCER_OT_select_box(), SEQUENCER_OT_view_ghost_border(), UV_OT_select_box(), VIEW2D_OT_zoom_border(), VIEW3D_OT_clip_border(), VIEW3D_OT_render_border(), VIEW3D_OT_select_box(), and VIEW3D_OT_zoom_border().

◆ WM_gesture_circle_cancel()

void WM_gesture_circle_cancel ( bContext C,
wmOperator op 
)

◆ WM_gesture_circle_invoke()

int WM_gesture_circle_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_circle_modal()

int WM_gesture_circle_modal ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_lasso_cancel()

void WM_gesture_lasso_cancel ( bContext C,
wmOperator op 
)

◆ WM_gesture_lasso_invoke()

int WM_gesture_lasso_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_lasso_modal()

int WM_gesture_lasso_modal ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_lasso_path_to_array()

const int(* WM_gesture_lasso_path_to_array ( bContext UNUSEDC,
wmOperator op,
int *  r_mcoords_len 
) )[2]

◆ WM_gesture_lines_cancel()

void WM_gesture_lines_cancel ( bContext C,
wmOperator op 
)

◆ WM_gesture_lines_invoke()

int WM_gesture_lines_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_lines_modal()

int WM_gesture_lines_modal ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_straightline_active_side_invoke()

int WM_gesture_straightline_active_side_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_straightline_cancel()

void WM_gesture_straightline_cancel ( bContext C,
wmOperator op 
)

◆ wm_gesture_straightline_do_angle_snap()

static void wm_gesture_straightline_do_angle_snap ( rcti rect)
static

◆ WM_gesture_straightline_invoke()

int WM_gesture_straightline_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_straightline_modal()

int WM_gesture_straightline_modal ( bContext C,
wmOperator op,
const wmEvent event 
)

◆ WM_gesture_straightline_oneshot_modal()

int WM_gesture_straightline_oneshot_modal ( bContext C,
wmOperator op,
const wmEvent event 
)