Merge pull request #2084 from iced-rs/fix/horizontal-scrollbar-width
Fix width of horizontal scrollbar in `Scrollable`
This commit is contained in:
commit
4613eb26cb
2 changed files with 12 additions and 12 deletions
|
|
@ -389,12 +389,12 @@ impl scrollable::StyleSheet for ScrollbarCustomStyle {
|
||||||
background: style
|
background: style
|
||||||
.active(&theme::Scrollable::default())
|
.active(&theme::Scrollable::default())
|
||||||
.background,
|
.background,
|
||||||
border_radius: 0.0.into(),
|
border_radius: 2.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Default::default(),
|
border_color: Default::default(),
|
||||||
scroller: Scroller {
|
scroller: Scroller {
|
||||||
color: Color::from_rgb8(250, 85, 134),
|
color: Color::from_rgb8(250, 85, 134),
|
||||||
border_radius: 0.0.into(),
|
border_radius: 2.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Default::default(),
|
border_color: Default::default(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1364,15 +1364,15 @@ impl Scrollbars {
|
||||||
|
|
||||||
let ratio = bounds.height / content_bounds.height;
|
let ratio = bounds.height / content_bounds.height;
|
||||||
// min height for easier grabbing with super tall content
|
// min height for easier grabbing with super tall content
|
||||||
let scroller_height = (bounds.height * ratio).max(2.0);
|
let scroller_height = (scrollbar_bounds.height * ratio).max(2.0);
|
||||||
let scroller_offset = translation.y * ratio;
|
let scroller_offset =
|
||||||
|
translation.y * ratio * scrollbar_bounds.height / bounds.height;
|
||||||
|
|
||||||
let scroller_bounds = Rectangle {
|
let scroller_bounds = Rectangle {
|
||||||
x: bounds.x + bounds.width
|
x: bounds.x + bounds.width
|
||||||
- total_scrollbar_width / 2.0
|
- total_scrollbar_width / 2.0
|
||||||
- scroller_width / 2.0,
|
- scroller_width / 2.0,
|
||||||
y: (scrollbar_bounds.y + scroller_offset - x_scrollbar_height)
|
y: (scrollbar_bounds.y + scroller_offset).max(0.0),
|
||||||
.max(0.0),
|
|
||||||
width: scroller_width,
|
width: scroller_width,
|
||||||
height: scroller_height,
|
height: scroller_height,
|
||||||
};
|
};
|
||||||
|
|
@ -1399,8 +1399,8 @@ impl Scrollbars {
|
||||||
|
|
||||||
// Need to adjust the width of the horizontal scrollbar if the vertical scrollbar
|
// Need to adjust the width of the horizontal scrollbar if the vertical scrollbar
|
||||||
// is present
|
// is present
|
||||||
let scrollbar_y_width = show_scrollbar_y
|
let scrollbar_y_width = y_scrollbar
|
||||||
.map_or(0.0, |v| v.width.max(v.scroller_width) + v.margin);
|
.map_or(0.0, |scrollbar| scrollbar.total_bounds.width);
|
||||||
|
|
||||||
let total_scrollbar_height =
|
let total_scrollbar_height =
|
||||||
width.max(scroller_width) + 2.0 * margin;
|
width.max(scroller_width) + 2.0 * margin;
|
||||||
|
|
@ -1425,12 +1425,12 @@ impl Scrollbars {
|
||||||
|
|
||||||
let ratio = bounds.width / content_bounds.width;
|
let ratio = bounds.width / content_bounds.width;
|
||||||
// min width for easier grabbing with extra wide content
|
// min width for easier grabbing with extra wide content
|
||||||
let scroller_length = (bounds.width * ratio).max(2.0);
|
let scroller_length = (scrollbar_bounds.width * ratio).max(2.0);
|
||||||
let scroller_offset = translation.x * ratio;
|
let scroller_offset =
|
||||||
|
translation.x * ratio * scrollbar_bounds.width / bounds.width;
|
||||||
|
|
||||||
let scroller_bounds = Rectangle {
|
let scroller_bounds = Rectangle {
|
||||||
x: (scrollbar_bounds.x + scroller_offset - scrollbar_y_width)
|
x: (scrollbar_bounds.x + scroller_offset).max(0.0),
|
||||||
.max(0.0),
|
|
||||||
y: bounds.y + bounds.height
|
y: bounds.y + bounds.height
|
||||||
- total_scrollbar_height / 2.0
|
- total_scrollbar_height / 2.0
|
||||||
- scroller_width / 2.0,
|
- scroller_width / 2.0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue