diff options
author | Julian Eisel <julian@blender.org> | 2021-10-08 17:17:29 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-10-08 17:31:16 +0300 |
commit | ff57ce86170d2e440d2e0566bf3c4a74bb745b32 (patch) | |
tree | 9f134c05c3d3fc77a9fe3b6a089c6b84b33f264e /source/blender/editors/interface/interface_region_tooltip.c | |
parent | 38c4888f0999ee5361dc76d2b9a7cd45e8ae2896 (diff) |
UI: Support showing superimposed icons as disabled (with disabled hint)
If the operator poll of a superimposed icon returned `false`, the
superimposed icon would just draw normally and fail silently. Instead it
will now be drawn grayed out, plus the tooltip of the icon can show the
usual "disabled hint" (a hint explaining why the button is disabled).
Diffstat (limited to 'source/blender/editors/interface/interface_region_tooltip.c')
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 6071e14d153..9aa65bd5b55 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -954,18 +954,19 @@ static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C, } /* button is disabled, we may be able to tell user why */ - if (but->flag & UI_BUT_DISABLED) { + if ((but->flag & UI_BUT_DISABLED) || extra_icon) { const char *disabled_msg = NULL; bool disabled_msg_free = false; /* if operator poll check failed, it can give pretty precise info why */ - if (but->optype) { + if (optype) { CTX_wm_operator_poll_msg_clear(C); - WM_operator_poll_context(C, but->optype, but->opcontext); + WM_operator_poll_context( + C, optype, extra_icon ? extra_icon->optype_params->opcontext : but->opcontext); disabled_msg = CTX_wm_operator_poll_msg_get(C, &disabled_msg_free); } /* alternatively, buttons can store some reasoning too */ - else if (but->disabled_info) { + else if (!extra_icon && but->disabled_info) { disabled_msg = TIP_(but->disabled_info); } |