iced_aw/widget/tab_bar/
tab_label.rs

1//! A [`TabLabel`] showing an icon and/or a text on a tab.
2//!
3//! *This API requires the following crate features to be activated: `tab_bar`*
4
5/// A [`TabLabel`] showing an icon and/or a text on a tab
6/// on a [`TabBar`](super::TabBar).
7#[allow(missing_debug_implementations)]
8#[derive(Clone, Hash)]
9pub enum TabLabel {
10    /// A [`TabLabel`] showing only an icon on the tab.
11    Icon(char),
12
13    /// A [`TabLabel`] showing only a text on the tab.
14    Text(String),
15
16    /// A [`TabLabel`] showing an icon and a text on the tab.
17    IconText(char, String),
18    // TODO: Support any element as a label.
19}
20
21impl From<char> for TabLabel {
22    fn from(value: char) -> Self {
23        Self::Icon(value)
24    }
25}
26
27impl From<&str> for TabLabel {
28    fn from(value: &str) -> Self {
29        Self::Text(value.to_owned())
30    }
31}
32
33impl From<String> for TabLabel {
34    fn from(value: String) -> Self {
35        Self::Text(value)
36    }
37}
38
39impl From<(char, &str)> for TabLabel {
40    fn from(value: (char, &str)) -> Self {
41        Self::IconText(value.0, value.1.to_owned())
42    }
43}
44
45impl From<(char, String)> for TabLabel {
46    fn from(value: (char, String)) -> Self {
47        Self::IconText(value.0, value.1)
48    }
49}