[Bf-blender-cvs] [2682a59efe5] blender-v3.3-release: WM Modal Keymaps: Add accessors to modal event values.
Bastien Montagne
noreply at git.blender.org
Tue Aug 9 12:35:50 CEST 2022
Commit: 2682a59efe53a719266da4175633789ef195c8d4
Author: Bastien Montagne
Date: Tue Aug 9 12:22:13 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB2682a59efe53a719266da4175633789ef195c8d4
WM Modal Keymaps: Add accessors to modal event values.
It is currently impossible to access modal keymaps' event values (from
`propvalue` enum) from python code (for API introspection).
This is needed for i18n messages extraction (see D15607).
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D15643
===================================================================
M source/blender/makesrna/intern/rna_wm.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 2009f51e1f2..ac1803b0a11 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -864,6 +864,21 @@ static void rna_Window_view_layer_set(PointerRNA *ptr,
WM_window_set_active_view_layer(win, view_layer);
}
+static void rna_KeyMap_modal_event_values_items_begin(CollectionPropertyIterator *iter,
+ PointerRNA *ptr)
+{
+ wmKeyMap *km = ptr->data;
+
+ const EnumPropertyItem *items = rna_enum_keymap_propvalue_items;
+ if ((km->flag & KEYMAP_MODAL) != 0 && km->modal_items != NULL) {
+ items = km->modal_items;
+ }
+
+ const int totitem = RNA_enum_items_count(items);
+
+ rna_iterator_array_begin(iter, (void *)items, sizeof(EnumPropertyItem), totitem, false, NULL);
+}
+
static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
@@ -2617,6 +2632,23 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
+ prop = RNA_def_property(srna, "modal_event_values", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "EnumPropertyItem");
+ RNA_def_property_collection_funcs(prop,
+ "rna_KeyMap_modal_event_values_items_begin",
+ "rna_iterator_array_next",
+ "rna_iterator_array_end",
+ "rna_iterator_array_get",
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ RNA_def_property_ui_text(prop,
+ "Modal Events",
+ "Give access to the possible event values of this modal keymap's items "
+ "(#KeyMapItem.propvalue), for API introspection");
+
RNA_api_keymap(srna);
/* KeyMapItem */
More information about the Bf-blender-cvs
mailing list