pub struct Tabs { /* private fields */ }Expand description
A row of tabs. The strip publishes one Role::Tab node per tab.
Implementations§
Source§impl Tabs
impl Tabs
pub fn new(ident: impl Into<Ident>) -> Self
pub fn tab(self, tab: TabItem) -> Self
pub fn tabs(self, tabs: impl IntoIterator<Item = TabItem>) -> Self
pub fn selected(self, id: impl Into<SharedString>) -> Self
pub fn on_select( self, handler: impl Fn(SharedString, &mut Window, &mut App) + 'static, ) -> Self
Sourcepub fn on_close(
self,
handler: impl Fn(SharedString, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_close( self, handler: impl Fn(SharedString, &mut Window, &mut App) + 'static, ) -> Self
Reports the tab that should be put away. The strip closes nothing.
Only a tab marked TabItem::closable gets a control, and the control
is a target of its own: it swallows the click that reaches it, so the
gesture that means “switch to this tab” cannot land on it by accident.
A middle click anywhere on a closable tab reports the same thing, which
is the platform convention wherever a pointer has three buttons.
Sourcepub fn overflow_after(self, count: usize) -> Self
pub fn overflow_after(self, count: usize) -> Self
Keeps the first count tabs in the strip and moves the rest into the
overflow menu.
The cut is declared rather than measured, for the reason
Toolbar::overflow_after
states: GPUI measures after the element tree exists, so a strip cannot
find out what fits and then still move a tab somewhere else.
A menu rather than a scrolling strip, because a scroll offset is not something a reader can address: a tab scrolled out of view is at a position nobody can name, has no bounds, publishes nothing, and a horizontal scroll region would also eat the left and right arrows the strip uses to step between tabs. A menu keeps every hidden tab named, listed, and carrying its own save state. Either way the keyboard reaches a hidden tab directly: arrow, home and end step over every tab the caller declared, hidden or not, and report the one they land on.
The menu the overflowed tabs are moved into.
Caller-owned, because whether it is open outlives a frame. The menu
reports the tab that was taken as MenuEvent::Invoked,
carrying the same id the strip would have reported.
Sourcepub fn reorderable(self, reorderable: bool) -> Self
pub fn reorderable(self, reorderable: bool) -> Self
Lets a tab be dragged to another place in the strip.
Sourcepub fn accepts(
self,
predicate: impl Fn(&DragItem, &DropPosition) -> bool + 'static,
) -> Self
pub fn accepts( self, predicate: impl Fn(&DragItem, &DropPosition) -> bool + 'static, ) -> Self
Whether this strip takes a payload, and where. Without one, it takes its own tabs and nothing else.
Sourcepub fn on_reorder(
self,
handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_reorder( self, handler: impl Fn(&DropIntent, &mut Window, &mut App) + 'static, ) -> Self
Reports where a dropped tab should go. The strip does not move it.
Trait Implementations§
Source§impl Disableable for Tabs
impl Disableable for Tabs
Source§impl IntoElement for Tabs
impl IntoElement for Tabs
Source§type Element = ViewElement<Tabs>
type Element = ViewElement<Tabs>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Tabs
impl RenderOnce for Tabs
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Tabs
impl !Send for Tabs
impl !Sync for Tabs
impl !UnwindSafe for Tabs
impl Freeze for Tabs
impl Unpin for Tabs
impl UnsafeUnpin for Tabs
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
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<E> Flipping for Ewhere
E: IntoElement,
impl<E> Flipping for Ewhere
E: IntoElement,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 more