Struct embedded_layout::layout::linear::LinearLayout[][src]

pub struct LinearLayout<LD, VG> { /* fields omitted */ }
Expand description

LinearLayout

LinearLayout is used to arrange views along the horizontal or vertical axis.

For more information and examples see the module level documentation.

Implementations

Create a new LinearLayout that places views left to right

Create a new LinearLayout that places views top to bottom

Change the secondary alignment for this LinearLayout object.

For layouts created using LinearLayout::horizontal the secondary alignment is vertical.

Change the element spacing

For available values and their properties, see spacing

Change the secondary alignment for this LinearLayout object.

For layouts created using LinearLayout::vertical the secondary alignment is horizontal.

Change the element spacing

For available values and their properties, see spacing

Consume the layout object and return the wrapped ViewGroup.

After calling arrange() it is no longer necessary to hold the views in a LinearLayout. Use this method to extract the original view group object if you need to work with the arranged views.

Example

Arrange an array of StyledText objects, then check the second object’s position.

let text_style = MonoTextStyle::new(&FONT_6X9, BinaryColor::On);

// First, wrap out views in a `ViewGroup`.
let mut texts = [
    Text::new("Hello,", Point::zero(), text_style),
    Text::new("World!", Point::zero(), text_style)
];
let mut views = Views::new(&mut texts);

// Arrange our views and extract our original view group.
let views = LinearLayout::vertical(views).arrange().into_inner();

// We can access our `StyledText` objects now. Note that `Views` works like a slice!
assert_eq!(Point::new(0, 9), views[1].bounds().top_left);

// `Views` is also a drawable `ViewGroup`, so let's display our arranged text!
views.draw(&mut display).unwrap();

Arrange the views according to the layout properties and return the views as a ViewGroup. Note: The top left point is always Point::zero().

Trait Implementations

The pixel color type.

The return type of the draw method. Read more

Draw the graphics object using the supplied DrawTarget.

Object-safe version of translate_mut(). Read more

Returns the bounding box of the View as a Rectangle

Get the size of a View.

Move the origin of an object by a given number of (x, y) pixels, mutating the object in place. Read more

Move the origin of an object by a given number of (x, y) pixels, returning a new object. Read more

Auto Trait Implementations

Blanket Implementations

Return the object aligned to an other one using the alignment parameters as rules

Align the object to an other one using the alignment parameters as rules

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Performs the conversion.

Performs the conversion.

Casts the value.

Casts the value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.