Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
title_bar: Use theme colors for window controls on Windows (#32400)
Jason Leebb5a763ef775
diff --git a/crates/title_bar/src/platforms/platform_windows.rs b/crates/title_bar/src/platforms/platform_windows.rsindex e56ea1c160e..1df75ee8a9b 100644--- a/crates/title_bar/src/platforms/platform_windows.rs+++ b/crates/title_bar/src/platforms/platform_windows.rs@@ -1,4 +1,4 @@-use gpui::{Rgba, WindowAppearance, WindowControlArea, prelude::*};+use gpui::{Hsla, Rgba, WindowControlArea, prelude::*};use ui::prelude::*;@@ -33,7 +33,7 @@ impl WindowsWindowControls {}impl RenderOnce for WindowsWindowControls {- fn render(self, window: &mut Window, _: &mut App) -> impl IntoElement {+ fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {let close_button_hover_color = Rgba {r: 232.0 / 255.0,g: 17.0 / 255.0,@@ -41,20 +41,8 @@ impl RenderOnce for WindowsWindowControls {a: 1.0,};- let button_hover_color = match window.appearance() {- WindowAppearance::Light | WindowAppearance::VibrantLight => Rgba {- r: 0.1,- g: 0.1,- b: 0.1,- a: 0.2,- },- WindowAppearance::Dark | WindowAppearance::VibrantDark => Rgba {- r: 0.9,- g: 0.9,- b: 0.9,- a: 0.1,- },- };+ let button_hover_color = cx.theme().colors().ghost_element_hover;+ let button_active_color = cx.theme().colors().ghost_element_active;div().id("windows-window-controls")@@ -69,6 +57,7 @@ impl RenderOnce for WindowsWindowControls {"minimize",WindowsCaptionButtonIcon::Minimize,button_hover_color,+ button_active_color,)).child(WindowsCaptionButton::new("maximize-or-restore",@@ -78,11 +67,13 @@ impl RenderOnce for WindowsWindowControls {WindowsCaptionButtonIcon::Maximize},button_hover_color,+ button_active_color,)).child(WindowsCaptionButton::new("close",WindowsCaptionButtonIcon::Close,close_button_hover_color,+ button_active_color,))}}@@ -99,19 +90,22 @@ enum WindowsCaptionButtonIcon {struct WindowsCaptionButton {id: ElementId,icon: WindowsCaptionButtonIcon,- hover_background_color: Rgba,+ hover_background_color: Hsla,+ active_background_color: Hsla,}impl WindowsCaptionButton {pub fn new(id: impl Into<ElementId>,icon: WindowsCaptionButtonIcon,- hover_background_color: Rgba,+ hover_background_color: impl Into<Hsla>,+ active_background_color: impl Into<Hsla>,) -> Self {Self {id: id.into(),icon,- hover_background_color,+ hover_background_color: hover_background_color.into(),+ active_background_color: active_background_color.into(),}}}@@ -127,12 +121,7 @@ impl RenderOnce for WindowsCaptionButton {.h_full().text_size(px(10.0)).hover(|style| style.bg(self.hover_background_color))- .active(|style| {- let mut active_color = self.hover_background_color;- active_color.a *= 0.2;-- style.bg(active_color)- })+ .active(|style| style.bg(self.active_background_color)).map(|this| match self.icon {WindowsCaptionButtonIcon::Close => {this.window_control_area(WindowControlArea::Close)