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:
authorJulian Eisel <eiseljulian@gmail.com>2016-09-16 15:50:47 +0300
committerJulian Eisel <eiseljulian@gmail.com>2016-09-16 16:05:27 +0300
commit1df115d9a35af7e187352f11ee24a0f797db2cb2 (patch)
tree3479f28ae632053da9c20081c80c75c43787cec4 /source/blender/editors/interface/interface_regions.c
parentf3058c1b664135fcad08f9e45ea64b3f55543b94 (diff)
UI: Allow showing why button is disabled in tooltip
Uses red alert color. Operators that failed poll check already did this.
Diffstat (limited to 'source/blender/editors/interface/interface_regions.c')
-rw-r--r--source/blender/editors/interface/interface_regions.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 4ea5e2092b6..d576f919467 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -453,20 +453,30 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
}
MEM_freeN(str);
+ }
+
+ /* button is disabled, we may be able to tell user why */
+ if ((but->flag & UI_BUT_DISABLED) || but->lock) {
+ const char *disabled_msg = NULL;
- /* second check if we are disabled - why */
- if (but->flag & UI_BUT_DISABLED) {
- const char *poll_msg;
+ /* if operator poll check failed, it can give pretty precise info why */
+ if (but->optype) {
CTX_wm_operator_poll_msg_set(C, NULL);
WM_operator_poll_context(C, but->optype, but->opcontext);
- poll_msg = CTX_wm_operator_poll_msg_get(C);
- if (poll_msg) {
- BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg);
- data->format[data->totline].color_id = UI_TIP_LC_ALERT;
- data->totline++;
- }
+ disabled_msg = CTX_wm_operator_poll_msg_get(C);
+ }
+ /* alternatively, buttons can store some reasoning too */
+ else if (but->lockstr && but->lockstr[0]) {
+ disabled_msg = but->lockstr;
+ }
+
+ if (disabled_msg) {
+ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), disabled_msg);
+ data->format[data->totline].color_id = UI_TIP_LC_ALERT;
+ data->totline++;
}
}
+
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0 && !but->optype && rna_struct.strinfo) {
if (rna_prop.strinfo) {
/* Struct and prop */