diff options
author | Silas Bartha <[email protected]> | 2024-06-04 15:00:16 -0400 |
---|---|---|
committer | Silas Bartha <[email protected]> | 2024-06-04 15:00:16 -0400 |
commit | a002e4d738535e6ca779c71231f7b84864b9a8d0 (patch) | |
tree | 8ec521b535f3820328f9ea6f2511ca29c630b82f /src/widgets/mod.rs | |
parent | 56aafda8495243fa939bdce01f36d4adbf4ec556 (diff) |
Refactored + Renamed + Added Docs
Diffstat (limited to 'src/widgets/mod.rs')
-rw-r--r-- | src/widgets/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs new file mode 100644 index 0000000..46bfa20 --- /dev/null +++ b/src/widgets/mod.rs @@ -0,0 +1,21 @@ +use bevy::prelude::*; +use downcast_rs::{impl_downcast, DowncastSync}; +use ratatui::{layout::Rect, Frame}; + +use crate::input::events::TerminalInputEvent; + +/// Components for this module +pub mod components; + +/// Systems for this module +pub(crate) mod systems; + +/// Trait which defines an interface for terminal widgets +pub trait TerminalWidget: DowncastSync { + /// Called every frame to render the widget + fn render(&mut self, frame: &mut Frame, rect: Rect); + + /// Called when a terminal input event is invoked to update any state accordingly + fn handle_events(&mut self, _event: &TerminalInputEvent, _commands: &mut Commands) {} +} +impl_downcast!(sync TerminalWidget); |