TextColor
-> Color
This commit is contained in:
parent
56d45e72cd
commit
453aa5ffd7
24 changed files with 148 additions and 148 deletions
|
@ -9,48 +9,6 @@ pub enum LabelSize {
|
|||
Small,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Copy, Clone)]
|
||||
pub enum TextColor {
|
||||
#[default]
|
||||
Default,
|
||||
Accent,
|
||||
Created,
|
||||
Deleted,
|
||||
Disabled,
|
||||
Error,
|
||||
Hidden,
|
||||
Info,
|
||||
Modified,
|
||||
Muted,
|
||||
Placeholder,
|
||||
Player(u32),
|
||||
Selected,
|
||||
Success,
|
||||
Warning,
|
||||
}
|
||||
|
||||
impl TextColor {
|
||||
pub fn color(&self, cx: &WindowContext) -> Hsla {
|
||||
match self {
|
||||
TextColor::Default => cx.theme().colors().text,
|
||||
TextColor::Muted => cx.theme().colors().text_muted,
|
||||
TextColor::Created => cx.theme().status().created,
|
||||
TextColor::Modified => cx.theme().status().modified,
|
||||
TextColor::Deleted => cx.theme().status().deleted,
|
||||
TextColor::Disabled => cx.theme().colors().text_disabled,
|
||||
TextColor::Hidden => cx.theme().status().hidden,
|
||||
TextColor::Info => cx.theme().status().info,
|
||||
TextColor::Placeholder => cx.theme().colors().text_placeholder,
|
||||
TextColor::Accent => cx.theme().colors().text_accent,
|
||||
TextColor::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,
|
||||
TextColor::Error => cx.theme().status().error,
|
||||
TextColor::Selected => cx.theme().colors().text_accent,
|
||||
TextColor::Success => cx.theme().status().success,
|
||||
TextColor::Warning => cx.theme().status().warning,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Copy, Clone)]
|
||||
pub enum LineHeightStyle {
|
||||
#[default]
|
||||
|
@ -64,7 +22,7 @@ pub struct Label {
|
|||
label: SharedString,
|
||||
size: LabelSize,
|
||||
line_height_style: LineHeightStyle,
|
||||
color: TextColor,
|
||||
color: Color,
|
||||
strikethrough: bool,
|
||||
}
|
||||
|
||||
|
@ -80,7 +38,7 @@ impl Component for Label {
|
|||
.top_1_2()
|
||||
.w_full()
|
||||
.h_px()
|
||||
.bg(TextColor::Hidden.color(cx)),
|
||||
.bg(Color::Hidden.color(cx)),
|
||||
)
|
||||
})
|
||||
.map(|this| match self.size {
|
||||
|
@ -101,7 +59,7 @@ impl Label {
|
|||
label: label.into(),
|
||||
size: LabelSize::Default,
|
||||
line_height_style: LineHeightStyle::default(),
|
||||
color: TextColor::Default,
|
||||
color: Color::Default,
|
||||
strikethrough: false,
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +69,7 @@ impl Label {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn color(mut self, color: TextColor) -> Self {
|
||||
pub fn color(mut self, color: Color) -> Self {
|
||||
self.color = color;
|
||||
self
|
||||
}
|
||||
|
@ -131,7 +89,7 @@ impl Label {
|
|||
pub struct HighlightedLabel {
|
||||
label: SharedString,
|
||||
size: LabelSize,
|
||||
color: TextColor,
|
||||
color: Color,
|
||||
highlight_indices: Vec<usize>,
|
||||
strikethrough: bool,
|
||||
}
|
||||
|
@ -185,7 +143,7 @@ impl Component for HighlightedLabel {
|
|||
.my_auto()
|
||||
.w_full()
|
||||
.h_px()
|
||||
.bg(TextColor::Hidden.color(cx)),
|
||||
.bg(Color::Hidden.color(cx)),
|
||||
)
|
||||
})
|
||||
.map(|this| match self.size {
|
||||
|
@ -203,7 +161,7 @@ impl HighlightedLabel {
|
|||
Self {
|
||||
label: label.into(),
|
||||
size: LabelSize::Default,
|
||||
color: TextColor::Default,
|
||||
color: Color::Default,
|
||||
highlight_indices,
|
||||
strikethrough: false,
|
||||
}
|
||||
|
@ -214,7 +172,7 @@ impl HighlightedLabel {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn color(mut self, color: TextColor) -> Self {
|
||||
pub fn color(mut self, color: Color) -> Self {
|
||||
self.color = color;
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue