Replace GitStatusColors with StatusColors (#3268)

This PR removes `GitStatusColors` in favor of just using `StatusColors`
instead.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-11-08 17:32:32 +01:00 committed by GitHub
parent 9e5a4ea6c4
commit b6766ba39a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 75 deletions

View File

@ -25,12 +25,12 @@ impl Render for FocusStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
let theme = cx.theme(); let theme = cx.theme();
let color_1 = theme.styles.git.created; let color_1 = theme.status().created;
let color_2 = theme.styles.git.modified; let color_2 = theme.status().modified;
let color_3 = theme.styles.git.deleted; let color_3 = theme.status().deleted;
let color_4 = theme.styles.git.conflict; let color_4 = theme.status().conflict;
let color_5 = theme.styles.git.ignored; let color_5 = theme.status().ignored;
let color_6 = theme.styles.git.renamed; let color_6 = theme.status().renamed;
let child_1 = cx.focus_handle(); let child_1 = cx.focus_handle();
let child_2 = cx.focus_handle(); let child_2 = cx.focus_handle();

View File

@ -17,8 +17,8 @@ impl Render for ScrollStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
let theme = cx.theme(); let theme = cx.theme();
let color_1 = theme.styles.git.created; let color_1 = theme.status().created;
let color_2 = theme.styles.git.modified; let color_2 = theme.status().modified;
div() div()
.id("parent") .id("parent")

View File

@ -29,17 +29,6 @@ pub struct StatusColors {
pub warning: Hsla, pub warning: Hsla,
} }
#[derive(Refineable, Clone, Debug)]
#[refineable(debug)]
pub struct GitStatusColors {
pub conflict: Hsla,
pub created: Hsla,
pub deleted: Hsla,
pub ignored: Hsla,
pub modified: Hsla,
pub renamed: Hsla,
}
#[derive(Refineable, Clone, Debug)] #[derive(Refineable, Clone, Debug)]
#[refineable(debug, deserialize)] #[refineable(debug, deserialize)]
pub struct ThemeColors { pub struct ThemeColors {
@ -260,7 +249,6 @@ pub struct ThemeStyles {
#[refineable] #[refineable]
pub colors: ThemeColors, pub colors: ThemeColors,
pub status: StatusColors, pub status: StatusColors,
pub git: GitStatusColors,
pub player: PlayerColors, pub player: PlayerColors,
pub syntax: Arc<SyntaxTheme>, pub syntax: Arc<SyntaxTheme>,
} }

View File

@ -2,12 +2,10 @@ use std::num::ParseIntError;
use gpui::{hsla, Hsla, Rgba}; use gpui::{hsla, Hsla, Rgba};
use crate::{ use crate::colors::{StatusColors, SystemColors, ThemeColors};
colors::{GitStatusColors, StatusColors, SystemColors, ThemeColors}, use crate::scale::{ColorScaleSet, ColorScales};
scale::{ColorScaleSet, ColorScales}, use crate::syntax::SyntaxTheme;
syntax::SyntaxTheme, use crate::{ColorScale, PlayerColor, PlayerColors};
ColorScale, PlayerColor, PlayerColors,
};
impl Default for PlayerColors { impl Default for PlayerColors {
fn default() -> Self { fn default() -> Self {
@ -136,19 +134,6 @@ impl Default for StatusColors {
} }
} }
impl Default for GitStatusColors {
fn default() -> Self {
Self {
conflict: orange().dark().step_9(),
created: grass().dark().step_9(),
deleted: red().dark().step_9(),
ignored: neutral().dark().step_9(),
modified: yellow().dark().step_9(),
renamed: blue().dark().step_9(),
}
}
}
impl SyntaxTheme { impl SyntaxTheme {
pub fn default_light() -> Self { pub fn default_light() -> Self {
Self { Self {

View File

@ -1,7 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
colors::{GitStatusColors, StatusColors, SystemColors, ThemeColors, ThemeStyles}, colors::{StatusColors, SystemColors, ThemeColors, ThemeStyles},
default_color_scales, Appearance, PlayerColors, SyntaxTheme, Theme, ThemeFamily, default_color_scales, Appearance, PlayerColors, SyntaxTheme, Theme, ThemeFamily,
}; };
@ -14,7 +14,6 @@ fn zed_pro_daylight() -> Theme {
system: SystemColors::default(), system: SystemColors::default(),
colors: ThemeColors::default_light(), colors: ThemeColors::default_light(),
status: StatusColors::default(), status: StatusColors::default(),
git: GitStatusColors::default(),
player: PlayerColors::default_light(), player: PlayerColors::default_light(),
syntax: Arc::new(SyntaxTheme::default_light()), syntax: Arc::new(SyntaxTheme::default_light()),
}, },
@ -30,7 +29,6 @@ pub(crate) fn zed_pro_moonlight() -> Theme {
system: SystemColors::default(), system: SystemColors::default(),
colors: ThemeColors::default_dark(), colors: ThemeColors::default_dark(),
status: StatusColors::default(), status: StatusColors::default(),
git: GitStatusColors::default(),
player: PlayerColors::default(), player: PlayerColors::default(),
syntax: Arc::new(SyntaxTheme::default_dark()), syntax: Arc::new(SyntaxTheme::default_dark()),
}, },

View File

@ -6,8 +6,8 @@ use gpui::SharedString;
use refineable::Refineable; use refineable::Refineable;
use crate::{ use crate::{
zed_pro_family, Appearance, GitStatusColors, PlayerColors, StatusColors, SyntaxTheme, zed_pro_family, Appearance, PlayerColors, StatusColors, SyntaxTheme, SystemColors, Theme,
SystemColors, Theme, ThemeColors, ThemeFamily, ThemeStyles, UserTheme, UserThemeFamily, ThemeColors, ThemeFamily, ThemeStyles, UserTheme, UserThemeFamily,
}; };
pub struct ThemeRegistry { pub struct ThemeRegistry {
@ -50,7 +50,6 @@ impl ThemeRegistry {
system: SystemColors::default(), system: SystemColors::default(),
colors: theme_colors, colors: theme_colors,
status: StatusColors::default(), status: StatusColors::default(),
git: GitStatusColors::default(),
player: PlayerColors::default(), player: PlayerColors::default(),
syntax: match user_theme.appearance { syntax: match user_theme.appearance {
Appearance::Light => Arc::new(SyntaxTheme::default_light()), Appearance::Light => Arc::new(SyntaxTheme::default_light()),

View File

@ -65,6 +65,12 @@ pub struct Theme {
} }
impl Theme { impl Theme {
/// Returns the [`SystemColors`] for the theme.
#[inline(always)]
pub fn system(&self) -> &SystemColors {
&self.styles.system
}
/// Returns the [`ThemeColors`] for the theme. /// Returns the [`ThemeColors`] for the theme.
#[inline(always)] #[inline(always)]
pub fn players(&self) -> &PlayerColors { pub fn players(&self) -> &PlayerColors {
@ -89,19 +95,13 @@ impl Theme {
&self.styles.status &self.styles.status
} }
/// Returns the [`GitStatusColors`] for the theme.
#[inline(always)]
pub fn git(&self) -> &GitStatusColors {
&self.styles.git
}
/// Returns the color for the syntax node with the given name. /// Returns the color for the syntax node with the given name.
#[inline(always)] #[inline(always)]
pub fn syntax_color(&self, name: &str) -> Hsla { pub fn syntax_color(&self, name: &str) -> Hsla {
self.syntax().color(name) self.syntax().color(name)
} }
/// Returns the [`StatusColors`] for the theme. /// Returns the [`DiagnosticStyle`] for the theme.
#[inline(always)] #[inline(always)]
pub fn diagnostic_style(&self) -> DiagnosticStyle { pub fn diagnostic_style(&self) -> DiagnosticStyle {
DiagnosticStyle { DiagnosticStyle {

View File

@ -2,8 +2,8 @@ use std::fmt::{self, Debug};
use gpui::{Hsla, Rgba}; use gpui::{Hsla, Rgba};
use theme::{ use theme::{
Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors, SyntaxTheme, Appearance, PlayerColor, PlayerColors, StatusColors, SyntaxTheme, SystemColors,
SystemColors, ThemeColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement, ThemeColorsRefinement, UserTheme, UserThemeFamily, UserThemeStylesRefinement,
}; };
struct RawSyntaxPrinter<'a>(&'a str); struct RawSyntaxPrinter<'a>(&'a str);
@ -270,21 +270,6 @@ impl<'a> Debug for StatusColorsPrinter<'a> {
} }
} }
pub struct GitStatusColorsPrinter<'a>(&'a GitStatusColors);
impl<'a> Debug for GitStatusColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GitStatusColors")
.field("conflict", &HslaPrinter(self.0.conflict))
.field("created", &HslaPrinter(self.0.created))
.field("deleted", &HslaPrinter(self.0.deleted))
.field("ignored", &HslaPrinter(self.0.ignored))
.field("modified", &HslaPrinter(self.0.modified))
.field("renamed", &HslaPrinter(self.0.renamed))
.finish()
}
}
pub struct PlayerColorsPrinter<'a>(&'a PlayerColors); pub struct PlayerColorsPrinter<'a>(&'a PlayerColors);
impl<'a> Debug for PlayerColorsPrinter<'a> { impl<'a> Debug for PlayerColorsPrinter<'a> {

View File

@ -46,12 +46,12 @@ pub enum GitStatus {
impl GitStatus { impl GitStatus {
pub fn hsla(&self, cx: &WindowContext) -> Hsla { pub fn hsla(&self, cx: &WindowContext) -> Hsla {
match self { match self {
Self::None => cx.theme().styles.system.transparent, Self::None => cx.theme().system().transparent,
Self::Created => cx.theme().styles.git.created, Self::Created => cx.theme().status().created,
Self::Modified => cx.theme().styles.git.modified, Self::Modified => cx.theme().status().modified,
Self::Deleted => cx.theme().styles.git.deleted, Self::Deleted => cx.theme().status().deleted,
Self::Conflict => cx.theme().styles.git.conflict, Self::Conflict => cx.theme().status().conflict,
Self::Renamed => cx.theme().styles.git.renamed, Self::Renamed => cx.theme().status().renamed,
} }
} }
} }