Trait carnelian::scene::facets::Facet

source ·
pub trait Facet {
    // Required methods
    fn update_layers(
        &mut self,
        size: Size,
        layer_group: &mut dyn LayerGroup,
        render_context: &mut RenderContext,
        view_context: &ViewAssistantContext
    ) -> Result<(), Error>;
    fn calculate_size(&self, available: Size) -> Size;

    // Provided methods
    fn associate_facet_id(&mut self, facet_id: FacetId) { ... }
    fn handle_message(&mut self, msg: Box<dyn Any>) { ... }
}
Expand description

The Facet trait is used to create composable units of rendering, sizing and message handling.

Required Methods§

source

fn update_layers( &mut self, size: Size, layer_group: &mut dyn LayerGroup, render_context: &mut RenderContext, view_context: &ViewAssistantContext ) -> Result<(), Error>

Called by the scene on facets when it is time for them to update their contents. Facets can add, remove or change layers in the layer group. Those layers will be combined with all the other facet layers in the scene and added to a render composition for display.

source

fn calculate_size(&self, available: Size) -> Size

Should return the current size needed by this facet.

Provided Methods§

source

fn associate_facet_id(&mut self, facet_id: FacetId)

Optional method for facets that wish to send themselves messages using an AppSender that they were passed during creation.

source

fn handle_message(&mut self, msg: Box<dyn Any>)

Method for receiving arbitrary message, like SetColorMessage or SetTextMessage.

Implementors§