vertical_layout

Function vertical_layout 

Source
pub fn vertical_layout<L: Layoutable<C>, C: PixelColor>(
    first_child: L,
    first_child_weight: u32,
) -> LayoutableLinearLayout<C, Vertical, SingleLinearLayout<L, C, Vertical>>
Expand description

Stack multiple layout elements vertically

§Arguments

  • first_child: First layout element to stack
  • first_child_weight: Weight of this element when expansion or shrinking is needed to fit elements vertically

returns: LayoutableLinearLayout<C, Vertical, SingleLinearLayout<L, C, Vertical>>

§Examples

use embedded_graphics::mono_font::iso_8859_1::FONT_6X12;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::Point;
use embedded_graphics::text::Text;
use simple_layout::prelude::{bordered, center, expand, horizontal_layout, optional_placement, owned_text, padding, RoundedLine, scale, vertical_layout};
const TEXT_STYLE: MonoTextStyle<BinaryColor> = MonoTextStyle::new(&FONT_6X12, BinaryColor::On);
let mut minus_button_placement=None;
let mut plus_button_placement=None;
let value = 0.7;
let data_visualization = vertical_layout(expand(center(owned_text(format!("{value:.1}"), TEXT_STYLE))),1,)
                .append(scale(value, BinaryColor::On), 0);
let numbered_scale = expand(center(
        horizontal_layout(
            center(optional_placement(
                &mut minus_button_placement,
                bordered(
                    padding(Text::new("-", Point::zero(), TEXT_STYLE), -2, 1, -1, 1),
                    RoundedLine::new(BinaryColor::On),
                ),
            )),
            0,
        )
        .append(data_visualization, 1)
        .append(
            center(optional_placement(
                &mut plus_button_placement,
                bordered(
                    padding(Text::new("+", Point::zero(), TEXT_STYLE), -2, 1, -1, 1),
                    RoundedLine::new(BinaryColor::On),
                ),
            )),
            0,
        ),
    ));