diff options
| author | 2022-08-07 14:43:54 -0700 | |
|---|---|---|
| committer | 2022-08-07 14:46:28 -0700 | |
| commit | a4d5b8276882e69bdafdd2e31a6db43e89622aaf (patch) | |
| tree | 114d58d1430b154bbd1d0c217be90fe569c926af /lazy | |
| parent | 8550550027bbe8123df5503fe616af8689a87360 (diff) | |
| download | iced-a4d5b8276882e69bdafdd2e31a6db43e89622aaf.tar.gz iced-a4d5b8276882e69bdafdd2e31a6db43e89622aaf.tar.bz2 iced-a4d5b8276882e69bdafdd2e31a6db43e89622aaf.zip | |
Impl operate for Component widget
Diffstat (limited to 'lazy')
| -rw-r--r-- | lazy/src/component.rs | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/lazy/src/component.rs b/lazy/src/component.rs index ea4d7311..8987b993 100644 --- a/lazy/src/component.rs +++ b/lazy/src/component.rs @@ -4,6 +4,7 @@ use iced_native::layout::{self, Layout};  use iced_native::mouse;  use iced_native::overlay;  use iced_native::renderer; +use iced_native::widget;  use iced_native::widget::tree::{self, Tree};  use iced_native::{      Clipboard, Element, Length, Point, Rectangle, Shell, Size, Widget, @@ -229,6 +230,47 @@ where          event_status      } +    fn operate( +        &self, +        tree: &mut Tree, +        layout: Layout<'_>, +        operation: &mut dyn widget::Operation<Message>, +    ) { +        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); +            } +        } + +        self.with_element(|element| { +            element.as_widget().operate( +                &mut tree.children[0], +                layout, +                &mut MapOperation { operation }, +            ); +        }); +    } +      fn draw(          &self,          tree: &Tree, | 
