Add button to reset UI
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -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
|
||||
|
@@ -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]);
|
||||
}
|
||||
|
@@ -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));
|
||||
|
Reference in New Issue
Block a user