API ReferenceLayout Widgets
Wrap
Flowing multi-run layout with per-run and cross-run alignment.
Wrap places children sequentially, wrapping onto new runs past the main-axis
extent. Defaults: direction = Horizontal, alignment = Start,
spacing = 0.0, run_alignment = Start, run_spacing = 0.0,
cross_axis_alignment = Start, text_direction = None (Ltr),
vertical_direction = Down.
Props
Prop
Type
Construction
A tag cloud — copy, paste, and run:
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(
Wrap::new(Vec::<Widget>::from([
Text::new("rust").into(),
Text::new("gui").into(),
Text::new("native").into(),
Text::new("retained").into(),
]))
.direction(Axis::Horizontal)
.alignment(WrapAlignment::Start)
.spacing(8.0)
.run_alignment(WrapAlignment::Start)
.run_spacing(8.0)
.cross_axis_alignment(WrapCrossAlignment::Start)
.text_direction(TextDirection::Ltr)
.vertical_direction(VerticalDirection::Down),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}Methods
pub fn new(children: impl IntoIterator<Item = impl Into<Widget>>) -> Self
pub fn direction(mut self, direction: Axis) -> Self
pub fn alignment(mut self, alignment: WrapAlignment) -> Self
pub fn spacing(mut self, spacing: f32) -> Self // clamped max(0.0)
pub fn run_alignment(mut self, alignment: WrapAlignment) -> Self
pub fn run_spacing(mut self, spacing: f32) -> Self // clamped max(0.0)
pub fn cross_axis_alignment(mut self, alignment: WrapCrossAlignment) -> Self
pub fn text_direction(mut self, direction: TextDirection) -> Self
pub fn vertical_direction(mut self, direction: VerticalDirection) -> Self
pub fn get_direction(&self) -> Axis
pub fn get_spacing(&self) -> f32
pub fn get_run_spacing(&self) -> f32WrapAlignment: Start / End / Center / SpaceBetween / SpaceAround /
SpaceEvenly (both within a run and across runs). WrapCrossAlignment:
Start / End / Center. See
WrapAlignment.
use incular::prelude::*;
fn main() {
let app = Application::new(|_cx| {
Wrap::new(Vec::<Widget>::from([
Text::new("rust").into(),
Text::new("gui").into(),
]))
.spacing(6.0)
.run_spacing(6.0).into()
})
.expect("valid application");
incular::run(app).expect("run application");
}