Update to egui/eframe 0.19.0
This commit is contained in:
parent
08b025b4e4
commit
88e0b19c50
666
Cargo.lock
generated
666
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -9,8 +9,8 @@ rust-version = "1.60"
|
|||
|
||||
|
||||
[dependencies]
|
||||
egui = "0.18.0"
|
||||
eframe = { version = "0.18.0", features = ["persistence"] }
|
||||
egui = "0.19.0"
|
||||
eframe = { version = "0.19.0", features = ["persistence"] }
|
||||
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
|
||||
|
||||
# native:
|
||||
|
@ -34,5 +34,5 @@ opt-level = 2 # fast and small wasm
|
|||
# eframe = { git = "https://github.com/emilk/egui", branch = "master" }
|
||||
|
||||
# If you fork https://github.com/emilk/egui you can test with:
|
||||
# egui = { path = "../egui/egui" }
|
||||
# eframe = { path = "../egui/eframe" }
|
||||
# egui = { path = "../egui/crates/egui" }
|
||||
# eframe = { path = "../egui/crates/eframe" }
|
||||
|
|
|
@ -51,8 +51,8 @@ You can compile your app to [WASM](https://en.wikipedia.org/wiki/WebAssembly) an
|
|||
|
||||
We use [Trunk](https://trunkrs.dev/) to build for web target.
|
||||
1. Install Trunk with `cargo install --locked trunk`.
|
||||
2. run `trunk serve` to build and serve on `http://127.0.0.1:8080`. will rebuild automatically if you edit the project.
|
||||
3. open `http://127.0.0.1:8080/index.html#dev` in a browser. see the warning below.
|
||||
2. Run `trunk serve` to build and serve on `http://127.0.0.1:8080`. Trunk will rebuild automatically if you edit the project.
|
||||
3. Open `http://127.0.0.1:8080/index.html#dev` in a browser. See the warning below.
|
||||
|
||||
> `assets/sw.js` script will try to cache our app, and loads the cached version when it cannot connect to server allowing your app to work offline (like PWA).
|
||||
> appending `#dev` to `index.html` will skip this caching, allowing us to load the latest builds during development.
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
overflow: hidden;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Position canvas in center-top: */
|
||||
|
|
|
@ -44,7 +44,7 @@ impl eframe::App for TemplateApp {
|
|||
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
let Self { label, value } = self;
|
||||
|
||||
// Examples of how to create different panels and windows.
|
||||
|
@ -52,12 +52,13 @@ impl eframe::App for TemplateApp {
|
|||
// Tip: a good default choice is to just keep the `CentralPanel`.
|
||||
// For inspiration and more examples, go to https://emilk.github.io/egui
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages!
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
egui::menu::bar(ui, |ui| {
|
||||
ui.menu_button("File", |ui| {
|
||||
if ui.button("Quit").clicked() {
|
||||
frame.quit();
|
||||
_frame.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ fn main() {
|
|||
Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))),
|
||||
);
|
||||
}
|
||||
|
||||
// when compiling to web using trunk.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn main() {
|
||||
|
@ -23,8 +24,10 @@ fn main() {
|
|||
// Redirect tracing to console.log and friends:
|
||||
tracing_wasm::set_as_global_default();
|
||||
|
||||
let web_options = eframe::WebOptions::default();
|
||||
eframe::start_web(
|
||||
"the_canvas_id", // hardcode it
|
||||
web_options,
|
||||
Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))),
|
||||
)
|
||||
.expect("failed to start eframe");
|
||||
|
|
Loading…
Reference in a new issue