use crate::compositor::engine::Compositor;
use crate::input::event::Event;
#[derive(Debug, Clone, Copy, Default)]
pub struct Bounds {
pub x: u16,
pub y: u16,
pub w: u16,
pub h: u16,
}
impl Bounds {
pub fn new(x: u16, y: u16, w: u16, h: u16) -> Self {
Self { x, y, w, h }
}
pub fn contains(&self, col: u16, row: u16) -> bool {
col >= self.x && col < self.x + self.w && row >= self.y && row < self.y + self.h
}
}
pub trait Component {
fn render(&self, compositor: &mut Compositor, bounds: Bounds);
fn on_event(&mut self, _event: &Event, _bounds: Bounds) -> bool {
false }
fn preferred_size(&self) -> (Option<u16>, Option<u16>) {
(None, None)
}
}