UI: Gray out Scene Auto-Masking option if equivalent Brush option is used #102971 #106126

Open
Henry-Chang wants to merge 11 commits from Henry-Chang/blender:gray-out-automasking into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 56 additions and 0 deletions
Showing only changes of commit 32b5ced13b - Show all commits

View File

@ -896,6 +896,7 @@ void UI_but_dragflag_enable(uiBut *but, int flag);
void UI_but_dragflag_disable(uiBut *but, int flag);
void UI_but_disable(uiBut *but, const char *disabled_hint);
void UI_but_inactive(uiBut *but, const char *disabled_hint);
void UI_but_type_set_menu_from_pulldown(uiBut *but);

View File

@ -4715,6 +4715,10 @@ static uiBut *ui_def_but_rna(uiBlock *block,
UI_but_disable(but, info);
}
if (but->rnapoin.data && RNA_property_is_inactive_info(&but->rnapoin, prop, &info)) {
UI_but_inactive(but, info);
}
if (proptype == PROP_POINTER) {
/* If the button shows an ID, automatically set it as focused in context so operators can
* access it. */
@ -5904,6 +5908,16 @@ void UI_but_dragflag_disable(uiBut *but, int flag)
but->dragflag &= ~flag;
}
void UI_but_inactive(uiBut *but, const char *inactive_hint)
{
/* Only one inactive hint at a time currently. Don't override the previous one here. */
if (but->disabled_info && but->disabled_info[0]) {
return;
}
but->disabled_info = inactive_hint;
}
void UI_but_disable(uiBut *but, const char *disabled_hint)
{
UI_but_flag_enable(but, UI_BUT_DISABLED);

View File

@ -274,6 +274,7 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop);
* that can be exposed in UI.
*/
bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info);
bool RNA_property_is_inactive_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info);
/**
* Same as RNA_property_editable(), except this checks individual items in an array.
*/

View File

@ -187,6 +187,15 @@ typedef enum PropertyFlag {
* for pointers and collections.
*/
PROP_EDITABLE = (1 << 0),
/**
* Inactive specifically only refers to the front end
* where UI elements are grayed out but can still be
* toggled. It is specifically used to add Disabled
* message for when UI is set to inactive through Python
* script. It is completely unrelated to anything that
* is performed in the backend.
*/
PROP_INACTIVE = (1 << 9),
/**
* This property is editable even if it is lib linked,
* meaning it will get lost on reload, but it's useful

View File

@ -1935,6 +1935,32 @@ int RNA_property_ui_icon(const PropertyRNA *prop)
return rna_ensure_property((PropertyRNA *)prop)->icon;
}
static bool rna_property_is_inactive_do(PointerRNA *ptr,
PropertyRNA *prop_orig,
const int index,
const char **r_info)
{
PropertyRNA *prop = rna_ensure_property(prop_orig);
const char *info = "";
const int flag = (prop->itemeditable != nullptr && index >= 0) ?
prop->itemeditable(ptr, index) :
(prop->editable != nullptr ? prop->editable(ptr, &info) : prop->flag);
if (r_info != nullptr) {
*r_info = info;
}
/* Return true if the property itself is inative. */
if ((flag & PROP_INACTIVE) != 0) {
if (r_info != nullptr && (*r_info)[0] == '\0') {
*r_info = N_("This property is for internal use only and can't be edited");
}
return true;
}
return false;
}
static bool rna_property_editable_do(PointerRNA *ptr,
PropertyRNA *prop_orig,
const int index,
@ -2001,6 +2027,11 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
return rna_property_editable_do(ptr, prop, -1, nullptr);
}
bool RNA_property_is_inactive_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info)
{
return rna_property_is_inactive_do(ptr, prop, -1, r_info);
}
bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info)
{
return rna_property_editable_do(ptr, prop, -1, r_info);