diff --git a/Changelog.md b/Changelog.md index 0dedcb1..10460b2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,6 @@ # Changelog -## V0.2.0 +## v0.2.0 — Coming Soon - Convert slice operation window to a dockable panel - Render parts of models that go beyond the print volume red diff --git a/TODO.md b/TODO.md index d2dd37e..a1723fb 100644 --- a/TODO.md +++ b/TODO.md @@ -97,3 +97,5 @@ - [x] Random triangle color render mode - [ ] Dont clone Config every frame for no reason - [x] Add button to reset UI +- [ ] Put all models in the same segments1d to improve slicing times with supports? +- [ ] Island detection diff --git a/mslicer/src/windows/mod.rs b/mslicer/src/windows/mod.rs index 4d0192c..9416ef1 100644 --- a/mslicer/src/windows/mod.rs +++ b/mslicer/src/windows/mod.rs @@ -37,6 +37,17 @@ pub enum Tab { } impl Tab { + const ALL: [Tab; 8] = [ + Tab::About, + Tab::Logs, + Tab::Models, + Tab::RemotePrint, + Tab::SliceConfig, + Tab::SliceOperation, + Tab::Supports, + Tab::Workspace, + ]; + pub fn name(&self) -> &'static str { match self { Tab::About => "About", @@ -73,25 +84,22 @@ impl TabViewer for Tabs<'_> { } } - fn add_popup(&mut self, ui: &mut Ui, _surface: SurfaceIndex, _node: NodeIndex) { + fn add_popup(&mut self, ui: &mut Ui, surface: SurfaceIndex, node: NodeIndex) { ui.set_min_width(120.0); ui.style_mut().visuals.button_frame = false; - for tab in [ - Tab::About, - Tab::Logs, - Tab::Models, - Tab::RemotePrint, - Tab::SliceConfig, - Tab::SliceOperation, - Tab::Supports, - Tab::Workspace, - ] { - let already_open = self.app.dock_state.find_tab(&tab).is_some(); - if !already_open { - ui.button(tab.name()) - .clicked() - .then(|| self.app.dock_state.add_window(vec![tab])); + let dock_state = &mut self.app.dock_state; + + for tab in Tab::ALL { + let already_open = dock_state.find_tab(&tab).is_some(); + if !already_open && ui.button(tab.name()).clicked() { + if let Some(surface) = dock_state.get_surface_mut(surface) { + let tree = surface.node_tree_mut().unwrap(); + tree.set_focused_node(node); + tree.push_to_focused_leaf(tab); + } else { + dock_state.add_window(vec![tab]); + } } } } diff --git a/mslicer/src/windows/models.rs b/mslicer/src/windows/models.rs index e92e71e..172da88 100644 --- a/mslicer/src/windows/models.rs +++ b/mslicer/src/windows/models.rs @@ -59,7 +59,7 @@ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) { .show(ui, |ui| { ui.label("Actions"); ui.vertical(|ui| { - ui.horizontal(|ui| { + ui.horizontal_wrapped(|ui| { ui.button(concatcp!(TRASH, " Delete")) .clicked() .then(|| action = Action::Remove(i)); @@ -69,9 +69,7 @@ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) { ui.button(concatcp!(ARROW_LINE_DOWN, " Align to Bed")) .clicked() .then(|| mesh.align_to_bed()); - }); - ui.horizontal(|ui| { ui.menu_button(concatcp!(VECTOR_THREE, " Normals"), |ui| { if ui .button(concatcp!(ARROWS_CLOCKWISE, " Recompute")) diff --git a/mslicer/src/windows/top_bar.rs b/mslicer/src/windows/top_bar.rs index 15b5e2c..ebf74a0 100644 --- a/mslicer/src/windows/top_bar.rs +++ b/mslicer/src/windows/top_bar.rs @@ -85,11 +85,6 @@ 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)); diff --git a/mslicer/src/windows/workspace.rs b/mslicer/src/windows/workspace.rs index 1b200ee..2dfacdf 100644 --- a/mslicer/src/windows/workspace.rs +++ b/mslicer/src/windows/workspace.rs @@ -1,7 +1,7 @@ use const_format::concatcp; use eframe::Theme; use egui::{ComboBox, Context, DragValue, Grid, Ui}; -use egui_phosphor::regular::{ARROW_COUNTER_CLOCKWISE, FOLDER}; +use egui_phosphor::regular::{ARROW_COUNTER_CLOCKWISE, FOLDER, LAYOUT}; use tracing::error; use crate::{ @@ -13,7 +13,7 @@ use crate::{ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) { ui.heading("Config"); - ui.horizontal(|ui| { + ui.horizontal_wrapped(|ui| { if ui .button(concatcp!(FOLDER, " Open Config Directory")) .clicked() @@ -29,6 +29,10 @@ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) { { app.config = Default::default(); } + + if ui.button(concatcp!(LAYOUT, " Reset UI")).clicked() { + app.reset_ui(); + } }); ui.add_space(8.0);