Blender  V3.3
Classes
wm_event_query.c File Reference
#include <stdlib.h>
#include <string.h>
#include "DNA_listBase.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm_event_system.h"
#include "wm_event_types.h"
#include "RNA_enum_types.h"
#include "DEG_depsgraph.h"

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_maxlen, const struct 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 Click/Drag Checks

Values under this limit are detected as clicks.

int WM_event_drag_threshold (const struct 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 struct 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 pressure)
 
float WM_event_tablet_data (const wmEvent *event, int *pen_flip, float tilt[2])
 
bool WM_event_is_tablet (const struct 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 struct wmEvent *event)
 
int WM_event_absolute_delta_y (const struct wmEvent *event)
 

Detailed Description

Read-only queries utility functions for the event system.

Definition in file wm_event_query.c.

Function Documentation

◆ event_ids_from_flag()

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

Definition at line 46 of file wm_event_query.c.

References BLI_strncpy_rlen(), and str.

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(@campbellbarton): 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 329 of file wm_event_query.c.

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 struct wmEvent event)

Definition at line 552 of file wm_event_query.c.

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 struct wmEvent event)

Definition at line 563 of file wm_event_query.c.

References wmEvent::flag, and WM_EVENT_SCROLL_INVERT.

Referenced by ui_pan_to_scroll(), and view_zoomdrag_invoke().

◆ WM_event_drag_direction()

int WM_event_drag_direction ( const wmEvent event)

◆ WM_event_drag_start_mval()

void WM_event_drag_start_mval ( const wmEvent event,
const ARegion region,
int  r_mval[2] 
)

◆ 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] 
)

◆ WM_event_drag_threshold()

int WM_event_drag_threshold ( const struct wmEvent event)

◆ WM_event_is_modal_drag_exit()

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

Definition at line 224 of file wm_event_query.c.

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 struct wmEvent event)

◆ WM_event_print()

void WM_event_print ( const wmEvent event)

◆ WM_event_tablet_data()

float WM_event_tablet_data ( const wmEvent event,
int *  pen_flip,
float  tilt[2] 
)

Definition at line 523 of file wm_event_query.c.

References EVT_TABLET_ERASER.

Referenced by paint_stroke_modal().

◆ WM_event_type_mask_test()

bool WM_event_type_mask_test ( const int  event_type,
const enum eEventType_Mask  mask 
)

◆ WM_event_utf8_to_ascii()

char WM_event_utf8_to_ascii ( const struct wmEvent event)

◆ wm_pressure_curve()

float wm_pressure_curve ( float  raw_pressure)

Applies the global tablet pressure correction curve.

Definition at line 508 of file wm_event_query.c.

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 420 of file wm_event_query.c.

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

Referenced by wm_eventmatch(), and WM_keymap_item_compare().

◆ WM_userdef_event_type_from_keymap_type()

int WM_userdef_event_type_from_keymap_type ( int  kmitype)