Blender V4.3
wm_gesture_ops.cc File Reference
#include "MEM_guardedalloc.h"
#include <fmt/format.h>
#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_math_base.hh"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_rect.h"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "wm.hh"
#include "wm_event_types.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "RNA_access.hh"

Go to the source code of this file.

Classes

struct  SnapAngle
 

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

There are two types of lasso gesture:

  1. WM_GESTURE_LASSO: A lasso that follows the mouse cursor with the enclosed area shaded.
  2. WM_GESTURE_LINES: A lasso that follows the mouse cursor without the enclosed area shaded.

The operator stores data in the "path" property as a series of screen space positions.

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)
 
Array< int2WM_gesture_lasso_path_to_array (bContext *, wmOperator *op)
 
Polyline Gesture

Gesture defined by three or more points in a viewport enclosing a particular area.

Like the Lasso Gesture, the data passed onto other operators via the 'path' property is a sequential array of mouse positions.

int WM_gesture_polyline_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int gesture_polyline_valid_points (const wmGesture &wmGesture, const bool is_click_submitted)
 
static bool gesture_polyline_can_apply (const wmGesture &wmGesture, const bool is_click_submitted)
 
static int gesture_polyline_apply (bContext *C, wmOperator *op, const bool is_click_submitted)
 
int WM_gesture_polyline_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void WM_gesture_polyline_cancel (bContext *C, wmOperator *op)
 
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.

static SnapAngle get_snap_angle (const ScrArea &area, const ToolSettings &tool_settings)
 
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, float snap_angle)
 
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.cc.

Function Documentation

◆ gesture_box_apply()

◆ gesture_box_apply_rect()

static bool gesture_box_apply_rect ( wmOperator * op)
static

◆ gesture_circle_apply()

◆ gesture_lasso_apply()

◆ gesture_modal_end()

◆ gesture_modal_state_from_operator()

◆ gesture_modal_state_to_operator()

◆ gesture_polyline_apply()

◆ gesture_polyline_can_apply()

static bool gesture_polyline_can_apply ( const wmGesture & wmGesture,
const bool is_click_submitted )
static

Evaluates whether the poly-line has at least three points and represents a shape and can be submitted for other gesture operators to act on.

We handle clicking within the original point radius differently than double clicking or submitting through the confirm key-bindings, as the user expects to not add a new point when interacting with this targeted area.

Definition at line 778 of file wm_gesture_ops.cc.

References gesture_polyline_valid_points(), and wmGesture::points.

Referenced by gesture_polyline_apply(), and WM_gesture_polyline_modal().

◆ gesture_polyline_valid_points()

static int gesture_polyline_valid_points ( const wmGesture & wmGesture,
const bool is_click_submitted )
static

◆ gesture_straightline_apply()

◆ get_snap_angle()

◆ WM_gesture_box_cancel()

◆ WM_gesture_box_invoke()

◆ WM_gesture_box_modal()

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

Definition at line 198 of file wm_gesture_ops.cc.

References BLI_rcti_translate(), CTX_wm_window(), wmGesture::customdata, wmOperator::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, wmEvent::type, wmGesture::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(), 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(), blender::ed::outliner::OUTLINER_OT_select_box(), blender::ed::sculpt_paint::hide::PAINT_OT_hide_show(), blender::ed::sculpt_paint::mask::PAINT_OT_mask_box_gesture(), blender::ed::sculpt_paint::face_set::SCULPT_OT_face_set_box_gesture(), blender::ed::sculpt_paint::trim::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()

◆ WM_gesture_circle_modal()

◆ WM_gesture_lasso_cancel()

◆ WM_gesture_lasso_invoke()

◆ WM_gesture_lasso_modal()

◆ WM_gesture_lasso_path_to_array()

◆ WM_gesture_lines_cancel()

◆ WM_gesture_lines_invoke()

◆ WM_gesture_lines_modal()

◆ WM_gesture_polyline_cancel()

void WM_gesture_polyline_cancel ( bContext * C,
wmOperator * op )

Definition at line 905 of file wm_gesture_ops.cc.

References gesture_modal_end().

◆ WM_gesture_polyline_invoke()

◆ WM_gesture_polyline_modal()

◆ WM_gesture_straightline_active_side_invoke()

◆ WM_gesture_straightline_cancel()

◆ wm_gesture_straightline_do_angle_snap()

static void wm_gesture_straightline_do_angle_snap ( rcti * rect,
float snap_angle )
static

◆ WM_gesture_straightline_invoke()

◆ WM_gesture_straightline_modal()

◆ WM_gesture_straightline_oneshot_modal()

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

This modal one-shot callback only calls exec once after the gesture finishes without any updates during the gesture execution. Should be used for operations that are intended to be applied once without real time preview (like a trimming tool that only applies the bisect operation once after finishing the gesture as the bisect operation is too heavy to be computed in real time for a preview).

Definition at line 1157 of file wm_gesture_ops.cc.

References BLI_rcti_translate(), CTX_data_scene(), CTX_wm_area(), CTX_wm_window(), wmGesture::customdata, wmOperator::customdata, EVT_MODAL_MAP, GESTURE_MODAL_BEGIN, GESTURE_MODAL_CANCEL, GESTURE_MODAL_DESELECT, gesture_modal_end(), GESTURE_MODAL_FLIP, GESTURE_MODAL_IN, GESTURE_MODAL_MOVE, GESTURE_MODAL_OUT, GESTURE_MODAL_SELECT, GESTURE_MODAL_SNAP, gesture_straightline_apply(), get_snap_angle(), SnapAngle::increment, wmGesture::is_active, wmGesture::is_active_prev, wmGesture::modal_state, MOUSEMOVE, wmGesture::move, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, wmEvent::type, wmGesture::use_flip, wmGesture::use_snap, wmEvent::val, wmGesture::wait_for_input, wmGesture::winrct, wm_gesture_straightline_do_angle_snap(), wm_gesture_tag_redraw(), rcti::xmax, rcti::xmin, wmEvent::xy, rcti::ymax, and rcti::ymin.

Referenced by blender::ed::sculpt_paint::hide::PAINT_OT_hide_show_line_gesture(), blender::ed::sculpt_paint::mask::PAINT_OT_mask_line_gesture(), blender::ed::sculpt_paint::face_set::SCULPT_OT_face_set_line_gesture(), blender::ed::sculpt_paint::project::SCULPT_OT_project_line_gesture(), and blender::ed::sculpt_paint::trim::SCULPT_OT_trim_line_gesture().