Improve layout when two scrollbars are shown
This commit is contained in:
parent
1f2d18e691
commit
a067729525
1 changed files with 68 additions and 57 deletions
|
@ -984,10 +984,18 @@ impl<S: ScrollbarVisibilitySetting, T: ScrollableHandle> Element for ScrollbarEl
|
||||||
.not()
|
.not()
|
||||||
.then(|| ScrollbarPrepaintState {
|
.then(|| ScrollbarPrepaintState {
|
||||||
parent_bounds: bounds,
|
parent_bounds: bounds,
|
||||||
thumbs: self
|
thumbs: {
|
||||||
.state
|
let thumb_ranges = self.state.read(cx).thumb_ranges().collect::<Vec<_>>();
|
||||||
.read(cx)
|
let width = self.state.read(cx).width.to_pixels();
|
||||||
.thumb_ranges()
|
|
||||||
|
let additional_padding = if thumb_ranges.len() == 2 {
|
||||||
|
width + SCROLLBAR_PADDING
|
||||||
|
} else {
|
||||||
|
Pixels::ZERO
|
||||||
|
};
|
||||||
|
|
||||||
|
thumb_ranges
|
||||||
|
.into_iter()
|
||||||
.map(|(axis, thumb_range, reserved_space)| {
|
.map(|(axis, thumb_range, reserved_space)| {
|
||||||
let track_anchor = match axis {
|
let track_anchor = match axis {
|
||||||
ScrollbarAxis::Horizontal => Corner::BottomLeft,
|
ScrollbarAxis::Horizontal => Corner::BottomLeft,
|
||||||
|
@ -997,10 +1005,10 @@ impl<S: ScrollbarVisibilitySetting, T: ScrollableHandle> Element for ScrollbarEl
|
||||||
track_anchor,
|
track_anchor,
|
||||||
bounds
|
bounds
|
||||||
.corner(track_anchor)
|
.corner(track_anchor)
|
||||||
.apply_along(axis.invert(), |corner| corner - SCROLLBAR_PADDING),
|
.apply_along(axis.invert(), |corner| {
|
||||||
bounds.size.apply_along(axis.invert(), |_| {
|
corner - SCROLLBAR_PADDING
|
||||||
self.state.read(cx).width.to_pixels()
|
|
||||||
}),
|
}),
|
||||||
|
bounds.size.apply_along(axis.invert(), |_| width),
|
||||||
);
|
);
|
||||||
let scroll_track_bounds = Bounds::new(self.origin + origin, size);
|
let scroll_track_bounds = Bounds::new(self.origin + origin, size);
|
||||||
|
|
||||||
|
@ -1017,9 +1025,11 @@ impl<S: ScrollbarVisibilitySetting, T: ScrollableHandle> Element for ScrollbarEl
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let thumb_offset = thumb_range.start * padded_bounds.size.along(axis);
|
let available_space =
|
||||||
let thumb_end = thumb_range.end * padded_bounds.size.along(axis);
|
padded_bounds.size.along(axis) - additional_padding;
|
||||||
|
|
||||||
|
let thumb_offset = thumb_range.start * available_space;
|
||||||
|
let thumb_end = thumb_range.end * available_space;
|
||||||
let thumb_bounds = Bounds::new(
|
let thumb_bounds = Bounds::new(
|
||||||
padded_bounds
|
padded_bounds
|
||||||
.origin
|
.origin
|
||||||
|
@ -1044,7 +1054,8 @@ impl<S: ScrollbarVisibilitySetting, T: ScrollableHandle> Element for ScrollbarEl
|
||||||
reserved_space,
|
reserved_space,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue