From 310049b22e2fe69987c13b4da453ccd521e8a484 Mon Sep 17 00:00:00 2001 From: dvorakmortonxd Date: Fri, 11 Sep 2026 22:11:25 +0200 Subject: [PATCH] UI tweaks again (made it so special symbols like stars arent affected since it makes it look weird on retina screens) --- style.css | 6 ++++++ theme.c | 36 +++++++++++++++++++++--------------- unitmap.c | 1 + 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/style.css b/style.css index 805ff97..6cee0cf 100644 --- a/style.css +++ b/style.css @@ -758,3 +758,9 @@ tooltip { border-radius: 10px; color: @fg_text; } + +/* no-scale */ +/* Rules below keep a fixed size (symbols/icons) even when the window grows. */ +.bubble-number.branch-star { + font-size: 22px; +} diff --git a/theme.c b/theme.c index c43d0d2..770d147 100644 --- a/theme.c +++ b/theme.c @@ -207,20 +207,36 @@ static gboolean scale_font_size_eval(const GMatchInfo *info, GString *result, } /* Scale every explicit `font-size: Npx` declaration so the interface grows on - * large (e.g. maximised / high-DPI) windows. Layout metrics stay untouched. */ + * large (e.g. maximised / high-DPI) windows. Layout metrics stay untouched. + * Rules after the no-scale marker keep their fixed size, so symbol / icon + * glyphs do not scale. */ static char *scale_font_sizes(const char *css, double scale) { - GRegex *re; + static const char marker[] = "/* no-scale */"; + const char *pos; + char *head; + char *scaled_head; char *out; + GRegex *re; FontScale fs; if (scale <= 1.0001) return g_strdup(css); + pos = g_strstr_len(css, -1, marker); + head = pos ? g_strndup(css, (gsize)(pos - css)) : g_strdup(css); + fs.scale = scale; re = g_regex_new("font-size:([ \t]*)([0-9]+)px", 0, 0, NULL); - out = g_regex_replace_eval(re, css, -1, 0, 0, - scale_font_size_eval, &fs, NULL); + scaled_head = g_regex_replace_eval(re, head, -1, 0, 0, + scale_font_size_eval, &fs, NULL); g_regex_unref(re); + g_free(head); + + if (pos) + out = g_strconcat(scaled_head, pos, NULL); + else + out = scaled_head; + g_free(scaled_head); return out; } @@ -254,21 +270,11 @@ char *build_theme_css(const ThemePalette *p) { p->node, p->locked_bg, p->locked_border); char *rules = read_css_file(); char *scaled = scale_font_sizes(rules, app_ui_scale); - char *base; - char *css; - - if (app_ui_scale > 1.0001) - base = g_strdup_printf("window { font-size: %dpx; }\n", - (int)(14.0 * app_ui_scale + 0.5)); - else - base = g_strdup(""); - - css = g_strconcat(palette, base, scaled, NULL); + char *css = g_strconcat(palette, scaled, NULL); g_free(palette); g_free(rules); g_free(scaled); - g_free(base); return css; } diff --git a/unitmap.c b/unitmap.c index cc1600d..aea83c6 100644 --- a/unitmap.c +++ b/unitmap.c @@ -286,6 +286,7 @@ static GtkWidget *make_branch_bubble(UnitCtx *u) { star = gtk_label_new("★"); gtk_widget_set_halign(star, GTK_ALIGN_CENTER); gtk_widget_add_css_class(star, "bubble-number"); + gtk_widget_add_css_class(star, "branch-star"); gtk_box_append(GTK_BOX(vbox), star); icon = icon_area_new(draw_check_icon, 0.1176, 0.1176, 0.1804, 16);