UI: Adjust header color when active instead of inactive

Currently, the background color of headers gets darkened when the editor is not active,
this makes it hard to theme, and adds contrast/noise when it's not needed.

This patch makes headers use the regular theme color when the editor is not active, so it
can be made to flush with the background more easily. And lightens the header (by +10,
same value as before) when the editor is active, providing the wanted highlight.

The motivations behind this change are:
* Simplify picking a theme color for headers.
* Widgets already become lighter on mouse hover, this change creates a connection with that concept.

Left: current master, inactive header is darkened.
Right: this patch, inactive header gets the theme color, active editor gets header in a slightly lighter color (like most widgets)

{F11052503, size=full, loop, autoplay}

Reviewed By: #user_interface, HooglyBoogly

Differential Revision: https://developer.blender.org/D12856
This commit is contained in:
Pablo Vazquez 2021-10-17 18:43:25 +02:00 committed by Pablo Vazquez
parent 93544b641b
commit 962b17b3ca
3 changed files with 13 additions and 11 deletions

View File

@ -64,7 +64,7 @@ typedef enum ThemeColorID {
TH_TAB_OUTLINE,
TH_HEADER,
TH_HEADERDESEL,
TH_HEADER_ACTIVE,
TH_HEADER_TEXT,
TH_HEADER_TEXT_HI,

View File

@ -85,7 +85,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
ThemeSpace *ts = NULL;
static uchar error[4] = {240, 0, 240, 255};
static uchar alert[4] = {240, 60, 60, 255};
static uchar headerdesel[4] = {0, 0, 0, 255};
static uchar header_active[4] = {0, 0, 0, 255};
static uchar back[4] = {0, 0, 0, 255};
static uchar setting = 0;
const uchar *cp = error;
@ -249,15 +249,17 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_HEADER:
cp = ts->header;
break;
case TH_HEADERDESEL:
/* We calculate a dynamic builtin header deselect color, also for pull-downs. */
case TH_HEADER_ACTIVE:
cp = ts->header;
headerdesel[0] = cp[0] > 10 ? cp[0] - 10 : 0;
headerdesel[1] = cp[1] > 10 ? cp[1] - 10 : 0;
headerdesel[2] = cp[2] > 10 ? cp[2] - 10 : 0;
headerdesel[3] = cp[3];
cp = headerdesel;
/* Lighten the header color when editor is active. */
header_active[0] = cp[0] > 245 ? cp[0] - 10 : cp[0] + 10;
header_active[1] = cp[1] > 245 ? cp[1] - 10 : cp[1] + 10;
header_active[2] = cp[2] > 245 ? cp[2] - 10 : cp[2] + 10;
header_active[3] = cp[3];
cp = header_active;
break;
case TH_HEADER_TEXT:
cp = ts->header_text;
break;

View File

@ -2658,10 +2658,10 @@ static ThemeColorID region_background_color_id(const bContext *C, const ARegion
case RGN_TYPE_HEADER:
case RGN_TYPE_TOOL_HEADER:
if (ED_screen_area_active(C) || ED_area_is_global(area)) {
return TH_HEADER;
return TH_HEADER_ACTIVE;
}
else {
return TH_HEADERDESEL;
return TH_HEADER;
}
case RGN_TYPE_PREVIEW:
return TH_PREVIEW_BACK;