Fix scroll bar position (#392)

* Fix scroll bar position

* Always position scroll bar on the right side of the ScrollArea inner rect

* Fix the clipping rect
This commit is contained in:
Jay Oster 2021-06-03 09:54:34 -07:00 committed by GitHub
parent 6468b2b84e
commit 2932ff0e53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,9 +137,9 @@ impl ScrollArea {
),
*ui.layout(),
);
let mut content_clip_rect = inner_rect.expand(ui.visuals().clip_rect_margin);
content_clip_rect = content_clip_rect.intersect(ui.clip_rect());
content_clip_rect.max.x = ui.clip_rect().max.x - current_scroll_bar_width; // Nice handling of forced resizing beyond the possible
let content_clip_rect = inner_rect
.expand(ui.visuals().clip_rect_margin)
.intersect(ui.clip_rect());
content_ui.set_clip_rect(content_clip_rect);
let viewport = Rect::from_min_size(Pos2::ZERO + state.offset, inner_size);
@ -251,7 +251,7 @@ impl Prepared {
}
let width = if inner_rect.width().is_finite() {
inner_rect.width().max(content_size.x) // Expand width to fit content
inner_rect.width() // Position scroll bar correctly
} else {
// ScrollArea is in an infinitely wide parent
content_size.x