~tm85/lintuini

ref: 59aa8988f0bcda8310e81cae31b762626f24d4ae lintuini/src/elements/element.rs -rw-r--r-- 497 bytes
59aa8988TerraMaster85 feat: macrofication 26 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: impl Into<Box<dyn Element>>) -> Result<(), error::LintuiniError>;
    fn children(&self) -> &[Box<dyn Element>];
    fn children_mut(&mut self) -> &mut [Box<dyn Element>];
}