egui: eframe-app-creation-refactor
This commit is contained in:
parent
5e9dc18469
commit
5d5b959f0d
@ -22,7 +22,7 @@ opt-level = 2
|
|||||||
lto = false
|
lto = false
|
||||||
|
|
||||||
[dependencies]
|
[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 }
|
shadow-rs = { version = "0.9", default-features = false }
|
||||||
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use egui::{
|
|||||||
Button, CentralPanel, Color32, ComboBox, Context, FontData, FontDefinitions, FontFamily,
|
Button, CentralPanel, Color32, ComboBox, Context, FontData, FontDefinitions, FontFamily,
|
||||||
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
||||||
};
|
};
|
||||||
use epi::{Frame, Storage};
|
use epi::Frame;
|
||||||
use instant::Duration;
|
use instant::Duration;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use shadow_rs::shadow;
|
use shadow_rs::shadow;
|
||||||
@ -318,6 +318,14 @@ impl Default for MathApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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) {
|
fn side_panel(&mut self, ctx: &Context) {
|
||||||
// Side Panel which contains vital options to the operation of the application
|
// Side Panel which contains vital options to the operation of the application
|
||||||
// (such as adding functions and other options)
|
// (such as adding functions and other options)
|
||||||
@ -497,19 +505,6 @@ impl MathApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl epi::App for 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<epi::glow::Context>,
|
|
||||||
) {
|
|
||||||
#[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.
|
// Called each time the UI needs repainting, which may be many times per second.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn update(&mut self, ctx: &Context, _frame: &Frame) {
|
fn update(&mut self, ctx: &Context, _frame: &Frame) {
|
||||||
|
|||||||
@ -27,8 +27,7 @@ cfg_if::cfg_if! {
|
|||||||
log_helper("Finished initializing!");
|
log_helper("Finished initializing!");
|
||||||
|
|
||||||
log_helper("Starting App...");
|
log_helper("Starting App...");
|
||||||
let app = egui_app::MathApp::default();
|
eframe::start_web("canvas", |cc| Box::new(egui_app::MathApp::new(cc)))
|
||||||
eframe::start_web("canvas", Box::new(app))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,11 +9,12 @@ mod parsing;
|
|||||||
// For running the program natively! (Because why not?)
|
// For running the program natively! (Because why not?)
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = egui_app::MathApp::default();
|
|
||||||
let options = eframe::NativeOptions {
|
let options = eframe::NativeOptions {
|
||||||
transparent: true,
|
transparent: true,
|
||||||
drag_and_drop_support: true,
|
drag_and_drop_support: true,
|
||||||
..Default::default()
|
..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))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user