Skip to main content

Splitter

Struct Splitter 

Source
pub struct Splitter<'a, Msg> { /* private fields */ }
Expand description

Two panes that share an area: side by side with Splitter::columns, stacked with Splitter::rows. The application owns the size of the first pane; the second takes the rest.

Without Splitter::on_resize the panes simply sit next to each other. With it, a one-cell boundary separates them. The boundary is invisible until the pointer reaches it: then it brightens one step, and while dragged it takes the accent. It can also be focused with Tab and moved with the arrow keys (Shift moves five cells, Home and End jump to the limits).

Style keys: split-handle (bg, fg) with hover, focus and active (dragging).

Implementations§

Source§

impl<'a, Msg: 'static> Splitter<'a, Msg>

Source

pub fn columns(width: u16) -> Self

Panes side by side; the first (left) pane is width columns wide.

Source

pub fn rows(height: u16) -> Self

Stacked panes; the first (top) pane is height rows tall.

Source

pub fn limits(self, min: u16, max: impl Into<Option<u16>>) -> Self

The smallest and largest size of the first pane, in cells: limits(16, 60) for a range, or limits(16, None) for no upper limit. By default 1 and no upper limit; whatever the limits, the second pane keeps at least one cell. A max below min counts as min.

Source

pub fn on_resize(self, message: impl Fn(u16) -> Msg + 'static) -> Self

Makes the boundary draggable and focusable; the message carries the first pane’s new size, already within the limits.

Source

pub fn first(self, build: impl FnOnce(&mut View<'_, Msg>) + 'a) -> Self

The left or top pane.

Source

pub fn second(self, build: impl FnOnce(&mut View<'_, Msg>) + 'a) -> Self

The right or bottom pane.

Source

pub fn show<'v>(self, ui: &'v mut View<'_, Msg>) -> NodeMut<'v, Msg>

Adds the splitter to ui, filling the space it gets.

Auto Trait Implementations§

§

impl<'a, Msg> !RefUnwindSafe for Splitter<'a, Msg>

§

impl<'a, Msg> !Send for Splitter<'a, Msg>

§

impl<'a, Msg> !Sync for Splitter<'a, Msg>

§

impl<'a, Msg> !UnwindSafe for Splitter<'a, Msg>

§

impl<'a, Msg> Freeze for Splitter<'a, Msg>
where Option<Box<dyn Fn(u16) -> Msg>>: Freeze, Option<Box<dyn FnOnce(&mut View<'_, Msg>) + 'a>>: Freeze,

§

impl<'a, Msg> Unpin for Splitter<'a, Msg>
where Option<Box<dyn Fn(u16) -> Msg>>: Unpin, Option<Box<dyn FnOnce(&mut View<'_, Msg>) + 'a>>: Unpin,

§

impl<'a, Msg> UnsafeUnpin for Splitter<'a, Msg>
where Option<Box<dyn Fn(u16) -> Msg>>: UnsafeUnpin, Option<Box<dyn FnOnce(&mut View<'_, Msg>) + 'a>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.