pub struct Strip<Id> { /* private fields */ }Expand description
An ordered set of tabs, one of them active.
Id is whatever names a tab to its owner — a counter, a path, a layout
member. Identity is PartialEq, so an id that compares equal to one already
in the strip is the same tab.
A strip with tabs in it always has one in front: Self::active is None
only while Self::is_empty.
Implementations§
Source§impl<Id: Clone + PartialEq> Strip<Id>
impl<Id: Clone + PartialEq> Strip<Id>
pub fn new() -> Self
pub fn active(&self) -> Option<&Id>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, id: &Id) -> bool
pub fn index_of(&self, id: &Id) -> Option<usize>
Sourcepub fn open(&mut self, id: Id)
pub fn open(&mut self, id: Id)
Bring id to the front, adding it at the end of the strip if it is not
already there. An id that is there keeps its place.
Sourcepub fn activate(&mut self, id: &Id) -> bool
pub fn activate(&mut self, id: &Id) -> bool
Bring an existing tab to the front. false, and nothing moves, when it
is not in the strip.
Sourcepub fn close(&mut self, id: &Id) -> bool
pub fn close(&mut self, id: &Id) -> bool
Take a tab out. false when it was not in the strip.
Closing the tab in front hands the front to its right-hand neighbour, or to the new last tab when it had none. Closing any other tab leaves the front where it is.
Sourcepub fn cycle(&mut self, step: isize)
pub fn cycle(&mut self, step: isize)
Step the front step tabs along, wrapping at both ends. An empty strip
does not move.
Sourcepub fn reorder(&mut self, from: usize, to: usize)
pub fn reorder(&mut self, from: usize, to: usize)
Move the tab at from so that it sits at to. Out-of-range ends are
ignored rather than clamped: a drag that left the strip did not mean the
last slot.
The front is held by identity, so reordering never changes which tab is in front.
Sourcepub fn carry(
&mut self,
id: &Id,
travel: f32,
width: impl Fn(&Id) -> Option<f32>,
) -> (Vec<Id>, f32)
pub fn carry( &mut self, id: &Id, travel: f32, width: impl Fn(&Id) -> Option<f32>, ) -> (Vec<Id>, f32)
Carry id travel pixels along the strip from its slot, positive to
the right, passing every neighbour whose centre its own centre crosses.
Returns the tabs passed, in the order passed, and the travel left over
past the new slot. width measures a tab; a tab it cannot measure is
not passed, and neither is anything beyond it.
Trait Implementations§
impl<Id: Eq> Eq for Strip<Id>
Source§impl<Id: Clone + PartialEq> FromIterator<Id> for Strip<Id>
impl<Id: Clone + PartialEq> FromIterator<Id> for Strip<Id>
Source§fn from_iter<T: IntoIterator<Item = Id>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Id>>(iter: T) -> Self
The first of the run is the one in front.
impl<Id: PartialEq> StructuralPartialEq for Strip<Id>
Auto Trait Implementations§
impl<Id> Freeze for Strip<Id>
impl<Id> RefUnwindSafe for Strip<Id>
impl<Id> Send for Strip<Id>
impl<Id> Sync for Strip<Id>
impl<Id> Unpin for Strip<Id>
impl<Id> UnsafeUnpin for Strip<Id>
impl<Id> UnwindSafe for Strip<Id>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().