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
## 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

View File

@@ -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

View File

@@ -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]);
}
}
}
}

View File

@@ -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"))

View File

@@ -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));

View File

@@ -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);