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() -> Self
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
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) -> Self
pub fn spacing(self, spacing: f32) -> Self
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) -> Self
pub fn shrink_left(self) -> Self
Try to shrink widgets on the left side.
Right widgets will be added first. The left Ui
s max rect will be limited to the
remaining space.
Sourcepub fn shrink_right(self) -> Self
pub fn shrink_right(self) -> Self
Try to shrink widgets on the right side.
Left widgets will be added first. The right Ui
s max rect will be limited to the
remaining space.
Sourcepub fn extend(self) -> Self
pub fn extend(self) -> Self
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) -> Self
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
The text wrap mode for the shrinking side.
Does nothing if Self::extend
is used (the default).
Sourcepub fn truncate(self) -> Self
pub fn truncate(self) -> Self
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) -> Self
pub fn wrap(self) -> Self
Wrap the text on the shrinking side.
This is a shortcut for Self::wrap_mode
.
Does nothing if Self::extend
is used (the default).