UI: experimental support for "alert" property in menus/popups #109828

Open
Philipp Oeser wants to merge 1 commits from lichtwerk/blender:109778 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 31 additions and 4 deletions

View File

@ -50,6 +50,7 @@ class OUTLINER_HT_header(Header):
row = layout.row(align=True)
if display_mode in {'SCENES', 'VIEW_LAYER', 'LIBRARY_OVERRIDES'}:
row.alert = True
row.popover(
panel="OUTLINER_PT_filter",
text="",

View File

@ -195,6 +195,7 @@ class VIEW3D_HT_tool_header(Header):
elif mode_string == 'PARTICLE':
layout.popover_group(context=".particlemode", **popover_kw)
elif mode_string == 'OBJECT':
layout.alert = True
layout.popover_group(context=".objectmode", **popover_kw)
elif mode_string in {'PAINT_GPENCIL', 'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
# Grease pencil layer.
@ -944,8 +945,9 @@ class VIEW3D_MT_editor_menus(Menu):
gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL',
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
tool_settings = context.scene.tool_settings
layout.menu("VIEW3D_MT_view")
sub = layout.row()
sub.alert = True
sub.menu("VIEW3D_MT_view")
# Select Menu
if gp_edit:
@ -1271,7 +1273,9 @@ class VIEW3D_MT_view(Menu):
layout.separator()
layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
sub = layout.row()
sub.alert = True
sub.menu("VIEW3D_MT_view_cameras", text="Cameras")
layout.separator()
layout.menu("VIEW3D_MT_view_viewpoint")

View File

@ -3057,6 +3057,10 @@ static uiBut *ui_item_menu(uiLayout *layout,
UI_but_type_set_menu_from_pulldown(but);
}
if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
return but;
}

View File

@ -2697,6 +2697,14 @@ static void widget_state_menu_item(uiWidgetType *wt,
if (state->but_flag & UI_ACTIVE) {
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
}
if (state->but_flag & UI_BUT_REDALERT) {
const uchar red[4] = {255, 0, 0};
if ((state->but_flag & UI_ACTIVE) == 0) {
color_blend_v3_v3(wt->wcol.text, red, 0.6f);
}
color_blend_v3_v3(wt->wcol.inner, red, 0.6f);
}
}
}
@ -3990,7 +3998,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol,
float back[4];
UI_GetThemeColor4fv(TH_BACK, back);
if ((state->but_flag & UI_ACTIVE) || (back[3] < 1.0f)) {
if ((state->but_flag & (UI_ACTIVE | UI_BUT_REDALERT)) || (back[3] < 1.0f)) {
uiWidgetBase wtb;
const float rad = widget_radius_from_zoom(zoom, wcol);
@ -4004,6 +4012,15 @@ static void widget_pulldownbut(uiWidgetColors *wcol,
wcol->outline[3] = 0.0f;
}
if (state->but_flag & UI_BUT_REDALERT) {
const uchar red[4] = {255, 0, 0};
if ((state->but_flag & UI_ACTIVE) == 0) {
color_blend_v3_v3(wcol->text, red, 0.6f);
}
color_blend_v3_v3(wcol->inner, red, 0.6f);
color_blend_v3_v3(wcol->outline, red, 0.6f);
}
widget_init(&wtb);
/* half rounded */

View File

@ -1343,6 +1343,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set");
RNA_def_property_ui_text(prop, "Alert", "When true, widgets will draw in red (background and/or text)");
prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, alignment_items);