[Bf-blender-cvs] [962b17b3ca1] master: UI: Adjust header color when active instead of inactive

Pablo Vazquez noreply at git.blender.org
Sun Oct 17 18:50:06 CEST 2021


Commit: 962b17b3ca140aca3ccce94e0e39c6631f830f8d
Author: Pablo Vazquez
Date:   Sun Oct 17 18:43:25 2021 +0200
Branches: master
https://developer.blender.org/rB962b17b3ca140aca3ccce94e0e39c6631f830f8d

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

===================================================================

M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/screen/area.c

===================================================================

diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index dde8a637e05..61da496d344 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -64,7 +64,7 @@ typedef enum ThemeColorID {
   TH_TAB_OUTLINE,
 
   TH_HEADER,
-  TH_HEADERDESEL,
+  TH_HEADER_ACTIVE,
   TH_HEADER_TEXT,
   TH_HEADER_TEXT_HI,
 
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index e13b69a9763..ad7c6332ee9 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -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;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 406f5c0904f..6b0b4d911cc 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -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;



More information about the Bf-blender-cvs mailing list