ltk

Struct TabStrip

Source
pub struct TabStrip<Msg: Clone> { /* private fields */ }
Expand description

The open documents, as a strip on a desktop and a bar on a phone.

On a desktop, a strip of tabs with their icon, title and close button, sharing the width between a minimum and a part of the screen and scrolling sideways when even the minimum does not fit; buttons may go before the tabs, right after the last one and at the far right, and part of the width is always left clear. On a phone, a bar with the active tab and a counter that asks for the TabOverview, a grid of cards of every tab.

The widget is stateless but for its TabMotion, which the app keeps so tabs grow, shrink and slide as they open and close:

tab_strip( self.titles.iter().map( |( key, title )| tab( *key, title.clone() ).symbol( "features/console" ) ) )
    .selected( self.active )
    .on_select( Msg::Select )
    .on_close( Msg::Close )
    .on_overview( Msg::Overview )
    .layout( if self.phone { TabLayout::Mobile } else { TabLayout::Desktop } )
    .motion( &self.motion )
    .into()

Implementations§

Source§

impl<Msg: Clone + 'static> TabStrip<Msg>

Source

pub fn new(tabs: impl IntoIterator<Item = TabItem>) -> Self

Source

pub fn selected(self, idx: usize) -> Self

Source

pub fn on_select(self, f: impl Fn(usize) -> Msg + 'static) -> Self

Called with the index of the tab pressed.

Source

pub fn on_close(self, f: impl Fn(usize) -> Msg + 'static) -> Self

Called with the index of the tab whose close button was pressed.

Source

pub fn on_overview(self, msg: Msg) -> Self

The message the phone bar’s counter sends, to show the TabOverview. Without it the bar has no counter.

Source

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

Whether the desktop strip’s tabs can be dragged into another order; the app forwards the drag to the TabMotion and moves the tab TabMotion::drag_end reports. Dragging a tab selects it. Default: false.

Source

pub fn leading(self, button: impl Into<Element<Msg>>) -> Self

A button at the far left, before the tabs; also at the left of the phone bar.

Source

pub fn after_tabs(self, button: impl Into<Element<Msg>>) -> Self

A button right after the last tab, such as a new tab button. Not on the phone bar: the overview’s header has those.

Source

pub fn trailing(self, button: impl Into<Element<Msg>>) -> Self

A button at the far right; also at the right of the phone bar.

Source

pub fn mobile_center(self, center: impl Into<Element<Msg>>) -> Self

What the phone bar shows in place of the active tab’s icon and title, such as an address field.

Source

pub fn colors(self, colors: TabStripColors) -> Self

Source

pub fn layout(self, layout: TabLayout) -> Self

Source

pub fn motion(self, motion: &TabMotion) -> Self

The animation state the app keeps; without it the tabs do not animate.

Source

pub fn build(self) -> Element<Msg>

Trait Implementations§

Source§

impl<Msg: Clone + 'static> From<TabStrip<Msg>> for Element<Msg>

Source§

fn from(strip: TabStrip<Msg>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Msg> Freeze for TabStrip<Msg>
where Msg: Freeze,

§

impl<Msg> !RefUnwindSafe for TabStrip<Msg>

§

impl<Msg> !Send for TabStrip<Msg>

§

impl<Msg> !Sync for TabStrip<Msg>

§

impl<Msg> Unpin for TabStrip<Msg>
where Msg: Unpin,

§

impl<Msg> !UnwindSafe for TabStrip<Msg>

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,