Boost global text contrast and enlarge fonts slightly

Mirror the logrs treatment: at startup, pull every widget state's
foreground stroke toward white (dark) / black (light) so all UI text —
menus, top bar, buttons, panels, headings, not just the file list and
editor — reads more clearly against the theme background. Also scale
every base font size up ~12%. Explicitly coloured spans and the existing
per-pane contrast controls are unaffected and still layer on top.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
landon
2026-07-29 17:09:50 -05:00
parent 503ef4f24a
commit a50fc5d521
+41 -1
View File
@@ -68,7 +68,8 @@ pub struct App {
} }
impl App { impl App {
pub fn new(_cc: &eframe::CreationContext<'_>) -> Self { pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
apply_global_style(&cc.egui_ctx);
let config = Config::load(); let config = Config::load();
let mut app = App { let mut app = App {
workspace_input: config.workspace.display().to_string(), workspace_input: config.workspace.display().to_string(),
@@ -1489,6 +1490,45 @@ fn build_editor_job(
job job
} }
/// Fraction each base font size is enlarged, applied once at startup so every
/// panel's text is slightly bigger without changing layout maths elsewhere.
const FONT_SCALE: f32 = 1.12;
/// Configure the shared context style once at startup: raise the contrast of
/// *all* UI text (menus, top bar, buttons, panels, headings — everything, not
/// just the file list and editor) and enlarge every base font size slightly.
///
/// The default dark theme uses fairly dim greys (~140) for body text, the main
/// legibility complaint; we pull each widget state's foreground toward white in
/// dark mode / black in light mode. Explicitly coloured spans (grammar
/// underlines, the cheatsheet's syntax colour) set their own colours and are
/// unaffected. The per-pane boosts (`boost_list_contrast`, the editor contrast
/// slider) still layer on top for their specific widgets.
fn apply_global_style(ctx: &egui::Context) {
let mut style = (*ctx.style()).clone();
// Enlarge every text style (Body, Button, Heading, Monospace, Small).
for font in style.text_styles.values_mut() {
font.size = (font.size * FONT_SCALE).round();
}
let v = &mut style.visuals;
let target = if v.dark_mode {
egui::Color32::WHITE
} else {
egui::Color32::BLACK
};
let w = &mut v.widgets;
w.noninteractive.fg_stroke.color =
lerp_color(w.noninteractive.fg_stroke.color, target, 0.55);
w.inactive.fg_stroke.color = lerp_color(w.inactive.fg_stroke.color, target, 0.45);
w.hovered.fg_stroke.color = lerp_color(w.hovered.fg_stroke.color, target, 0.35);
w.active.fg_stroke.color = lerp_color(w.active.fg_stroke.color, target, 0.35);
w.open.fg_stroke.color = lerp_color(w.open.fg_stroke.color, target, 0.45);
ctx.set_style(style);
}
/// Raise the text contrast of list-style widgets in the current `ui`, so file /// Raise the text contrast of list-style widgets in the current `ui`, so file
/// names in the left pane stay legible against the panel background. Only the /// names in the left pane stay legible against the panel background. Only the
/// widget foreground colours are touched; layout and the rest of the app are /// widget foreground colours are touched; layout and the rest of the app are