UI: Shadowed Text for GN Viewer Node Attribute and Bone Names #116528

Merged
Harley Acheson merged 11 commits from Julian-Plak/blender:readable-att-text into main 2024-01-31 19:21:59 +01:00
4 changed files with 23 additions and 8 deletions
Showing only changes of commit 6c1fd2cd7f - Show all commits

View File

@ -1953,7 +1953,8 @@ static void draw_bone_name(const ArmatureDrawContext *ctx,
10,
0,
DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR,
color);
color,
true);
}
/** \} */

View File

@ -84,7 +84,7 @@ static void add_values_to_text_cache(const GVArray &values,
}
DRW_text_cache_add(
dt, position, numstr, numstr_len, 0, 0, DRW_TEXT_CACHE_GLOBALSPACE, col, true);
dt, position, numstr, numstr_len, 0, 0, DRW_TEXT_CACHE_GLOBALSPACE, col, true, true);
}
});
}

View File

@ -55,6 +55,7 @@ struct ViewCachedString {
short xoffs, yoffs;
short flag;
int str_len;
bool shadow;
bool align_center;
/* str is allocated past the end */
@ -86,6 +87,7 @@ void DRW_text_cache_add(DRWTextStore *dt,
short yoffs,
short flag,
const uchar col[4],
const bool shadow,
const bool align_center)
{
int alloc_len;
@ -108,6 +110,7 @@ void DRW_text_cache_add(DRWTextStore *dt,
vos->yoffs = yoffs;
vos->flag = flag;
vos->str_len = str_len;
vos->shadow = shadow;
vos->align_center = align_center;
/* allocate past the end */
@ -156,12 +159,22 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region)
vos->yoffs -= short(height / 2.0f);
}
BLF_draw_default_shadowed(
float(vos->sco[0] + vos->xoffs),
float(vos->sco[1] + vos->yoffs),
2.0f,
(vos->flag & DRW_TEXT_CACHE_STRING_PTR) ? *((const char **)vos->str) : vos->str,
vos->str_len);
if (vos->shadow) {
BLF_draw_default_shadowed(
float(vos->sco[0] + vos->xoffs),
float(vos->sco[1] + vos->yoffs),
2.0f,
(vos->flag & DRW_TEXT_CACHE_STRING_PTR) ? *((const char **)vos->str) : vos->str,
vos->str_len);
}
else {
BLF_draw_default(float(vos->sco[0] + vos->xoffs),
float(vos->sco[1] + vos->yoffs),
2.0f,
(vos->flag & DRW_TEXT_CACHE_STRING_PTR) ? *((const char **)vos->str) :
vos->str,
vos->str_len);
}
}
}

View File

@ -27,6 +27,7 @@ void DRW_text_cache_add(DRWTextStore *dt,
short yoffs,
short flag,
const uchar col[4],
const bool shadow = false,
const bool align_center = false);
void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, View3D *v3d);