wip: gui_status, should use a hashset?

This commit is contained in:
Jack Wills
2022-10-14 21:26:20 +00:00
parent 46ffbeef6a
commit 90e26c300e
7 changed files with 240 additions and 192 deletions
+21 -2
View File
@@ -173,6 +173,17 @@ impl fmt::Display for Loading {
}
}
/// The application can be in these four states
/// Various functions (e.g input handler), operate differently depending upon current Status
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Status {
Init,
Help,
DockerConnect,
Error,
Normal,
}
/// Global gui_state, stored in an Arc<Mutex>
#[derive(Debug, Clone)]
pub struct GuiState {
@@ -180,8 +191,8 @@ pub struct GuiState {
heading_map: HashMap<Header, Rect>,
loading_icon: Loading,
is_loading: HashSet<Uuid>,
status: Status,
pub selected_panel: SelectablePanel,
pub show_help: bool,
pub info_box_text: Option<String>,
}
impl GuiState {
@@ -192,9 +203,9 @@ impl GuiState {
heading_map: HashMap::new(),
loading_icon: Loading::One,
selected_panel: SelectablePanel::Containers,
show_help: false,
is_loading: HashSet::new(),
info_box_text: None,
status: Status::Init,
}
}
@@ -242,6 +253,14 @@ impl GuiState {
};
}
pub fn set_status(&mut self, status: Status) {
self.status = status
}
pub fn get_status(&self) -> Status {
self.status
}
/// Change to next selectable panel
pub fn next_panel(&mut self) {
self.selected_panel = self.selected_panel.next();