Checkpoint - Still Broken

This commit is contained in:
Nate Butler 2023-10-19 14:38:01 -04:00
parent bca97f7186
commit 58650b7d2d
31 changed files with 298 additions and 213 deletions

View file

@ -9,6 +9,7 @@ pub use crate::{theme, ButtonVariant, ElementExt, Theme};
use gpui3::{hsla, rems, rgb, Hsla, Rems};
use strum::EnumIter;
// TODO Remove uses in favor of ThemeColor
#[derive(Default)]
pub struct SystemColor {
pub transparent: Hsla,
@ -35,6 +36,30 @@ impl SystemColor {
}
}
#[derive(Clone, Copy)]
pub struct PlayerThemeColors {
pub cursor: Hsla,
pub selection: Hsla,
}
impl PlayerThemeColors {
pub fn new(cx: &WindowContext, ix: usize) -> Self {
let theme = theme(cx);
if ix < theme.players.len() {
Self {
cursor: theme.players[ix].cursor,
selection: theme.players[ix].selection,
}
} else {
Self {
cursor: rgb::<Hsla>(0xff00ff),
selection: rgb::<Hsla>(0xff00ff),
}
}
}
}
#[derive(Clone, Copy)]
pub struct SyntaxColor {
pub comment: Hsla,
@ -48,16 +73,36 @@ impl SyntaxColor {
let theme = theme(cx);
Self {
comment: theme.syntax.comment,
string: theme.syntax.string,
function: theme.syntax.function,
keyword: theme.syntax.keyword,
comment: theme
.syntax
.get("comment")
.cloned()
.unwrap_or_else(|| rgb::<Hsla>(0xff00ff)),
string: theme
.syntax
.get("string")
.cloned()
.unwrap_or_else(|| rgb::<Hsla>(0xff00ff)),
function: theme
.syntax
.get("function")
.cloned()
.unwrap_or_else(|| rgb::<Hsla>(0xff00ff)),
keyword: theme
.syntax
.get("keyword")
.cloned()
.unwrap_or_else(|| rgb::<Hsla>(0xff00ff)),
}
}
}
#[derive(Clone, Copy)]
pub struct ThemeColor {
pub transparent: Hsla,
pub mac_os_traffic_light_red: Hsla,
pub mac_os_traffic_light_yellow: Hsla,
pub mac_os_traffic_light_green: Hsla,
pub border: Hsla,
pub border_variant: Hsla,
pub border_focused: Hsla,
@ -96,14 +141,28 @@ pub struct ThemeColor {
pub text_muted: Hsla,
pub text_placeholder: Hsla,
pub text_disabled: Hsla,
pub text_accent: Hsla,
pub icon_muted: Hsla,
pub syntax: SyntaxColor,
pub toolbar_background: Hsla,
pub editor_background: Hsla,
pub status_bar: Hsla,
pub title_bar: Hsla,
pub toolbar: Hsla,
pub tab_bar: Hsla,
pub editor: Hsla,
pub editor_subheader: Hsla,
pub editor_active_line: Hsla,
pub terminal: Hsla,
pub image_fallback_background: Hsla,
pub git_created: Hsla,
pub git_modified: Hsla,
pub git_deleted: Hsla,
pub git_conflict: Hsla,
pub git_ignored: Hsla,
pub git_renamed: Hsla,
pub player: [PlayerThemeColors; 8],
}
impl ThemeColor {
@ -111,7 +170,22 @@ impl ThemeColor {
let theme = theme(cx);
let system_color = SystemColor::new();
let players = [
PlayerThemeColors::new(cx, 0),
PlayerThemeColors::new(cx, 1),
PlayerThemeColors::new(cx, 2),
PlayerThemeColors::new(cx, 3),
PlayerThemeColors::new(cx, 4),
PlayerThemeColors::new(cx, 5),
PlayerThemeColors::new(cx, 6),
PlayerThemeColors::new(cx, 7),
];
Self {
transparent: hsla(0.0, 0.0, 0.0, 0.0),
mac_os_traffic_light_red: rgb::<Hsla>(0xEC695E),
mac_os_traffic_light_yellow: rgb::<Hsla>(0xF4BF4F),
mac_os_traffic_light_green: rgb::<Hsla>(0x62C554),
border: theme.lowest.base.default.border,
border_variant: theme.lowest.variant.default.border,
border_focused: theme.lowest.accent.default.border,
@ -134,13 +208,28 @@ impl ThemeColor {
/// TODO: map this to a real value
text_placeholder: theme.lowest.negative.default.foreground,
text_disabled: theme.lowest.base.disabled.foreground,
text_accent: theme.lowest.accent.default.foreground,
icon_muted: theme.lowest.variant.default.foreground,
syntax: SyntaxColor::new(cx),
toolbar_background: theme.highest.base.default.background,
editor_background: theme.highest.base.default.background,
status_bar: theme.lowest.base.default.background,
title_bar: theme.lowest.base.default.background,
toolbar: theme.highest.base.default.background,
tab_bar: theme.middle.base.default.background,
editor: theme.highest.base.default.background,
editor_subheader: theme.middle.base.default.background,
terminal: theme.highest.base.default.background,
editor_active_line: theme.highest.on.default.background,
image_fallback_background: theme.lowest.base.default.background,
git_created: theme.lowest.positive.default.foreground,
git_modified: theme.lowest.accent.default.foreground,
git_deleted: theme.lowest.negative.default.foreground,
git_conflict: theme.lowest.warning.default.foreground,
git_ignored: theme.lowest.base.disabled.foreground,
git_renamed: theme.lowest.warning.default.foreground,
player: players,
}
}
}
@ -244,11 +333,11 @@ impl GitStatus {
match self {
Self::None => system_color.transparent,
Self::Created => theme.lowest.positive.default.foreground,
Self::Modified => theme.lowest.warning.default.foreground,
Self::Deleted => theme.lowest.negative.default.foreground,
Self::Conflict => theme.lowest.warning.default.foreground,
Self::Renamed => theme.lowest.accent.default.foreground,
Self::Created => color.git_created,
Self::Modified => color.git_modified,
Self::Deleted => color.git_deleted,
Self::Conflict => color.git_conflict,
Self::Renamed => color.git_renamed,
}
}
}