summaryrefslogtreecommitdiffstats
path: root/wgpu/src/renderer/scrollable.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-29 02:00:17 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-29 02:00:17 +0100
commitbe488ac73837c9a741d900617840ee5c4ed74d61 (patch)
treea3326658670d96ec583255210a016e91240a447a /wgpu/src/renderer/scrollable.rs
parent23ebfb707a52d03a7beceaa5e197b4491619ae1d (diff)
downloadiced-be488ac73837c9a741d900617840ee5c4ed74d61.tar.gz
iced-be488ac73837c9a741d900617840ee5c4ed74d61.tar.bz2
iced-be488ac73837c9a741d900617840ee5c4ed74d61.zip
Draw scrollbar on top of scrollable content
Diffstat (limited to '')
-rw-r--r--wgpu/src/renderer/scrollable.rs51
1 files changed, 24 insertions, 27 deletions
diff --git a/wgpu/src/renderer/scrollable.rs b/wgpu/src/renderer/scrollable.rs
index 5b93a765..43dddeed 100644
--- a/wgpu/src/renderer/scrollable.rs
+++ b/wgpu/src/renderer/scrollable.rs
@@ -34,34 +34,31 @@ impl scrollable::Renderer for Renderer {
};
(
- Primitive::Group {
- primitives: if is_mouse_over
- && content_bounds.height > bounds.height
- {
- let ratio = bounds.height / content_bounds.height;
- let scrollbar_height = bounds.height * ratio;
- let y_offset = offset as f32 * ratio;
+ if is_mouse_over && content_bounds.height > bounds.height {
+ let ratio = bounds.height / content_bounds.height;
+ let scrollbar_height = bounds.height * ratio;
+ let y_offset = offset as f32 * ratio;
- let scrollbar = Primitive::Quad {
- bounds: Rectangle {
- x: bounds.x + bounds.width - 12.0,
- y: bounds.y + y_offset,
- width: 10.0,
- height: scrollbar_height,
- },
- background: Background::Color(Color {
- r: 0.0,
- g: 0.0,
- b: 0.0,
- a: 0.5,
- }),
- border_radius: 5,
- };
-
- vec![primitive, scrollbar]
- } else {
- vec![primitive]
- },
+ let scrollbar = Primitive::Quad {
+ bounds: Rectangle {
+ x: bounds.x + bounds.width - 12.0,
+ y: bounds.y + y_offset,
+ width: 10.0,
+ height: scrollbar_height,
+ },
+ background: Background::Color(Color {
+ r: 0.0,
+ g: 0.0,
+ b: 0.0,
+ a: 0.7,
+ }),
+ border_radius: 5,
+ };
+ Primitive::Group {
+ primitives: vec![primitive, scrollbar],
+ }
+ } else {
+ primitive
},
mouse_cursor,
)