summaryrefslogtreecommitdiffstats
path: root/native/src/overlay
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-09 23:50:23 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-09 23:50:23 +0100
commit1283f2153cf300272a4cb3464f8166b0ec9c83de (patch)
treed21b7a093ccbc2045ca1ab47a47c8a1f06aba0ff /native/src/overlay
parent397f2910e02868419373a93b58da93c80449ff64 (diff)
downloadiced-1283f2153cf300272a4cb3464f8166b0ec9c83de.tar.gz
iced-1283f2153cf300272a4cb3464f8166b0ec9c83de.tar.bz2
iced-1283f2153cf300272a4cb3464f8166b0ec9c83de.zip
Implement `Overlay::operate` for `overlay::element::Map`
Diffstat (limited to 'native/src/overlay')
-rw-r--r--native/src/overlay/element.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs
index b919c221..9500df27 100644
--- a/native/src/overlay/element.rs
+++ b/native/src/overlay/element.rs
@@ -141,6 +141,49 @@ where
self.content.layout(renderer, bounds, position)
}
+ fn operate(
+ &self,
+ layout: Layout<'_>,
+ operation: &mut dyn widget::Operation<B>,
+ ) {
+ struct MapOperation<'a, B> {
+ operation: &'a mut dyn widget::Operation<B>,
+ }
+
+ impl<'a, T, B> widget::Operation<T> for MapOperation<'a, B> {
+ fn container(
+ &mut self,
+ id: Option<&widget::Id>,
+ operate_on_children: &mut dyn FnMut(
+ &mut dyn widget::Operation<T>,
+ ),
+ ) {
+ self.operation.container(id, &mut |operation| {
+ operate_on_children(&mut MapOperation { operation });
+ });
+ }
+
+ fn focusable(
+ &mut self,
+ state: &mut dyn widget::operation::Focusable,
+ id: Option<&widget::Id>,
+ ) {
+ self.operation.focusable(state, id);
+ }
+
+ fn scrollable(
+ &mut self,
+ state: &mut dyn widget::operation::Scrollable,
+ id: Option<&widget::Id>,
+ ) {
+ self.operation.scrollable(state, id);
+ }
+ }
+
+ self.content
+ .operate(layout, &mut MapOperation { operation });
+ }
+
fn on_event(
&mut self,
event: Event,