Refine project panel styling

This commit is contained in:
Antonio Scandurra 2021-09-29 11:32:06 +02:00
parent bd7bf82d18
commit e030917769
5 changed files with 34 additions and 11 deletions

View file

@ -84,6 +84,11 @@ impl Container {
self
}
pub fn with_padding_left(mut self, padding: f32) -> Self {
self.style.padding.left = padding;
self
}
pub fn with_padding_right(mut self, padding: f32) -> Self {
self.style.padding.right = padding;
self

View file

@ -161,9 +161,16 @@ corner_radius = 6
[project_panel]
extends = "$panel"
entry = "$text.0"
padding.left = "$panel.padding"
padding.right = "$panel.padding"
padding = 0
entry_base_padding = "$panel.padding"
[project_panel.entry]
extends = "$text.0"
padding = { top = 3, bottom = 3 }
[project_panel.hovered_entry]
extends = "$project_panel.entry"
background = "$state.hover"
[selector]
background = "$surface.0"

View file

@ -2,6 +2,7 @@ use crate::{project::Project, theme, Settings};
use gpui::{
action,
elements::{Label, MouseEventHandler, UniformList, UniformListState},
platform::CursorStyle,
Element, ElementBox, Entity, ModelHandle, MutableAppContext, ReadModel, View, ViewContext,
WeakViewHandle,
};
@ -165,10 +166,16 @@ impl ProjectPanel {
MouseEventHandler::new::<Self, _, _, _>(
(entry.worktree_ix, entry.entry_id),
cx,
|state, cx| {
Label::new(details.filename, theme.entry.clone())
|state, _| {
let style = if state.hovered {
&theme.hovered_entry
} else {
&theme.entry
};
Label::new(details.filename, style.text.clone())
.contained()
.with_margin_left(details.depth as f32 * 20.)
.with_style(style.container)
.with_padding_left(theme.entry_base_padding + details.depth as f32 * 20.)
.boxed()
},
)
@ -179,6 +186,7 @@ impl ProjectPanel {
cx.dispatch_action(Open(entry))
}
})
.with_cursor_style(CursorStyle::PointingHand)
.boxed()
}
}

View file

@ -111,7 +111,9 @@ pub struct ChatPanel {
pub struct ProjectPanel {
#[serde(flatten)]
pub container: ContainerStyle,
pub entry: TextStyle,
pub entry_base_padding: f32,
pub entry: ContainedText,
pub hovered_entry: ContainedText,
}
#[derive(Deserialize)]

View file

@ -1592,7 +1592,6 @@ impl Snapshot {
}
fn insert_entry(&mut self, mut entry: Entry, fs: &dyn Fs) -> Entry {
println!("insert entry {:?}", entry.path);
if !entry.is_dir() && entry.path.file_name() == Some(&GITIGNORE) {
let abs_path = self.abs_path.join(&entry.path);
match build_gitignore(&abs_path, fs) {
@ -1665,10 +1664,8 @@ impl Snapshot {
fn reuse_entry_id(&mut self, entry: &mut Entry) {
if let Some(removed_entry_id) = self.removed_entry_ids.remove(&entry.inode) {
log::info!("reusing removed entry id {}", removed_entry_id);
entry.id = removed_entry_id;
} else if let Some(existing_entry) = self.entry_for_path(&entry.path) {
log::info!("reusing removed entry id {}", existing_entry.id);
entry.id = existing_entry.id;
}
}
@ -2234,7 +2231,11 @@ impl BackgroundScanner {
new_ignore = Some(ignore);
}
Err(error) => {
log::error!("error loading .gitignore file {:?} - {:?}", child_name, error);
log::error!(
"error loading .gitignore file {:?} - {:?}",
child_name,
error
);
}
}