Skip to main content

sizing

Macro sizing 

Source
macro_rules! sizing {
    ($width:expr, $height:expr) => { ... };
    ($size:expr) => { ... };
    (width: $width:expr, height: $height:expr) => { ... };
    ($key:ident : $value:expr$(,)?) => { ... };
    ($($key:ident : $value:expr),* $(,)?) => { ... };
    () => { ... };
}
Expand description

Defines the sizing behavior for a flex box.

  • sizing!(width, height) will create a box sizing with the specified width and height behaviors.
  • sizing!(size) will create a box sizing with the same behavior for both axes.
  • sizing!() will define a box sizing behavior with default values (fit for both axes).

You can also use sizing!(key: value) to specify width or height behavior individually (where key is either width or height, duh).

Example:

// grow both width and height
FlexStyle::new()
    .sizing(sizing!(grow!())),

// fit width (max 100.0) and fixed height (200.0)
FlexStyle::new()
    .sizing(sizing!(fit!(100.0), fixed!(200.0))),