kubi/kubi-ui/src/element.rs

22 lines
761 B
Rust
Raw Normal View History

2023-11-21 13:08:22 +00:00
use std::any::Any;
use crate::{
LayoutInfo,
draw::UiDrawCall,
2023-11-21 15:14:26 +00:00
measure::Response,
2023-11-21 13:08:22 +00:00
state::StateRepo
};
2023-11-21 15:14:26 +00:00
#[cfg(feature = "builtin_elements")] pub mod container;
#[cfg(feature = "builtin_elements")] pub mod spacer;
2023-11-21 13:08:22 +00:00
#[cfg(feature = "builtin_elements")] pub mod progress_bar;
pub trait UiElement {
fn name(&self) -> &'static str { "UiElement" }
fn state_id(&self) -> Option<u64> { None }
fn is_stateful(&self) -> bool { self.state_id().is_some() }
fn is_stateless(&self) -> bool { self.state_id().is_none() }
fn init_state(&self) -> Option<Box<dyn Any>> { None }
2023-11-21 15:14:26 +00:00
fn measure(&self, state: &StateRepo, layout: &LayoutInfo) -> Response;
fn draw(&self, measure: &Response, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>);
2023-11-21 13:08:22 +00:00
}