[−][src]Struct druid::widget::FlexParams
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]
pub fn clone(&self) -> FlexParams
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for FlexParams
[src]
impl Default for FlexParams
[src]
pub fn default() -> FlexParams
[src]
impl From<f64> for FlexParams
[src]
pub fn from(flex: f64) -> FlexParams
[src]
Auto Trait Implementations
impl RefUnwindSafe for FlexParams
[src]
impl Send for FlexParams
[src]
impl Sync for FlexParams
[src]
impl Unpin for FlexParams
[src]
impl UnwindSafe for FlexParams
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,