[][src]Struct druid::widget::FlexParams

pub struct FlexParams { /* fields omitted */ }

Optional parameters for an item in a Flex container (row or column).

Generally, when you would like to add a flexible child to a container, you can simply call with_flex_child or add_flex_child, passing the child and the desired flex factor as a f64, which has an impl of Into<FlexParams>.

If you need to set additional paramaters, such as a custom CrossAxisAlignment, you can construct FlexParams directly. By default, the child has the same CrossAxisAlignment as the container.

For an overview of the flex layout algorithm, see the Flex docs.

Examples

use druid::widget::{FlexParams, Label, CrossAxisAlignment};

let mut row = druid::widget::Flex::<()>::row();
let child_1 = Label::new("I'm hungry");
let child_2 = Label::new("I'm scared");
// normally you just use a float:
row.add_flex_child(child_1, 1.0);
// you can construct FlexParams if needed:
let params = FlexParams::new(2.0, CrossAxisAlignment::End);
row.add_flex_child(child_2, params);

Implementations

impl FlexParams[src]

pub fn new(flex: f64, alignment: impl Into<Option<CrossAxisAlignment>>) -> Self[src]

Create custom FlexParams with a specific flex_factor and an optional CrossAxisAlignment.

You likely only need to create these manually if you need to specify a custom alignment; if you only need to use a custom flex_factor you can pass an f64 to any of the functions that take FlexParams.

By default, the widget uses the alignment of its parent Flex container.

Trait Implementations

impl Clone for FlexParams[src]

impl Copy for FlexParams[src]

impl Default for FlexParams[src]

impl From<f64> for FlexParams[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.