pub trait Component: Debug + Send + Sync {
type Message: Debug + Send + Sync + Clone;
// Required methods
fn children(
&self
) -> Option<Vec<&Box<dyn Component<Message = Self::Message>>>>;
fn children_mut(
&mut self
) -> Option<Vec<&mut Box<dyn Component<Message = Self::Message>>>>;
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 mut MakeupUpdate<'_, Self>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn render<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 RenderContext
) -> Pin<Box<dyn Future<Output = Result<DrawCommandBatch>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn key(&self) -> Key;
fn dimensions(&self) -> Result<Option<Dimensions>>;
// Provided methods
fn batch(&self, commands: Vec<DrawCommand>) -> Result<DrawCommandBatch> { ... }
fn style(&self) -> Option<Style> { ... }
}
Expand description
A component in a makeup UI.
Component layout is done via flexbox. This means that container-like components CANNOT render text directly on themselves, but must instead have child components for all rendering.
Required Associated Types§
Required Methods§
sourcefn children(&self) -> Option<Vec<&Box<dyn Component<Message = Self::Message>>>>
fn children(&self) -> Option<Vec<&Box<dyn Component<Message = Self::Message>>>>
The children this component has. May be empty when present.
NOTE: This intentionally returns a borrowed box!
sourcefn children_mut(
&mut self
) -> Option<Vec<&mut Box<dyn Component<Message = Self::Message>>>>
fn children_mut( &mut self ) -> Option<Vec<&mut Box<dyn Component<Message = Self::Message>>>>
The children this component has, but mutable. May be empty when present.
sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 mut MakeupUpdate<'_, Self>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 mut MakeupUpdate<'_, Self>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process any messages that have been sent to this component. Messages
are expected to be process asynchronously, ie. any long-running
operations should be tokio::spawn
ed as a task.
sourcefn render<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 RenderContext
) -> Pin<Box<dyn Future<Output = Result<DrawCommandBatch>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn render<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 RenderContext
) -> Pin<Box<dyn Future<Output = Result<DrawCommandBatch>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Render this component.
sourcefn key(&self) -> Key
fn key(&self) -> Key
A unique key for this component. See generate_key
.
sourcefn dimensions(&self) -> Result<Option<Dimensions>>
fn dimensions(&self) -> Result<Option<Dimensions>>
The dimensions of this component. Coordinates are calculated automatically by the parent component that manages layout, or are implied by render order.
Provided Methods§
sourcefn batch(&self, commands: Vec<DrawCommand>) -> Result<DrawCommandBatch>
fn batch(&self, commands: Vec<DrawCommand>) -> Result<DrawCommandBatch>
Batch the given render commands with this component’s key.