Skip to main content

TabBar

Struct TabBar 

Source
pub struct TabBar<TabId: Clone + PartialEq> {
    pub tabs: Vec<Tab<TabId>>,
    pub active: TabId,
}
Expand description

A horizontal tab strip.

TabBar is generic over TabId so that applications can use any Clone + PartialEq type — typically a small enum.

§Example

use snora_core::{Tab, TabBar};

#[derive(Clone, PartialEq, Eq, Debug)]
enum WorkspaceTab { Library, Editor }

let bar = TabBar {
    tabs: vec![
        Tab { id: WorkspaceTab::Library, label: "Library".into(), icon: None },
        Tab { id: WorkspaceTab::Editor,  label: "Editor".into(),  icon: None },
    ],
    active: WorkspaceTab::Library,
};
assert_eq!(bar.tabs.len(), 2);
assert_eq!(bar.active, WorkspaceTab::Library);

Fields§

§tabs: Vec<Tab<TabId>>

Tabs in display order. The widget engine respects this order; horizontal mirroring under crate::LayoutDirection::Rtl is the engine’s responsibility.

§active: TabId

The currently selected tab id. The widget renders this tab with an active treatment (typically an underline). If active does not match any tab in tabs, no tab is highlighted.

Trait Implementations§

Source§

impl<TabId: Clone + Clone + PartialEq> Clone for TabBar<TabId>

Source§

fn clone(&self) -> TabBar<TabId>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<TabId: Debug + Clone + PartialEq> Debug for TabBar<TabId>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TabId> Freeze for TabBar<TabId>
where Vec<Tab<TabId>>: Freeze, TabId: Freeze,

§

impl<TabId> RefUnwindSafe for TabBar<TabId>
where Vec<Tab<TabId>>: RefUnwindSafe, TabId: RefUnwindSafe,

§

impl<TabId> Send for TabBar<TabId>
where Vec<Tab<TabId>>: Send, TabId: Send,

§

impl<TabId> Sync for TabBar<TabId>
where Vec<Tab<TabId>>: Sync, TabId: Sync,

§

impl<TabId> Unpin for TabBar<TabId>
where Vec<Tab<TabId>>: Unpin, TabId: Unpin,

§

impl<TabId> UnsafeUnpin for TabBar<TabId>
where Vec<Tab<TabId>>: UnsafeUnpin, TabId: UnsafeUnpin,

§

impl<TabId> UnwindSafe for TabBar<TabId>
where Vec<Tab<TabId>>: UnwindSafe, TabId: UnwindSafe,

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.