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.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.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9cede126890..c8526c16dba 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6758,9 +6758,6 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) else if (but->tip && but->tip[0]) { tmp = BLI_strdup(but->tip); } - else if (but->optype && but->optype->get_description) { - tmp = WM_operatortype_description(C, but->optype, but->opptr); - } else { type = BUT_GET_RNA_TIP; /* Fail-safe solution... */ } @@ -6805,13 +6802,10 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else if (but->optype) { if (type == BUT_GET_RNA_LABEL) { - tmp = BLI_strdup(WM_operatortype_name(but->optype, NULL)); + tmp = BLI_strdup(WM_operatortype_name(but->optype, but->opptr)); } else { - const char *t = RNA_struct_ui_description(but->optype->srna); - if (t && t[0]) { - tmp = BLI_strdup(t); - } + tmp = WM_operatortype_description(C, but->optype, but->opptr); } } else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER)) { @@ -6834,6 +6828,18 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } if (tmp == NULL) { + wmOperatorType *ot = UI_but_operatortype_get_from_enum_menu(but, NULL); + if (ot) { + if (type == BUT_GET_RNA_LABEL) { + tmp = BLI_strdup(WM_operatortype_name(ot, NULL)); + } + else { + tmp = WM_operatortype_description(C, ot, NULL); + } + } + } + + if (tmp == NULL) { PanelType *pt = UI_but_paneltype_get(but); if (pt) { if (type == BUT_GET_RNA_LABEL) { |