Project panel horizontal scrollbar (#18513)

<img width="389" alt="image"
src="https://github.com/user-attachments/assets/c6718c6e-0fe1-40ed-b3db-7d576c4d98c8">


https://github.com/user-attachments/assets/734f1f52-70d9-4308-b1fc-36c7cfd4dd76

Closes https://github.com/zed-industries/zed/issues/7001
Closes https://github.com/zed-industries/zed/issues/4427
Part of https://github.com/zed-industries/zed/issues/15324
Part of https://github.com/zed-industries/zed/issues/14551

* Adjusts a `UniformList` to have a horizontal sizing behavior: the old
mode forced all items to have the size of the list exactly.
A new mode (with corresponding `ListItems` having `overflow_x` enabled)
lays out the uniform list elements with width of its widest element,
setting the same width to the list itself too.

* Using the new behavior, adds a new scrollbar into the project panel
and enhances its file name editor to scroll it during editing of long
file names

* Also restyles the scrollbar a bit, making it narrower and removing its
background

* Changes the project_panel.scrollbar.show settings to accept `null` and
be `null` by default, to inherit `editor`'s scrollbar settings. All
editor scrollbar settings are supported now.

Release Notes:

- Added a horizontal scrollbar to project panel
([#7001](https://github.com/zed-industries/zed/issues/7001))
([#4427](https://github.com/zed-industries/zed/issues/4427))

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
Kirill Bulatov 2024-10-01 18:32:16 +03:00 committed by GitHub
parent 68d6177d37
commit 051627c449
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 567 additions and 149 deletions

View file

@ -36,6 +36,7 @@ pub struct ListItem {
on_secondary_mouse_down: Option<Box<dyn Fn(&MouseDownEvent, &mut WindowContext) + 'static>>,
children: SmallVec<[AnyElement; 2]>,
selectable: bool,
overflow_x: bool,
}
impl ListItem {
@ -58,6 +59,7 @@ impl ListItem {
tooltip: None,
children: SmallVec::new(),
selectable: true,
overflow_x: false,
}
}
@ -131,6 +133,11 @@ impl ListItem {
self.end_hover_slot = end_hover_slot.into().map(IntoElement::into_any_element);
self
}
pub fn overflow_x(mut self) -> Self {
self.overflow_x = true;
self
}
}
impl Disableable for ListItem {
@ -239,7 +246,13 @@ impl RenderOnce for ListItem {
.flex_shrink_0()
.flex_basis(relative(0.25))
.gap(Spacing::Small.rems(cx))
.overflow_hidden()
.map(|list_content| {
if self.overflow_x {
list_content
} else {
list_content.overflow_hidden()
}
})
.children(self.start_slot)
.children(self.children),
)