Skip to main content

Divider

Struct Divider 

Source
pub struct Divider {
    pub min_before: usize,
    pub min_after: usize,
    pub thickness: usize,
    /* private fields */
}
Expand description

A border between two panes along one axis, where the mouse can grab and drag it and the keyboard can nudge it.

Positions are cells along the axis: the first pane’s size, then thickness cells of border, then the second pane. Both panes keep at least their minimum while the total has room for that.

Fields§

§min_before: usize

The fewest cells the first pane takes.

§min_after: usize

The fewest cells the second pane takes.

§thickness: usize

The cells the border takes.

Implementations§

Source§

impl Divider

Source

pub fn new(thickness: usize) -> Divider

A border thickness cells thick, with no minimum pane size.

Source

pub fn min(self, cells: usize) -> Divider

Both panes at least cells.

Source

pub fn at(self, position: usize) -> Divider

Put the border at position (the first pane’s size), until dragged.

Source

pub fn position(&self) -> Option<usize>

Where the border was put or dragged to, before clamping.

Source

pub fn set_position(&mut self, position: Option<usize>)

Source

pub fn dragging(&self) -> bool

Whether a drag is under way.

Source

pub fn clamp(&self, position: usize, total: usize) -> usize

The first pane’s size for a border at position in total cells: both panes at least their minimum when there is room for that.

Source

pub fn resolve(&self, total: usize, default: usize) -> usize

The first pane’s size in total cells: where the border was put or dragged, clamped, or default when it has not been.

Source

pub fn hit(&self, at: usize, first: usize) -> bool

Whether at (a cell along the axis) is on the border when the first pane is first cells.

Source

pub fn press(&mut self, at: usize, first: usize) -> bool

A press at at: grab the border if it is there. Returns whether it was grabbed.

Source

pub fn drag(&mut self, at: usize, total: usize) -> bool

A drag to at in total cells: move the border there if grabbed. Returns whether it moved.

Source

pub fn release(&mut self)

Let go of the border.

Source

pub fn handle_mouse( &mut self, mouse: &Mouse, at: usize, first: usize, total: usize, ) -> bool

Press, drag and release from one mouse event along the axis, at being the event’s cell along it. Returns whether the divider used the event.

Source

pub fn nudge(&mut self, delta: isize, first: usize, total: usize)

Move the border by delta cells from first, within total.

Trait Implementations§

Source§

impl Clone for Divider

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Divider

Source§

impl Debug for Divider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Divider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Divider

Source§

impl PartialEq for Divider

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Divider

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.