Add button to reset UI

This commit is contained in:
Connor Slade
2025-02-16 16:10:54 -05:00
parent 74ac8b88a2
commit 27e462e335
3 changed files with 21 additions and 7 deletions

View File

@@ -96,4 +96,4 @@
- [ ] Save panel layout
- [x] Random triangle color render mode
- [ ] Dont clone Config every frame for no reason
- [ ] Add button to reset UI
- [x] Add button to reset UI

View File

@@ -81,12 +81,7 @@ impl App {
if let Some(past_state) = &mut config.panels {
*surface = mem::take(past_state);
} else {
surface.split_right(NodeIndex::root(), 0.7, vec![Tab::About]);
let [_old_node, new_node] =
surface.split_left(NodeIndex::root(), 0.2, vec![Tab::Models]);
let [_old_node, new_node] =
surface.split_below(new_node, 0.5, vec![Tab::SliceConfig, Tab::Supports]);
surface.split_below(new_node, 0.5, vec![Tab::Workspace, Tab::RemotePrint]);
default_dock_layoyt(surface);
}
if surface.find_tab(&Tab::Viewport).is_none() {
@@ -228,6 +223,12 @@ impl App {
self.meshes.write().push(rendered_mesh);
}
pub fn reset_ui(&mut self) {
self.dock_state = DockState::new(vec![Tab::Viewport]);
let surface = self.dock_state.main_surface_mut();
default_dock_layoyt(surface);
}
}
impl eframe::App for App {
@@ -286,3 +287,11 @@ impl FpsTracker {
self.last_frame_time
}
}
fn default_dock_layoyt(surface: &mut Tree<Tab>) {
surface.split_right(NodeIndex::root(), 0.7, vec![Tab::About]);
let [_old_node, new_node] = surface.split_left(NodeIndex::root(), 0.2, vec![Tab::Models]);
let [_old_node, new_node] =
surface.split_below(new_node, 0.5, vec![Tab::SliceConfig, Tab::Supports]);
surface.split_below(new_node, 0.5, vec![Tab::Workspace, Tab::RemotePrint]);
}

View File

@@ -85,6 +85,11 @@ pub fn ui(app: &mut App, ctx: &Context) {
ui.separator();
if ui.button("Reset UI").clicked() {
app.reset_ui();
ui.close_menu();
}
let quit_button =
ui.add(Button::new("Quit").shortcut_text(ctx.format_shortcut(&QUIT_SHORTCUT)));
quit_button.clicked().then(|| quit(ctx));