Add disclosure arrows to the project panel

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-09-30 10:24:52 -07:00
co-authored by Nathan Sobo
parent 18a379f20c
commit 6fba17a5e1
5 changed files with 59 additions and 6 deletions
+36 -2
View File
@@ -7,7 +7,10 @@ use crate::{
};
use gpui::{
action,
elements::{Label, MouseEventHandler, UniformList, UniformListState},
elements::{
Align, ConstrainedBox, Empty, Flex, Label, MouseEventHandler, ParentElement, Svg,
UniformList, UniformListState,
},
keymap::{
self,
menu::{SelectNext, SelectPrev},
@@ -474,7 +477,38 @@ impl ProjectPanel {
} else {
&theme.entry
};
Label::new(details.filename, style.text.clone())
Flex::row()
.with_child(
ConstrainedBox::new(
Align::new(
ConstrainedBox::new(if is_dir {
if details.is_expanded {
Svg::new("icons/disclosure-open.svg")
.with_color(style.icon_color)
.boxed()
} else {
Svg::new("icons/disclosure-closed.svg")
.with_color(style.icon_color)
.boxed()
}
} else {
Empty::new().boxed()
})
.with_max_width(style.icon_size)
.with_max_height(style.icon_size)
.boxed(),
)
.boxed(),
)
.with_width(style.icon_size)
.boxed(),
)
.with_child(
Label::new(details.filename, style.text.clone())
.contained()
.with_margin_left(style.icon_spacing)
.boxed(),
)
.contained()
.with_style(style.container)
.with_padding_left(theme.entry_base_padding + details.depth as f32 * 20.)
+13 -3
View File
@@ -112,9 +112,19 @@ pub struct ProjectPanel {
#[serde(flatten)]
pub container: ContainerStyle,
pub entry_base_padding: f32,
pub entry: ContainedText,
pub hovered_entry: ContainedText,
pub selected_entry: ContainedText,
pub entry: ProjectPanelEntry,
pub hovered_entry: ProjectPanelEntry,
pub selected_entry: ProjectPanelEntry,
}
#[derive(Deserialize)]
pub struct ProjectPanelEntry {
#[serde(flatten)]
pub container: ContainerStyle,
pub text: TextStyle,
pub icon_color: Color,
pub icon_size: f32,
pub icon_spacing: f32,
}
#[derive(Deserialize)]