pub struct Sides { /* private fields */ }Expand description
Put some widgets on the left and right sides of a ui.
The result will look like this:
parent Ui
______________________________________________________
| | | | ^
| -> left widgets -> | gap | <- right widgets <- | | height
|____________________| |_____________________| v
| |
| |The width of the gap is dynamic, based on the max width of the parent Ui.
When the parent is being auto-sized (Ui::is_sizing_pass) the gap will be as small as possible.
If the parent is not wide enough to fit all widgets, the parent will be expanded to the right.
The left widgets are added left-to-right. The right widgets are added right-to-left.
Which side is first depends on the configuration:
Sides::extend- left widgets are added firstSides::shrink_left- right widgets are added firstSides::shrink_right- left widgets are added first
egui::containers::Sides::new().show(ui,
|ui| {
ui.label("Left");
},
|ui| {
ui.label("Right");
}
);Implementations§
Source§impl Sides
impl Sides
pub fn new() -> Sides
Sourcepub fn height(self, height: f32) -> Sides
pub fn height(self, height: f32) -> Sides
The minimum height of the sides.
The content will be centered vertically within this height.
The default height is crate::Spacing::interact_size.y.
Sourcepub fn spacing(self, spacing: f32) -> Sides
pub fn spacing(self, spacing: f32) -> Sides
The horizontal spacing between the left and right UIs.
This is the minimum gap.
The default is crate::Spacing::item_spacing.x.
Sourcepub fn shrink_left(self) -> Sides
pub fn shrink_left(self) -> Sides
Try to shrink widgets on the left side.
Right widgets will be added first. The left Uis max rect will be limited to the
remaining space.
Sourcepub fn shrink_right(self) -> Sides
pub fn shrink_right(self) -> Sides
Try to shrink widgets on the right side.
Left widgets will be added first. The right Uis max rect will be limited to the
remaining space.
Sourcepub fn extend(self) -> Sides
pub fn extend(self) -> Sides
Extend the left and right sides to fill the available space.
This is the default behavior. The left widgets will be added first, followed by the right widgets.
Sourcepub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Sides
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Sides
The text wrap mode for the shrinking side.
Does nothing if Self::extend is used (the default).
Sourcepub fn truncate(self) -> Sides
pub fn truncate(self) -> Sides
Truncate the text on the shrinking side.
This is a shortcut for Self::wrap_mode.
Does nothing if Self::extend is used (the default).
Sourcepub fn wrap(self) -> Sides
pub fn wrap(self) -> Sides
Wrap the text on the shrinking side.
This is a shortcut for Self::wrap_mode.
Does nothing if Self::extend is used (the default).
pub fn show<RetL, RetR>( self, ui: &mut Ui, add_left: impl FnOnce(&mut Ui) -> RetL, add_right: impl FnOnce(&mut Ui) -> RetR, ) -> (RetL, RetR)
Trait Implementations§
Auto Trait Implementations§
impl Forget for Sides
impl Freeze for Sides
impl Move for Sides
impl RefUnwindSafe for Sides
impl Send for Sides
impl Sync for Sides
impl Unpin for Sides
impl UnsafeUnpin for Sides
impl UnwindSafe for Sides
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more