Fix Windows Title button hover, active color.
This commit is contained in:
parent
2785f38eeb
commit
08fc62ada0
2 changed files with 10 additions and 26 deletions
|
|
@ -6,7 +6,6 @@ use gpui::{
|
||||||
use ui::{
|
use ui::{
|
||||||
button::{Button, ButtonStyle},
|
button::{Button, ButtonStyle},
|
||||||
h_flex,
|
h_flex,
|
||||||
label::Label,
|
|
||||||
list::ListItem,
|
list::ListItem,
|
||||||
picker::{Picker, PickerDelegate},
|
picker::{Picker, PickerDelegate},
|
||||||
v_flex, Clickable as _,
|
v_flex, Clickable as _,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use gpui::{prelude::*, Rgba, WindowAppearance};
|
use gpui::{hsla, prelude::*, Hsla};
|
||||||
|
|
||||||
use crate::{prelude::*, stock::h_flex, theme::ActiveTheme};
|
use crate::{prelude::*, stock::h_flex, theme::ActiveTheme};
|
||||||
|
|
||||||
|
|
@ -15,26 +15,12 @@ impl WindowsWindowControls {
|
||||||
|
|
||||||
impl RenderOnce for WindowsWindowControls {
|
impl RenderOnce for WindowsWindowControls {
|
||||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||||
let close_button_hover_color = Rgba {
|
let close_button_hover_color = hsla(356.0 / 360.0, 0.86, 0.4, 1.0);
|
||||||
r: 232.0 / 255.0,
|
|
||||||
g: 17.0 / 255.0,
|
|
||||||
b: 32.0 / 255.0,
|
|
||||||
a: 1.0,
|
|
||||||
};
|
|
||||||
|
|
||||||
let button_hover_color = match cx.appearance() {
|
let button_hover_color = if cx.theme().mode.is_dark() {
|
||||||
WindowAppearance::Light | WindowAppearance::VibrantLight => Rgba {
|
hsla(180.0 / 360.0, 0.01, 0.21, 1.0)
|
||||||
r: 0.1,
|
} else {
|
||||||
g: 0.1,
|
hsla(0.0, 0.0, 0.91, 1.0)
|
||||||
b: 0.1,
|
|
||||||
a: 0.2,
|
|
||||||
},
|
|
||||||
WindowAppearance::Dark | WindowAppearance::VibrantDark => Rgba {
|
|
||||||
r: 0.9,
|
|
||||||
g: 0.9,
|
|
||||||
b: 0.9,
|
|
||||||
a: 0.1,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
|
@ -79,14 +65,14 @@ enum WindowsCaptionButtonIcon {
|
||||||
struct WindowsCaptionButton {
|
struct WindowsCaptionButton {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
icon: WindowsCaptionButtonIcon,
|
icon: WindowsCaptionButtonIcon,
|
||||||
hover_background_color: Rgba,
|
hover_background_color: Hsla,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowsCaptionButton {
|
impl WindowsCaptionButton {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
id: impl Into<ElementId>,
|
id: impl Into<ElementId>,
|
||||||
icon: WindowsCaptionButtonIcon,
|
icon: WindowsCaptionButtonIcon,
|
||||||
hover_background_color: Rgba,
|
hover_background_color: Hsla,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
|
|
@ -117,7 +103,6 @@ impl WindowsCaptionButton {
|
||||||
|
|
||||||
impl RenderOnce for WindowsCaptionButton {
|
impl RenderOnce for WindowsCaptionButton {
|
||||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
|
||||||
// todo(windows) report this width to the Windows platform API
|
// todo(windows) report this width to the Windows platform API
|
||||||
// NOTE: this is intentionally hard coded. An option to use the 'native' size
|
// NOTE: this is intentionally hard coded. An option to use the 'native' size
|
||||||
// could be added when the width is reported to the Windows platform API
|
// could be added when the width is reported to the Windows platform API
|
||||||
|
|
@ -132,11 +117,11 @@ impl RenderOnce for WindowsCaptionButton {
|
||||||
.h_full()
|
.h_full()
|
||||||
.text_size(px(10.0))
|
.text_size(px(10.0))
|
||||||
.font_family(Self::get_font())
|
.font_family(Self::get_font())
|
||||||
.text_color(theme.foreground)
|
.text_color(cx.theme().foreground)
|
||||||
.hover(|style| style.bg(self.hover_background_color))
|
.hover(|style| style.bg(self.hover_background_color))
|
||||||
.active(|style| {
|
.active(|style| {
|
||||||
let mut active_color = self.hover_background_color;
|
let mut active_color = self.hover_background_color;
|
||||||
active_color.a *= 0.2;
|
active_color.l *= 0.95;
|
||||||
|
|
||||||
style.bg(active_color)
|
style.bg(active_color)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue