UI: Editor Edge Highlighting

Customizable highlighting of editor edges that can be used to help
differentiate between areas, indicate active area, and/or help users
with visual impairment. Can be completely removed as well. This
replaces the active area header highlighting, which doesn't work for
transparent headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/116684
This commit is contained in:
Harley Acheson
2024-09-26 21:55:26 +02:00
committed by Harley Acheson
parent 6d9641daee
commit 28e5c1412e
10 changed files with 102 additions and 33 deletions

View File

@@ -221,7 +221,9 @@ const bTheme U_theme_default = {
.widget_emboss = RGBA(0x00000026),
.menu_shadow_fac = 0.4f,
.menu_shadow_width = 2,
.editor_outline = RGBA(0x161616ff),
.editor_border = RGBA(0x161616ff),
.editor_outline = RGBA(0xffffff15),
.editor_outline_active = RGBA(0xffffff2a),
.transparent_checker_primary = RGBA(0x333333ff),
.transparent_checker_secondary = RGBA(0x262626ff),
.transparent_checker_size = 8,

View File

@@ -1166,7 +1166,9 @@ class USERPREF_PT_theme_interface_styles(ThemePanel, CenterAlignMixIn, Panel):
col = flow.column()
col.prop(ui, "widget_text_cursor")
col.prop(ui, "editor_border")
col.prop(ui, "editor_outline")
col.prop(ui, "editor_outline_active")
col.prop(ui, "widget_emboss")
col.prop(ui, "panel_roundness")

View File

@@ -31,7 +31,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 26
#define BLENDER_FILE_SUBVERSION 27
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@@ -198,6 +198,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_node.node_zone_foreach_geometry_element);
}
if (!USER_VERSION_ATLEAST(403, 27)) {
FROM_DEFAULT_V4_UCHAR(tui.editor_border);
FROM_DEFAULT_V4_UCHAR(tui.editor_outline);
FROM_DEFAULT_V4_UCHAR(tui.editor_outline_active);
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a USER_VERSION_ATLEAST check.

View File

@@ -57,7 +57,6 @@ enum ThemeColorID {
TH_TAB_OUTLINE,
TH_HEADER,
TH_HEADER_ACTIVE,
TH_HEADER_TEXT,
TH_HEADER_TEXT_HI,
@@ -319,6 +318,8 @@ enum ThemeColorID {
TH_WIDGET_TEXT_SELECTION,
TH_WIDGET_TEXT_HIGHLIGHT,
TH_EDITOR_OUTLINE,
TH_EDITOR_OUTLINE_ACTIVE,
TH_EDITOR_BORDER,
TH_TRANSPARENT_CHECKER_PRIMARY,
TH_TRANSPARENT_CHECKER_SECONDARY,

View File

@@ -63,7 +63,6 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
ThemeSpace *ts = nullptr;
static uchar error[4] = {240, 0, 240, 255};
static uchar alert[4] = {240, 60, 60, 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;
@@ -246,17 +245,6 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp = ts->header;
break;
case TH_HEADER_ACTIVE: {
cp = ts->header;
const int factor = 5;
/* Lighten the header color when editor is active. */
header_active[0] = cp[0] > 245 ? cp[0] - factor : cp[0] + factor;
header_active[1] = cp[1] > 245 ? cp[1] - factor : cp[1] + factor;
header_active[2] = cp[2] > 245 ? cp[2] - factor : cp[2] + factor;
header_active[3] = cp[3];
cp = header_active;
break;
}
case TH_HEADER_TEXT:
cp = ts->header_text;
break;
@@ -943,9 +931,15 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp = btheme->tui.widget_emboss;
break;
case TH_EDITOR_BORDER:
cp = btheme->tui.editor_border;
break;
case TH_EDITOR_OUTLINE:
cp = btheme->tui.editor_outline;
break;
case TH_EDITOR_OUTLINE_ACTIVE:
cp = btheme->tui.editor_outline_active;
break;
case TH_WIDGET_TEXT_CURSOR:
cp = btheme->tui.widget_text_cursor;
break;

View File

@@ -79,7 +79,7 @@ static void region_draw_emboss(const ARegion *region, const rcti *scirct, int si
GPU_blend(GPU_BLEND_ALPHA);
float color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
UI_GetThemeColor3fv(TH_EDITOR_BORDER, color);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -342,7 +342,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region)
static void region_draw_status_text(ScrArea * /*area*/, ARegion *region)
{
float header_color[4];
UI_GetThemeColor4fv(TH_HEADER_ACTIVE, header_color);
UI_GetThemeColor4fv(TH_HEADER, header_color);
/* Clear the region from the buffer. */
GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
@@ -517,7 +517,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
UI_SetTheme(area ? area->spacetype : 0, at->regionid);
if (area && area_is_pseudo_minimized(area)) {
UI_ThemeClearColor(TH_EDITOR_OUTLINE);
UI_ThemeClearColor(TH_EDITOR_BORDER);
return;
}
/* optional header info instead? */
@@ -572,7 +572,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
/* draw separating lines between the quad views */
float color[4] = {0.0f, 0.0f, 0.0f, 0.8f};
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
UI_GetThemeColor3fv(TH_EDITOR_BORDER, color);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
@@ -2943,19 +2943,12 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
/************************ standard UI regions ************************/
static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
static ThemeColorID region_background_color_id(const bContext * /*C*/, const ARegion *region)
{
ScrArea *area = CTX_wm_area(C);
switch (region->regiontype) {
case RGN_TYPE_HEADER:
case RGN_TYPE_TOOL_HEADER:
if (ED_screen_area_active(C) && !ED_area_is_global(area)) {
return TH_HEADER_ACTIVE;
}
else {
return TH_HEADER;
}
return TH_HEADER;
case RGN_TYPE_PREVIEW:
return TH_PREVIEW_BACK;
default:

View File

@@ -7,12 +7,16 @@
*/
#include "ED_screen.hh"
#include "ED_screen_types.hh"
#include "GPU_batch_presets.hh"
#include "GPU_immediate.hh"
#include "GPU_platform.hh"
#include "GPU_state.hh"
#include "BKE_global.hh"
#include "BKE_screen.hh"
#include "BLF_api.hh"
#include "BLI_listbase.h"
@@ -165,6 +169,38 @@ void ED_screen_draw_edges(wmWindow *win)
return;
}
ARegion *region = screen->active_region;
ScrArea *active_area = nullptr;
if (region) {
/* Find active area from active region. */
const int pos[2] = {region->winrct.xmin, region->winrct.ymin};
active_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, pos);
}
if (!active_area) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
AZone *zone = ED_area_actionzone_find_xy(area, win->eventstate->xy);
/* Get area from action zone, if not scrollbar. */
if (zone && zone->type != AZONE_REGION_SCROLL) {
active_area = area;
break;
}
}
}
if (!active_area && G.moving & G_TRANSFORM_WM) {
active_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, win->eventstate->xy);
/* We don't want an active area if at a border edge. */
if (active_area) {
rcti rect = active_area->totrct;
BLI_rcti_pad(&rect, -BORDERPADDING, -BORDERPADDING);
if (!BLI_rcti_isect_pt_v(&rect, win->eventstate->xy)) {
active_area = nullptr;
}
}
}
const blender::int2 win_size = WM_window_native_pixel_size(win);
float col[4], corner_scale, edge_thickness;
int verts_per_corner = 0;
@@ -193,7 +229,7 @@ void ED_screen_draw_edges(wmWindow *win)
GPU_scissor_test(true);
}
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, col);
UI_GetThemeColor4fv(TH_EDITOR_BORDER, col);
col[3] = 1.0f;
corner_scale = U.pixelsize * 8.0f;
edge_thickness = corner_scale * 0.21f;
@@ -206,8 +242,28 @@ void ED_screen_draw_edges(wmWindow *win)
GPU_batch_uniform_1f(batch, "scale", corner_scale);
GPU_batch_uniform_4fv(batch, "color", col);
float outline1[4];
float outline2[4];
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, outline1);
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE_ACTIVE, outline2);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
const float offset = UI_SCALE_FAC * 1.34f;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
drawscredge_area(area, win_size[0], win_size[1], edge_thickness);
rctf rectf2 = {float(area->totrct.xmin) + offset - 0.5f,
float(area->totrct.xmax) - offset + 1.0f,
float(area->totrct.ymin) + offset - 0.5f,
float(area->totrct.ymax) - offset + 1.0f};
UI_draw_roundbox_4fv_ex(&rectf2,
nullptr,
nullptr,
1.0f,
(area == active_area) ? outline2 : outline1,
U.pixelsize,
6.0f * U.pixelsize);
}
GPU_blend(GPU_BLEND_NONE);
@@ -369,7 +425,7 @@ void screen_draw_dock_preview(
float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f};
float inner[4] = {1.0f, 1.0f, 1.0f, 0.1f};
float border[4];
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, border);
UI_GetThemeColor4fv(TH_EDITOR_BORDER, border);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
float half_line_width = 2.0f * U.pixelsize;
@@ -432,7 +488,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const
float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f};
float inner[4] = {1.0f, 1.0f, 1.0f, 0.10f};
float border[4];
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, border);
UI_GetThemeColor4fv(TH_EDITOR_BORDER, border);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
rctf rect;

View File

@@ -165,7 +165,9 @@ typedef struct ThemeUI {
float menu_shadow_fac;
short menu_shadow_width;
unsigned char editor_border[4];
unsigned char editor_outline[4];
unsigned char editor_outline_active[4];
/* Transparent Grid */
unsigned char transparent_checker_primary[4], transparent_checker_secondary[4];

View File

@@ -1950,11 +1950,24 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
prop, "Widget Emboss", "Color of the 1px shadow line underlying widgets");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "editor_border", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, nullptr, "editor_border");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Editor Border", "Color of the border between editors");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "editor_outline", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, nullptr, "editor_outline");
RNA_def_property_array(prop, 3);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(
prop, "Editor Outline", "Color of the outline of the editors and their round corners");
prop, "Editor Outline", "Color of the outline of each editor, except the active one");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "editor_outline_active", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, nullptr, "editor_outline_active");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(
prop, "Active Editor Outline", "Color of the outline of the active editor");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "widget_text_cursor", PROP_FLOAT, PROP_COLOR_GAMMA);