summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-07 03:18:39 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-07 03:18:39 +0100
commit3d26eb79c2b6a4ed4d186552b052c31235bd0b83 (patch)
tree22ec833f1148d51014599602342a96a395313278 /wgpu
parented30b487d649ffa0967ab8bfd66f4820ee2150fd (diff)
downloadiced-3d26eb79c2b6a4ed4d186552b052c31235bd0b83.tar.gz
iced-3d26eb79c2b6a4ed4d186552b052c31235bd0b83.tar.bz2
iced-3d26eb79c2b6a4ed4d186552b052c31235bd0b83.zip
Always show scroller if scrollbar is visible
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/renderer/widget/scrollable.rs73
1 files changed, 38 insertions, 35 deletions
diff --git a/wgpu/src/renderer/widget/scrollable.rs b/wgpu/src/renderer/widget/scrollable.rs
index 30d7f337..bfee7411 100644
--- a/wgpu/src/renderer/widget/scrollable.rs
+++ b/wgpu/src/renderer/widget/scrollable.rs
@@ -66,50 +66,53 @@ impl scrollable::Renderer for Renderer {
(
if let Some(scrollbar) = scrollbar {
- if is_mouse_over || state.is_scroller_grabbed() {
- let style = if state.is_scroller_grabbed() {
- style_sheet.dragging()
- } else if is_mouse_over_scrollbar {
- style_sheet.hovered()
- } else {
- style_sheet.active()
- };
+ let style = if state.is_scroller_grabbed() {
+ style_sheet.dragging()
+ } else if is_mouse_over_scrollbar {
+ style_sheet.hovered()
+ } else {
+ style_sheet.active()
+ };
+
+ let is_scrollbar_visible =
+ style.background.is_some() || style.border_width > 0;
- let scroller = Primitive::Quad {
+ let scroller = if is_mouse_over
+ || state.is_scroller_grabbed()
+ || is_scrollbar_visible
+ {
+ Primitive::Quad {
bounds: scrollbar.scroller.bounds,
background: Background::Color(style.scroller.color),
border_radius: style.scroller.border_radius,
border_width: style.scroller.border_width,
border_color: style.scroller.border_color,
- };
-
- if style.background.is_some() || style.border_width > 0 {
- let scrollbar = Primitive::Quad {
- bounds: Rectangle {
- x: scrollbar.bounds.x
- + f32::from(SCROLLBAR_MARGIN),
- width: scrollbar.bounds.width
- - f32::from(2 * SCROLLBAR_MARGIN),
- ..scrollbar.bounds
- },
- background: style.background.unwrap_or(
- Background::Color(Color::TRANSPARENT),
- ),
- border_radius: style.border_radius,
- border_width: style.border_width,
- border_color: style.border_color,
- };
+ }
+ } else {
+ Primitive::None
+ };
- Primitive::Group {
- primitives: vec![clip, scrollbar, scroller],
- }
- } else {
- Primitive::Group {
- primitives: vec![clip, scroller],
- }
+ let scrollbar = if is_scrollbar_visible {
+ Primitive::Quad {
+ bounds: Rectangle {
+ x: scrollbar.bounds.x + f32::from(SCROLLBAR_MARGIN),
+ width: scrollbar.bounds.width
+ - f32::from(2 * SCROLLBAR_MARGIN),
+ ..scrollbar.bounds
+ },
+ background: style
+ .background
+ .unwrap_or(Background::Color(Color::TRANSPARENT)),
+ border_radius: style.border_radius,
+ border_width: style.border_width,
+ border_color: style.border_color,
}
} else {
- clip
+ Primitive::None
+ };
+
+ Primitive::Group {
+ primitives: vec![clip, scrollbar, scroller],
}
} else {
clip