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§

source

type Message: Debug + Send + Sync + Clone

The type of messages that can be sent to this component.

Required Methods§

source

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!

source

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.

source

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::spawned as a task.

source

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.

source

fn key(&self) -> Key

A unique key for this component. See generate_key.

source

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§

source

fn batch(&self, commands: Vec<DrawCommand>) -> Result<DrawCommandBatch>

Batch the given render commands with this component’s key.

source

fn style(&self) -> Option<Style>

Implementors§

source§

impl<Message: Debug + Send + Sync + Clone + 'static> Component for Spinner<Message>

§

type Message = Message

source§

impl<Message: Debug + Send + Sync + Clone> Component for Container<Message>

§

type Message = Message

source§

impl<Message: Debug + Send + Sync + Clone> Component for EchoText<Message>

§

type Message = Message

source§

impl<Message: Debug + Send + Sync + Clone> Component for Fps<Message>

§

type Message = Message

source§

impl<Message: Debug + Send + Sync + Clone> Component for TextInput<Message>

§

type Message = Message