UI Cleanup

This commit is contained in:
Connor Slade
2025-02-17 00:22:54 -05:00
parent ca752806d8
commit 7b06fae684
6 changed files with 34 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
# Changelog # Changelog
## V0.2.0 ## v0.2.0 — Coming Soon
- Convert slice operation window to a dockable panel - Convert slice operation window to a dockable panel
- Render parts of models that go beyond the print volume red - Render parts of models that go beyond the print volume red

View File

@@ -97,3 +97,5 @@
- [x] Random triangle color render mode - [x] Random triangle color render mode
- [ ] Dont clone Config every frame for no reason - [ ] Dont clone Config every frame for no reason
- [x] Add button to reset UI - [x] Add button to reset UI
- [ ] Put all models in the same segments1d to improve slicing times with supports?
- [ ] Island detection

View File

@@ -37,6 +37,17 @@ pub enum Tab {
} }
impl 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 { pub fn name(&self) -> &'static str {
match self { match self {
Tab::About => "About", 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.set_min_width(120.0);
ui.style_mut().visuals.button_frame = false; ui.style_mut().visuals.button_frame = false;
for tab in [ let dock_state = &mut self.app.dock_state;
Tab::About,
Tab::Logs, for tab in Tab::ALL {
Tab::Models, let already_open = dock_state.find_tab(&tab).is_some();
Tab::RemotePrint, if !already_open && ui.button(tab.name()).clicked() {
Tab::SliceConfig, if let Some(surface) = dock_state.get_surface_mut(surface) {
Tab::SliceOperation, let tree = surface.node_tree_mut().unwrap();
Tab::Supports, tree.set_focused_node(node);
Tab::Workspace, tree.push_to_focused_leaf(tab);
] { } else {
let already_open = self.app.dock_state.find_tab(&tab).is_some(); dock_state.add_window(vec![tab]);
if !already_open { }
ui.button(tab.name())
.clicked()
.then(|| self.app.dock_state.add_window(vec![tab]));
} }
} }
} }

View File

@@ -59,7 +59,7 @@ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) {
.show(ui, |ui| { .show(ui, |ui| {
ui.label("Actions"); ui.label("Actions");
ui.vertical(|ui| { ui.vertical(|ui| {
ui.horizontal(|ui| { ui.horizontal_wrapped(|ui| {
ui.button(concatcp!(TRASH, " Delete")) ui.button(concatcp!(TRASH, " Delete"))
.clicked() .clicked()
.then(|| action = Action::Remove(i)); .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")) ui.button(concatcp!(ARROW_LINE_DOWN, " Align to Bed"))
.clicked() .clicked()
.then(|| mesh.align_to_bed()); .then(|| mesh.align_to_bed());
});
ui.horizontal(|ui| {
ui.menu_button(concatcp!(VECTOR_THREE, " Normals"), |ui| { ui.menu_button(concatcp!(VECTOR_THREE, " Normals"), |ui| {
if ui if ui
.button(concatcp!(ARROWS_CLOCKWISE, " Recompute")) .button(concatcp!(ARROWS_CLOCKWISE, " Recompute"))

View File

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

View File

@@ -1,7 +1,7 @@
use const_format::concatcp; use const_format::concatcp;
use eframe::Theme; use eframe::Theme;
use egui::{ComboBox, Context, DragValue, Grid, Ui}; 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 tracing::error;
use crate::{ use crate::{
@@ -13,7 +13,7 @@ use crate::{
pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) { pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) {
ui.heading("Config"); ui.heading("Config");
ui.horizontal(|ui| { ui.horizontal_wrapped(|ui| {
if ui if ui
.button(concatcp!(FOLDER, " Open Config Directory")) .button(concatcp!(FOLDER, " Open Config Directory"))
.clicked() .clicked()
@@ -29,6 +29,10 @@ pub fn ui(app: &mut App, ui: &mut Ui, _ctx: &Context) {
{ {
app.config = Default::default(); app.config = Default::default();
} }
if ui.button(concatcp!(LAYOUT, " Reset UI")).clicked() {
app.reset_ui();
}
}); });
ui.add_space(8.0); ui.add_space(8.0);