From 9cbd1020cac9fda9a141c5c5e4ed8985c3c2b908 Mon Sep 17 00:00:00 2001 From: Michael Mikovsky <77305074+Astatin3@users.noreply.github.com> Date: Thu, 4 Dec 2025 09:55:22 -0700 Subject: [PATCH] Work on paylaod config, move config buttons to titlebar --- unshell-gui/src/app/mod.rs | 16 ++++-- unshell-gui/src/config/mod.rs | 75 ++++++++++++++------------ unshell-gui/src/flowchart/flowchart.rs | 6 +++ unshell-gui/src/lib.rs | 1 + unshell-gui/src/payload_config/mod.rs | 18 +++++++ 5 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 unshell-gui/src/payload_config/mod.rs diff --git a/unshell-gui/src/app/mod.rs b/unshell-gui/src/app/mod.rs index b79f696..c6dfe51 100644 --- a/unshell-gui/src/app/mod.rs +++ b/unshell-gui/src/app/mod.rs @@ -3,7 +3,10 @@ mod windows; use std::collections::HashMap; -use crate::{app::windows::WindowWrapper, auth::Auth, config::Config, flowchart::FlowChart}; +use crate::{ + app::windows::WindowWrapper, auth::Auth, config::Config, flowchart::FlowChart, + payload_config::PayloadConfig, +}; pub use app::TemplateApp; use egui_tiles::{TileId, Tree}; @@ -15,12 +18,14 @@ pub struct AppState { pub flowchart: FlowChart, pub config: Config, + pub payload_config: PayloadConfig, } impl AppState { pub fn labels(&mut self, tree: &mut Tree, ui: &mut egui::Ui) { for (_, (key, name)) in (vec![ (AppWindow::Flowchart, "Flowchart"), + (AppWindow::PayloadConfig, "Payload Config"), (AppWindow::Config, "Config"), ]) .iter() @@ -69,6 +74,7 @@ impl AppState { pub enum AppWindow { Flowchart, Config, + PayloadConfig, } impl AppWindow { @@ -76,15 +82,17 @@ impl AppWindow { match self { AppWindow::Flowchart => state.flowchart.paint(ui), AppWindow::Config => state.config.update(&mut state.auth, ui), + AppWindow::PayloadConfig => state.payload_config.update(ui), } } fn render_title_buttons(&self, state: &mut AppState, ui: &mut egui::Ui) { match self { AppWindow::Flowchart => { - if ui.button("Arrange").clicked() { - state.flowchart.arrange(); - } + state.flowchart.titlebar_buttons(ui); + } + AppWindow::Config => { + state.config.titlebar_buttons(ui); } _ => { ui.label(""); diff --git a/unshell-gui/src/config/mod.rs b/unshell-gui/src/config/mod.rs index 0ec9909..350160d 100644 --- a/unshell-gui/src/config/mod.rs +++ b/unshell-gui/src/config/mod.rs @@ -58,17 +58,6 @@ impl Config { drop(state_lock); ui.horizontal(|ui| { - if ui.button("Refresh").clicked() { - // self.tree_option.clear(); - let mut state_lock = self.state.lock().unwrap(); - (*state_lock).trees = None; - (*state_lock).tree_keys = None; - drop(state_lock); - - tree_list_none = true; - key_list_none = true; - } - if tree_list_none && !is_requesting { self.state.lock().unwrap().is_requesting = true; let state_clone = self.state.clone(); @@ -83,28 +72,9 @@ impl Config { ui.spinner(); } - let state_lock = self.state.lock().unwrap(); - // This might have changed since the above api call - tree_list_none = state_lock.trees.is_none(); - - if !tree_list_none { - let trees = state_lock.trees.as_ref().unwrap().clone(); - drop(state_lock); - - let before = &self.tree_option.clone(); - egui::ComboBox::from_id_salt("Select Tree") - .selected_text(&self.tree_option) - .show_ui(ui, |ui| { - for tree in trees { - ui.selectable_value(&mut self.tree_option, tree.clone(), tree); - } - }); - - if before.ne(&self.tree_option) { - (*self.state.lock().unwrap()).tree_keys = None; - key_list_none = true; - } - } + // let state_lock = self.state.lock().unwrap(); + // // This might have changed since the above api call + // tree_list_none = state_lock.trees.is_none(); if !self.tree_option.is_empty() && !tree_list_none { // ui.horizontal(|ui| { @@ -179,4 +149,43 @@ impl Config { // }); } } + + pub fn titlebar_buttons(&mut self, ui: &mut egui::Ui) { + let state_lock = self.state.lock().unwrap(); + let mut tree_list_none = state_lock.trees.is_none(); + let mut key_list_none = state_lock.tree_keys.is_none(); + let is_requesting = state_lock.is_requesting; + drop(state_lock); + + if ui.button("Refresh").clicked() { + let mut state_lock = self.state.lock().unwrap(); + + (*state_lock).trees = None; + (*state_lock).tree_keys = None; + drop(state_lock); + + tree_list_none = true; + key_list_none = true; + } + + if !tree_list_none { + let state_lock = self.state.lock().unwrap(); + let trees = state_lock.trees.as_ref().unwrap().clone(); + drop(state_lock); + + let before = &self.tree_option.clone(); + egui::ComboBox::from_id_salt("Select Tree") + .selected_text(&self.tree_option) + .show_ui(ui, |ui| { + for tree in trees { + ui.selectable_value(&mut self.tree_option, tree.clone(), tree); + } + }); + + if before.ne(&self.tree_option) { + (*self.state.lock().unwrap()).tree_keys = None; + key_list_none = true; + } + } + } } diff --git a/unshell-gui/src/flowchart/flowchart.rs b/unshell-gui/src/flowchart/flowchart.rs index 27d975a..33e273e 100644 --- a/unshell-gui/src/flowchart/flowchart.rs +++ b/unshell-gui/src/flowchart/flowchart.rs @@ -145,4 +145,10 @@ impl FlowChart { self.scene_rect = inner_rect; } } + + pub fn titlebar_buttons(&mut self, ui: &mut egui::Ui) { + if ui.button("Arrange").clicked() { + self.arrange(); + } + } } diff --git a/unshell-gui/src/lib.rs b/unshell-gui/src/lib.rs index 98b1660..1d6a030 100644 --- a/unshell-gui/src/lib.rs +++ b/unshell-gui/src/lib.rs @@ -7,6 +7,7 @@ pub mod app; mod auth; mod config; mod flowchart; +mod payload_config; use std::time::Duration; const FORCE_REDRAW_DELAY: Duration = Duration::from_millis(300); diff --git a/unshell-gui/src/payload_config/mod.rs b/unshell-gui/src/payload_config/mod.rs new file mode 100644 index 0000000..aa9d412 --- /dev/null +++ b/unshell-gui/src/payload_config/mod.rs @@ -0,0 +1,18 @@ +#[derive(serde::Deserialize, serde::Serialize)] +pub struct PayloadConfig {} + +struct ServerConfigState { + // config: Vec +} + +impl PayloadConfig { + pub fn update(&mut self, ui: &mut egui::Ui) { + ui.heading("Test"); + } +} + +impl Default for PayloadConfig { + fn default() -> Self { + Self {} + } +}