[demo] add menu option to auto-reorganize windows

This commit is contained in:
Emil Ernerfeldt 2020-08-28 16:21:35 +02:00
parent 559b026b87
commit b8938e01c4
2 changed files with 14 additions and 1 deletions

View file

@ -236,7 +236,14 @@ impl OpenWindows {
fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) {
menu::bar(ui, |ui| {
menu::menu(ui, "File", |ui| {
if ui.add(Button::new("Clear memory")).clicked {
if ui.add(Button::new("Reorganize windows")).clicked {
ui.ctx().memory().reset_areas();
}
if ui
.add(Button::new("Clear entire Egui memory"))
.tooltip_text("Forget scroll, collapsibles etc")
.clicked
{
*ui.ctx().memory() = Default::default();
}
});

View file

@ -152,6 +152,12 @@ impl Memory {
self.interaction.kb_focus_id = None;
}
}
/// Forget window positions, sizes etc.
/// Can be used to auto-layout windows.
pub fn reset_areas(&mut self) {
self.areas = Default::default();
}
}
impl Areas {