mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-31 09:36:00 +00:00
fix: crash windows at startup, apply custom style to all dark/light theme
This commit is contained in:
parent
2c9187c29d
commit
b57fcb7207
1 changed files with 42 additions and 42 deletions
84
src/inits.rs
84
src/inits.rs
|
@ -26,48 +26,48 @@ 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)),
|
||||||
(
|
(
|
||||||
Button,
|
Button,
|
||||||
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Monospace,
|
Monospace,
|
||||||
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Heading,
|
Heading,
|
||||||
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
|
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Name("Tab".into()),
|
Name("Tab".into()),
|
||||||
FontId::new(scale * 1.05, egui::FontFamily::Monospace),
|
FontId::new(scale * 1.05, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Name("Bottom".into()),
|
Name("Bottom".into()),
|
||||||
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
FontId::new(scale / 2.0, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Name("MonospaceSmall".into()),
|
Name("MonospaceSmall".into()),
|
||||||
FontId::new(scale / 2.5, egui::FontFamily::Monospace),
|
FontId::new(scale / 2.5, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Name("MonospaceLarge".into()),
|
Name("MonospaceLarge".into()),
|
||||||
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
|
FontId::new(scale / 1.5, egui::FontFamily::Monospace),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
.into();
|
.into();
|
||||||
style.spacing.icon_width_inner = width / 35.0;
|
style.spacing.icon_width_inner = width / 35.0;
|
||||||
style.spacing.icon_width = width / 25.0;
|
style.spacing.icon_width = width / 25.0;
|
||||||
style.spacing.icon_spacing = 20.0;
|
style.spacing.icon_spacing = 20.0;
|
||||||
style.spacing.scroll = egui::style::ScrollStyle {
|
style.spacing.scroll = egui::style::ScrollStyle {
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue