fix: crash windows at startup, apply custom style to all dark/light theme

This commit is contained in:
Cyrix126 2024-11-01 21:06:22 +01:00
parent 2c9187c29d
commit b57fcb7207

View file

@ -26,7 +26,7 @@ use std::time::Instant;
#[inline(never)] #[inline(never)]
pub fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32) { pub fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32) {
let scale = width / 35.5; let scale = width / 35.5;
let mut style = (*ctx.style()).clone(); ctx.all_styles_mut(|style| {
style.text_styles = [ style.text_styles = [
(Small, FontId::new(scale / 3.0, egui::FontFamily::Monospace)), (Small, FontId::new(scale / 3.0, egui::FontFamily::Monospace)),
(Body, FontId::new(scale / 2.0, egui::FontFamily::Monospace)), (Body, FontId::new(scale / 2.0, egui::FontFamily::Monospace)),
@ -67,7 +67,7 @@ pub fn init_text_styles(ctx: &egui::Context, width: f32, pixels_per_point: f32)
bar_width: width / 150.0, bar_width: width / 150.0,
..egui::style::ScrollStyle::solid() ..egui::style::ScrollStyle::solid()
}; };
ctx.set_style(style); });
// Make sure scale f32 is a regular number. // Make sure scale f32 is a regular number.
let pixels_per_point = clamp_scale(pixels_per_point); let pixels_per_point = clamp_scale(pixels_per_point);
ctx.set_pixels_per_point(pixels_per_point); ctx.set_pixels_per_point(pixels_per_point);