summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-18 19:28:05 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-07-08 10:59:57 +0200
commitada8d7c77f9e1d4a1de762b514c9610f7e09b17f (patch)
tree7f0490a0c3833924881b95fed1218c5ef5455313 /native
parentf7a370b6b9b5d33d1d3c078d2865eacf813cd652 (diff)
downloadiced-ada8d7c77f9e1d4a1de762b514c9610f7e09b17f.tar.gz
iced-ada8d7c77f9e1d4a1de762b514c9610f7e09b17f.tar.bz2
iced-ada8d7c77f9e1d4a1de762b514c9610f7e09b17f.zip
Implement `Widget::overlay` for `Scrollable`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/scrollable.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs
index 25fd8982..92e5265a 100644
--- a/native/src/widget/scrollable.rs
+++ b/native/src/widget/scrollable.rs
@@ -1,7 +1,7 @@
//! Navigate an endless amount of content with a scrollbar.
use crate::{
column, layout, mouse, Align, Clipboard, Column, Element, Event, Hasher,
- Layout, Length, Point, Rectangle, Size, Widget,
+ Layout, Length, Overlay, Point, Rectangle, Size, Vector, Widget,
};
use std::{f32, hash::Hash, u32};
@@ -315,6 +315,22 @@ where
self.content.hash_layout(state)
}
+
+ fn overlay(
+ &mut self,
+ layout: Layout<'_>,
+ ) -> Option<Overlay<'a, Message, Renderer>> {
+ self.content
+ .overlay(layout.children().next().unwrap())
+ .map(|overlay| {
+ let bounds = layout.bounds();
+ let content_layout = layout.children().next().unwrap();
+ let content_bounds = content_layout.bounds();
+ let offset = self.state.offset(bounds, content_bounds);
+
+ overlay.translate(Vector::new(0.0, -(offset as f32)))
+ })
+ }
}
/// The local state of a [`Scrollable`].