UI: Positioning of 3DView Sidebar Tab Titles

Improve the positioning of the tab titles in the 3D Viewport sidebar
by taking the Text Style size into consideration.

Pull Request: https://projects.blender.org/blender/blender/pulls/119231
This commit is contained in:
Harley Acheson
2024-03-09 01:34:42 +01:00
committed by Harley Acheson
parent 2d3d8c80c3
commit 196cd48aad

View File

@@ -1342,8 +1342,6 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
/* Intentionally don't scale by 'px'. */
const int rct_xmin = is_left ? v2d->mask.xmin + 3 : (v2d->mask.xmax - category_tabs_width);
const int rct_xmax = is_left ? v2d->mask.xmin + category_tabs_width : (v2d->mask.xmax - 3);
const int text_v_ofs = (rct_xmax - rct_xmin) * 0.3f;
int y_ofs = tab_v_pad;
/* Primary theme colors. */
@@ -1504,8 +1502,14 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
/* Tab titles. */
/* Offset toward the middle of the rect. */
const int text_v_ofs = (rct_xmax - rct_xmin) * 0.5f;
/* Offset down as the font size increases. */
const int text_size_offset = int(fstyle_points * UI_SCALE_FAC * 0.35f);
BLF_position(fontid,
is_left ? rct->xmax - text_v_ofs : rct->xmin + text_v_ofs,
is_left ? rct->xmax - text_v_ofs + text_size_offset :
rct->xmin + text_v_ofs - text_size_offset,
is_left ? rct->ymin + tab_v_pad_text : rct->ymax - tab_v_pad_text,
0.0f);
BLF_color3ubv(fontid, is_active ? theme_col_text_hi : theme_col_text);