diff --git a/src/app.rs b/src/app.rs index 811bd45..1d0a9c4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -68,7 +68,8 @@ pub struct 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 mut app = App { workspace_input: config.workspace.display().to_string(), @@ -1489,6 +1490,45 @@ fn build_editor_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 /// 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