diff --git a/source/blender/blenfont/BLF_api.hh b/source/blender/blenfont/BLF_api.hh index 8535e08c3c3..e9f4c205031 100644 --- a/source/blender/blenfont/BLF_api.hh +++ b/source/blender/blenfont/BLF_api.hh @@ -307,15 +307,6 @@ int BLF_default(); * Draw the string using the default font, size and DPI. */ void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL(); -/** - * As above but with a very contrasting dark shadow. - */ -void BLF_draw_default_shadowed(float x, - float y, - float z, - const char *str, - size_t str_len, - const float shadow_color[4] = nullptr) ATTR_NONNULL(4); /** * Set size and DPI, and return default font ID. */ diff --git a/source/blender/blenfont/intern/blf_default.cc b/source/blender/blenfont/intern/blf_default.cc index f7801b37193..09f48b6897e 100644 --- a/source/blender/blenfont/intern/blf_default.cc +++ b/source/blender/blenfont/intern/blf_default.cc @@ -59,17 +59,3 @@ void BLF_draw_default(float x, float y, float z, const char *str, const size_t s BLF_position(global_font_default, x, y, z); BLF_draw(global_font_default, str, str_len); } - -void BLF_draw_default_shadowed( - float x, float y, float z, const char *str, const size_t str_len, const float shadow_color[4]) -{ - ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_size * UI_SCALE_FAC); - - BLF_enable(global_font_default, BLF_SHADOW); - BLF_shadow(global_font_default, FontShadowType::Outline, shadow_color); - BLF_shadow_offset(global_font_default, 0, 0); - BLF_position(global_font_default, x, y, z); - BLF_draw(global_font_default, str, str_len); - BLF_disable(global_font_default, BLF_SHADOW); -} diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index e7d5db83d18..1512c13665e 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -1146,15 +1146,13 @@ void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height) { DRW_ENABLED_ENGINE_ITER (DST.view_data_active, engine, data) { if (data->info[0] != '\0') { - const int font_id = BLF_default(); - UI_FontThemeColor(font_id, TH_TEXT_HI); const char *buf_step = IFACE_(data->info); do { const char *buf = buf_step; buf_step = BLI_strchr_or_end(buf, '\n'); const int buf_len = buf_step - buf; *yoffset -= line_height; - BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, buf, buf_len); + BLF_draw_default(xoffset, *yoffset, 0.0f, buf, buf_len); } while (*buf_step ? ((void)buf_step++, true) : false); } } diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index dab6b0c29bc..46417141f58 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -196,16 +196,16 @@ void DRW_stats_reset() static void draw_stat_5row(const rcti *rect, int u, int v, const char *txt, const int size) { - BLF_draw_default_shadowed(rect->xmin + (1 + u * 5) * U.widget_unit, - rect->ymax - (3 + v) * U.widget_unit, - 0.0f, - txt, - size); + BLF_draw_default(rect->xmin + (1 + u * 5) * U.widget_unit, + rect->ymax - (3 + v) * U.widget_unit, + 0.0f, + txt, + size); } static void draw_stat(const rcti *rect, int u, int v, const char *txt, const int size) { - BLF_draw_default_shadowed( + BLF_draw_default( rect->xmin + (1 + u) * U.widget_unit, rect->ymax - (3 + v) * U.widget_unit, 0.0f, txt, size); } diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 3259ba99b3b..bf963ccae50 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -166,23 +166,21 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region) vos->yoffs -= short(height / 2.0f); } + const int font_id = BLF_default(); 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, - shadow_color); + BLF_enable(font_id, BLF_SHADOW); + BLF_shadow(font_id, FontShadowType::Outline, shadow_color); + BLF_shadow_offset(font_id, 0, 0); } 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); + BLF_disable(font_id, BLF_SHADOW); } + 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); } } diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 1d772b7d475..c59f7b3b464 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -748,10 +748,10 @@ static void stats_row(int col1, int height) { *y -= height; - BLF_draw_default_shadowed(col1, *y, 0.0f, key, 128); + BLF_draw_default(col1, *y, 0.0f, key, 128); char values[128]; SNPRINTF(values, (value2) ? "%s / %s" : "%s", value1, value2); - BLF_draw_default_shadowed(col2, *y, 0.0f, values, sizeof(values)); + BLF_draw_default(col2, *y, 0.0f, values, sizeof(values)); } void ED_info_draw_stats( diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index d1c2e3b10c8..239ae303d91 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -784,11 +784,11 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, /* camera name - draw in highlighted text color */ if (ca && ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) && (ca->flag & CAM_SHOWNAME)) { UI_FontThemeColor(BLF_default(), TH_TEXT_HI); - BLF_draw_default_shadowed(x1i, - y1i - (0.7f * U.widget_unit), - 0.0f, - v3d->camera->id.name + 2, - sizeof(v3d->camera->id.name) - 2); + BLF_draw_default(x1i, + y1i - (0.7f * U.widget_unit), + 0.0f, + v3d->camera->id.name + 2, + sizeof(v3d->camera->id.name) - 2); } } @@ -1285,7 +1285,7 @@ static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *y name = tmpstr; } *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT; - BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr)); + BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr)); } /** @@ -1423,7 +1423,7 @@ static void draw_selected_name( BLI_string_join_array(info, sizeof(info), info_array, i); *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT; - BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, info, sizeof(info)); + BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info)); } static void draw_grid_unit_name( @@ -1441,8 +1441,7 @@ static void draw_grid_unit_name( } *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT; - BLF_draw_default_shadowed( - xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr)); + BLF_draw_default(xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr)); } } } @@ -1500,15 +1499,18 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) BLF_default_size(fstyle->points); BLF_set_default(); + const int font_id = BLF_default(); float text_color[4], shadow_color[4]; ED_view3d_text_colors_get(scene, v3d, text_color, shadow_color); - BLF_color4fv(BLF_default(), text_color); - BLF_shadow(BLF_default(), FontShadowType::Outline, shadow_color); + BLF_color4fv(font_id, text_color); + BLF_enable(font_id, BLF_SHADOW); + BLF_shadow_offset(font_id, 0, 0); + BLF_shadow(font_id, FontShadowType::Outline, shadow_color); if ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) { if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) { ED_scene_draw_fps(scene, xoffset, &yoffset); - BLF_color4fv(BLF_default(), text_color); + BLF_color4fv(font_id, text_color); } else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(region, v3d, xoffset, &yoffset); @@ -1518,7 +1520,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); draw_selected_name(v3d, scene, view_layer, ob, xoffset, &yoffset); - BLF_color4fv(BLF_default(), text_color); + BLF_color4fv(font_id, text_color); } if (v3d->gridflag & (V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) { @@ -2629,7 +2631,7 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset) *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT; - BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, printable, sizeof(printable)); + BLF_draw_default(xoffset, *yoffset, 0.0f, printable, sizeof(printable)); } /** \} */ diff --git a/source/blender/editors/transform/transform.cc b/source/blender/editors/transform/transform.cc index 708bbe28cd2..14b0015aaf7 100644 --- a/source/blender/editors/transform/transform.cc +++ b/source/blender/editors/transform/transform.cc @@ -1562,8 +1562,10 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *region) const rcti *rect = ED_region_visible_rect(region); View3D *v3d = nullptr; + Scene *scene = nullptr; if (t->spacetype == SPACE_VIEW3D) { v3d = static_cast(t->view); + scene = static_cast(t->scene); } const int font_id = BLF_set_default(); @@ -1600,10 +1602,17 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *region) /* Warning text (to clarify meaning of overlays) * - Original color was red to match the icon, but that clashes badly with a less nasty border. */ - uchar color[3]; - UI_GetThemeColorShade3ubv(TH_TEXT_HI, -50, color); - BLF_color3ubv(font_id, color); - BLF_draw_default_shadowed(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX); + + float text_color[4], shadow_color[4]; + if (v3d && scene) { + ED_view3d_text_colors_get(scene, v3d, text_color, shadow_color); + } + else { + UI_GetThemeColor4fv(TH_TEXT_HI, text_color); + UI_GetThemeColor4fv(TH_BACK, text_color); + } + BLF_color4fv(BLF_default(), text_color); + BLF_shadow(BLF_default(), FontShadowType::Outline, shadow_color); /* Auto-key recording icon. */ GPU_blend(GPU_BLEND_ALPHA);