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§
Sourcefn size(&self) -> ComponentSize
fn size(&self) -> ComponentSize
Returns size constraints of that element returns ComponentSize preferred placement constraints of this element
Sourcefn draw_placed<DrawError>(
&self,
target: &mut impl DrawTarget<Color = Color, Error = DrawError>,
position: Rectangle,
) -> Result<(), DrawError>
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 drawnposition
: 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
impl<'a, C: PixelColor, T: ImageDrawable<Color = C>> Layoutable<C> for Image<'a, T>
Render Image as Layoutable
fn size(&self) -> ComponentSize
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
impl<'a, S: TextRenderer<Color = Color>, Color: PixelColor> Layoutable<Color> for Text<'a, S>
Render Text as Layoutable
fn size(&self) -> ComponentSize
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
impl<C: PixelColor, L: Layoutable<C>> Layoutable<C> for Option<L>
Render a Optional<impl Layoutable> as Layoutable