pub struct Flex { /* private fields */ }
Expand description
A flex container.
Implementations§
Source§impl Flex
impl Flex
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Create a new horizontal flex container.
Sourcepub fn direction(self, direction: FlexDirection) -> Self
pub fn direction(self, direction: FlexDirection) -> Self
Set the direction of the flex container.
Sourcepub fn justify(self, justify: FlexJustify) -> Self
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.
Sourcepub fn align_items(self, align_items: FlexAlign) -> Self
pub fn align_items(self, align_items: FlexAlign) -> Self
Set the default configuration for the items in the flex container.
Sourcepub fn align_items_content(self, align_item_content: Align2) -> Self
pub fn align_items_content(self, align_item_content: Align2) -> Self
If align_items
is stretch, how do we align the item content?
Sourcepub fn align_content(self, align_content: FlexAlignContent) -> Self
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
.
Sourcepub fn grow_items(self, grow: impl Into<Option<f32>>) -> Self
pub fn grow_items(self, grow: impl Into<Option<f32>>) -> Self
Set the default grow factor for the items in the flex container.
Sourcepub fn gap(self, gap: Vec2) -> Self
pub fn gap(self, gap: Vec2) -> Self
Set the gap between the items in the flex container.
Default is item_spacing
of the Ui
.
Sourcepub fn wrap(self, wrap: bool) -> Self
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
Sourcepub fn id_salt(self, id_salt: impl Into<Id>) -> Self
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.
Sourcepub fn width(self, width: impl Into<Size>) -> Self
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.
Sourcepub fn height(self, height: impl Into<Size>) -> Self
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.
Sourcepub fn width_percent(self, width: f32) -> Self
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.
Sourcepub fn height_percent(self, height: f32) -> Self
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.
Sourcepub fn size(self, size: impl Into<Vec2>) -> Self
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.
Sourcepub fn w_auto(self) -> Self
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.
Sourcepub fn h_auto(self) -> Self
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.
Sourcepub fn show<R>(
self,
ui: &mut Ui,
f: impl FnOnce(&mut FlexInstance<'_>) -> R,
) -> InnerResponse<R>
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.
Sourcepub fn show_in<R>(
self,
flex: &mut FlexInstance<'_>,
item: FlexItem<'_>,
f: impl FnOnce(&mut FlexInstance<'_>) -> R,
) -> InnerResponse<R>
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.