mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
fix theme selector gaps (#3682)
- Don't scroll beyond end of uniform list - Restore position of uniform_list padding [[PR Description]] Release Notes: - N/A
This commit is contained in:
commit
b8cdcf4e93
1 changed files with 16 additions and 6 deletions
|
@ -191,19 +191,26 @@ impl Element for UniformList {
|
||||||
content_size,
|
content_size,
|
||||||
&mut element_state.interactive,
|
&mut element_state.interactive,
|
||||||
cx,
|
cx,
|
||||||
|style, scroll_offset, cx| {
|
|style, mut scroll_offset, cx| {
|
||||||
let border = style.border_widths.to_pixels(cx.rem_size());
|
let border = style.border_widths.to_pixels(cx.rem_size());
|
||||||
let padding = style.padding.to_pixels(bounds.size.into(), cx.rem_size());
|
let padding = style.padding.to_pixels(bounds.size.into(), cx.rem_size());
|
||||||
|
|
||||||
let padded_bounds = Bounds::from_corners(
|
let padded_bounds = Bounds::from_corners(
|
||||||
bounds.origin + point(border.left + padding.left, border.top + padding.top),
|
bounds.origin + point(border.left + padding.left, border.top),
|
||||||
bounds.lower_right()
|
bounds.lower_right() - point(border.right + padding.right, border.bottom),
|
||||||
- point(border.right + padding.right, border.bottom + padding.bottom),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
cx.with_z_index(style.z_index.unwrap_or(0), |cx| {
|
cx.with_z_index(style.z_index.unwrap_or(0), |cx| {
|
||||||
style.paint(bounds, cx, |cx| {
|
style.paint(bounds, cx, |cx| {
|
||||||
if self.item_count > 0 {
|
if self.item_count > 0 {
|
||||||
|
let content_height =
|
||||||
|
item_height * self.item_count + padding.top + padding.bottom;
|
||||||
|
let min_scroll_offset = padded_bounds.size.height - content_height;
|
||||||
|
if scroll_offset.y < min_scroll_offset {
|
||||||
|
shared_scroll_offset.borrow_mut().y = min_scroll_offset;
|
||||||
|
scroll_offset.y = min_scroll_offset;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(scroll_handle) = self.scroll_handle.clone() {
|
if let Some(scroll_handle) = self.scroll_handle.clone() {
|
||||||
scroll_handle.0.borrow_mut().replace(ScrollHandleState {
|
scroll_handle.0.borrow_mut().replace(ScrollHandleState {
|
||||||
item_height,
|
item_height,
|
||||||
|
@ -213,7 +220,7 @@ impl Element for UniformList {
|
||||||
}
|
}
|
||||||
|
|
||||||
let first_visible_element_ix =
|
let first_visible_element_ix =
|
||||||
(-scroll_offset.y / item_height).floor() as usize;
|
(-(scroll_offset.y + padding.top) / item_height).floor() as usize;
|
||||||
let last_visible_element_ix =
|
let last_visible_element_ix =
|
||||||
((-scroll_offset.y + padded_bounds.size.height) / item_height)
|
((-scroll_offset.y + padded_bounds.size.height) / item_height)
|
||||||
.ceil() as usize;
|
.ceil() as usize;
|
||||||
|
@ -226,7 +233,10 @@ impl Element for UniformList {
|
||||||
cx.with_content_mask(Some(content_mask), |cx| {
|
cx.with_content_mask(Some(content_mask), |cx| {
|
||||||
for (item, ix) in items.iter_mut().zip(visible_range) {
|
for (item, ix) in items.iter_mut().zip(visible_range) {
|
||||||
let item_origin = padded_bounds.origin
|
let item_origin = padded_bounds.origin
|
||||||
+ point(px(0.), item_height * ix + scroll_offset.y);
|
+ point(
|
||||||
|
px(0.),
|
||||||
|
item_height * ix + scroll_offset.y + padding.top,
|
||||||
|
);
|
||||||
let available_space = size(
|
let available_space = size(
|
||||||
AvailableSpace::Definite(padded_bounds.size.width),
|
AvailableSpace::Definite(padded_bounds.size.width),
|
||||||
AvailableSpace::Definite(item_height),
|
AvailableSpace::Definite(item_height),
|
||||||
|
|
Loading…
Reference in a new issue