~tm85/lintuini

ref: a247719c2c965a261e1571fbe45cff8d2ab6175c lintuini/src/elements/element.rs -rw-r--r-- 487 bytes
a247719cTerraMaster85 feat: rapid development 28 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ratatui_core::layout;
use ratatui_core::terminal::Frame;

use crate::error;

pub trait Element {
    fn constraint(&self) -> &layout::Constraint;
    fn render(&self, frm: &mut Frame, rect: layout::Rect) -> Result<(), error::LintuiniError>;
}

pub trait ElementWithChildren: Element {
    fn add_child(&mut self, child: Box<dyn Element>) -> Result<(), error::LintuiniError>;
    fn children(&self) -> &[Box<dyn Element>];
    fn children_mut(&mut self) -> &mut [Box<dyn Element>];
}