Simplify scrollable disabled styling calculation
This commit is contained in:
parent
8d9fe61d76
commit
cff3eb217f
1 changed files with 11 additions and 24 deletions
|
|
@ -1600,27 +1600,15 @@ impl Scrollbars {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let translation = state.translation(direction, bounds, content_bounds);
|
let translation = state.translation(direction, bounds, content_bounds);
|
||||||
|
|
||||||
let show_scrollbar_x = direction
|
let show_scrollbar_x = direction.horizontal().filter(|scrollbar| {
|
||||||
.horizontal()
|
scrollbar.spacing.is_some() || content_bounds.width > bounds.width
|
||||||
.filter(|scrollbar| {
|
});
|
||||||
scrollbar.spacing.is_some()
|
|
||||||
|| content_bounds.width > bounds.width
|
|
||||||
})
|
|
||||||
.map(|properties| {
|
|
||||||
(properties, content_bounds.width <= bounds.width)
|
|
||||||
});
|
|
||||||
|
|
||||||
let show_scrollbar_y = direction
|
let show_scrollbar_y = direction.vertical().filter(|scrollbar| {
|
||||||
.vertical()
|
scrollbar.spacing.is_some() || content_bounds.height > bounds.height
|
||||||
.filter(|scrollbar| {
|
});
|
||||||
scrollbar.spacing.is_some()
|
|
||||||
|| content_bounds.height > bounds.height
|
|
||||||
})
|
|
||||||
.map(|properties| {
|
|
||||||
(properties, content_bounds.height <= bounds.height)
|
|
||||||
});
|
|
||||||
|
|
||||||
let y_scrollbar = if let Some((vertical, disabled)) = show_scrollbar_y {
|
let y_scrollbar = if let Some(vertical) = show_scrollbar_y {
|
||||||
let Scrollbar {
|
let Scrollbar {
|
||||||
width,
|
width,
|
||||||
margin,
|
margin,
|
||||||
|
|
@ -1631,7 +1619,7 @@ impl Scrollbars {
|
||||||
// Adjust the height of the vertical scrollbar if the horizontal scrollbar
|
// Adjust the height of the vertical scrollbar if the horizontal scrollbar
|
||||||
// is present
|
// is present
|
||||||
let x_scrollbar_height = show_scrollbar_x
|
let x_scrollbar_height = show_scrollbar_x
|
||||||
.map_or(0.0, |(h, _)| h.width.max(h.scroller_width) + h.margin);
|
.map_or(0.0, |h| h.width.max(h.scroller_width) + h.margin);
|
||||||
|
|
||||||
let total_scrollbar_width =
|
let total_scrollbar_width =
|
||||||
width.max(scroller_width) + 2.0 * margin;
|
width.max(scroller_width) + 2.0 * margin;
|
||||||
|
|
@ -1685,14 +1673,13 @@ impl Scrollbars {
|
||||||
bounds: scrollbar_bounds,
|
bounds: scrollbar_bounds,
|
||||||
scroller,
|
scroller,
|
||||||
alignment: vertical.alignment,
|
alignment: vertical.alignment,
|
||||||
disabled,
|
disabled: content_bounds.height <= bounds.height,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let x_scrollbar = if let Some((horizontal, disabled)) = show_scrollbar_x
|
let x_scrollbar = if let Some(horizontal) = show_scrollbar_x {
|
||||||
{
|
|
||||||
let Scrollbar {
|
let Scrollbar {
|
||||||
width,
|
width,
|
||||||
margin,
|
margin,
|
||||||
|
|
@ -1756,7 +1743,7 @@ impl Scrollbars {
|
||||||
bounds: scrollbar_bounds,
|
bounds: scrollbar_bounds,
|
||||||
scroller,
|
scroller,
|
||||||
alignment: horizontal.alignment,
|
alignment: horizontal.alignment,
|
||||||
disabled,
|
disabled: content_bounds.width <= bounds.width,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue