diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-09-02 05:54:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-02 06:01:04 +0300 |
commit | 89ed6b12936bc2a89b18cf6dbd7b86e0fbc760d3 (patch) | |
tree | 40721eeba62010ee81d86df55fed5fb236d58364 /source/blender/editors/interface/interface_layout.c | |
parent | ddea2f234f0a5f00ffcc35bb6ee1a1ace6c26d8e (diff) |
UI: simplify tool-tip logic for operators
- Use WM_operatortype_description to get the operator description.
- Pass properties to WM_operatortype_name,
so the operator name callback is used.
- Add UI_but_operatortype_get_from_enum_menu function
to access the operator from enum menus.
- Change WM_operatortype_description to return NULL when there is no
description, use WM_operatortype_description_or_name
when either can be used.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f7955c15dc4..50355d350ac 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -3404,14 +3404,7 @@ void uiItemMenuEnumO_ptr(uiLayout *layout, BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); lvl->opcontext = layout->root->opcontext; - but = ui_item_menu(layout, - name, - icon, - menu_item_enum_opname_menu, - NULL, - lvl, - RNA_struct_ui_description(ot->srna), - true); + but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, NULL, true); /* add hotkey here, lower UI code can't detect it */ if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) { @@ -5501,6 +5494,24 @@ void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but) } /* this is a bit of a hack but best keep it in one place at least */ +wmOperatorType *UI_but_operatortype_get_from_enum_menu(uiBut *but, PropertyRNA **r_prop) +{ + if (r_prop != NULL) { + *r_prop = NULL; + } + + if (but->menu_create_func == menu_item_enum_opname_menu) { + MenuItemLevel *lvl = but->func_argN; + wmOperatorType *ot = WM_operatortype_find(lvl->opname, false); + if ((ot != NULL) && (r_prop != NULL)) { + *r_prop = RNA_struct_type_find_property(ot->srna, lvl->propname); + } + return ot; + } + return NULL; +} + +/* this is a bit of a hack but best keep it in one place at least */ MenuType *UI_but_menutype_get(uiBut *but) { if (but->menu_create_func == ui_item_menutype_func) { |