Update to egui 0.17.0
This commit is contained in:
parent
8f5247e831
commit
a259f2558c
1228
Cargo.lock
generated
1228
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,7 @@ rust-version = "1.56"
|
|||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
eframe = "0.16.0" # Gives us egui, epi and web+native backends
|
||||
eframe = "0.17.0" # Gives us egui, epi and web+native backends
|
||||
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
|
@ -29,3 +29,7 @@ opt-level = 2 # fast and small wasm
|
|||
|
||||
# If you fork https://github.com/emilk/egui you can test with:
|
||||
# eframe = { path = "../egui/eframe" }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_error_panic_hook = "0.1.6"
|
||||
tracing-wasm = "0.2"
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -46,7 +46,7 @@
|
|||
transform: translate(-50%, 0%);
|
||||
}
|
||||
|
||||
.loading {
|
||||
.centered {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
display: block;
|
||||
|
@ -54,9 +54,10 @@
|
|||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: white;
|
||||
color: #f0f0f0;
|
||||
font-size: 24px;
|
||||
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
|
@ -89,25 +90,15 @@
|
|||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="manifest" href="./manifest.json">
|
||||
<script>
|
||||
// register ServiceWorker
|
||||
window.onload = () => {
|
||||
'use strict';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('./sw.js');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- The WASM code will resize this canvas to cover the entire screen -->
|
||||
<!-- The WASM code will resize the canvas dynamically -->
|
||||
<canvas id="the_canvas_id"></canvas>
|
||||
<div class="loading" id="loading">
|
||||
Loading…
|
||||
<div class="centered" id="center_text">
|
||||
<p style="font-size:16px">
|
||||
Loading…
|
||||
</p>
|
||||
<div class="lds-dual-ring"></div>
|
||||
</div>
|
||||
|
||||
|
@ -124,25 +115,40 @@
|
|||
delete WebAssembly.instantiateStreaming;
|
||||
</script>
|
||||
|
||||
<!-- This is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||
<script src="eframe_template.js"></script>
|
||||
|
||||
<script>
|
||||
// We'll defer our execution until the wasm is ready to go.
|
||||
// Here we tell bindgen the path to the wasm file so it can start
|
||||
// initialization and return to us a promise when it's done.
|
||||
console.debug("loading wasm…");
|
||||
wasm_bindgen("./eframe_template_bg.wasm")
|
||||
.then(on_wasm_loaded)
|
||||
.catch(console.error);
|
||||
.catch(on_wasm_error);
|
||||
|
||||
function on_wasm_loaded() {
|
||||
console.log("loaded wasm, starting egui app…");
|
||||
console.debug("wasm loaded. starting app…");
|
||||
|
||||
// This call installs a bunch of callbacks and then returns:
|
||||
wasm_bindgen.start("the_canvas_id");
|
||||
|
||||
console.log("egui app started.");
|
||||
document.getElementById("loading").remove();
|
||||
console.debug("app started.");
|
||||
document.getElementById("center_text").remove();
|
||||
}
|
||||
|
||||
function on_wasm_error(error) {
|
||||
console.error("Failed to start: " + error);
|
||||
document.getElementById("center_text").innerHTML = `
|
||||
<p>
|
||||
An error occurred during loading:
|
||||
</p>
|
||||
<p style="font-family:Courier New">
|
||||
${error}
|
||||
</p>
|
||||
<p style="font-size:14px">
|
||||
Make sure you use a modern browser with WebGL and WASM enabled.
|
||||
</p>`;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -30,7 +30,7 @@ impl epi::App for TemplateApp {
|
|||
/// Called once before the first frame.
|
||||
fn setup(
|
||||
&mut self,
|
||||
_ctx: &egui::CtxRef,
|
||||
_ctx: &egui::Context,
|
||||
_frame: &epi::Frame,
|
||||
_storage: Option<&dyn epi::Storage>,
|
||||
) {
|
||||
|
@ -51,7 +51,7 @@ impl epi::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::CtxRef, frame: &epi::Frame) {
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) {
|
||||
let Self { label, value } = self;
|
||||
|
||||
// Examples of how to create different panels and windows.
|
||||
|
|
|
@ -18,6 +18,12 @@ use eframe::wasm_bindgen::{self, prelude::*};
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
#[wasm_bindgen]
|
||||
pub fn start(canvas_id: &str) -> Result<(), eframe::wasm_bindgen::JsValue> {
|
||||
// Make sure panics are logged using `console.error`.
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
// Redirect tracing to console.log and friends:
|
||||
tracing_wasm::set_as_global_default();
|
||||
|
||||
let app = TemplateApp::default();
|
||||
eframe::start_web(canvas_id, Box::new(app))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue