From 6185ee8ce48f7f04cae7eb8c72f66238d7fbdb94 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 23 Oct 2021 05:50:42 +0200 Subject: [PATCH] Demo: add button to reset the demo --- egui_demo_lib/src/apps/demo/demo_app_windows.rs | 2 +- egui_demo_lib/src/backend_panel.rs | 8 -------- egui_demo_lib/src/wrap_app.rs | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/egui_demo_lib/src/apps/demo/demo_app_windows.rs b/egui_demo_lib/src/apps/demo/demo_app_windows.rs index 31f380d70..586e1b2c6 100644 --- a/egui_demo_lib/src/apps/demo/demo_app_windows.rs +++ b/egui_demo_lib/src/apps/demo/demo_app_windows.rs @@ -232,7 +232,7 @@ fn show_menu_bar(ui: &mut Ui) { ui.ctx().memory().reset_areas(); } if ui - .button("Clear egui memory") + .button("Reset egui memory") .on_hover_text("Forget scroll, positions, sizes etc") .clicked() { diff --git a/egui_demo_lib/src/backend_panel.rs b/egui_demo_lib/src/backend_panel.rs index 8b5dc4689..c5b25039a 100644 --- a/egui_demo_lib/src/backend_panel.rs +++ b/egui_demo_lib/src/backend_panel.rs @@ -115,14 +115,6 @@ impl BackendPanel { ui.label("egui windows:"); self.egui_windows.checkboxes(ui); - if ui - .button("Clear egui memory") - .on_hover_text("Forget scroll, positions, sizes etc") - .clicked() - { - *ui.ctx().memory() = Default::default(); - } - ui.separator(); { diff --git a/egui_demo_lib/src/wrap_app.rs b/egui_demo_lib/src/wrap_app.rs index 60c706bb3..5a62f3baa 100644 --- a/egui_demo_lib/src/wrap_app.rs +++ b/egui_demo_lib/src/wrap_app.rs @@ -93,6 +93,23 @@ impl epi::App for WrapApp { if self.backend_panel.open || ctx.memory().everything_is_visible() { egui::SidePanel::left("backend_panel").show(ctx, |ui| { self.backend_panel.ui(ui, frame); + + ui.separator(); + + ui.horizontal(|ui| { + if ui + .button("Reset egui") + .on_hover_text("Forget scroll, positions, sizes etc") + .clicked() + { + *ui.ctx().memory() = Default::default(); + } + + if ui.button("Reset everything").clicked() { + *self = Default::default(); + *ui.ctx().memory() = Default::default(); + } + }); }); }