Blender V4.3
wm_event_query.cc File Reference
#include <cstdlib>
#include <cstring>
#include "DNA_listBase.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "RNA_access.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "wm_event_system.hh"
#include "wm_event_types.hh"
#include "RNA_enum_types.hh"

Go to the source code of this file.

Classes

struct  FlagIdentifierPair
 

Functions

Event Printing
static void event_ids_from_flag (char *str, const int str_maxncpy, const FlagIdentifierPair *flag_data, const int flag_data_len, const uint flag)
 
static void event_ids_from_type_and_value (const short type, const short val, const char **r_type_id, const char **r_val_id)
 
void WM_event_print (const wmEvent *event)
 
Event Modifier/Type Queries
bool WM_event_type_mask_test (const int event_type, const enum eEventType_Mask mask)
 
Event Motion Queries
bool WM_event_is_modal_drag_exit (const wmEvent *event, const short init_event_type, const short init_event_val)
 
bool WM_event_is_mouse_drag (const wmEvent *event)
 
bool WM_event_is_mouse_drag_or_press (const wmEvent *event)
 
int WM_event_drag_direction (const wmEvent *event)
 
bool WM_cursor_test_motion_and_update (const int mval[2])
 
Event Consecutive Checks
bool WM_event_consecutive_gesture_test (const wmEvent *event)
 
bool WM_event_consecutive_gesture_test_break (const wmWindow *win, const wmEvent *event)
 
Event Click/Drag Checks

Values under this limit are detected as clicks.

int WM_event_drag_threshold (const wmEvent *event)
 
bool WM_event_drag_test_with_delta (const wmEvent *event, const int drag_delta[2])
 
bool WM_event_drag_test (const wmEvent *event, const int prev_xy[2])
 
void WM_event_drag_start_mval (const wmEvent *event, const ARegion *region, int r_mval[2])
 
void WM_event_drag_start_mval_fl (const wmEvent *event, const ARegion *region, float r_mval[2])
 
void WM_event_drag_start_xy (const wmEvent *event, int r_xy[2])
 
Event Text Queries
char WM_event_utf8_to_ascii (const wmEvent *event)
 
Event Preference Mapping
int WM_userdef_event_map (int kmitype)
 
int WM_userdef_event_type_from_keymap_type (int kmitype)
 
Event Tablet Input Access
float wm_pressure_curve (float raw_pressure)
 
float WM_event_tablet_data (const wmEvent *event, bool *r_pen_flip, float r_tilt[2])
 
bool WM_event_is_tablet (const wmEvent *event)
 
Event Scroll's Absolute Deltas

User may change the scroll behavior, and the deltas are automatically inverted. These functions return the absolute direction, swipe up/right gives positive values.

int WM_event_absolute_delta_x (const wmEvent *event)
 
int WM_event_absolute_delta_y (const wmEvent *event)
 

Detailed Description

Read-only queries utility functions for the event system.

Definition in file wm_event_query.cc.

Function Documentation

◆ event_ids_from_flag()

static void event_ids_from_flag ( char * str,
const int str_maxncpy,
const FlagIdentifierPair * flag_data,
const int flag_data_len,
const uint flag )
static

Definition at line 43 of file wm_event_query.cc.

References BLI_strncpy_rlen(), flag, str, and UNUSED_VARS.

Referenced by WM_event_print().

◆ event_ids_from_type_and_value()

static void event_ids_from_type_and_value ( const short type,
const short val,
const char ** r_type_id,
const char ** r_val_id )
static

◆ WM_cursor_test_motion_and_update()

bool WM_cursor_test_motion_and_update ( const int mval[2])

Detect motion between selection (callers should only use this for selection picking), typically mouse press/click events.

Parameters
mvalRegion relative coordinates, call with (-1, -1) resets the last cursor location.
Returns
True when there was motion since last called.

NOTE(@ideasman42): The logic used here isn't foolproof. It's possible that users move the cursor past WM_EVENT_CURSOR_MOTION_THRESHOLD then back to a position within the threshold (between mouse clicks). In practice users never reported this since the threshold is very small (a few pixels). To prevent the unlikely case of values matching from another region, changing regions resets this value to (-1, -1).

Definition at line 328 of file wm_event_query.cc.

References copy_v2_v2_int(), len_manhattan_v2v2_int(), and WM_EVENT_CURSOR_MOTION_THRESHOLD.

Referenced by ED_screen_set_active_region(), get_nearest_editbonepoint(), mixed_bones_object_selectbuffer_extended(), seq_select_seq_from_preview(), and unified_findnearest().

◆ WM_event_absolute_delta_x()

int WM_event_absolute_delta_x ( const wmEvent * event)

Definition at line 588 of file wm_event_query.cc.

References wmEvent::flag, and WM_EVENT_SCROLL_INVERT.

Referenced by view_zoomdrag_invoke().

◆ WM_event_absolute_delta_y()

int WM_event_absolute_delta_y ( const wmEvent * event)

Definition at line 599 of file wm_event_query.cc.

References wmEvent::flag, and WM_EVENT_SCROLL_INVERT.

Referenced by ui_pan_to_scroll(), and view_zoomdrag_invoke().

◆ WM_event_consecutive_gesture_test()

bool WM_event_consecutive_gesture_test ( const wmEvent * event)

Return true if this event type is a candidate for being flagged as consecutive.

See: WM_EVENT_IS_CONSECUTIVE doc-string.

Definition at line 342 of file wm_event_query.cc.

References ISMOUSE_GESTURE, NDOF_MOTION, and wmEvent::type.

Referenced by ED_view3d_autodist_last_set(), and wm_event_do_handlers().

◆ WM_event_consecutive_gesture_test_break()

bool WM_event_consecutive_gesture_test_break ( const wmWindow * win,
const wmEvent * event )

Return true if this event should break the chain of consecutive gestures. Practically all intentional user input should, key presses or button clicks.

Definition at line 347 of file wm_event_query.cc.

References wmWindow::event_queue_consecutive_gesture_xy, ISKEYBOARD_OR_BUTTON, ISKEYMODIFIER, ISMOUSE_MOTION, len_manhattan_v2v2_int(), wmEvent::type, WINDEACTIVATE, WM_EVENT_CURSOR_MOTION_THRESHOLD, and wmEvent::xy.

Referenced by wm_event_do_handlers().

◆ WM_event_drag_direction()

◆ WM_event_drag_start_mval()

◆ WM_event_drag_start_mval_fl()

void WM_event_drag_start_mval_fl ( const wmEvent * event,
const ARegion * region,
float r_mval[2] )

◆ WM_event_drag_start_xy()

void WM_event_drag_start_xy ( const wmEvent * event,
int r_xy[2] )

◆ WM_event_drag_test()

bool WM_event_drag_test ( const wmEvent * event,
const int prev_xy[2] )

◆ WM_event_drag_test_with_delta()

bool WM_event_drag_test_with_delta ( const wmEvent * event,
const int drag_delta[2] )

Definition at line 404 of file wm_event_query.cc.

References abs(), and WM_event_drag_threshold().

Referenced by WM_event_drag_test(), and WM_generic_select_modal().

◆ WM_event_drag_threshold()

int WM_event_drag_threshold ( const wmEvent * event)

◆ WM_event_is_modal_drag_exit()

bool WM_event_is_modal_drag_exit ( const wmEvent * event,
short init_event_type,
short init_event_val )

For modal callbacks, check configuration for how to interpret exit when dragging.

Definition at line 223 of file wm_event_query.cc.

References KM_CLICK_DRAG, KM_RELEASE, wmEvent::type, USER_RELEASECONFIRM, and wmEvent::val.

Referenced by ed_marker_move_modal().

◆ WM_event_is_mouse_drag()

bool WM_event_is_mouse_drag ( const wmEvent * event)

◆ WM_event_is_mouse_drag_or_press()

bool WM_event_is_mouse_drag_or_press ( const wmEvent * event)

◆ WM_event_is_tablet()

bool WM_event_is_tablet ( const wmEvent * event)

◆ WM_event_print()

◆ WM_event_tablet_data()

float WM_event_tablet_data ( const wmEvent * event,
bool * r_pen_flip,
float r_tilt[2] )

If this is a tablet event, return tablet pressure and set *pen_flip to 1 if the eraser tool is being used, 0 otherwise.

Definition at line 559 of file wm_event_query.cc.

References EVT_TABLET_ERASER.

Referenced by blender::ed::sculpt_paint::paint_stroke_modal(), and blender::ed::sculpt_paint::filter::sculpt_mesh_filter_modal().

◆ WM_event_type_mask_test()

◆ WM_event_utf8_to_ascii()

char WM_event_utf8_to_ascii ( const wmEvent * event)

Definition at line 442 of file wm_event_query.cc.

References BLI_str_utf8_size_or_error(), and wmEvent::utf8_buf.

Referenced by handleNumInput(), and text_line_number_invoke().

◆ wm_pressure_curve()

float wm_pressure_curve ( float raw_pressure)

Applies the global tablet pressure correction curve.

Definition at line 544 of file wm_event_query.cc.

References CLAMP, and powf.

Referenced by wm_tablet_data_from_ghost().

◆ WM_userdef_event_map()

int WM_userdef_event_map ( int kmitype)

Event map that takes preferences into account.

Definition at line 456 of file wm_event_query.cc.

References USER_WHEELZOOMDIR, WHEELDOWNMOUSE, WHEELINMOUSE, WHEELOUTMOUSE, and WHEELUPMOUSE.

Referenced by wm_eventmatch(), and WM_keymap_item_compare().

◆ WM_userdef_event_type_from_keymap_type()