Trait TabsItem

Source
pub trait TabsItem {
    // Required methods
    fn id(&self) -> &str;
    fn title(&self) -> &str;
    fn selected(&self) -> bool;

    // Provided methods
    fn leading_icon(&self) -> Option<&IconId> { ... }
    fn leading_icon_tint(&self) -> Option<Color> { ... }
    fn scope_kind(&self) -> &str { ... }
    fn unread(&self) -> bool { ... }
    fn processing(&self) -> bool { ... }
}
Expand description

Read-only data source for one immediate-mode tab.

IDs are cloned into TabsLayout::tab_rects and should be unique if the caller uses them for hit routing. The renderer does not validate uniqueness.

§Examples

use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "docs" }
    fn title(&self) -> &str { "Docs" }
    fn selected(&self) -> bool { true }
}
assert!(Tab.selected());

Required Methods§

Source

fn id(&self) -> &str

Returns the stable identity copied into output hit geometry.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
}
assert_eq!(Tab.id(), "one");
Source

fn title(&self) -> &str

Returns the visible title; empty text is rendered as "Conversation".

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
}
assert_eq!(Tab.title(), "One");
Source

fn selected(&self) -> bool

Returns whether selected background and border colors are used.

The renderer permits zero, one, or multiple selected items.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { true }
}
assert!(Tab.selected());

Provided Methods§

Source

fn leading_icon(&self) -> Option<&IconId>

Returns an optional 14-logical-pixel icon before the title.

The default is None and reserves no icon space.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
}
assert!(Tab.leading_icon().is_none());
Source

fn leading_icon_tint(&self) -> Option<Color>

Returns an optional icon tint; None uses TabsStyle::text_muted.

The value has no effect when Self::leading_icon returns None.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
}
assert!(Tab.leading_icon_tint().is_none());
Source

fn scope_kind(&self) -> &str

Returns the exact scope sentinel used to color the optional strip.

Accepted colored sentinels are "app_global", "workspace_global", "server", "path", "file", and "task". Empty or any other value uses neutral gray. Disable the strip with TabsBarOptions::show_scope_strip.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
    fn scope_kind(&self) -> &str { "workspace_global" }
}
assert_eq!(Tab.scope_kind(), "workspace_global");
Source

fn unread(&self) -> bool

Returns whether the shared unread/processing dot should be shown.

The default is false.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
}
assert!(!Tab.unread());
Source

fn processing(&self) -> bool

Returns whether the same status dot used for unread state is shown.

unread() || processing() produces one dot, never two. The default is false; this helper does not animate processing state.

§Examples
use ailloli_ui_widgets::controls::tabs::TabsItem;
struct Tab;
impl TabsItem for Tab {
    fn id(&self) -> &str { "one" }
    fn title(&self) -> &str { "One" }
    fn selected(&self) -> bool { false }
    fn processing(&self) -> bool { true }
}
assert!(Tab.processing());

Implementors§