Start work on server

This commit is contained in:
Michael Mikovsky
2025-11-28 18:39:14 -07:00
parent 598068d3ee
commit fcb8c6f6f5
13 changed files with 1800 additions and 613 deletions
+28 -74
View File
@@ -3,11 +3,9 @@ mod windows;
use std::collections::HashMap;
use crate::{app::windows::WindowWrapper, config::Config, flowchart::FlowChart};
pub use app::TemplateApp;
use egui_tiles::{TileId, Tree};
use log::info;
use crate::{app::windows::WindowWrapper, config::Config, flowchart::FlowChart};
#[derive(Default, serde::Deserialize, serde::Serialize)]
struct AppState {
@@ -29,87 +27,44 @@ impl AppState {
let enabled = self.open_windows.contains_key(&key);
if ui.selectable_label(enabled, *name).clicked() {
// if enabled {
// let tid = *self.open_windows.get(&key).unwrap();
// tree.remove_recursively(tid);
// tree.tiles.remove(tid);
// self.open_windows.remove(&key);
if enabled {
let tid = *self.open_windows.get(&key).unwrap();
tree.remove_recursively(tid);
tree.tiles.remove(tid);
self.open_windows.remove(&key);
// // if self.open_windows.is_empty()
// } else {
let tid = tree.tiles.insert_pane(WindowWrapper {
nr: i + 1,
window: *key,
});
// if self.open_windows.is_empty()
} else {
let tid = tree.tiles.insert_pane(WindowWrapper {
nr: i + 1,
window: *key,
});
match self.open_windows.len() {
0 => {
tree.root = Some(tid);
}
1 => {
let old_root = tree.root.unwrap();
let tab_id = tree.tiles.insert_tab_tile(vec![old_root, tid]);
tree.root = Some(tab_id);
}
_ => {
let pid = tree.tiles.insert_tab_tile(vec![tid]);
tree.move_tile_to_container(pid, tree.root.unwrap().clone(), 0, true);
match self.open_windows.len() {
0 => {
tree.root = Some(tid);
}
1 => {
let old_root = tree.root.unwrap();
let tab_id = tree.tiles.insert_tab_tile(vec![old_root, tid]);
tree.root = Some(tab_id);
tree.make_active(|t, _| t == tid);
}
_ => {
let root = tree.root().unwrap();
let n = tree.tiles.get_container(root).unwrap().num_children();
tree.move_tile_to_container(tid, tree.root.unwrap().clone(), n, true);
}
}
self.open_windows.insert(key.clone(), tid);
}
self.open_windows.insert(key.clone(), tid);
}
}
// if ui
// .selectable_label(
// self.open_windows.contains_key(&AppWindow::Flowchart),
// "Network",
// )
// .clicked()
// {
// // self.open_windows. = Tab::Flowchart;
// }
// if ui
// .selectable_label(self.open_windows.contains_key(&AppWindow::Config), "Config")
// .clicked()
// {
// // self.open_windows. = Tab::Flowchart;
// }
// if ui
// .selectable_label(self.tab == Tab::Test, self.config.title())
// .clicked()
// {
// self.tab = Tab::Test;
// }
}
// fn contains(&self, key: &AppWindow)
// fn toggle(&mut self, key: &AppWindow) {
// if self.
// }
}
// impl Default for AppState {
// fn default() -> Self {
// Self {
// open_windows: HashMap::from([
// (AppWindow::Flowchart, false),
// (AppWindow::Config, false),
// ]),
// flowchart: Default::default(),
// config: Default::default(),
// }
// }
// }
#[derive(Clone, Copy, serde::Deserialize, serde::Serialize, PartialEq, Eq, Hash)]
enum AppWindow {
None,
Flowchart,
Config,
}
@@ -117,7 +72,6 @@ enum AppWindow {
impl AppWindow {
fn update(&self, state: &mut AppState, ui: &mut egui::Ui) {
match self {
AppWindow::None => {}
AppWindow::Flowchart => state.flowchart.paint(ui),
AppWindow::Config => state.config.update(ui),
}