Implement Overlay::operate for overlay::element::Map

This commit is contained in:
Héctor Ramón Jiménez 2022-11-09 23:50:23 +01:00
parent 397f2910e0
commit 1283f2153c
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -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,