egui_extras

Struct StripBuilder

source
pub struct StripBuilder<'a> { /* private fields */ }
Expand description

Builder for creating a new Strip.

This can be used to do dynamic layouts.

In contrast to normal egui behavior, strip cells do not grow with its children!

First use Self::size and Self::sizes to allocate space for the rows or columns will follow. Then build the strip with Self::horizontal/Self::vertical, and add ‘cells’ to it using Strip::cell. The number of cells MUST match the number of pre-allocated sizes.

§Example

use egui_extras::{StripBuilder, Size};
StripBuilder::new(ui)
    .size(Size::remainder().at_least(100.0)) // top cell
    .size(Size::exact(40.0)) // bottom cell
    .vertical(|mut strip| {
        // Add the top 'cell'
        strip.cell(|ui| {
            ui.label("Fixed");
        });
        // We add a nested strip in the bottom cell:
        strip.strip(|builder| {
            builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
                strip.cell(|ui| {
                    ui.label("Top Left");
                });
                strip.cell(|ui| {
                    ui.label("Top Right");
                });
            });
        });
    });

Implementations§

source§

impl<'a> StripBuilder<'a>

source

pub fn new(ui: &'a mut Ui) -> Self

Create new strip builder.

source

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

Should we clip the contents of each cell? Default: false.

source

pub fn cell_layout(self, cell_layout: Layout) -> Self

What layout should we use for the individual cells?

source

pub fn sense(self, sense: Sense) -> Self

What should strip cells sense for? Default: egui::Sense::hover().

source

pub fn size(self, size: Size) -> Self

Allocate space for one column/row.

source

pub fn sizes(self, size: Size, count: usize) -> Self

Allocate space for several columns/rows at once.

source

pub fn horizontal<F>(self, strip: F) -> Response
where F: for<'b> FnOnce(Strip<'a, 'b>),

Build horizontal strip: Cells are positions from left to right. Takes the available horizontal width, so there can’t be anything right of the strip or the container will grow slowly!

Returns a egui::Response for hover events.

source

pub fn vertical<F>(self, strip: F) -> Response
where F: for<'b> FnOnce(Strip<'a, 'b>),

Build vertical strip: Cells are positions from top to bottom. Takes the full available vertical height, so there can’t be anything below of the strip or the container will grow slowly!

Returns a egui::Response for hover events.

Auto Trait Implementations§

§

impl<'a> Freeze for StripBuilder<'a>

§

impl<'a> !RefUnwindSafe for StripBuilder<'a>

§

impl<'a> Send for StripBuilder<'a>

§

impl<'a> Sync for StripBuilder<'a>

§

impl<'a> Unpin for StripBuilder<'a>

§

impl<'a> !UnwindSafe for StripBuilder<'a>

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.