diff --git a/Cargo.toml b/Cargo.toml index 59bf3b4..035667d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ opt-level = 2 lto = false [dependencies] -eframe = { git = "https://github.com/emilk/egui", default-features = false } +eframe = { git = "https://github.com/emilk/egui", default-features = false, branch = "eframe-app-creation-refactor" } shadow-rs = { version = "0.9", default-features = false } const_format = { version = "0.2.22", default-features = false, features = ["fmt"] } cfg-if = "1.0.0" diff --git a/src/egui_app.rs b/src/egui_app.rs index 7d82197..c2665aa 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -10,7 +10,7 @@ use egui::{ Button, CentralPanel, Color32, ComboBox, Context, FontData, FontDefinitions, FontFamily, RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window, }; -use epi::{Frame, Storage}; +use epi::Frame; use instant::Duration; use serde_json::Value; use shadow_rs::shadow; @@ -318,6 +318,14 @@ impl Default for MathApp { } impl MathApp { + #[allow(dead_code)] // this is used lol + pub fn new(_cc: &eframe::CreationContext<'_>) -> Self { + #[cfg(target_arch = "wasm32")] + stop_loading(); + log_helper("egui app initialized."); + Self::default() + } + fn side_panel(&mut self, ctx: &Context) { // Side Panel which contains vital options to the operation of the application // (such as adding functions and other options) @@ -497,19 +505,6 @@ impl MathApp { } impl epi::App for MathApp { - // The name of the program (displayed when running natively as the window title) - fn name(&self) -> &str { "(Yet-to-be-named) Graphing Software" } - - // Called once before the first frame. - fn setup( - &mut self, _ctx: &Context, _frame: &Frame, _storage: Option<&dyn Storage>, - _gl: &std::rc::Rc, - ) { - #[cfg(target_arch = "wasm32")] - stop_loading(); - log_helper("egui app initialized."); - } - // Called each time the UI needs repainting, which may be many times per second. #[inline(always)] fn update(&mut self, ctx: &Context, _frame: &Frame) { diff --git a/src/lib.rs b/src/lib.rs index 3ad0ece..98e490c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,7 @@ cfg_if::cfg_if! { log_helper("Finished initializing!"); log_helper("Starting App..."); - let app = egui_app::MathApp::default(); - eframe::start_web("canvas", Box::new(app)) + eframe::start_web("canvas", |cc| Box::new(egui_app::MathApp::new(cc))) } } } diff --git a/src/main.rs b/src/main.rs index 1d2281c..93984c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,11 +9,12 @@ mod parsing; // For running the program natively! (Because why not?) #[cfg(not(target_arch = "wasm32"))] fn main() { - let app = egui_app::MathApp::default(); let options = eframe::NativeOptions { transparent: true, drag_and_drop_support: true, ..Default::default() }; - eframe::run_native(Box::new(app), options); + eframe::run_native("(Yet-to-be-named) Graphing Software", options, |cc| { + Box::new(egui_app::MathApp::new(cc)) + }); }