UI tweaks again (made it so special symbols like stars arent affected since it makes it look weird on retina screens)

This commit is contained in:
dvorakmortonxd 2026-09-11 22:11:25 +02:00
commit 310049b22e
3 changed files with 28 additions and 15 deletions

View file

@ -758,3 +758,9 @@ tooltip {
border-radius: 10px; border-radius: 10px;
color: @fg_text; 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;
}

34
theme.c
View file

@ -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 /* 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) { 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; char *out;
GRegex *re;
FontScale fs; FontScale fs;
if (scale <= 1.0001) if (scale <= 1.0001)
return g_strdup(css); 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; fs.scale = scale;
re = g_regex_new("font-size:([ \t]*)([0-9]+)px", 0, 0, NULL); re = g_regex_new("font-size:([ \t]*)([0-9]+)px", 0, 0, NULL);
out = g_regex_replace_eval(re, css, -1, 0, 0, scaled_head = g_regex_replace_eval(re, head, -1, 0, 0,
scale_font_size_eval, &fs, NULL); scale_font_size_eval, &fs, NULL);
g_regex_unref(re); 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; return out;
} }
@ -254,21 +270,11 @@ char *build_theme_css(const ThemePalette *p) {
p->node, p->locked_bg, p->locked_border); p->node, p->locked_bg, p->locked_border);
char *rules = read_css_file(); char *rules = read_css_file();
char *scaled = scale_font_sizes(rules, app_ui_scale); char *scaled = scale_font_sizes(rules, app_ui_scale);
char *base; char *css = g_strconcat(palette, scaled, NULL);
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);
g_free(palette); g_free(palette);
g_free(rules); g_free(rules);
g_free(scaled); g_free(scaled);
g_free(base);
return css; return css;
} }

View file

@ -286,6 +286,7 @@ static GtkWidget *make_branch_bubble(UnitCtx *u) {
star = gtk_label_new("★"); star = gtk_label_new("★");
gtk_widget_set_halign(star, GTK_ALIGN_CENTER); gtk_widget_set_halign(star, GTK_ALIGN_CENTER);
gtk_widget_add_css_class(star, "bubble-number"); gtk_widget_add_css_class(star, "bubble-number");
gtk_widget_add_css_class(star, "branch-star");
gtk_box_append(GTK_BOX(vbox), star); gtk_box_append(GTK_BOX(vbox), star);
icon = icon_area_new(draw_check_icon, 0.1176, 0.1176, 0.1804, 16); icon = icon_area_new(draw_check_icon, 0.1176, 0.1176, 0.1804, 16);