summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-01-06 20:23:26 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-01-06 20:23:26 +0100
commitcff3eb217f7f0d9a49d323f4c3231eec76f380a2 (patch)
tree2e9acd11887d19b16ee54c1207df8873633e686f /widget
parent8d9fe61d76cbac1d752a0b77629fd46be6908074 (diff)
downloadiced-cff3eb217f7f0d9a49d323f4c3231eec76f380a2.tar.gz
iced-cff3eb217f7f0d9a49d323f4c3231eec76f380a2.tar.bz2
iced-cff3eb217f7f0d9a49d323f4c3231eec76f380a2.zip
Simplify `scrollable` disabled styling calculation
Diffstat (limited to 'widget')
-rw-r--r--widget/src/scrollable.rs35
1 files changed, 11 insertions, 24 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 9800a5c2..43fd47fe 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -1600,27 +1600,15 @@ impl Scrollbars {
) -> Self {
let translation = state.translation(direction, bounds, content_bounds);
- let show_scrollbar_x = direction
- .horizontal()
- .filter(|scrollbar| {
- scrollbar.spacing.is_some()
- || content_bounds.width > bounds.width
- })
- .map(|properties| {
- (properties, content_bounds.width <= bounds.width)
- });
+ let show_scrollbar_x = direction.horizontal().filter(|scrollbar| {
+ scrollbar.spacing.is_some() || content_bounds.width > bounds.width
+ });
- let show_scrollbar_y = direction
- .vertical()
- .filter(|scrollbar| {
- scrollbar.spacing.is_some()
- || content_bounds.height > bounds.height
- })
- .map(|properties| {
- (properties, content_bounds.height <= bounds.height)
- });
+ let show_scrollbar_y = direction.vertical().filter(|scrollbar| {
+ scrollbar.spacing.is_some() || 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 {
width,
margin,
@@ -1631,7 +1619,7 @@ impl Scrollbars {
// Adjust the height of the vertical scrollbar if the horizontal scrollbar
// is present
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 =
width.max(scroller_width) + 2.0 * margin;
@@ -1685,14 +1673,13 @@ impl Scrollbars {
bounds: scrollbar_bounds,
scroller,
alignment: vertical.alignment,
- disabled,
+ disabled: content_bounds.height <= bounds.height,
})
} else {
None
};
- let x_scrollbar = if let Some((horizontal, disabled)) = show_scrollbar_x
- {
+ let x_scrollbar = if let Some(horizontal) = show_scrollbar_x {
let Scrollbar {
width,
margin,
@@ -1756,7 +1743,7 @@ impl Scrollbars {
bounds: scrollbar_bounds,
scroller,
alignment: horizontal.alignment,
- disabled,
+ disabled: content_bounds.width <= bounds.width,
})
} else {
None