aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/mod.rs
blob: 7751b2de8ddedde2cfffec43a2c15ddc56744d72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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) {}

    /// Called every frame during the Update schedule
    fn update(&mut self, _time: &Time, _commands: &mut Commands) {}
}
impl_downcast!(sync TerminalWidget);