project panel: Remove active selection border when project panel is not focused (#12385)

This should make it less attention-grabbing.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-05-28 19:12:28 +02:00 committed by GitHub
parent 01e86881f0
commit ff9d6cc512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1889,13 +1889,13 @@ impl ProjectPanel {
worktree_id: details.worktree_id, worktree_id: details.worktree_id,
entry_id, entry_id,
}; };
let is_selected = self.marked_entries.contains(&selection); let is_marked = self.marked_entries.contains(&selection);
let is_active = self let is_active = self
.selection .selection
.map_or(false, |selection| selection.entry_id == entry_id); .map_or(false, |selection| selection.entry_id == entry_id);
let width = self.size(cx); let width = self.size(cx);
let filename_text_color = let filename_text_color =
entry_git_aware_label_color(details.git_status, details.is_ignored, is_selected); entry_git_aware_label_color(details.git_status, details.is_ignored, is_marked);
let file_name = details.filename.clone(); let file_name = details.filename.clone();
let mut icon = details.icon.clone(); let mut icon = details.icon.clone();
if show_editor && details.kind.is_file() { if show_editor && details.kind.is_file() {
@ -1938,7 +1938,7 @@ impl ProjectPanel {
ListItem::new(entry_id.to_proto() as usize) ListItem::new(entry_id.to_proto() as usize)
.indent_level(depth) .indent_level(depth)
.indent_step_size(px(settings.indent_size)) .indent_step_size(px(settings.indent_size))
.selected(is_selected) .selected(is_marked)
.when_some(canonical_path, |this, path| { .when_some(canonical_path, |this, path| {
this.end_slot::<Icon>( this.end_slot::<Icon>(
Icon::new(IconName::ArrowUpRight) Icon::new(IconName::ArrowUpRight)
@ -2046,13 +2046,21 @@ impl ProjectPanel {
) )
.border_1() .border_1()
.rounded_none() .rounded_none()
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover)) .hover(|style| {
.when(is_selected, |this| { if is_active || is_marked {
style
} else {
let hover_color = cx.theme().colors().ghost_element_hover;
style.bg(hover_color).border_color(hover_color)
}
})
.when(is_marked, |this| {
this.border_color(cx.theme().colors().ghost_element_selected) this.border_color(cx.theme().colors().ghost_element_selected)
}) })
.when(is_active, |this| { .when(
this.border_color(Color::Selected.color(cx)) is_active && self.focus_handle.contains_focused(cx),
}) |this| this.border_color(Color::Selected.color(cx)),
)
} }
fn dispatch_context(&self, cx: &ViewContext<Self>) -> KeyContext { fn dispatch_context(&self, cx: &ViewContext<Self>) -> KeyContext {