UI: Fade In Active Editor Border Highlight

Our themes have two colors that we use as outlines for the editors, so
that we can differentiate the active area. This PR just fades in the
"Active Editor Outline" color rather than show it instantly. It makes
the change a little less jarring. As this transitions in the old active
area similarly transitions out. Note that this is very fast, only 150
milliseconds, so barely noticeable. Just a "softening" of the effect.

Pull Request: https://projects.blender.org/blender/blender/pulls/140836
This commit is contained in:
Harley Acheson
2025-06-26 20:19:01 +02:00
committed by Harley Acheson
parent 72de50483e
commit 0ea03b5137
2 changed files with 59 additions and 30 deletions

View File

@@ -108,20 +108,8 @@ static void drawscredge_area(const ScrArea &area, float edge_thickness)
GPU_batch_draw(batch);
}
void ED_screen_draw_edges(wmWindow *win)
static void screen_draw_editor_outlines(bScreen *screen, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
screen->do_draw = false;
if (screen->state != SCREENNORMAL) {
return;
}
if (BLI_listbase_is_single(&screen->areabase) && win->global_areas.areabase.first == nullptr) {
/* Do not show edges on windows without global areas and with only one editor. */
return;
}
ARegion *region = screen->active_region;
ScrArea *active_area = nullptr;
@@ -151,6 +139,60 @@ void ED_screen_draw_edges(wmWindow *win)
}
}
static ScrArea *current_active_area = nullptr;
static ScrArea *last_active_area = nullptr;
double now = BLI_time_now_seconds();
static double start_time = now;
double end_time = start_time + AREA_ACTIVE_FADEIN;
if (active_area != current_active_area) {
if (now > start_time + AREA_ACTIVE_FADEIN) {
start_time = now;
end_time = start_time + AREA_ACTIVE_FADEIN;
}
last_active_area = current_active_area;
current_active_area = active_area;
}
float col_inactive[4];
float col_active[4];
float col_active_last[4];
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE_ACTIVE, col_active);
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, col_inactive);
copy_v4_v4(col_active_last, col_inactive);
if (now < end_time) {
const float factor = pow((now - start_time) / (end_time - start_time), 2);
UI_GetThemeColorBlend4f(TH_EDITOR_OUTLINE, TH_EDITOR_OUTLINE_ACTIVE, factor, col_active);
UI_GetThemeColorBlend4f(TH_EDITOR_OUTLINE_ACTIVE, TH_EDITOR_OUTLINE, factor, col_active_last);
screen->do_refresh = true;
}
rctf bounds;
UI_draw_roundbox_corner_set(UI_CNR_ALL);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
BLI_rctf_rcti_copy(&bounds, &area->totrct);
float *color = (area == active_area) ? col_active :
(area == last_active_area) ? col_active_last :
col_inactive;
UI_draw_roundbox_4fv_ex(&bounds, nullptr, nullptr, 1.0f, color, U.pixelsize, EDITORRADIUS);
}
}
void ED_screen_draw_edges(wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
screen->do_draw = false;
if (screen->state != SCREENNORMAL) {
return;
}
if (BLI_listbase_is_single(&screen->areabase) && win->global_areas.areabase.first == nullptr) {
/* Do not show edges on windows without global areas and with only one editor. */
return;
}
rcti scissor_rect;
BLI_rcti_init_minmax(&scissor_rect);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
@@ -196,25 +238,10 @@ void ED_screen_draw_edges(wmWindow *win)
drawscredge_area(*area, edge_thickness);
}
float outline1[4];
float outline2[4];
rctf bounds;
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, outline1);
UI_GetThemeColor4fv(TH_EDITOR_OUTLINE_ACTIVE, outline2);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
BLI_rctf_rcti_copy(&bounds, &area->totrct);
UI_draw_roundbox_4fv_ex(&bounds,
nullptr,
nullptr,
1.0f,
(area == active_area) ? outline2 : outline1,
U.pixelsize,
EDITORRADIUS);
}
GPU_blend(GPU_BLEND_NONE);
GPU_scissor_test(false);
screen_draw_editor_outlines(screen, win);
}
void screen_draw_move_highlight(const wmWindow *win, bScreen *screen, eScreenAxis dir_axis)

View File

@@ -85,6 +85,8 @@ enum class AreaDockTarget {
#define AREA_JOIN_FADEOUT 0.15f /* seconds */
#define AREA_SPLIT_FADEOUT 0.15f /* seconds */
#define AREA_ACTIVE_FADEIN 0.15f /* seconds */
/* `area.cc` */
/**