This commit is contained in:
Simon Gardling
2022-05-18 19:27:11 -04:00
parent 8ed749ef72
commit 99f134a52d
4 changed files with 74 additions and 68 deletions

View File

@@ -9,6 +9,7 @@
#![feature(const_option_ext)] #![feature(const_option_ext)]
#![feature(const_slice_index)] #![feature(const_slice_index)]
#![feature(slice_split_at_unchecked)] #![feature(slice_split_at_unchecked)]
#![feature(inline_const)]
#[macro_use] #[macro_use]
extern crate static_assertions; extern crate static_assertions;

View File

@@ -9,6 +9,7 @@
#![feature(const_option_ext)] #![feature(const_option_ext)]
#![feature(const_slice_index)] #![feature(const_slice_index)]
#![feature(slice_split_at_unchecked)] #![feature(slice_split_at_unchecked)]
#![feature(inline_const)]
#[macro_use] #[macro_use]
extern crate static_assertions; extern crate static_assertions;

View File

@@ -239,11 +239,11 @@ impl MathApp {
cc.egui_ctx.set_fonts(data.fonts); cc.egui_ctx.set_fonts(data.fonts);
// Set dark mode by default // Set dark mode by default
cc.egui_ctx.set_visuals(crate::style::STYLE); cc.egui_ctx.set_visuals(const { crate::style::dark() });
// Set spacing // Set spacing
let mut style: egui::Style = (*cc.egui_ctx.style()).clone(); let mut style: egui::Style = (*cc.egui_ctx.style()).clone();
style.spacing = crate::style::SPACING; style.spacing = const { crate::style::spacing() };
cc.egui_ctx.set_style(style); cc.egui_ctx.set_style(style);
tracing::info!("Initialized! Took: {:?}", start.elapsed()); tracing::info!("Initialized! Took: {:?}", start.elapsed());
@@ -514,15 +514,19 @@ impl App for MathApp {
self.side_panel(ctx); self.side_panel(ctx);
} }
const EMPTY_FRAME: Frame = Frame { // Central panel which contains the central plot (or an error created when parsing)
CentralPanel::default()
.frame(
const {
Frame {
inner_margin: Margin::symmetric(0.0, 0.0), inner_margin: Margin::symmetric(0.0, 0.0),
rounding: Rounding::none(), rounding: Rounding::none(),
fill: crate::style::STYLE.window_fill(), fill: crate::style::STYLE.window_fill(),
..Frame::none() ..Frame::none()
}; }
},
// Central panel which contains the central plot (or an error created when parsing) )
CentralPanel::default().frame(EMPTY_FRAME).show(ctx, |ui| { .show(ctx, |ui| {
// Display an error if it exists // Display an error if it exists
let errors_formatted: String = self let errors_formatted: String = self
.functions .functions
@@ -533,7 +537,9 @@ impl App for MathApp {
.filter(|(_, error)| error.is_some()) .filter(|(_, error)| error.is_some())
.map(|(i, error)| { .map(|(i, error)| {
// use unwrap_unchecked as None Errors are already filtered out // use unwrap_unchecked as None Errors are already filtered out
unsafe { format!("(Function #{}) {}\n", i, error.as_ref().unwrap_unchecked()) } unsafe {
format!("(Function #{}) {}\n", i, error.as_ref().unwrap_unchecked())
}
}) })
.collect::<String>(); .collect::<String>();

View File

@@ -69,8 +69,6 @@ pub const fn dark() -> Visuals {
} }
} }
pub const SPACING: Spacing = spacing();
pub const fn spacing() -> Spacing { pub const fn spacing() -> Spacing {
Spacing { Spacing {
item_spacing: vec2(8.0, 3.0), item_spacing: vec2(8.0, 3.0),