Struct Flex

Source
pub struct Flex { /* private fields */ }
Expand description

A flex container.

Implementations§

Source§

impl Flex

Source

pub fn new() -> Self

Create a new flex container.

Source

pub fn horizontal() -> Self

Create a new horizontal flex container.

Source

pub fn vertical() -> Self

Create a new vertical flex container.

Source

pub fn direction(self, direction: FlexDirection) -> Self

Set the direction of the flex container.

Source

pub fn justify(self, justify: FlexJustify) -> Self

Set how to justify the content (alignment in the main axis). This will only have an effect if all items have grow set to 0.

Source

pub fn align_items(self, align_items: FlexAlign) -> Self

Set the default configuration for the items in the flex container.

Source

pub fn align_items_content(self, align_item_content: Align2) -> Self

If align_items is stretch, how do we align the item content?

Source

pub fn align_content(self, align_content: FlexAlignContent) -> Self

Set how to align the content in the cross axis across the whole container.

This only has an effect if wrap is set to true.

Default is stretch.

Source

pub fn grow_items(self, grow: impl Into<Option<f32>>) -> Self

Set the default grow factor for the items in the flex container.

Source

pub fn gap(self, gap: Vec2) -> Self

Set the gap between the items in the flex container.

Default is item_spacing of the Ui.

Source

pub fn wrap(self, wrap: bool) -> Self

Should the flex container wrap it’s content. If this is set to false the content may overflow the Ui::max_rect

Default: false

Source

pub fn id_salt(self, id_salt: impl Into<Id>) -> Self

Customize the id of the flex container to prevent conflicts with other flex containers.

Source

pub fn width(self, width: impl Into<Size>) -> Self

Set the width of the flex container in points (pixels).

The default depends on the parents horizontal justify. If ui.layout().horizontal_justify() is:

  • true, the width will be set to 100%.
  • false, the width will depend on the width of the content.
Source

pub fn height(self, height: impl Into<Size>) -> Self

Set the height of the flex container in points (pixels).

The default depends on the parents vertical justify. If ui.layout().vertical_justify() is:

  • true, the height will be set to 100%.
  • false, the height will depend on the height of the content.
Source

pub fn width_percent(self, width: f32) -> Self

Set the width of the flex container as a percentage of the available width. 1.0 means 100%.

Check Self::width for more info.

Source

pub fn height_percent(self, height: f32) -> Self

Set the height of the flex container as a percentage of the available height. 1.0 means 100%.

Check Self::height for more info.

Source

pub fn size(self, size: impl Into<Vec2>) -> Self

Set the size of the flex container in points (pixels).

Check Self::width and Self::height for more info.

Source

pub fn w_full(self) -> Self

Set the width of the flex container to 100%.

Source

pub fn h_full(self) -> Self

Set the height of the flex container to 100%.

Source

pub fn w_auto(self) -> Self

The width of the flex container will be set to the width of the content, but not larger than the available width (unless wrap is set to false).

This is the default.

Source

pub fn h_auto(self) -> Self

The height of the flex container will be set to the height of the content, but not larger than the available height (unless wrap is set to false).

This is the default.

Source

pub fn show<R>( self, ui: &mut Ui, f: impl FnOnce(&mut FlexInstance<'_>) -> R, ) -> InnerResponse<R>

Show the flex ui. If Self::wrap is true, it will try to stay within Ui::max_rect.

Note: You will likely get weird results when showing this within a Ui::horizontal layout, since it limits the max_rect to some small value. Use Ui::horizontal_top instead.

Source

pub fn show_in<R>( self, flex: &mut FlexInstance<'_>, item: FlexItem<'_>, f: impl FnOnce(&mut FlexInstance<'_>) -> R, ) -> InnerResponse<R>

Show this flex in another Flex. See also FlexInstance::add_flex.

Trait Implementations§

Source§

impl Clone for Flex

Source§

fn clone(&self) -> Flex

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Flex

Source§

fn default() -> Flex

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Flex

Source§

fn eq(&self, other: &Flex) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Flex

Auto Trait Implementations§

§

impl Freeze for Flex

§

impl RefUnwindSafe for Flex

§

impl Send for Flex

§

impl Sync for Flex

§

impl Unpin for Flex

§

impl UnwindSafe for Flex

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,