Reference theme2 colors in ThemeColor

This commit is contained in:
Marshall Bowers 2023-10-25 15:58:56 +02:00
parent dd34bb273e
commit 8043d0d8a9
2 changed files with 51 additions and 51 deletions

View file

@ -1,3 +1,4 @@
use crate::theme2;
pub use crate::{theme, ButtonVariant, ElementExt, Theme}; pub use crate::{theme, ButtonVariant, ElementExt, Theme};
use gpui2::{hsla, rgb, Hsla, WindowContext}; use gpui2::{hsla, rgb, Hsla, WindowContext};
use strum::EnumIter; use strum::EnumIter;
@ -253,6 +254,7 @@ impl std::fmt::Debug for ThemeColor {
impl ThemeColor { impl ThemeColor {
pub fn new(cx: &WindowContext) -> Self { pub fn new(cx: &WindowContext) -> Self {
let theme = theme(cx); let theme = theme(cx);
let theme2 = theme2(cx);
let transparent = hsla(0.0, 0.0, 0.0, 0.0); let transparent = hsla(0.0, 0.0, 0.0, 0.0);
let players = [ let players = [
@ -267,52 +269,52 @@ impl ThemeColor {
]; ];
Self { Self {
transparent, transparent: theme2.transparent,
mac_os_traffic_light_red: rgb::<Hsla>(0xEC695E), mac_os_traffic_light_red: theme2.mac_os_traffic_light_red,
mac_os_traffic_light_yellow: rgb::<Hsla>(0xF4BF4F), mac_os_traffic_light_yellow: theme2.mac_os_traffic_light_yellow,
mac_os_traffic_light_green: rgb::<Hsla>(0x62C554), mac_os_traffic_light_green: theme2.mac_os_traffic_light_green,
border: theme.lowest.base.default.border, border: theme2.border,
border_variant: theme.lowest.variant.default.border, border_variant: theme2.border_variant,
border_focused: theme.lowest.accent.default.border, border_focused: theme2.border_focused,
border_transparent: transparent, border_transparent: theme2.border_transparent,
elevated_surface: theme.lowest.base.default.background, elevated_surface: theme2.elevated_surface,
surface: theme.middle.base.default.background, surface: theme2.surface,
background: theme.lowest.base.default.background, background: theme2.background,
filled_element: theme.lowest.base.default.background, filled_element: theme2.filled_element,
filled_element_hover: hsla(0.0, 0.0, 100.0, 0.12), filled_element_hover: theme2.filled_element_hover,
filled_element_active: hsla(0.0, 0.0, 100.0, 0.16), filled_element_active: theme2.filled_element_active,
filled_element_selected: theme.lowest.accent.default.background, filled_element_selected: theme2.filled_element_selected,
filled_element_disabled: transparent, filled_element_disabled: theme2.filled_element_disabled,
ghost_element: transparent, ghost_element: theme2.ghost_element,
ghost_element_hover: hsla(0.0, 0.0, 100.0, 0.08), ghost_element_hover: theme2.ghost_element_hover,
ghost_element_active: hsla(0.0, 0.0, 100.0, 0.12), ghost_element_active: theme2.ghost_element_active,
ghost_element_selected: theme.lowest.accent.default.background, ghost_element_selected: theme2.ghost_element_selected,
ghost_element_disabled: transparent, ghost_element_disabled: theme2.ghost_element_disabled,
text: theme.lowest.base.default.foreground, text: theme2.text,
text_muted: theme.lowest.variant.default.foreground, text_muted: theme2.text_muted,
/// TODO: map this to a real value /// TODO: map this to a real value
text_placeholder: theme.lowest.negative.default.foreground, text_placeholder: theme2.text_placeholder,
text_disabled: theme.lowest.base.disabled.foreground, text_disabled: theme2.text_disabled,
text_accent: theme.lowest.accent.default.foreground, text_accent: theme2.text_accent,
icon_muted: theme.lowest.variant.default.foreground, icon_muted: theme2.icon_muted,
syntax: SyntaxColor::new(cx), syntax: SyntaxColor::new(cx),
status_bar: theme.lowest.base.default.background, status_bar: theme2.status_bar,
title_bar: theme.lowest.base.default.background, title_bar: theme2.title_bar,
toolbar: theme.highest.base.default.background, toolbar: theme2.toolbar,
tab_bar: theme.middle.base.default.background, tab_bar: theme2.tab_bar,
editor: theme.highest.base.default.background, editor: theme2.editor,
editor_subheader: theme.middle.base.default.background, editor_subheader: theme2.editor_subheader,
terminal: theme.highest.base.default.background, terminal: theme2.terminal,
editor_active_line: theme.highest.on.default.background, editor_active_line: theme2.editor_active_line,
image_fallback_background: theme.lowest.base.default.background, image_fallback_background: theme2.image_fallback_background,
git_created: theme.lowest.positive.default.foreground, git_created: theme2.git_created,
git_modified: theme.lowest.accent.default.foreground, git_modified: theme2.git_modified,
git_deleted: theme.lowest.negative.default.foreground, git_deleted: theme2.git_deleted,
git_conflict: theme.lowest.warning.default.foreground, git_conflict: theme2.git_conflict,
git_ignored: theme.lowest.base.disabled.foreground, git_ignored: theme2.git_ignored,
git_renamed: theme.lowest.warning.default.foreground, git_renamed: theme2.git_renamed,
player: players, player: players,
} }

View file

@ -178,9 +178,7 @@ where
element_state: Option<Self::ElementState>, element_state: Option<Self::ElementState>,
cx: &mut ViewContext<Self::ViewState>, cx: &mut ViewContext<Self::ViewState>,
) -> Self::ElementState { ) -> Self::ElementState {
cx.default_global::<ThemeStack>() cx.default_global::<ThemeStack>().0.push(self.theme.clone());
.0
.push(self.theme.clone());
let element_state = self.child.initialize(view_state, element_state, cx); let element_state = self.child.initialize(view_state, element_state, cx);
cx.default_global::<ThemeStack>().0.pop(); cx.default_global::<ThemeStack>().0.pop();
element_state element_state
@ -195,9 +193,7 @@ where
where where
Self: Sized, Self: Sized,
{ {
cx.default_global::<ThemeStack>() cx.default_global::<ThemeStack>().0.push(self.theme.clone());
.0
.push(self.theme.clone());
let layout_id = self.child.layout(view_state, element_state, cx); let layout_id = self.child.layout(view_state, element_state, cx);
cx.default_global::<ThemeStack>().0.pop(); cx.default_global::<ThemeStack>().0.pop();
layout_id layout_id
@ -212,9 +208,7 @@ where
) where ) where
Self: Sized, Self: Sized,
{ {
cx.default_global::<ThemeStack>() cx.default_global::<ThemeStack>().0.push(self.theme.clone());
.0
.push(self.theme.clone());
self.child.paint(bounds, view_state, frame_state, cx); self.child.paint(bounds, view_state, frame_state, cx);
cx.default_global::<ThemeStack>().0.pop(); cx.default_global::<ThemeStack>().0.pop();
} }
@ -223,3 +217,7 @@ where
pub fn theme(cx: &WindowContext) -> Arc<Theme> { pub fn theme(cx: &WindowContext) -> Arc<Theme> {
Arc::new(cx.global::<Theme>().clone()) Arc::new(cx.global::<Theme>().clone())
} }
pub fn theme2(cx: &WindowContext) -> Arc<theme2::Theme> {
cx.global::<Arc<theme2::Theme>>().clone()
}