diff options
author | Bastien Montagne <bastien@blender.org> | 2022-08-09 13:22:13 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-09 14:07:32 +0300 |
commit | efc1d4bb9aa3c2b55867d624670a125b9163cad8 (patch) | |
tree | fa824081b016fe72887d3f5fd2f925249d66c1b1 /source | |
parent | a2bdd6a71aafe565c0a7f5df5aa396d02f37aa62 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 */ |