diff options
author | Silas Bartha <[email protected]> | 2024-05-16 20:28:58 -0400 |
---|---|---|
committer | Silas Bartha <[email protected]> | 2024-05-16 20:28:58 -0400 |
commit | 56aafda8495243fa939bdce01f36d4adbf4ec556 (patch) | |
tree | df8b1bbe1dc0e8b3f2d179a36c015b16e1f3d483 /src/systems.rs | |
parent | 363157a7f831fc29c6ed1a26880ea756521317b9 (diff) |
Added configurable logfile path
Diffstat (limited to 'src/systems.rs')
-rw-r--r-- | src/systems.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/systems.rs b/src/systems.rs index b0055b9..dedef65 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -8,8 +8,7 @@ use grex_framebuffer_extract::{ }; use crate::{ - events::TerminalInputEvent, - resources::{EventQueue, Terminal, TerminalInput, TerminalUI}, + components::Widget, events::TerminalInputEvent, resources::{EventQueue, Terminal, TerminalInput} }; use ratatui::{ @@ -40,7 +39,7 @@ pub fn setup(event_queue: Res<EventQueue>) { pub fn print_to_terminal( mut terminal: ResMut<Terminal>, - mut terminal_ui: ResMut<TerminalUI>, + mut widgets: Query<&mut Widget>, image_exports: Query<&FramebufferExtractDestination>, ) { for image_export in image_exports.iter() { @@ -96,8 +95,10 @@ pub fn print_to_terminal( .wrap(Wrap { trim: true }), area, ); - for widget in terminal_ui.widgets().iter_mut() { - widget.render(frame, area); + let mut active_widgets = widgets.iter_mut().filter(|widget| widget.enabled).collect::<Vec<_>>(); + active_widgets.sort_by(|a, b| a.depth.cmp(&b.depth)); + for mut widget in active_widgets { + widget.widget.render(frame, area); } }) .expect("Failed to draw terminal frame"); @@ -117,13 +118,13 @@ fn braille_char(mask: u8) -> char { } pub fn widget_input_handling( - mut terminal_ui: ResMut<TerminalUI>, + mut widgets: Query<&mut Widget>, mut event_reader: EventReader<TerminalInputEvent>, mut commands: Commands, ) { for event in event_reader.read() { - for widget in terminal_ui.widgets().iter_mut() { - widget.handle_events(event, &mut commands); + for mut widget in widgets.iter_mut().filter(|widget| widget.enabled) { + widget.widget.handle_events(event, &mut commands); } } } |