Fix #126908: 3D view background color affects attribute text outline color

The change was accidentally done in #121383 which primarily concerned
itself with overlay text colors, but started to use TH_BACK theme color
for the draw manager text (e.g. for geometry nodes value visualization)
outline color. Change behavior to use black or white outline color, based
on lightness of text color.

Pull Request: https://projects.blender.org/blender/blender/pulls/127071
This commit is contained in:
Aras Pranckevicius
2024-09-03 22:01:14 +02:00
committed by Harley Acheson
parent 324e1441a2
commit 174387e4d9

View File

@@ -142,14 +142,17 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region)
BLF_default_size(UI_style_get()->widget.points);
const int font_id = BLF_set_default();
float shadow_color[4] = {0, 0, 0, 0.8f};
UI_GetThemeColor3fv(TH_BACK, shadow_color);
float outline_dark_color[4] = {0, 0, 0, 0.8f};
float outline_light_color[4] = {1, 1, 1, 0.8f};
bool outline_is_dark = true;
BLI_memiter_iter_init(dt->cache_strings, &it);
while ((vos = static_cast<ViewCachedString *>(BLI_memiter_iter_step(&it)))) {
if (vos->sco[0] != IS_CLIPPED) {
if (col_pack_prev != vos->col.pack) {
BLF_color4ubv(font_id, vos->col.ub);
const uchar lightness = rgb_to_grayscale_byte(vos->col.ub);
outline_is_dark = lightness > 96;
col_pack_prev = vos->col.pack;
}
@@ -169,7 +172,9 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region)
const int font_id = BLF_default();
if (vos->shadow) {
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, FontShadowType::Outline, shadow_color);
BLF_shadow(font_id,
FontShadowType::Outline,
outline_is_dark ? outline_dark_color : outline_light_color);
BLF_shadow_offset(font_id, 0, 0);
}
else {