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/windowmanager/intern | |
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/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_type.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 457cd0f16be..7cc20baf606 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -611,15 +611,27 @@ char *WM_operatortype_description(struct bContext *C, } const char *info = RNA_struct_ui_description(ot->srna); - - if (!(info && info[0])) { - info = RNA_struct_ui_name(ot->srna); - } - if (info && info[0]) { return BLI_strdup(info); } return NULL; } +/** + * Use when we want a label, preferring the description. + */ +char *WM_operatortype_description_or_name(struct bContext *C, + struct wmOperatorType *ot, + struct PointerRNA *properties) +{ + char *text = WM_operatortype_description(C, ot, properties); + if (text == NULL) { + const char *text_orig = WM_operatortype_name(ot, properties); + if (text_orig != NULL) { + text = BLI_strdup(text_orig); + } + } + return text; +} + /** \} */ |