fix most UI text color
There are still many places to fix. I'll miss the bright yellow! This commit also uses the new BLF_default function where possible. Part of T49043 since we call glColor less often.
This commit is contained in:
@@ -1563,13 +1563,15 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
|
||||
const char *printable = IFACE_("GPencil Stroke Editing");
|
||||
float printable_size[2];
|
||||
|
||||
BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
|
||||
int font_id = BLF_default();
|
||||
|
||||
BLF_width_and_height(font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
|
||||
|
||||
int xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
|
||||
int yco = (rect.ymax - U.widget_unit);
|
||||
|
||||
/* text label */
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
|
||||
#else
|
||||
|
||||
@@ -1805,7 +1805,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
||||
/* tab titles */
|
||||
|
||||
/* draw white shadow to give text more depth */
|
||||
glColor3ubv(theme_col_text);
|
||||
BLF_color3ubv(fontid, theme_col_text);
|
||||
|
||||
/* main tab title */
|
||||
BLF_draw(fontid, category_id_draw, category_draw_len);
|
||||
|
||||
@@ -1457,7 +1457,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
}
|
||||
#endif
|
||||
|
||||
glColor4ubv((unsigned char *)wcol->text);
|
||||
BLF_color4ubv(fstyle->uifont_id, (unsigned char *)wcol->text);
|
||||
|
||||
if (!use_right_only) {
|
||||
/* for underline drawing */
|
||||
@@ -4125,7 +4125,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
|
||||
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
|
||||
}
|
||||
|
||||
glColor4ubv((unsigned char *)wt->wcol.text);
|
||||
BLF_color4ubv(fstyle->uifont_id, (unsigned char *)wt->wcol.text);
|
||||
UI_fontstyle_draw(fstyle, rect, drawstr);
|
||||
}
|
||||
|
||||
@@ -4192,7 +4192,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
|
||||
BLI_strncpy(drawstr, name, sizeof(drawstr));
|
||||
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
|
||||
|
||||
glColor4ubv((unsigned char *)wt->wcol.text);
|
||||
BLF_color4ubv(fstyle->uifont_id, (unsigned char *)wt->wcol.text);
|
||||
UI_fontstyle_draw(fstyle, &trect, drawstr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1978,7 +1978,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
dfac = dfac * BLI_rcti_size_y(&vert);
|
||||
|
||||
/* set starting value, and text color */
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
const int font_id = BLF_default();
|
||||
UI_FontThemeColor(font_id, TH_TEXT);
|
||||
val = grid->starty;
|
||||
|
||||
/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */
|
||||
@@ -1987,9 +1988,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
|
||||
/* draw vertical steps */
|
||||
if (dfac > 0.0f) {
|
||||
|
||||
BLF_rotation_default(M_PI_2);
|
||||
BLF_enable_default(BLF_ROTATION);
|
||||
BLF_rotation(font_id, M_PI_2);
|
||||
BLF_enable(font_id, BLF_ROTATION);
|
||||
|
||||
for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) {
|
||||
|
||||
@@ -2000,7 +2000,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
|
||||
scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v');
|
||||
}
|
||||
|
||||
BLF_disable_default(BLF_ROTATION);
|
||||
BLF_disable(font_id, BLF_ROTATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2514,7 +2514,8 @@ void UI_view2d_text_cache_draw(ARegion *ar)
|
||||
int col_pack_prev = 0;
|
||||
|
||||
/* investigate using BLF_ascender() */
|
||||
const float default_height = g_v2d_strings ? BLF_height_default("28", 3) : 0.0f;
|
||||
const int font_id = BLF_default();
|
||||
const float default_height = g_v2d_strings ? BLF_height(font_id, "28", 3) : 0.0f;
|
||||
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
|
||||
@@ -2525,7 +2526,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
|
||||
if (yofs < 1) yofs = 1;
|
||||
|
||||
if (col_pack_prev != v2s->col.pack) {
|
||||
glColor3ubv(v2s->col.ub);
|
||||
BLF_color3ubv(font_id, v2s->col.ub);
|
||||
col_pack_prev = v2s->col.pack;
|
||||
}
|
||||
|
||||
@@ -2533,11 +2534,11 @@ void UI_view2d_text_cache_draw(ARegion *ar)
|
||||
BLF_draw_default((float)(v2s->mval[0] + xofs), (float)(v2s->mval[1] + yofs), 0.0,
|
||||
v2s->str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
else {
|
||||
BLF_clipping_default(v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4);
|
||||
BLF_enable_default(BLF_CLIPPING);
|
||||
BLF_enable(font_id, BLF_CLIPPING);
|
||||
BLF_clipping(font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4);
|
||||
BLF_draw_default(v2s->rect.xmin + xofs, v2s->rect.ymin + yofs, 0.0f,
|
||||
v2s->str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
BLF_disable_default(BLF_CLIPPING);
|
||||
BLF_disable(font_id, BLF_CLIPPING);
|
||||
}
|
||||
}
|
||||
g_v2d_strings = NULL;
|
||||
|
||||
@@ -557,7 +557,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
|
||||
UI_ThemeClearColor(TH_HEADER);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
UI_FontThemeColor(BLF_default(), TH_TEXT);
|
||||
BLF_draw_default(UI_UNIT_X, 0.4f * UI_UNIT_Y, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
|
||||
}
|
||||
else if (at->draw) {
|
||||
@@ -2161,7 +2161,7 @@ void ED_region_info_draw(ARegion *ar, const char *text, float fill_color[4], con
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* text */
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(fontid, TH_TEXT_HI);
|
||||
BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
BLF_enable(fontid, BLF_CLIPPING);
|
||||
BLF_position(fontid, rect.xmin + 0.6f * U.widget_unit, rect.ymin + 0.3f * U.widget_unit, 0.0f);
|
||||
@@ -2369,7 +2369,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
|
||||
BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
BLF_enable(blf_mono_font, BLF_CLIPPING);
|
||||
|
||||
UI_ThemeColor(TH_METADATA_TEXT);
|
||||
UI_FontThemeColor(blf_mono_font, TH_METADATA_TEXT);
|
||||
metadata_draw_imbuf(ibuf, &rect, blf_mono_font, true);
|
||||
|
||||
BLF_disable(blf_mono_font, BLF_CLIPPING);
|
||||
@@ -2394,7 +2394,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
|
||||
BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
BLF_enable(blf_mono_font, BLF_CLIPPING);
|
||||
|
||||
UI_ThemeColor(TH_METADATA_TEXT);
|
||||
UI_FontThemeColor(blf_mono_font, TH_METADATA_TEXT);
|
||||
metadata_draw_imbuf(ibuf, &rect, blf_mono_font, false);
|
||||
|
||||
BLF_disable(blf_mono_font, BLF_CLIPPING);
|
||||
@@ -2547,7 +2547,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f
|
||||
immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
|
||||
immUnbindProgram();
|
||||
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
UI_FontThemeColor(fontid, TH_TEXT);
|
||||
BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f);
|
||||
BLF_draw(fontid, numstr, sizeof(numstr));
|
||||
}
|
||||
|
||||
@@ -1269,7 +1269,7 @@ static void draw_tree_path(SpaceNode *snode)
|
||||
|
||||
ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info));
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
||||
BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info));
|
||||
}
|
||||
|
||||
|
||||
@@ -698,7 +698,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
|
||||
/* camera name - draw in highlighted text color */
|
||||
if (ca && (ca->flag & CAM_SHOWNAME)) {
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
||||
BLF_draw_default(
|
||||
x1i, y1i - (0.7f * U.widget_unit), 0.0f,
|
||||
v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2);
|
||||
@@ -1644,11 +1644,11 @@ static void draw_view_axis(RegionView3D *rv3d, rcti *rect)
|
||||
int i = axis_order[axis_i];
|
||||
|
||||
const char axis_text[2] = {'x' + i, '\0'};
|
||||
glColor4ubv(axis_col[i]); /* text shader still uses gl_Color */
|
||||
BLF_color4ubv(BLF_default(), axis_col[i]);
|
||||
BLF_draw_default_ascii(axis_pos[i][0] + 2, axis_pos[i][1] + 2, 0.0f, axis_text, 1);
|
||||
}
|
||||
|
||||
/* BLF_draw_default disabled blending for us */
|
||||
/* BLF_draw disabled blending for us */
|
||||
}
|
||||
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
|
||||
@@ -291,7 +291,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect)
|
||||
name = tmpstr;
|
||||
}
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
BLF_draw_default(U.widget_unit + rect->xmin, rect->ymax - U.widget_unit, 0.0f, name, sizeof(tmpstr));
|
||||
#else
|
||||
@@ -309,6 +309,8 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
|
||||
const char *msg_pin = " (Pinned)";
|
||||
const char *msg_sep = " : ";
|
||||
|
||||
const int font_id = BLF_default();
|
||||
|
||||
char info[300];
|
||||
char *s = info;
|
||||
short offset = 1.5f * UI_UNIT_X + rect->xmin;
|
||||
@@ -384,18 +386,18 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect)
|
||||
|
||||
/* color depends on whether there is a keyframe */
|
||||
if (id_frame_has_keyframe((ID *)ob, /* BKE_scene_frame_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL))
|
||||
UI_ThemeColor(TH_TIME_KEYFRAME);
|
||||
UI_FontThemeColor(font_id, TH_TIME_KEYFRAME);
|
||||
else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra))
|
||||
UI_ThemeColor(TH_TIME_GP_KEYFRAME);
|
||||
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
||||
}
|
||||
else {
|
||||
/* no object */
|
||||
if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra))
|
||||
UI_ThemeColor(TH_TIME_GP_KEYFRAME);
|
||||
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
||||
}
|
||||
|
||||
if (markern) {
|
||||
@@ -2348,13 +2350,15 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect)
|
||||
}
|
||||
#endif
|
||||
|
||||
const int font_id = BLF_default();
|
||||
|
||||
/* is this more than half a frame behind? */
|
||||
if (fps + 0.5f < (float)(FPS)) {
|
||||
UI_ThemeColor(TH_REDALERT);
|
||||
UI_FontThemeColor(font_id, TH_REDALERT);
|
||||
BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %.2f"), fps);
|
||||
}
|
||||
else {
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
||||
BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), (int)(fps + 0.5f));
|
||||
}
|
||||
|
||||
@@ -2683,7 +2687,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene,
|
||||
if (grid_unit) { /* draw below the viewport name */
|
||||
char numstr[32] = "";
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
||||
if (v3d->grid != 1.0f) {
|
||||
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
|
||||
}
|
||||
|
||||
@@ -1852,8 +1852,9 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
|
||||
int xco, yco;
|
||||
|
||||
ED_region_visible_rect(ar, &rect);
|
||||
|
||||
BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
|
||||
|
||||
const int font_id = BLF_default();
|
||||
BLF_width_and_height(font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
|
||||
|
||||
xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
|
||||
yco = (rect.ymax - U.widget_unit);
|
||||
@@ -1861,7 +1862,9 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
|
||||
/* warning text (to clarify meaning of overlays)
|
||||
* - original color was red to match the icon, but that clashes badly with a less nasty border
|
||||
*/
|
||||
UI_ThemeColorShade(TH_TEXT_HI, -50);
|
||||
unsigned char color[3];
|
||||
UI_GetThemeColorShade3ubv(TH_TEXT_HI, -50, color);
|
||||
BLF_color3ubv(font_id, color);
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user