[Bf-blender-cvs] [7af8271c34a] master: Fix WM_event_print error printing tweak events value
Campbell Barton
noreply at git.blender.org
Wed Jan 13 10:03:05 CET 2021
Commit: 7af8271c34ac07a0ea50aafbde7cc72262a8c451
Author: Campbell Barton
Date: Wed Jan 13 19:48:54 2021 +1100
Branches: master
https://developer.blender.org/rB7af8271c34ac07a0ea50aafbde7cc72262a8c451
Fix WM_event_print error printing tweak events value
===================================================================
M source/blender/makesrna/RNA_enum_types.h
M source/blender/makesrna/intern/rna_wm.c
M source/blender/windowmanager/intern/wm_event_query.c
===================================================================
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 0272451357f..00326afa4a3 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -119,6 +119,9 @@ extern const EnumPropertyItem rna_enum_nla_mode_blend_items[];
extern const EnumPropertyItem rna_enum_motionpath_bake_location_items[];
extern const EnumPropertyItem rna_enum_event_value_items[];
+extern const EnumPropertyItem rna_enum_event_value_keymouse_items[];
+extern const EnumPropertyItem rna_enum_event_value_tweak_items[];
+
extern const EnumPropertyItem rna_enum_event_type_items[];
extern const EnumPropertyItem rna_enum_event_type_mask_items[];
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index e9b31b1d8b9..f4b9c8fd8c2 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -42,31 +42,6 @@
#ifdef RNA_RUNTIME
-static const EnumPropertyItem event_keymouse_value_items[] = {
- {KM_ANY, "ANY", 0, "Any", ""},
- {KM_PRESS, "PRESS", 0, "Press", ""},
- {KM_RELEASE, "RELEASE", 0, "Release", ""},
- {KM_CLICK, "CLICK", 0, "Click", ""},
- {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
- {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
- /* Used for NDOF and trackpad events. */
- {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
- {0, NULL, 0, NULL, NULL},
-};
-
-static const EnumPropertyItem event_tweak_value_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", ""},
- {0, NULL, 0, NULL, NULL},
-};
-
static const EnumPropertyItem event_tweak_type_items[] = {
{EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
{EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
@@ -390,6 +365,14 @@ const EnumPropertyItem rna_enum_event_type_items[] = {
{0, NULL, 0, NULL, NULL},
};
+/**
+ * \note This contains overlapping items from:
+ * - #rna_enum_event_value_keymouse_items
+ * - #rna_enum_event_value_tweak_items
+ *
+ * This is needed for `km.keymap_items.new` value argument,
+ * to accept values from different types.
+ */
const EnumPropertyItem rna_enum_event_value_items[] = {
{KM_ANY, "ANY", 0, "Any", ""},
{KM_PRESS, "PRESS", 0, "Press", ""},
@@ -409,6 +392,31 @@ const EnumPropertyItem rna_enum_event_value_items[] = {
{0, NULL, 0, NULL, NULL},
};
+const EnumPropertyItem rna_enum_event_value_keymouse_items[] = {
+ {KM_ANY, "ANY", 0, "Any", ""},
+ {KM_PRESS, "PRESS", 0, "Press", ""},
+ {KM_RELEASE, "RELEASE", 0, "Release", ""},
+ {KM_CLICK, "CLICK", 0, "Click", ""},
+ {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
+ {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
+ /* Used for NDOF and trackpad events. */
+ {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+
+const EnumPropertyItem rna_enum_event_value_tweak_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", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+
const EnumPropertyItem rna_enum_keymap_propvalue_items[] = {
{0, "NONE", 0, "", ""},
{0, NULL, 0, NULL, NULL},
@@ -613,7 +621,7 @@ static const EnumPropertyItem *rna_Event_value_itemf(bContext *UNUSED(C),
{
const wmEvent *event = ptr->data;
if (ISTWEAK(event->type)) {
- return event_tweak_value_items;
+ return rna_enum_event_value_tweak_items;
}
return rna_enum_event_value_items;
}
@@ -976,10 +984,10 @@ static const EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C),
int map_type = rna_wmKeyMapItem_map_type_get(ptr);
if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF) {
- return event_keymouse_value_items;
+ return rna_enum_event_value_keymouse_items;
}
if (map_type == KMI_TYPE_TWEAK) {
- return event_tweak_value_items;
+ return rna_enum_event_value_tweak_items;
}
else {
return rna_enum_event_value_items;
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index a996796104b..9d23617d5b4 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -54,6 +54,23 @@
/** \name Event Printing
* \{ */
+static void event_ids_from_type_and_value(const short type,
+ const short val,
+ const char **r_type_id,
+ const char **r_val_id)
+{
+ /* Type. */
+ RNA_enum_identifier(rna_enum_event_type_items, type, r_type_id);
+
+ /* Value. */
+ if (ISTWEAK(type)) {
+ RNA_enum_identifier(rna_enum_event_value_tweak_items, val, r_val_id);
+ }
+ else {
+ RNA_enum_identifier(rna_enum_event_value_items, val, r_val_id);
+ }
+}
+
/* for debugging only, getting inspecting events manually is tedious */
void WM_event_print(const wmEvent *event)
{
@@ -64,11 +81,8 @@ void WM_event_print(const wmEvent *event)
const char *prev_type_id = unknown;
const char *prev_val_id = unknown;
- RNA_enum_identifier(rna_enum_event_type_items, event->type, &type_id);
- RNA_enum_identifier(rna_enum_event_value_items, event->val, &val_id);
-
- RNA_enum_identifier(rna_enum_event_type_items, event->prevtype, &prev_type_id);
- RNA_enum_identifier(rna_enum_event_value_items, event->prevval, &prev_val_id);
+ event_ids_from_type_and_value(event->type, event->val, &type_id, &val_id);
+ event_ids_from_type_and_value(event->prevtype, event->prevval, &prev_type_id, &prev_val_id);
printf(
"wmEvent type:%d / %s, val:%d / %s,\n"
More information about the Bf-blender-cvs
mailing list