project panel: Reintroduce project panel knockout color (#21926)

Reintroduces #20760 after it was reverted in #21807

Closes #20572

/cc @danilo-leal 

Release Notes:

- N/A

---------

Co-authored-by: Cole <cole@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2024-12-13 04:52:03 +01:00 committed by GitHub
parent 6ceec5d9a2
commit 636c28b652
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 60 additions and 28 deletions

View file

@ -427,7 +427,9 @@ pub struct IconDecoration {
kind: IconDecorationKind,
color: Hsla,
knockout_color: Hsla,
knockout_hover_color: Hsla,
position: Point<Pixels>,
group_name: Option<SharedString>,
}
impl IconDecoration {
@ -440,7 +442,9 @@ impl IconDecoration {
kind,
color,
knockout_color,
knockout_hover_color: knockout_color,
position,
group_name: None,
}
}
@ -465,11 +469,23 @@ impl IconDecoration {
self
}
/// Sets the color of the decoration that is used on hover
pub fn knockout_hover_color(mut self, color: Hsla) -> Self {
self.knockout_hover_color = color;
self
}
/// Sets the position of the decoration
pub fn position(mut self, position: Point<Pixels>) -> Self {
self.position = position;
self
}
/// Sets the name of the group the decoration belongs to
pub fn group_name(mut self, name: Option<SharedString>) -> Self {
self.group_name = name;
self
}
}
impl RenderOnce for IconDecoration {
@ -498,7 +514,15 @@ impl RenderOnce for IconDecoration {
.right_0()
.size(px(ICON_DECORATION_SIZE))
.path(self.kind.bg().path())
.text_color(self.knockout_color),
.text_color(self.knockout_color)
.when(self.group_name.is_none(), |this| {
this.hover(|style| style.text_color(self.knockout_hover_color))
})
.when_some(self.group_name.clone(), |this, group_name| {
this.group_hover(group_name, |style| {
style.text_color(self.knockout_hover_color)
})
}),
)
}
}