Trait Layoutable

Source
pub trait Layoutable<Color: PixelColor> {
    // Required methods
    fn size(&self) -> ComponentSize;
    fn draw_placed<DrawError>(
        &self,
        target: &mut impl DrawTarget<Color = Color, Error = DrawError>,
        position: Rectangle,
    ) -> Result<(), DrawError>;
}
Expand description

Defines any Layoutable element (anything that can be layouted)

Required Methods§

Source

fn size(&self) -> ComponentSize

Returns size constraints of that element returns ComponentSize preferred placement constraints of this element

Source

fn draw_placed<DrawError>( &self, target: &mut impl DrawTarget<Color = Color, Error = DrawError>, position: Rectangle, ) -> Result<(), DrawError>

Draws this element onto a defined region onto a target

§Arguments
  • target: Target where this element should be drawn
  • position: place to draw this element onto

returns: Result<(), DrawError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, C: PixelColor, T: ImageDrawable<Color = C>> Layoutable<C> for Image<'a, T>

Render Image as Layoutable

Source§

fn size(&self) -> ComponentSize

Source§

fn draw_placed<DrawError>( &self, target: &mut impl DrawTarget<Color = C, Error = DrawError>, position: Rectangle, ) -> Result<(), DrawError>

Source§

impl<'a, S: TextRenderer<Color = Color>, Color: PixelColor> Layoutable<Color> for Text<'a, S>

Render Text as Layoutable

Source§

fn size(&self) -> ComponentSize

Source§

fn draw_placed<DrawError>( &self, target: &mut impl DrawTarget<Color = Color, Error = DrawError>, position: Rectangle, ) -> Result<(), DrawError>

Source§

impl<C: PixelColor, L: Layoutable<C>> Layoutable<C> for Option<L>

Render a Optional<impl Layoutable> as Layoutable

Source§

fn size(&self) -> ComponentSize

Source§

fn draw_placed<DrawError>( &self, target: &mut impl DrawTarget<Color = C, Error = DrawError>, position: Rectangle, ) -> Result<(), DrawError>

Implementors§