~tm85/lintuini

ref: 281900fe61d7df4c18826576a3ed56064e914e45 lintuini/src/elements/element.rs -rw-r--r-- 551 bytes
281900feTerraMaster85 fmt: all 26 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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>];
}