added setting to clear canvas

This commit is contained in:
grimsace
2026-03-23 11:49:24 -05:00
parent f46a9d5b90
commit 68d45956ac
2 changed files with 27 additions and 4 deletions
+18 -1
View File
@@ -97,7 +97,9 @@ impl eframe::App for DungeonApp {
self.settings.max_corridor_width = self.settings.min_corridor_width; self.settings.max_corridor_width = self.settings.min_corridor_width;
} }
if panel_result.reset_clicked || panel_result.settings_changed { if panel_result.clear_clicked {
self.clear_layout();
} else if panel_result.reset_clicked || panel_result.settings_changed {
self.regenerate_layout(); self.regenerate_layout();
} }
if ctx.input(|i| i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace)) { if ctx.input(|i| i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace)) {
@@ -208,6 +210,21 @@ impl eframe::App for DungeonApp {
} }
impl DungeonApp { impl DungeonApp {
// Clear the current layout and reset transient interaction state.
fn clear_layout(&mut self) {
self.layout = DungeonLayout {
packed_rooms: self.settings.pack_rooms_without_corridors,
..DungeonLayout::default()
};
self.drag_state = None;
self.add_corridor_drag = None;
self.resize_state = None;
self.hover_room_idx = None;
self.hover_corridor_idx = None;
self.hover_door_idx = None;
self.pending_delete = false;
}
// Regenerate the dungeon layout from current settings and reset drag state. // Regenerate the dungeon layout from current settings and reset drag state.
fn regenerate_layout(&mut self) { fn regenerate_layout(&mut self) {
self.drag_state = None; self.drag_state = None;
+9 -3
View File
@@ -172,6 +172,7 @@ pub enum AddTool {
pub struct SidePanelResult { pub struct SidePanelResult {
pub settings_changed: bool, pub settings_changed: bool,
pub reset_clicked: bool, pub reset_clicked: bool,
pub clear_clicked: bool,
pub export_clicked: bool, pub export_clicked: bool,
} }
@@ -273,9 +274,14 @@ fn draw_generate_tab(
}); });
ui.add_space(8.0); ui.add_space(8.0);
if ui.button("Reset").clicked() { ui.horizontal(|ui| {
result.reset_clicked = true; if ui.button("Reset").clicked() {
} result.reset_clicked = true;
}
if ui.button("Clear").clicked() {
result.clear_clicked = true;
}
});
ui.add_space(12.0); ui.add_space(12.0);
ui.separator(); ui.separator();