Cleanup: rename direction enum as it's part of the key-map item

Also improve doc-strings for key-map item constants.
This commit is contained in:
Campbell Barton 2022-03-02 17:54:06 +11:00
parent 7e4c031328
commit 46a5a15d30
5 changed files with 73 additions and 52 deletions

View File

@ -411,7 +411,7 @@ static bool keymap_item_update_tweak_event(wmKeyMapItem *kmi, void *UNUSED(user_
return false;
}
if (kmi->val >= EVT_GESTURE_N && kmi->val <= EVT_GESTURE_NW) {
if (kmi->val >= KM_DIRECTION_N && kmi->val <= KM_DIRECTION_NW) {
kmi->direction = kmi->val;
}
else {

View File

@ -365,14 +365,14 @@ const EnumPropertyItem rna_enum_event_value_items[] = {
const EnumPropertyItem rna_enum_event_direction_items[] = {
{KM_ANY, "ANY", 0, "Any", ""},
{EVT_GESTURE_N, "NORTH", 0, "North", ""},
{EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
{EVT_GESTURE_E, "EAST", 0, "East", ""},
{EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
{EVT_GESTURE_S, "SOUTH", 0, "South", ""},
{EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
{EVT_GESTURE_W, "WEST", 0, "West", ""},
{EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
{KM_DIRECTION_N, "NORTH", 0, "North", ""},
{KM_DIRECTION_NE, "NORTH_EAST", 0, "North-East", ""},
{KM_DIRECTION_E, "EAST", 0, "East", ""},
{KM_DIRECTION_SE, "SOUTH_EAST", 0, "South-East", ""},
{KM_DIRECTION_S, "SOUTH", 0, "South", ""},
{KM_DIRECTION_SW, "SOUTH_WEST", 0, "South-West", ""},
{KM_DIRECTION_W, "WEST", 0, "West", ""},
{KM_DIRECTION_NW, "NORTH_WEST", 0, "North-West", ""},
{0, NULL, 0, NULL, NULL},
};

View File

@ -225,35 +225,68 @@ typedef enum eOperatorPropTags {
} eOperatorPropTags;
#define OP_PROP_TAG_ADVANCED ((eOperatorPropTags)OP_PROP_TAG_ADVANCED)
/* ************** wmKeyMap ************************ */
/* -------------------------------------------------------------------- */
/** \name #wmKeyMapItem
* \{ */
/* modifier */
#define KM_SHIFT 1
#define KM_CTRL 2
#define KM_ALT 4
#define KM_OSKEY 8
/**
* 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 (never stored in DNA). */
#define KM_SHIFT_ANY 16
#define KM_CTRL_ANY 32
#define KM_ALT_ANY 64
#define KM_OSKEY_ANY 128
/* 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 */
/* `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
/**
* #wmKeyMapItem.type
* NOTE: most types are defined in `wm_event_types.h`.
*/
enum {
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.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 ***************** */

View File

@ -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

View File

@ -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 {