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 <julian@blender.org>2020-09-03 18:39:57 +0300
committerJulian Eisel <julian@blender.org>2020-09-03 18:46:23 +0300
commitd2c52d4de2ca20dd2ba0254dd6207a70e9bd0597 (patch)
tree336b9f581487911e5bb2c100002868a5e86c5ed1 /source/blender/editors/interface/interface.c
parentd8a80e5949e454d8e326f54abf0ef9a0bc3aeb83 (diff)
Cleanup: Add/use function to disable buttons with a disabled hint
We do this in a couple of places, so it's worth having the logic wrapped into a function. Also, the only way to set the disabled hint for a button from outside of `interface/` was through `UI_block_lock_set()`/`UI_block_lock_clear()`, for which the usage isn't obvious when you just try to disable a single button.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c8526c16dba..bfa3f3a011c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -4078,12 +4078,6 @@ void ui_def_but_icon_clear(uiBut *but)
but->drawflag &= ~UI_BUT_ICON_LEFT;
}
-static void ui_def_but_rna__disable(uiBut *but, const char *info)
-{
- but->flag |= UI_BUT_DISABLED;
- but->disabled_info = info;
-}
-
static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p)
{
uiBlock *block = uiLayoutGetBlock(layout);
@@ -4502,7 +4496,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
const char *info;
if (but->rnapoin.data && !RNA_property_editable_info(&but->rnapoin, prop, &info)) {
- ui_def_but_rna__disable(but, info);
+ UI_but_disable(but, info);
}
if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == false)) {
@@ -4550,7 +4544,7 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block,
but = ui_def_but(
block, type, retval, propname, x, y, width, height, NULL, min, max, a1, a2, tip);
- ui_def_but_rna__disable(but, "Unknown Property.");
+ UI_but_disable(but, "Unknown Property.");
}
return but;
@@ -4588,8 +4582,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block,
but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_rna_undo(), we never need undo here */
if (!ot) {
- but->flag |= UI_BUT_DISABLED;
- but->disabled_info = "";
+ UI_but_disable(but, "");
}
return but;
@@ -6034,6 +6027,18 @@ void UI_but_drawflag_disable(uiBut *but, int flag)
but->drawflag &= ~flag;
}
+void UI_but_disable(uiBut *but, const char *disabled_hint)
+{
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+
+ /* Only one disabled hint at a time currently. Don't override the previous one here. */
+ if (but->disabled_info && but->disabled_info[0]) {
+ return;
+ }
+
+ but->disabled_info = disabled_hint;
+}
+
void UI_but_type_set_menu_from_pulldown(uiBut *but)
{
BLI_assert(but->type == UI_BTYPE_PULLDOWN);