mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Improve view open and close code
This commit is contained in:
+10
-11
@@ -35,13 +35,15 @@ impl AppState {
|
|||||||
|
|
||||||
if ui.selectable_label(enabled, *name).clicked() {
|
if ui.selectable_label(enabled, *name).clicked() {
|
||||||
if enabled {
|
if enabled {
|
||||||
// if let Some(tid) = Self::find_pane_id(*key, tree) {
|
self.close_window(tree, key);
|
||||||
// tree.remove_recursively(*tid);
|
} else {
|
||||||
// tree.tiles.remove(*tid);
|
self.open_window(tree, key, name);
|
||||||
// self.open_windows.remove(&key);
|
}
|
||||||
// }
|
}
|
||||||
// let tid = *self.open_windows.get(&key).unwrap();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn close_window(&mut self, tree: &mut Tree<WindowWrapper>, key: &AppWindow) {
|
||||||
match Self::find_pane_id(*key, tree) {
|
match Self::find_pane_id(*key, tree) {
|
||||||
Some(tid) => {
|
Some(tid) => {
|
||||||
let tid = tid.clone();
|
let tid = tid.clone();
|
||||||
@@ -51,9 +53,9 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
None => unreachable!(),
|
None => unreachable!(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if self.open_windows.is_empty()
|
pub fn open_window(&mut self, tree: &mut Tree<WindowWrapper>, key: &AppWindow, name: &str) {
|
||||||
} else {
|
|
||||||
let tid = tree.tiles.insert_pane(WindowWrapper {
|
let tid = tree.tiles.insert_pane(WindowWrapper {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
window: *key,
|
window: *key,
|
||||||
@@ -77,9 +79,6 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
self.open_windows.insert(key.clone());
|
self.open_windows.insert(key.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_pane_id(window_type: AppWindow, tree: &Tree<WindowWrapper>) -> Option<&TileId> {
|
fn find_pane_id(window_type: AppWindow, tree: &Tree<WindowWrapper>) -> Option<&TileId> {
|
||||||
for (tid, window) in tree.tiles.iter() {
|
for (tid, window) in tree.tiles.iter() {
|
||||||
|
|||||||
Reference in New Issue
Block a user