Skip to main content

TabDelegate

Struct TabDelegate 

Source
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>

Source

pub fn new(label: impl Fn(usize, &T) -> LocalizedString + 'static) -> Self

Construct from the label callback. Every other field defaults to its identity behavior.

Source

pub fn icon(self, f: impl Fn(usize, &T) -> Option<IconWidget> + 'static) -> Self

Per-tab leading icon (rendered before the label).

Source

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).

Source

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).

Source

pub fn context_menu( self, f: impl Fn(usize, &T) -> Option<ContextMenuFactory> + 'static, ) -> Self

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<T: 'static> Debug for TabDelegate<T>

Source§

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

Formats the value using the given formatter. Read more

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> 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<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> 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.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<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