Incular logoIncular
API ReferenceLayout Widgets

Align

Position a child with fractional alignment and optional size factors.

Align positions its child with Alignment and optionally sizes itself as child * factor. Factors default None, clamped to max(0.0).

Props

Prop

Type

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Align::new(Alignment::BOTTOM_RIGHT, Text::new("Corner"))
                    .width_factor(2.0)
                    .height_factor(2.0),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Methods

pub fn new(alignment: Alignment, child: impl Into<Widget>) -> Self
pub fn width_factor(mut self, factor: f32) -> Self
pub fn height_factor(mut self, factor: f32) -> Self
pub fn get_alignment(&self) -> Alignment

Related: Center, Alignment.

On this page