diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-02 09:54:06 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-02 10:00:59 +0300 |
commit | 46a5a15d30f951b150b66856442566d5b657ab1e (patch) | |
tree | f55b4001595bed72bfa004d6727d762c12c01ac6 /source/blender/windowmanager | |
parent | 7e4c0313283304bd8f020eaedb94b35e75b50068 (diff) |
Cleanup: rename direction enum as it's part of the key-map item
Also improve doc-strings for key-map item constants.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 87 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_query.c | 16 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 12 |
3 files changed, 68 insertions, 47 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index b2e214782f0..c4858a8a1fa 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -225,35 +225,68 @@ typedef enum eOperatorPropTags { } eOperatorPropTags; #define OP_PROP_TAG_ADVANCED ((eOperatorPropTags)OP_PROP_TAG_ADVANCED) -/* ************** wmKeyMap ************************ */ - -/* modifier */ -#define KM_SHIFT 1 -#define KM_CTRL 2 -#define KM_ALT 4 -#define KM_OSKEY 8 - -/* Used for key-map item creation function arguments (never stored in DNA). */ -#define KM_SHIFT_ANY 16 -#define KM_CTRL_ANY 32 -#define KM_ALT_ANY 64 -#define KM_OSKEY_ANY 128 - -/* KM_MOD_ flags for `wmKeyMapItem` and `wmEvent.alt/shift/oskey/ctrl`. */ -/* note that KM_ANY and KM_NOTHING are used with these defines too */ +/* -------------------------------------------------------------------- */ +/** \name #wmKeyMapItem + * \{ */ + +/** + * Modifier keys, not actually used for #wmKeyMapItem (never stored in DNA), used for: + * - #wmEvent.modifier without the `KM_*_ANY` flags. + * - #WM_keymap_add_item & #WM_modalkeymap_add_item + */ +enum { + KM_SHIFT = (1 << 0), + KM_CTRL = (1 << 1), + KM_ALT = (1 << 2), + KM_OSKEY = (1 << 3), + + /* Used for key-map item creation function arguments. */ + KM_SHIFT_ANY = (1 << 4), + KM_CTRL_ANY = (1 << 5), + KM_ALT_ANY = (1 << 6), + KM_OSKEY_ANY = (1 << 7), +}; + +/* `KM_MOD_*` flags for #wmKeyMapItem and `wmEvent.alt/shift/oskey/ctrl`. */ +/* Note that #KM_ANY and #KM_NOTHING are used with these defines too. */ #define KM_MOD_HELD 1 -/* type: defined in wm_event_types.c */ -#define KM_TEXTINPUT -2 - -/* val */ -#define KM_ANY -1 -#define KM_NOTHING 0 -#define KM_PRESS 1 -#define KM_RELEASE 2 -#define KM_CLICK 3 -#define KM_DBL_CLICK 4 -#define KM_CLICK_DRAG 5 +/** + * #wmKeyMapItem.type + * NOTE: most types are defined in `wm_event_types.h`. + */ +enum { + KM_TEXTINPUT = -2, +}; + +/** #wmKeyMapItem.val */ +enum { + KM_ANY = -1, + KM_NOTHING = 0, + KM_PRESS = 1, + KM_RELEASE = 2, + KM_CLICK = 3, + KM_DBL_CLICK = 4, + KM_CLICK_DRAG = 5, +}; + +/** + * #wmKeyMapItem.direction + * + * Value of tweaks and line gestures. #KM_ANY (-1) works for this case too. + */ +enum { + KM_DIRECTION_N = 1, + KM_DIRECTION_NE = 2, + KM_DIRECTION_E = 3, + KM_DIRECTION_SE = 4, + KM_DIRECTION_S = 5, + KM_DIRECTION_SW = 6, + KM_DIRECTION_W = 7, + KM_DIRECTION_NW = 8, +}; + +/** \} */ /* ************** UI Handler ***************** */ diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c index e56d3fb3886..ee13e1832ed 100644 --- a/source/blender/windowmanager/intern/wm_event_query.c +++ b/source/blender/windowmanager/intern/wm_event_query.c @@ -232,28 +232,28 @@ int WM_event_drag_direction(const wmEvent *event) }; int theta = round_fl_to_int(4.0f * atan2f((float)delta[1], (float)delta[0]) / (float)M_PI); - int val = EVT_GESTURE_W; + int val = KM_DIRECTION_W; if (theta == 0) { - val = EVT_GESTURE_E; + val = KM_DIRECTION_E; } else if (theta == 1) { - val = EVT_GESTURE_NE; + val = KM_DIRECTION_NE; } else if (theta == 2) { - val = EVT_GESTURE_N; + val = KM_DIRECTION_N; } else if (theta == 3) { - val = EVT_GESTURE_NW; + val = KM_DIRECTION_NW; } else if (theta == -1) { - val = EVT_GESTURE_SE; + val = KM_DIRECTION_SE; } else if (theta == -2) { - val = EVT_GESTURE_S; + val = KM_DIRECTION_S; } else if (theta == -3) { - val = EVT_GESTURE_SW; + val = KM_DIRECTION_SW; } #if 0 diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 1e907578e52..d5c8c5022cc 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -429,18 +429,6 @@ bool WM_event_type_mask_test(int event_type, enum eEventType_Mask mask); * \{ */ /* Gestures */ -/* NOTE: these values are saved in keymap files, do not change them but just add new ones */ -enum { - /* Value of tweaks and line gestures. #KM_ANY (-1) works for this case too. */ - EVT_GESTURE_N = 1, - EVT_GESTURE_NE = 2, - EVT_GESTURE_E = 3, - EVT_GESTURE_SE = 4, - EVT_GESTURE_S = 5, - EVT_GESTURE_SW = 6, - EVT_GESTURE_W = 7, - EVT_GESTURE_NW = 8, -}; /* File select */ enum { |