From 6007fa6ab37020ef84e47dfd5f63481dd12837be Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 30 Sep 2021 14:16:28 -0700 Subject: [PATCH] Style the active entry in the project panel Co-Authored-By: Nathan Sobo --- zed/assets/themes/_base.toml | 6 +++++- zed/src/project_panel.rs | 11 +++++------ zed/src/theme.rs | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/zed/assets/themes/_base.toml b/zed/assets/themes/_base.toml index ddbd0fc86e..e03b3eb134 100644 --- a/zed/assets/themes/_base.toml +++ b/zed/assets/themes/_base.toml @@ -179,7 +179,11 @@ background = "$state.hover" [project_panel.selected_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] background = "$surface.0" diff --git a/zed/src/project_panel.rs b/zed/src/project_panel.rs index d6830de7a3..94348b92f9 100644 --- a/zed/src/project_panel.rs +++ b/zed/src/project_panel.rs @@ -469,12 +469,11 @@ impl ProjectPanel { (entry.worktree_id, entry.entry_id), cx, |state, _| { - let style = if details.is_selected { - &theme.selected_entry - } else if state.hovered { - &theme.hovered_entry - } else { - &theme.entry + let style = match (details.is_selected, state.hovered) { + (false, false) => &theme.entry, + (false, true) => &theme.hovered_entry, + (true, false) => &theme.selected_entry, + (true, true) => &theme.hovered_selected_entry, }; Flex::row() .with_child( diff --git a/zed/src/theme.rs b/zed/src/theme.rs index 0788cacb47..59bd2c5d6e 100644 --- a/zed/src/theme.rs +++ b/zed/src/theme.rs @@ -116,6 +116,7 @@ pub struct ProjectPanel { pub entry: ProjectPanelEntry, pub hovered_entry: ProjectPanelEntry, pub selected_entry: ProjectPanelEntry, + pub hovered_selected_entry: ProjectPanelEntry, } #[derive(Debug, Deserialize)]