Style the active entry in the project panel

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-09-30 14:16:28 -07:00
parent ad92bfe79f
commit 6007fa6ab3
3 changed files with 11 additions and 7 deletions

View file

@ -179,7 +179,11 @@ background = "$state.hover"
[project_panel.selected_entry] [project_panel.selected_entry]
extends = "$project_panel.entry" extends = "$project_panel.entry"
background = "#ff0000" text = { extends = "$text.0" }
[project_panel.hovered_selected_entry]
extends = "$project_panel.hovered_entry"
text = { extends = "$text.0" }
[selector] [selector]
background = "$surface.0" background = "$surface.0"

View file

@ -469,12 +469,11 @@ impl ProjectPanel {
(entry.worktree_id, entry.entry_id), (entry.worktree_id, entry.entry_id),
cx, cx,
|state, _| { |state, _| {
let style = if details.is_selected { let style = match (details.is_selected, state.hovered) {
&theme.selected_entry (false, false) => &theme.entry,
} else if state.hovered { (false, true) => &theme.hovered_entry,
&theme.hovered_entry (true, false) => &theme.selected_entry,
} else { (true, true) => &theme.hovered_selected_entry,
&theme.entry
}; };
Flex::row() Flex::row()
.with_child( .with_child(

View file

@ -116,6 +116,7 @@ pub struct ProjectPanel {
pub entry: ProjectPanelEntry, pub entry: ProjectPanelEntry,
pub hovered_entry: ProjectPanelEntry, pub hovered_entry: ProjectPanelEntry,
pub selected_entry: ProjectPanelEntry, pub selected_entry: ProjectPanelEntry,
pub hovered_selected_entry: ProjectPanelEntry,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]