pub struct TabDelegate<T: 'static> { /* private fields */ }Expand description
Resolves per-tab UI from a model item.
Required: a label callback. Everything else is optional and
defaults to “no leading icon, no slots, no tooltip, not closable,
not pinned, enabled”.
Implementations§
Source§impl<T: 'static> TabDelegate<T>
impl<T: 'static> TabDelegate<T>
Sourcepub fn new(label: impl Fn(usize, &T) -> LocalizedString + 'static) -> Self
pub fn new(label: impl Fn(usize, &T) -> LocalizedString + 'static) -> Self
Construct from the label callback. Every other field defaults to its identity behavior.
Sourcepub fn icon(self, f: impl Fn(usize, &T) -> Option<IconWidget> + 'static) -> Self
pub fn icon(self, f: impl Fn(usize, &T) -> Option<IconWidget> + 'static) -> Self
Per-tab leading icon (rendered before the label).
Sourcepub fn leading(
self,
f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static,
) -> Self
pub fn leading( self, f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static, ) -> Self
Per-tab leading slot (between the icon and label, or before the label when no icon is present).
Sourcepub fn trailing(
self,
f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static,
) -> Self
pub fn trailing( self, f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static, ) -> Self
Per-tab trailing slot (between the label and the close button, or at the trailing edge when no close button is present).
Per-tab context menu factory. Activated by right-click /
long-press / accesskit::Action::ShowContextMenu.
The closure runs once per build and returns an optional
ContextMenuFactory. The factory itself is called every
time the menu opens, returning a fresh menu widget each call —
the framework cannot reuse a single widget instance across
multiple openings.
Sourcepub fn closable(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
pub fn closable(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
Per-tab closable flag. When true, the tab gets a trailing
close button and middle-click / Ctrl+W close affordances.
Pinned tabs suppress the close button regardless of this flag
(pinned tabs only close via the context menu — Firefox
convention).
Sourcepub fn pinned(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
pub fn pinned(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
Per-tab pinned flag. Pinned tabs render in a leading non-scrolling region with a fixed icon-only width.
Sourcepub fn enabled(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
pub fn enabled(self, f: impl Fn(usize, &T) -> bool + 'static) -> Self
Per-tab enabled flag. Disabled tabs are visible but not activatable, skipped by keyboard navigation, and excluded from the close / pin / context-menu affordances.
Sourcepub fn tooltip(
self,
f: impl Fn(usize, &T) -> Option<LocalizedString> + 'static,
) -> Self
pub fn tooltip( self, f: impl Fn(usize, &T) -> Option<LocalizedString> + 'static, ) -> Self
Per-tab tooltip text. Shown on hover via the existing
WidgetBuilder::tooltip mechanism.
Sourcepub fn rich_tooltip_key(
self,
f: impl Fn(usize, &T) -> Option<String> + 'static,
) -> Self
pub fn rich_tooltip_key( self, f: impl Fn(usize, &T) -> Option<String> + 'static, ) -> Self
Per-tab rich-tooltip registry key. Returning Some(key) makes
the tab show a rich tooltip resolved against
TooltipRegistry.
Sourcepub fn rich_tooltip_content_with(
self,
f: impl Fn(usize, &T) -> Option<TooltipContent> + 'static,
) -> Self
pub fn rich_tooltip_content_with( self, f: impl Fn(usize, &T) -> Option<TooltipContent> + 'static, ) -> Self
Per-tab inline rich-tooltip content. Skips the registry — useful
for tooltips whose body depends on T’s state.
Sourcepub fn composite_tooltip_with(
self,
f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static,
) -> Self
pub fn composite_tooltip_with( self, f: impl Fn(usize, &T) -> Option<Box<dyn Widget>> + 'static, ) -> Self
Per-tab composite-tooltip body factory. Returning
Some(boxed_widget) makes the tab show a composite tooltip
containing that subtree. The closure runs at tab-header build
time (and on every rebuild after data changes), so the body
can carry per-tab dynamic state.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TabDelegate<T>
impl<T> !Send for TabDelegate<T>
impl<T> !Sync for TabDelegate<T>
impl<T> !UnwindSafe for TabDelegate<T>
impl<T> Freeze for TabDelegate<T>
impl<T> Unpin for TabDelegate<T>
impl<T> UnsafeUnpin for TabDelegate<T>
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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