Storage and frame refactor (#1418)

The purpose of this is to expose `frame.storage()` and `frame.storage_mut()` so users can save/load app state from the `App::update` function, without having to add another parameter to that function.

Changes:
* Added `Frame::storage()` and `Frame::storage_mut()`
* `App::update` now takes a `&mut Frame` rather than just `&Frame`
* `Frame` is no longer `Clone` or `Sync` (doesn't have to be since https://github.com/emilk/egui/pull/1366)
This commit is contained in:
Emil Ernerfeldt
2022-03-25 21:19:31 +01:00
committed by GitHub
parent bc0fdefceb
commit b7ebe16cfb
27 changed files with 157 additions and 199 deletions
+3 -3
View File
@@ -73,7 +73,7 @@ impl Default for BackendPanel {
}
impl BackendPanel {
pub fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) {
pub fn update(&mut self, ctx: &egui::Context, frame: &mut epi::Frame) {
self.frame_history
.on_new_frame(ctx.input().time, frame.info().cpu_usage);
@@ -87,7 +87,7 @@ impl BackendPanel {
self.egui_windows.windows(ctx);
}
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &epi::Frame) {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut epi::Frame) {
egui::trace!(ui);
ui.vertical_centered(|ui| {
ui.heading("💻 Backend");
@@ -142,7 +142,7 @@ impl BackendPanel {
}
}
fn integration_ui(&mut self, ui: &mut egui::Ui, frame: &epi::Frame) {
fn integration_ui(&mut self, ui: &mut egui::Ui, frame: &mut epi::Frame) {
if frame.is_web() {
ui.label("egui is an immediate mode GUI written in Rust, compiled to WebAssembly, rendered with WebGL.");
ui.label(