aboutsummaryrefslogtreecommitdiff
path: root/src/display/systems.rs
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-05 10:53:49 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-05 10:54:40 -0400
commit2c44bf5efa1fa0894057eb4ed87dc88c9484c2e7 (patch)
tree8470eb1da103f5149ac9227d3b359637cf526c51 /src/display/systems.rs
parent8fe2406277eb11719a03122b82199c06e0f54ed0 (diff)
Moved widget rendering back into display system
Diffstat (limited to 'src/display/systems.rs')
-rw-r--r--src/display/systems.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/display/systems.rs b/src/display/systems.rs
index a768af5..037f72d 100644
--- a/src/display/systems.rs
+++ b/src/display/systems.rs
@@ -2,16 +2,16 @@ use bevy::{
prelude::*,
render::render_resource::{Extent3d, TextureFormat},
};
-use crossterm::event::Event;
use bevy_framebuffer_extract::{
components::FramebufferExtractDestination, render_assets::FramebufferExtractSource,
};
+use crossterm::event::Event;
use ratatui::{
style::Stylize,
widgets::{Paragraph, Wrap},
};
-use crate::input::events::TerminalInputEvent;
+use crate::{input::events::TerminalInputEvent, widgets::components::Widget};
use super::resources::Terminal;
@@ -28,6 +28,7 @@ const BRAILLE_DOT_BIT_POSITIONS: [u8; 8] = [0, 1, 2, 6, 3, 4, 5, 7];
pub fn print_to_terminal(
mut terminal: ResMut<Terminal>,
image_exports: Query<&FramebufferExtractDestination>,
+ mut widgets: Query<&mut Widget>,
) {
for image_export in image_exports.iter() {
let mut image = image_export
@@ -77,6 +78,15 @@ pub fn print_to_terminal(
.wrap(Wrap { trim: true }),
frame.size(),
);
+
+ 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, frame.size());
+ }
})
.expect("Failed to draw terminal frame");
}