Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge branch 'gpui2' into gpui2-theme-to-color
Marshall Bowers3932c1064e33
diff --cc crates/ui2/src/components/assistant_panel.rsindex fcba18a60f3,e6b099f3387..b9340be6c8a--- a/crates/ui2/src/components/assistant_panel.rs+++ b/crates/ui2/src/components/assistant_panel.rs@@@ -27,9 -27,9 +27,9 @@@ impl<S: 'static + Send + Sync + Clone>}fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {- let theme = theme(cx);+ let color = ThemeColor::new(cx);- Panel::new(self.scroll_state.clone())+ Panel::new(cx).children(vec![div().flex().flex_col()diff --cc crates/ui2/src/components/collab_panel.rsindex 8d36f1b1d71,caf900d8e65..8afc4256c48--- a/crates/ui2/src/components/collab_panel.rs+++ b/crates/ui2/src/components/collab_panel.rs@@@ -125,17 -130,16 +125,18 @@@ impl<S: 'static + Send + Sync + Clone>&self,avatar_uri: impl Into<SharedString>,label: impl Into<SharedString>,- theme: &Theme,+ cx: &WindowContext,) -> impl Element<ViewState = S> {+ let color = ThemeColor::new(cx);+div()+ .id("list_item").h_7().px_2().flex().items_center()- .hover(|style| style.bg(theme.lowest.variant.hovered.background))- .active(|style| style.bg(theme.lowest.variant.pressed.background))+ .hover(|style| style.bg(color.ghost_element_hover))- // .active(|style| style.fill(theme.lowest.variant.pressed.background))++ .active(|style| style.bg(color.ghost_element_active)).child(div().flex()diff --cc crates/ui2/src/components/icon_button.rsindex 43e5a33cdff,ebe7d29e58a..cf8d3119294--- a/crates/ui2/src/components/icon_button.rs+++ b/crates/ui2/src/components/icon_button.rs@@@ -90,11 -78,12 +90,11 @@@ impl<S: 'static + Send + Sync> IconButtlet mut button = h_stack().justify_center().rounded_md()- .py(ui_size(0.25))- .px(ui_size(6. / 14.))+ .py(ui_size(cx, 0.25))+ .px(ui_size(cx, 6. / 14.))- .when(self.variant == ButtonVariant::Filled, |this| {- this.bg(color.filled_element)- })- .hover(|style| style.bg(theme.highest.base.hovered.background))+ .bg(bg_color)+ .hover(|style| style.bg(bg_hover_color))- // .active(|style| style.bg(bg_active_color))++ .active(|style| style.bg(bg_active_color)).child(IconElement::new(self.icon).color(icon_color));if let Some(click_handler) = self.handlers.click.clone() {diff --cc crates/ui2/src/components/list.rsindex 2f77553ac1f,ce7977e7ea2..6d37521d17a--- a/crates/ui2/src/components/list.rs+++ b/crates/ui2/src/components/list.rs@@@ -359,10 -360,10 +359,10 @@@ impl<S: 'static + Send + Sync + Clone>}fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {- let theme = theme(cx);+ let color = ThemeColor::new(cx);let system_color = SystemColor::new();let color = ThemeColor::new(cx);- let setting = user_settings();+ let settings = user_settings(cx);let left_content = match self.left_content.clone() {Some(LeftContent::Icon(i)) => Some(diff --cc crates/ui2/src/components/palette.rsindex 8de26502a7b,a080f85938c..49ee1fd3b73--- a/crates/ui2/src/components/palette.rs+++ b/crates/ui2/src/components/palette.rs@@@ -89,8 -91,8 +90,8 @@@ impl<S: 'static + Send + Sync + Clone>.px_2().py_0p5().rounded_lg()- .hover(|style| style.bg(theme.lowest.base.hovered.background))- .active(|style| style.bg(theme.lowest.base.pressed.background))+ .hover(|style| style.bg(color.ghost_element_hover))- // .active(|style| style.bg(color.ghost_element_active))++ .active(|style| style.bg(color.ghost_element_active)).child(item.clone())})),),diff --cc crates/ui2/src/components/title_bar.rsindex 76d40f7f11f,6d2a3164314..4c106c82d60--- a/crates/ui2/src/components/title_bar.rs+++ b/crates/ui2/src/components/title_bar.rs@@@ -6,8 -6,8 +6,8 @@@ use gpui3::{view, Context, View}use crate::prelude::*;use crate::settings::user_settings;use crate::{- random_players_with_call_status, Avatar, Button, Icon, IconButton, IconColor, MicStatus,- theme, Avatar, Button, Icon, IconButton, IconColor, MicStatus, PlayerStack,-- PlayerWithCallStatus, ScreenShareStatus, ToolDivider, TrafficLights,++ Avatar, Button, Icon, IconButton, IconColor, MicStatus, PlayerStack, PlayerWithCallStatus,++ ScreenShareStatus, ToolDivider, TrafficLights,};#[derive(Clone)]@@@ -93,9 -88,9 +88,9 @@@ impl TitleBar}fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {- let theme = theme(cx);+ let color = ThemeColor::new(cx);let color = ThemeColor::new(cx);- let setting = user_settings();+ let settings = user_settings(cx);// let has_focus = cx.window_is_active();let has_focus = true;diff --cc crates/ui2/src/elements/icon.rsindex 61f9ed4a64c,000863a3997..a5b6adff489--- a/crates/ui2/src/elements/icon.rs+++ b/crates/ui2/src/elements/icon.rs@@@ -177,11 -177,11 +177,11 @@@ impl<S: 'static + Send + Sync> IconElem}fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {- let theme = theme(cx);- let fill = self.color.color(theme);+ let color = ThemeColor::new(cx);+ let fill = self.color.color(cx);let svg_size = match self.size {- IconSize::Small => ui_size(12. / 14.),- IconSize::Medium => ui_size(15. / 14.),+ IconSize::Small => ui_size(cx, 12. / 14.),+ IconSize::Medium => ui_size(cx, 15. / 14.),};svg()diff --cc crates/ui2/src/elements/input.rsindex c5076cfab93,ea8c3306bf8..19c51c1ec0b--- a/crates/ui2/src/elements/input.rs+++ b/crates/ui2/src/elements/input.rs@@@ -50,54 -45,56 +50,55 @@@ impl<S: 'static + Send + Sync + Clone>self}- fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {- let theme = theme(cx);-- let text_el;- let text_color;- let background_color_default;- let background_color_active;+ pub fn disabled(mut self, disabled: bool) -> Self {+ self.disabled = disabled;+ self+ }- let mut border_color_default = theme.middle.base.default.border;- let mut border_color_hover = theme.middle.base.hovered.border;- let border_color_focus = theme.middle.base.pressed.background;+ pub fn is_active(mut self, is_active: bool) -> Self {+ self.is_active = is_active;+ self+ }- match self.variant {- InputVariant::Ghost => {- background_color_default = theme.middle.base.default.background;- background_color_active = theme.middle.base.active.background;- }- InputVariant::Filled => {- background_color_default = theme.middle.on.default.background;- background_color_active = theme.middle.on.active.background;- }+ fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {+ let color = ThemeColor::new(cx);+ let system_color = SystemColor::new();++ let (input_bg, input_hover_bg, input_active_bg) = match self.variant {+ InputVariant::Ghost => (+ color.ghost_element,+ color.ghost_element_hover,+ color.ghost_element_active,+ ),+ InputVariant::Filled => (+ color.filled_element,+ color.filled_element_hover,+ color.filled_element_active,+ ),};- if self.state == InteractionState::Focused {- border_color_default = theme.players[0].cursor;- border_color_hover = theme.players[0].cursor;- }+ let placeholder_label = Label::new(self.placeholder.clone()).color(if self.disabled {+ LabelColor::Disabled+ } else {+ LabelColor::Placeholder+ });- if self.state == InteractionState::Focused || self.state == InteractionState::Active {- text_el = self.value.clone();- text_color = theme.lowest.base.default.foreground;+ let label = Label::new(self.value.clone()).color(if self.disabled {+ LabelColor::Disabled} else {- text_el = self.placeholder.to_string().clone();- text_color = theme.lowest.base.disabled.foreground;- }+ LabelColor::Default+ });div()+ .id("input").h_7().w_full().px_2().border()- .border_color(border_color_default)- .bg(background_color_default)- .hover(|style| {- style- .border_color(border_color_hover)- .bg(background_color_active)- })- .active(|style| style.border_color(theme.middle.base.active.border))+ .border_color(system_color.transparent)+ .bg(input_bg)+ .hover(|style| style.bg(input_hover_bg))- // .active(|style| style.bg(input_active_bg))++ .active(|style| style.bg(input_active_bg)).flex().items_center().child(