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 <ideasman42@gmail.com>2019-10-27 18:51:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-10-27 18:57:56 +0300
commitae55523013642f2897e840f30ad62c74d31df3e0 (patch)
treec8f3af1b967ef05b1aee8a6c90a828c1dbc499b1 /source/blender/makesrna/intern/rna_ui_api.c
parentc036db9f57ff1bf5762e2b4dda802ee41cdbd115 (diff)
UI: add utility to show icons for the keymap item
This is useful for drawing keymap items into the header or status bar While these icons are available directly, mapping them from the keymap item isn't trivial.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 74d1743dfc1..94fe43a0a77 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -479,6 +479,14 @@ static void rna_uiTemplatePathBuilder(uiLayout *layout,
uiTemplatePathBuilder(layout, ptr, propname, root_ptr, name);
}
+static void rna_uiTemplateEventFromKeymapItem(
+ uiLayout *layout, wmKeyMapItem *kmi, const char *name, const char *text_ctxt, bool translate)
+{
+ /* Get translated name (label). */
+ name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
+ uiTemplateEventFromKeymapItem(layout, name, kmi, true);
+}
+
static int rna_ui_get_rnaptr_icon(bContext *C, PointerRNA *ptr_icon)
{
return UI_rnaptr_icon_get(C, ptr_icon, RNA_struct_ui_icon(ptr_icon->type), false);
@@ -1526,6 +1534,15 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "params", "FileSelectParams", "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+
+ func = RNA_def_function(
+ srna, "template_event_from_keymap_item", "rna_uiTemplateEventFromKeymapItem");
+ RNA_def_function_ui_description(func, "Display keymap item as icons/text");
+ parm = RNA_def_property(func, "item", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(parm, "KeyMapItem");
+ RNA_def_property_ui_text(parm, "Item", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ api_ui_item_common_text(func);
}
#endif