TextColor
-> Color
This commit is contained in:
parent
56d45e72cd
commit
453aa5ffd7
24 changed files with 148 additions and 148 deletions
|
@ -37,7 +37,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextColor, Tooltip};
|
use ui::{h_stack, Button, ButtonVariant, Color, KeyBinding, Label, Tooltip};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
// const MAX_PROJECT_NAME_LENGTH: usize = 40;
|
// const MAX_PROJECT_NAME_LENGTH: usize = 40;
|
||||||
|
@ -115,7 +115,7 @@ impl Render for CollabTitlebarItem {
|
||||||
.child(
|
.child(
|
||||||
Button::new("player")
|
Button::new("player")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
.color(Some(TextColor::Player(0))),
|
.color(Some(Color::Player(0))),
|
||||||
)
|
)
|
||||||
.tooltip(move |cx| Tooltip::text("Toggle following", cx)),
|
.tooltip(move |cx| Tooltip::text("Toggle following", cx)),
|
||||||
)
|
)
|
||||||
|
@ -133,7 +133,7 @@ impl Render for CollabTitlebarItem {
|
||||||
.child(
|
.child(
|
||||||
Button::new("branch_name")
|
Button::new("branch_name")
|
||||||
.variant(ButtonVariant::Ghost)
|
.variant(ButtonVariant::Ghost)
|
||||||
.color(Some(TextColor::Muted)),
|
.color(Some(Color::Muted)),
|
||||||
)
|
)
|
||||||
.tooltip(move |cx| {
|
.tooltip(move |cx| {
|
||||||
cx.build_view(|_| {
|
cx.build_view(|_| {
|
||||||
|
|
|
@ -36,7 +36,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
pub use toolbar_controls::ToolbarControls;
|
pub use toolbar_controls::ToolbarControls;
|
||||||
use ui::{h_stack, HighlightedLabel, Icon, IconElement, Label, TextColor};
|
use ui::{h_stack, Color, HighlightedLabel, Icon, IconElement, Label};
|
||||||
use util::TryFutureExt;
|
use util::TryFutureExt;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
item::{BreadcrumbText, Item, ItemEvent, ItemHandle},
|
item::{BreadcrumbText, Item, ItemEvent, ItemHandle},
|
||||||
|
@ -778,15 +778,15 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
|
||||||
.bg(gpui::red())
|
.bg(gpui::red())
|
||||||
.map(|stack| {
|
.map(|stack| {
|
||||||
let icon = if diagnostic.severity == DiagnosticSeverity::ERROR {
|
let icon = if diagnostic.severity == DiagnosticSeverity::ERROR {
|
||||||
IconElement::new(Icon::XCircle).color(TextColor::Error)
|
IconElement::new(Icon::XCircle).color(Color::Error)
|
||||||
} else {
|
} else {
|
||||||
IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning)
|
IconElement::new(Icon::ExclamationTriangle).color(Color::Warning)
|
||||||
};
|
};
|
||||||
|
|
||||||
stack.child(div().pl_8().child(icon))
|
stack.child(div().pl_8().child(icon))
|
||||||
})
|
})
|
||||||
.when_some(diagnostic.source.as_ref(), |stack, source| {
|
.when_some(diagnostic.source.as_ref(), |stack, source| {
|
||||||
stack.child(Label::new(format!("{source}:")).color(TextColor::Accent))
|
stack.child(Label::new(format!("{source}:")).color(Color::Accent))
|
||||||
})
|
})
|
||||||
.child(HighlightedLabel::new(message.clone(), highlights.clone()))
|
.child(HighlightedLabel::new(message.clone(), highlights.clone()))
|
||||||
.when_some(diagnostic.code.as_ref(), |stack, code| {
|
.when_some(diagnostic.code.as_ref(), |stack, code| {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use gpui::{
|
||||||
use language::Diagnostic;
|
use language::Diagnostic;
|
||||||
use lsp::LanguageServerId;
|
use lsp::LanguageServerId;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{h_stack, Icon, IconElement, Label, TextColor, Tooltip};
|
use ui::{h_stack, Color, Icon, IconElement, Label, Tooltip};
|
||||||
use workspace::{item::ItemHandle, StatusItemView, ToolbarItemEvent, Workspace};
|
use workspace::{item::ItemHandle, StatusItemView, ToolbarItemEvent, Workspace};
|
||||||
|
|
||||||
use crate::ProjectDiagnosticsEditor;
|
use crate::ProjectDiagnosticsEditor;
|
||||||
|
@ -26,20 +26,20 @@ impl Render for DiagnosticIndicator {
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
|
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
|
||||||
(0, 0) => h_stack().child(IconElement::new(Icon::Check).color(TextColor::Success)),
|
(0, 0) => h_stack().child(IconElement::new(Icon::Check).color(Color::Success)),
|
||||||
(0, warning_count) => h_stack()
|
(0, warning_count) => h_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning))
|
.child(IconElement::new(Icon::ExclamationTriangle).color(Color::Warning))
|
||||||
.child(Label::new(warning_count.to_string())),
|
.child(Label::new(warning_count.to_string())),
|
||||||
(error_count, 0) => h_stack()
|
(error_count, 0) => h_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(IconElement::new(Icon::XCircle).color(TextColor::Error))
|
.child(IconElement::new(Icon::XCircle).color(Color::Error))
|
||||||
.child(Label::new(error_count.to_string())),
|
.child(Label::new(error_count.to_string())),
|
||||||
(error_count, warning_count) => h_stack()
|
(error_count, warning_count) => h_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(IconElement::new(Icon::XCircle).color(TextColor::Error))
|
.child(IconElement::new(Icon::XCircle).color(Color::Error))
|
||||||
.child(Label::new(error_count.to_string()))
|
.child(Label::new(error_count.to_string()))
|
||||||
.child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning))
|
.child(IconElement::new(Icon::ExclamationTriangle).color(Color::Warning))
|
||||||
.child(Label::new(warning_count.to_string())),
|
.child(Label::new(warning_count.to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4408,7 +4408,7 @@ impl Editor {
|
||||||
editor.fold_at(&FoldAt { buffer_row }, cx);
|
editor.fold_at(&FoldAt { buffer_row }, cx);
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.color(ui::TextColor::Muted)
|
.color(ui::Color::Muted)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
|
|
|
@ -30,7 +30,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use text::Selection;
|
use text::Selection;
|
||||||
use theme::{ActiveTheme, Theme};
|
use theme::{ActiveTheme, Theme};
|
||||||
use ui::{Label, TextColor};
|
use ui::{Color, Label};
|
||||||
use util::{paths::PathExt, ResultExt, TryFutureExt};
|
use util::{paths::PathExt, ResultExt, TryFutureExt};
|
||||||
use workspace::item::{BreadcrumbText, FollowEvent, FollowableEvents, FollowableItemHandle};
|
use workspace::item::{BreadcrumbText, FollowEvent, FollowableEvents, FollowableItemHandle};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
|
@ -604,7 +604,7 @@ impl Item for Editor {
|
||||||
&description,
|
&description,
|
||||||
MAX_TAB_TITLE_LEN,
|
MAX_TAB_TITLE_LEN,
|
||||||
))
|
))
|
||||||
.color(TextColor::Muted),
|
.color(Color::Muted),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})),
|
})),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use text::{Bias, Point};
|
use text::{Bias, Point};
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{h_stack, v_stack, Label, StyledExt, TextColor};
|
use ui::{h_stack, v_stack, Color, Label, StyledExt};
|
||||||
use util::paths::FILE_ROW_COLUMN_DELIMITER;
|
use util::paths::FILE_ROW_COLUMN_DELIMITER;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ impl Render for GoToLine {
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.px_2()
|
.px_2()
|
||||||
.py_1()
|
.py_1()
|
||||||
.child(Label::new(self.current_text.clone()).color(TextColor::Muted)),
|
.child(Label::new(self.current_text.clone()).color(Color::Muted)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gpui::{
|
||||||
MouseDownEvent, Render, Task, UniformListScrollHandle, View, ViewContext, WindowContext,
|
MouseDownEvent, Render, Task, UniformListScrollHandle, View, ViewContext, WindowContext,
|
||||||
};
|
};
|
||||||
use std::{cmp, sync::Arc};
|
use std::{cmp, sync::Arc};
|
||||||
use ui::{prelude::*, v_stack, Divider, Label, TextColor};
|
use ui::{prelude::*, v_stack, Color, Divider, Label};
|
||||||
|
|
||||||
pub struct Picker<D: PickerDelegate> {
|
pub struct Picker<D: PickerDelegate> {
|
||||||
pub delegate: D,
|
pub delegate: D,
|
||||||
|
@ -250,7 +250,7 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
||||||
v_stack().p_1().grow().child(
|
v_stack().p_1().grow().child(
|
||||||
div()
|
div()
|
||||||
.px_1()
|
.px_1()
|
||||||
.child(Label::new("No matches").color(TextColor::Muted)),
|
.child(Label::new("No matches").color(Color::Muted)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,6 +2,7 @@ mod avatar;
|
||||||
mod button;
|
mod button;
|
||||||
mod checkbox;
|
mod checkbox;
|
||||||
mod context_menu;
|
mod context_menu;
|
||||||
|
mod disclosure;
|
||||||
mod divider;
|
mod divider;
|
||||||
mod icon;
|
mod icon;
|
||||||
mod icon_button;
|
mod icon_button;
|
||||||
|
@ -19,6 +20,7 @@ pub use avatar::*;
|
||||||
pub use button::*;
|
pub use button::*;
|
||||||
pub use checkbox::*;
|
pub use checkbox::*;
|
||||||
pub use context_menu::*;
|
pub use context_menu::*;
|
||||||
|
pub use disclosure::*;
|
||||||
pub use divider::*;
|
pub use divider::*;
|
||||||
pub use icon::*;
|
pub use icon::*;
|
||||||
pub use icon_button::*;
|
pub use icon_button::*;
|
||||||
|
|
|
@ -6,7 +6,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{h_stack, Icon, IconButton, IconElement, Label, LineHeightStyle, TextColor};
|
use crate::{h_stack, Color, Icon, IconButton, IconElement, Label, LineHeightStyle};
|
||||||
|
|
||||||
/// Provides the flexibility to use either a standard
|
/// Provides the flexibility to use either a standard
|
||||||
/// button or an icon button in a given context.
|
/// button or an icon button in a given context.
|
||||||
|
@ -73,7 +73,7 @@ pub struct Button {
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
variant: ButtonVariant,
|
variant: ButtonVariant,
|
||||||
width: Option<DefiniteLength>,
|
width: Option<DefiniteLength>,
|
||||||
color: Option<TextColor>,
|
color: Option<Color>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Button {
|
impl Component for Button {
|
||||||
|
@ -81,9 +81,9 @@ impl Component for Button {
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
let (icon_color, label_color) = match (self.disabled, self.color) {
|
let (icon_color, label_color) = match (self.disabled, self.color) {
|
||||||
(true, _) => (TextColor::Disabled, TextColor::Disabled),
|
(true, _) => (Color::Disabled, Color::Disabled),
|
||||||
(_, None) => (TextColor::Default, TextColor::Default),
|
(_, None) => (Color::Default, Color::Default),
|
||||||
(_, Some(color)) => (TextColor::from(color), color),
|
(_, Some(color)) => (Color::from(color), color),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut button = h_stack()
|
let mut button = h_stack()
|
||||||
|
@ -181,14 +181,14 @@ impl Button {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: Option<TextColor>) -> Self {
|
pub fn color(mut self, color: Option<Color>) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn label_color(&self, color: Option<TextColor>) -> TextColor {
|
pub fn label_color(&self, color: Option<Color>) -> Color {
|
||||||
if self.disabled {
|
if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else if let Some(color) = color {
|
} else if let Some(color) = color {
|
||||||
color
|
color
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,13 +196,13 @@ impl Button {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_label(&self, color: TextColor) -> Label {
|
fn render_label(&self, color: Color) -> Label {
|
||||||
Label::new(self.label.clone())
|
Label::new(self.label.clone())
|
||||||
.color(color)
|
.color(color)
|
||||||
.line_height_style(LineHeightStyle::UILabel)
|
.line_height_style(LineHeightStyle::UILabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_icon(&self, icon_color: TextColor) -> Option<IconElement> {
|
fn render_icon(&self, icon_color: Color) -> Option<IconElement> {
|
||||||
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use gpui::{div, prelude::*, Div, Element, ElementId, RenderOnce, Styled, WindowC
|
||||||
|
|
||||||
use theme2::ActiveTheme;
|
use theme2::ActiveTheme;
|
||||||
|
|
||||||
use crate::{Icon, IconElement, Selection, TextColor};
|
use crate::{Color, Icon, IconElement, Selection};
|
||||||
|
|
||||||
pub type CheckHandler = Box<dyn Fn(&Selection, &mut WindowContext) + 'static>;
|
pub type CheckHandler = Box<dyn Fn(&Selection, &mut WindowContext) + 'static>;
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ impl Component for Checkbox {
|
||||||
.color(
|
.color(
|
||||||
// If the checkbox is disabled we change the color of the icon.
|
// If the checkbox is disabled we change the color of the icon.
|
||||||
if self.disabled {
|
if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Selected
|
Color::Selected
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -49,9 +49,9 @@ impl Component for Checkbox {
|
||||||
.color(
|
.color(
|
||||||
// If the checkbox is disabled we change the color of the icon.
|
// If the checkbox is disabled we change the color of the icon.
|
||||||
if self.disabled {
|
if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Selected
|
Color::Selected
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -176,9 +176,9 @@ impl Checkbox {
|
||||||
.color(
|
.color(
|
||||||
// If the checkbox is disabled we change the color of the icon.
|
// If the checkbox is disabled we change the color of the icon.
|
||||||
if self.disabled {
|
if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Selected
|
Color::Selected
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -191,9 +191,9 @@ impl Checkbox {
|
||||||
.color(
|
.color(
|
||||||
// If the checkbox is disabled we change the color of the icon.
|
// If the checkbox is disabled we change the color of the icon.
|
||||||
if self.disabled {
|
if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Selected
|
Color::Selected
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
19
crates/ui2/src/components/disclosure.rs
Normal file
19
crates/ui2/src/components/disclosure.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use gpui::{div, Element, ParentElement};
|
||||||
|
|
||||||
|
use crate::{Color, Icon, IconElement, IconSize, Toggle};
|
||||||
|
|
||||||
|
pub fn disclosure_control(toggle: Toggle) -> impl Element {
|
||||||
|
match (toggle.is_toggleable(), toggle.is_toggled()) {
|
||||||
|
(false, _) => div(),
|
||||||
|
(_, true) => div().child(
|
||||||
|
IconElement::new(Icon::ChevronDown)
|
||||||
|
.color(Color::Muted)
|
||||||
|
.size(IconSize::Small),
|
||||||
|
),
|
||||||
|
(_, false) => div().child(
|
||||||
|
IconElement::new(Icon::ChevronRight)
|
||||||
|
.color(Color::Muted)
|
||||||
|
.size(IconSize::Small),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ pub enum Icon {
|
||||||
BellOff,
|
BellOff,
|
||||||
BellRing,
|
BellRing,
|
||||||
Bolt,
|
Bolt,
|
||||||
|
CaseSensitive,
|
||||||
Check,
|
Check,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
ChevronLeft,
|
ChevronLeft,
|
||||||
|
@ -65,9 +66,8 @@ pub enum Icon {
|
||||||
Split,
|
Split,
|
||||||
SplitMessage,
|
SplitMessage,
|
||||||
Terminal,
|
Terminal,
|
||||||
XCircle,
|
|
||||||
WholeWord,
|
WholeWord,
|
||||||
CaseSensitive,
|
XCircle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Icon {
|
impl Icon {
|
||||||
|
@ -84,6 +84,7 @@ impl Icon {
|
||||||
Icon::BellOff => "icons/bell-off.svg",
|
Icon::BellOff => "icons/bell-off.svg",
|
||||||
Icon::BellRing => "icons/bell-ring.svg",
|
Icon::BellRing => "icons/bell-ring.svg",
|
||||||
Icon::Bolt => "icons/bolt.svg",
|
Icon::Bolt => "icons/bolt.svg",
|
||||||
|
Icon::CaseSensitive => "icons/case_insensitive.svg",
|
||||||
Icon::Check => "icons/check.svg",
|
Icon::Check => "icons/check.svg",
|
||||||
Icon::ChevronDown => "icons/chevron_down.svg",
|
Icon::ChevronDown => "icons/chevron_down.svg",
|
||||||
Icon::ChevronLeft => "icons/chevron_left.svg",
|
Icon::ChevronLeft => "icons/chevron_left.svg",
|
||||||
|
@ -126,9 +127,8 @@ impl Icon {
|
||||||
Icon::Split => "icons/split.svg",
|
Icon::Split => "icons/split.svg",
|
||||||
Icon::SplitMessage => "icons/split_message.svg",
|
Icon::SplitMessage => "icons/split_message.svg",
|
||||||
Icon::Terminal => "icons/terminal.svg",
|
Icon::Terminal => "icons/terminal.svg",
|
||||||
Icon::XCircle => "icons/error.svg",
|
|
||||||
Icon::WholeWord => "icons/word_search.svg",
|
Icon::WholeWord => "icons/word_search.svg",
|
||||||
Icon::CaseSensitive => "icons/case_insensitive.svg",
|
Icon::XCircle => "icons/error.svg",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ impl Icon {
|
||||||
#[derive(RenderOnce)]
|
#[derive(RenderOnce)]
|
||||||
pub struct IconElement {
|
pub struct IconElement {
|
||||||
path: SharedString,
|
path: SharedString,
|
||||||
color: TextColor,
|
color: Color,
|
||||||
size: IconSize,
|
size: IconSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ impl IconElement {
|
||||||
pub fn new(icon: Icon) -> Self {
|
pub fn new(icon: Icon) -> Self {
|
||||||
Self {
|
Self {
|
||||||
path: icon.path().into(),
|
path: icon.path().into(),
|
||||||
color: TextColor::default(),
|
color: Color::default(),
|
||||||
size: IconSize::default(),
|
size: IconSize::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,12 +169,12 @@ impl IconElement {
|
||||||
pub fn from_path(path: impl Into<SharedString>) -> Self {
|
pub fn from_path(path: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
color: TextColor::default(),
|
color: Color::default(),
|
||||||
size: IconSize::default(),
|
size: IconSize::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: TextColor) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use gpui::{prelude::*, Action, AnyView, Div, MouseButton, MouseDownEvent, Statef
|
||||||
pub struct IconButton {
|
pub struct IconButton {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color: TextColor,
|
color: Color,
|
||||||
variant: ButtonVariant,
|
variant: ButtonVariant,
|
||||||
state: InteractionState,
|
state: InteractionState,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
|
@ -18,8 +18,8 @@ impl Component for IconButton {
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
let icon_color = match (self.state, self.color) {
|
let icon_color = match (self.state, self.color) {
|
||||||
(InteractionState::Disabled, _) => TextColor::Disabled,
|
(InteractionState::Disabled, _) => Color::Disabled,
|
||||||
(InteractionState::Active, _) => TextColor::Selected,
|
(InteractionState::Active, _) => Color::Selected,
|
||||||
_ => self.color,
|
_ => self.color,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ impl IconButton {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
icon,
|
icon,
|
||||||
color: TextColor::default(),
|
color: Color::default(),
|
||||||
variant: ButtonVariant::default(),
|
variant: ButtonVariant::default(),
|
||||||
state: InteractionState::default(),
|
state: InteractionState::default(),
|
||||||
selected: false,
|
selected: false,
|
||||||
|
@ -90,7 +90,7 @@ impl IconButton {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: TextColor) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,15 @@ impl Component for Input {
|
||||||
};
|
};
|
||||||
|
|
||||||
let placeholder_label = Label::new(self.placeholder.clone()).color(if self.disabled {
|
let placeholder_label = Label::new(self.placeholder.clone()).color(if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Placeholder
|
Color::Placeholder
|
||||||
});
|
});
|
||||||
|
|
||||||
let label = Label::new(self.value.clone()).color(if self.disabled {
|
let label = Label::new(self.value.clone()).color(if self.disabled {
|
||||||
TextColor::Disabled
|
Color::Disabled
|
||||||
} else {
|
} else {
|
||||||
TextColor::Default
|
Color::Default
|
||||||
});
|
});
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -9,48 +9,6 @@ pub enum LabelSize {
|
||||||
Small,
|
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)]
|
#[derive(Default, PartialEq, Copy, Clone)]
|
||||||
pub enum LineHeightStyle {
|
pub enum LineHeightStyle {
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -64,7 +22,7 @@ pub struct Label {
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
size: LabelSize,
|
size: LabelSize,
|
||||||
line_height_style: LineHeightStyle,
|
line_height_style: LineHeightStyle,
|
||||||
color: TextColor,
|
color: Color,
|
||||||
strikethrough: bool,
|
strikethrough: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +38,7 @@ impl Component for Label {
|
||||||
.top_1_2()
|
.top_1_2()
|
||||||
.w_full()
|
.w_full()
|
||||||
.h_px()
|
.h_px()
|
||||||
.bg(TextColor::Hidden.color(cx)),
|
.bg(Color::Hidden.color(cx)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|this| match self.size {
|
.map(|this| match self.size {
|
||||||
|
@ -101,7 +59,7 @@ impl Label {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
size: LabelSize::Default,
|
size: LabelSize::Default,
|
||||||
line_height_style: LineHeightStyle::default(),
|
line_height_style: LineHeightStyle::default(),
|
||||||
color: TextColor::Default,
|
color: Color::Default,
|
||||||
strikethrough: false,
|
strikethrough: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +69,7 @@ impl Label {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: TextColor) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -131,7 +89,7 @@ impl Label {
|
||||||
pub struct HighlightedLabel {
|
pub struct HighlightedLabel {
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
size: LabelSize,
|
size: LabelSize,
|
||||||
color: TextColor,
|
color: Color,
|
||||||
highlight_indices: Vec<usize>,
|
highlight_indices: Vec<usize>,
|
||||||
strikethrough: bool,
|
strikethrough: bool,
|
||||||
}
|
}
|
||||||
|
@ -185,7 +143,7 @@ impl Component for HighlightedLabel {
|
||||||
.my_auto()
|
.my_auto()
|
||||||
.w_full()
|
.w_full()
|
||||||
.h_px()
|
.h_px()
|
||||||
.bg(TextColor::Hidden.color(cx)),
|
.bg(Color::Hidden.color(cx)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|this| match self.size {
|
.map(|this| match self.size {
|
||||||
|
@ -203,7 +161,7 @@ impl HighlightedLabel {
|
||||||
Self {
|
Self {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
size: LabelSize::Default,
|
size: LabelSize::Default,
|
||||||
color: TextColor::Default,
|
color: Color::Default,
|
||||||
highlight_indices,
|
highlight_indices,
|
||||||
strikethrough: false,
|
strikethrough: false,
|
||||||
}
|
}
|
||||||
|
@ -214,7 +172,7 @@ impl HighlightedLabel {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: TextColor) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl Component for ListHeader {
|
||||||
.items_center()
|
.items_center()
|
||||||
.children(icons.into_iter().map(|i| {
|
.children(icons.into_iter().map(|i| {
|
||||||
IconElement::new(i)
|
IconElement::new(i)
|
||||||
.color(TextColor::Muted)
|
.color(Color::Muted)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
|
@ -80,10 +80,10 @@ impl Component for ListHeader {
|
||||||
.items_center()
|
.items_center()
|
||||||
.children(self.left_icon.map(|i| {
|
.children(self.left_icon.map(|i| {
|
||||||
IconElement::new(i)
|
IconElement::new(i)
|
||||||
.color(TextColor::Muted)
|
.color(Color::Muted)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
}))
|
}))
|
||||||
.child(Label::new(self.label.clone()).color(TextColor::Muted)),
|
.child(Label::new(self.label.clone()).color(Color::Muted)),
|
||||||
)
|
)
|
||||||
.child(disclosure_control),
|
.child(disclosure_control),
|
||||||
)
|
)
|
||||||
|
@ -222,10 +222,10 @@ impl Component for ListSubHeader {
|
||||||
.items_center()
|
.items_center()
|
||||||
.children(self.left_icon.map(|i| {
|
.children(self.left_icon.map(|i| {
|
||||||
IconElement::new(i)
|
IconElement::new(i)
|
||||||
.color(TextColor::Muted)
|
.color(Color::Muted)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
}))
|
}))
|
||||||
.child(Label::new(self.label.clone()).color(TextColor::Muted)),
|
.child(Label::new(self.label.clone()).color(Color::Muted)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ impl Component for ListItem {
|
||||||
h_stack().child(
|
h_stack().child(
|
||||||
IconElement::new(i)
|
IconElement::new(i)
|
||||||
.size(IconSize::Small)
|
.size(IconSize::Small)
|
||||||
.color(TextColor::Muted),
|
.color(Color::Muted),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
|
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
|
||||||
|
@ -432,9 +432,7 @@ impl Component for List {
|
||||||
let list_content = match (self.children.is_empty(), self.toggle) {
|
let list_content = match (self.children.is_empty(), self.toggle) {
|
||||||
(false, _) => div().children(self.children),
|
(false, _) => div().children(self.children),
|
||||||
(true, Toggle::Toggled(false)) => div(),
|
(true, Toggle::Toggled(false)) => div(),
|
||||||
(true, _) => {
|
(true, _) => div().child(Label::new(self.empty_message.clone()).color(Color::Muted)),
|
||||||
div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub use stories::*;
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
mod stories {
|
mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{h_stack, v_stack, Story, TextColor};
|
use crate::{h_stack, v_stack, Color, Story};
|
||||||
use gpui::{rems, Div, Render};
|
use gpui::{rems, Div, Render};
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
use gpui::{div, Element, ParentElement};
|
|
||||||
|
|
||||||
use crate::{Icon, IconElement, IconSize, TextColor};
|
|
||||||
|
|
||||||
/// Whether the entry is toggleable, and if so, whether it is currently toggled.
|
/// Whether the entry is toggleable, and if so, whether it is currently toggled.
|
||||||
///
|
///
|
||||||
/// To make an element toggleable, simply add a `Toggle::Toggled(_)` and handle it's cases.
|
/// To make an element toggleable, simply add a `Toggle::Toggled(_)` and handle it's cases.
|
||||||
|
@ -43,19 +39,3 @@ impl From<bool> for Toggle {
|
||||||
Toggle::Toggled(toggled)
|
Toggle::Toggled(toggled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disclosure_control(toggle: Toggle) -> impl Element {
|
|
||||||
match (toggle.is_toggleable(), toggle.is_toggled()) {
|
|
||||||
(false, _) => div(),
|
|
||||||
(_, true) => div().child(
|
|
||||||
IconElement::new(Icon::ChevronDown)
|
|
||||||
.color(TextColor::Muted)
|
|
||||||
.size(IconSize::Small),
|
|
||||||
),
|
|
||||||
(_, false) => div().child(
|
|
||||||
IconElement::new(Icon::ChevronRight)
|
|
||||||
.color(TextColor::Muted)
|
|
||||||
.size(IconSize::Small),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use settings2::Settings;
|
||||||
use theme2::{ActiveTheme, ThemeSettings};
|
use theme2::{ActiveTheme, ThemeSettings};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{h_stack, v_stack, KeyBinding, Label, LabelSize, StyledExt, TextColor};
|
use crate::{h_stack, v_stack, Color, KeyBinding, Label, LabelSize, StyledExt};
|
||||||
|
|
||||||
pub struct Tooltip {
|
pub struct Tooltip {
|
||||||
title: SharedString,
|
title: SharedString,
|
||||||
|
@ -90,11 +90,7 @@ impl Render for Tooltip {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.when_some(self.meta.clone(), |this, meta| {
|
.when_some(self.meta.clone(), |this, meta| {
|
||||||
this.child(
|
this.child(Label::new(meta).size(LabelSize::Small).color(Color::Muted))
|
||||||
Label::new(meta)
|
|
||||||
.size(LabelSize::Small)
|
|
||||||
.color(TextColor::Muted),
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub use gpui::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::StyledExt;
|
pub use crate::StyledExt;
|
||||||
pub use crate::{ButtonVariant, TextColor};
|
pub use crate::{ButtonVariant, Color};
|
||||||
pub use theme2::ActiveTheme;
|
pub use theme2::ActiveTheme;
|
||||||
|
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
mod color;
|
||||||
mod elevation;
|
mod elevation;
|
||||||
mod typography;
|
mod typography;
|
||||||
|
|
||||||
|
pub use color::*;
|
||||||
pub use elevation::*;
|
pub use elevation::*;
|
||||||
pub use typography::*;
|
pub use typography::*;
|
||||||
|
|
44
crates/ui2/src/styles/color.rs
Normal file
44
crates/ui2/src/styles/color.rs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
use gpui::{Hsla, WindowContext};
|
||||||
|
use theme2::ActiveTheme;
|
||||||
|
|
||||||
|
#[derive(Default, PartialEq, Copy, Clone)]
|
||||||
|
pub enum Color {
|
||||||
|
#[default]
|
||||||
|
Default,
|
||||||
|
Accent,
|
||||||
|
Created,
|
||||||
|
Deleted,
|
||||||
|
Disabled,
|
||||||
|
Error,
|
||||||
|
Hidden,
|
||||||
|
Info,
|
||||||
|
Modified,
|
||||||
|
Muted,
|
||||||
|
Placeholder,
|
||||||
|
Player(u32),
|
||||||
|
Selected,
|
||||||
|
Success,
|
||||||
|
Warning,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Color {
|
||||||
|
pub fn color(&self, cx: &WindowContext) -> Hsla {
|
||||||
|
match self {
|
||||||
|
Color::Default => cx.theme().colors().text,
|
||||||
|
Color::Muted => cx.theme().colors().text_muted,
|
||||||
|
Color::Created => cx.theme().status().created,
|
||||||
|
Color::Modified => cx.theme().status().modified,
|
||||||
|
Color::Deleted => cx.theme().status().deleted,
|
||||||
|
Color::Disabled => cx.theme().colors().text_disabled,
|
||||||
|
Color::Hidden => cx.theme().status().hidden,
|
||||||
|
Color::Info => cx.theme().status().info,
|
||||||
|
Color::Placeholder => cx.theme().colors().text_placeholder,
|
||||||
|
Color::Accent => cx.theme().colors().text_accent,
|
||||||
|
Color::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,
|
||||||
|
Color::Error => cx.theme().status().error,
|
||||||
|
Color::Selected => cx.theme().colors().text_accent,
|
||||||
|
Color::Success => cx.theme().status().success,
|
||||||
|
Color::Warning => cx.theme().status().warning,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use ui::v_stack;
|
use ui::v_stack;
|
||||||
use ui::{prelude::*, Icon, IconButton, IconElement, TextColor, Tooltip};
|
use ui::{prelude::*, Color, Icon, IconButton, IconElement, Tooltip};
|
||||||
use util::truncate_and_remove_front;
|
use util::truncate_and_remove_front;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]
|
#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]
|
||||||
|
@ -1425,12 +1425,12 @@ impl Pane {
|
||||||
.then(|| {
|
.then(|| {
|
||||||
IconElement::new(Icon::ExclamationTriangle)
|
IconElement::new(Icon::ExclamationTriangle)
|
||||||
.size(ui::IconSize::Small)
|
.size(ui::IconSize::Small)
|
||||||
.color(TextColor::Warning)
|
.color(Color::Warning)
|
||||||
})
|
})
|
||||||
.or(item.is_dirty(cx).then(|| {
|
.or(item.is_dirty(cx).then(|| {
|
||||||
IconElement::new(Icon::ExclamationTriangle)
|
IconElement::new(Icon::ExclamationTriangle)
|
||||||
.size(ui::IconSize::Small)
|
.size(ui::IconSize::Small)
|
||||||
.color(TextColor::Info)
|
.color(Color::Info)
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.children((!close_right).then(|| close_icon()))
|
.children((!close_right).then(|| close_icon()))
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gpui::{
|
||||||
ViewContext, WindowContext,
|
ViewContext, WindowContext,
|
||||||
};
|
};
|
||||||
use theme2::ActiveTheme;
|
use theme2::ActiveTheme;
|
||||||
use ui::{h_stack, v_stack, Button, Icon, IconButton, Label, TextColor};
|
use ui::{h_stack, v_stack, Button, Color, Icon, IconButton, Label};
|
||||||
|
|
||||||
pub enum ToolbarItemEvent {
|
pub enum ToolbarItemEvent {
|
||||||
ChangeLocation(ToolbarItemLocation),
|
ChangeLocation(ToolbarItemLocation),
|
||||||
|
@ -92,7 +92,7 @@ impl Render for Toolbar {
|
||||||
h_stack()
|
h_stack()
|
||||||
.p_1()
|
.p_1()
|
||||||
.child(Button::new("crates"))
|
.child(Button::new("crates"))
|
||||||
.child(Label::new("/").color(TextColor::Muted))
|
.child(Label::new("/").color(Color::Muted))
|
||||||
.child(Button::new("workspace2")),
|
.child(Button::new("workspace2")),
|
||||||
)
|
)
|
||||||
// Toolbar right side
|
// Toolbar right side
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue