Fix Scrollbar bound calculations in Scrollable

This commit is contained in:
Héctor Ramón Jiménez 2023-02-07 19:27:03 +01:00
parent 570600ce51
commit 70483e7fdd
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -1116,8 +1116,9 @@ impl Scrollbars {
// Bounds of just the scrollbar
let scrollbar_bounds = Rectangle {
x: bounds.x + bounds.width - total_scrollbar_width / 2.0
+ width / 2.0,
x: bounds.x + bounds.width
- total_scrollbar_width / 2.0
- width / 2.0,
y: bounds.y,
width,
height: (bounds.height - x_scrollbar_height).max(0.0),
@ -1129,8 +1130,9 @@ impl Scrollbars {
let scroller_offset = offset.y * ratio;
let scroller_bounds = Rectangle {
x: bounds.x + bounds.width - total_scrollbar_width / 2.0
+ scroller_width / 2.0,
x: bounds.x + bounds.width
- total_scrollbar_width / 2.0
- scroller_width / 2.0,
y: (scrollbar_bounds.y + scroller_offset - x_scrollbar_height)
.max(0.0),
width: scroller_width,
@ -1175,8 +1177,9 @@ impl Scrollbars {
// Bounds of just the scrollbar
let scrollbar_bounds = Rectangle {
x: bounds.x,
y: bounds.y + bounds.height - total_scrollbar_height / 2.0
+ width / 2.0,
y: bounds.y + bounds.height
- total_scrollbar_height / 2.0
- width / 2.0,
width: (bounds.width - scrollbar_y_width).max(0.0),
height: width,
};
@ -1189,9 +1192,9 @@ impl Scrollbars {
let scroller_bounds = Rectangle {
x: (scrollbar_bounds.x + scroller_offset - scrollbar_y_width)
.max(0.0),
y: bounds.y + bounds.height - total_scrollbar_height / 2.0
+ scroller_width / 2.0,
y: bounds.y + bounds.height
- total_scrollbar_height / 2.0
- scroller_width / 2.0,
width: scroller_length,
height: scroller_width,
};