Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-02 09:54:06 +0300
committerCampbell Barton <campbell@blender.org>2022-03-02 10:00:59 +0300
commit46a5a15d30f951b150b66856442566d5b657ab1e (patch)
treef55b4001595bed72bfa004d6727d762c12c01ac6 /source/blender
parent7e4c0313283304bd8f020eaedb94b35e75b50068 (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')
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c2
-rw-r--r--source/blender/makesrna/intern/rna_wm.c16
-rw-r--r--source/blender/windowmanager/WM_types.h87
-rw-r--r--source/blender/windowmanager/intern/wm_event_query.c16
-rw-r--r--source/blender/windowmanager/wm_event_types.h12
5 files changed, 77 insertions, 56 deletions
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 862e8a09166..e933964221b 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index d88f150c1dd..8835591f303 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -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},
};
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 {