pub struct LinearLayout<LD, VG> { /* private fields */ }
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§
Source§impl<LD, VG> LinearLayout<LD, VG>
impl<LD, VG> LinearLayout<LD, VG>
Source§impl<VG> LinearLayout<Horizontal<Bottom, Tight>, VG>where
VG: ViewGroup,
impl<VG> LinearLayout<Horizontal<Bottom, Tight>, VG>where
VG: ViewGroup,
Sourcepub fn horizontal(views: VG) -> Self
pub fn horizontal(views: VG) -> Self
Create a new LinearLayout
that places views left to right
Source§impl<VG> LinearLayout<Vertical<Left, Tight>, VG>where
VG: ViewGroup,
impl<VG> LinearLayout<Vertical<Left, Tight>, VG>where
VG: ViewGroup,
Sourcepub fn vertical(views: VG) -> Self
pub fn vertical(views: VG) -> Self
Create a new LinearLayout
that places views top to bottom
Source§impl<S, ELS, VG> LinearLayout<Horizontal<S, ELS>, VG>
impl<S, ELS, VG> LinearLayout<Horizontal<S, ELS>, VG>
Sourcepub fn with_alignment<Sec>(
self,
alignment: Sec,
) -> LinearLayout<Horizontal<Sec, ELS>, VG>where
Sec: SecondaryAlignment + VerticalAlignment,
pub fn with_alignment<Sec>(
self,
alignment: Sec,
) -> LinearLayout<Horizontal<Sec, ELS>, VG>where
Sec: SecondaryAlignment + VerticalAlignment,
Change the secondary alignment for this LinearLayout
object.
For layouts created using LinearLayout::horizontal
the secondary alignment is vertical
.
Sourcepub fn with_spacing<ES>(
self,
spacing: ES,
) -> LinearLayout<Horizontal<S, ES>, VG>where
ES: ElementSpacing,
pub fn with_spacing<ES>(
self,
spacing: ES,
) -> LinearLayout<Horizontal<S, ES>, VG>where
ES: ElementSpacing,
Change the element spacing
For available values and their properties, see spacing
Source§impl<S, ELS, VG> LinearLayout<Vertical<S, ELS>, VG>
impl<S, ELS, VG> LinearLayout<Vertical<S, ELS>, VG>
Sourcepub fn with_alignment<Sec>(
self,
alignment: Sec,
) -> LinearLayout<Vertical<Sec, ELS>, VG>where
Sec: SecondaryAlignment + HorizontalAlignment,
pub fn with_alignment<Sec>(
self,
alignment: Sec,
) -> LinearLayout<Vertical<Sec, ELS>, VG>where
Sec: SecondaryAlignment + HorizontalAlignment,
Change the secondary alignment for this LinearLayout
object.
For layouts created using LinearLayout::vertical
the secondary alignment is horizontal
.
Sourcepub fn with_spacing<ES>(self, spacing: ES) -> LinearLayout<Vertical<S, ES>, VG>where
ES: ElementSpacing,
pub fn with_spacing<ES>(self, spacing: ES) -> LinearLayout<Vertical<S, ES>, VG>where
ES: ElementSpacing,
Change the element spacing
For available values and their properties, see spacing
Source§impl<LD, VG> LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
impl<LD, VG> LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
Sourcepub fn into_inner(self) -> VG
pub fn into_inner(self) -> VG
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();
Sourcepub fn arrange(self) -> Self
pub fn arrange(self) -> Self
Arrange the views according to the layout properties and return the views as a ViewGroup
.
Sourcepub fn arrange_view_group(&self, view_group: &mut impl ViewGroup)
pub fn arrange_view_group(&self, view_group: &mut impl ViewGroup)
Arrange a ViewGroup
according to the layout properties.
Trait Implementations§
Source§impl<LD, VG> Clone for LinearLayout<LD, VG>
impl<LD, VG> Clone for LinearLayout<LD, VG>
Source§impl<C, LD, VG> Drawable for LinearLayout<LD, VG>
impl<C, LD, VG> Drawable for LinearLayout<LD, VG>
Source§impl<LD, VG> View for LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
impl<LD, VG> View for LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
Source§impl<LD, VG> ViewGroup for LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
impl<LD, VG> ViewGroup for LinearLayout<LD, VG>where
LD: Orientation,
VG: ViewGroup,
Source§fn at(&self, idx: usize) -> &dyn View
fn at(&self, idx: usize) -> &dyn View
View
object at position idx
.Source§fn at_mut(&mut self, idx: usize) -> &mut dyn View
fn at_mut(&mut self, idx: usize) -> &mut dyn View
View
object at position idx
.