[go: up one dir, main page]

Component

Trait Component 

Source
pub trait Component: Debug {
    // Required methods
    fn children_mut(&mut self) -> Vec<&mut dyn Drawable>;
    fn children(&self) -> Vec<&dyn Drawable>;
    fn request_size(
        &self,
        ctx: &mut Context,
        children: Vec<SizeRequest>,
    ) -> SizeRequest;
    fn build(
        &mut self,
        ctx: &mut Context,
        size: (f32, f32),
        children: Vec<SizeRequest>,
    ) -> Vec<Area>;
}
Expand description

A composable UI element with children.

Component represents higher-level UI building blocks. Unlike simple Drawables, components can contain other drawables and define their own layout, rendering, and event handling.

Required Methods§

Source

fn children_mut(&mut self) -> Vec<&mut dyn Drawable>

Returns mutable reference to child drawables.

Source

fn children(&self) -> Vec<&dyn Drawable>

Returns reference to child drawables.

Source

fn request_size( &self, ctx: &mut Context, children: Vec<SizeRequest>, ) -> SizeRequest

Compute layout needs based on children.

Source

fn build( &mut self, ctx: &mut Context, size: (f32, f32), children: Vec<SizeRequest>, ) -> Vec<Area>

Position children and return their areas.

Implementors§

Source§

impl Component for Enum

Source§

impl<D: Drawable + 'static> Component for Button<D>

Source§

impl<D: Drawable + 'static> Component for Scrollable<D>

Source§

impl<D: Drawable + 'static> Component for Selectable<D>

Source§

impl<D: Drawable + 'static> Component for Slider<D>

Source§

impl<D: Drawable + 'static> Component for TextInput<D>

Source§

impl<D: Drawable + 'static> Component for Opt<D>

Source§

impl<L: Layout + 'static, D: Drawable + 'static> Component for Bin<L, D>

Source§

impl<L: Drawable + 'static, R: Drawable + 'static> Component for EitherOr<L, R>