From 51c20071adef0800ff077b05140e1e79d597fdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 6 Nov 2023 08:36:28 +0100 Subject: [PATCH] Add `View::for_each_child_rev_mut` and handle events front to back --- src/view.rs | 29 +++++++++++++++++-- src/views/clip.rs | 7 +++++ src/views/container.rs | 7 +++++ src/views/container_box.rs | 43 ++++++---------------------- src/views/drag_resize_window_area.rs | 7 +++++ src/views/drag_window_area.rs | 7 +++++ src/views/dyn_container.rs | 7 +++++ src/views/list.rs | 16 +++++++++++ src/views/scroll.rs | 7 +++++ src/views/stack.rs | 11 +++++++ src/views/static_list.rs | 11 +++++++ src/views/tab.rs | 43 +++++++++++----------------- src/views/virtual_list.rs | 16 +++++++++++ 13 files changed, 146 insertions(+), 65 deletions(-) diff --git a/src/view.rs b/src/view.rs index 066a519a..5f7453cf 100644 --- a/src/view.rs +++ b/src/view.rs @@ -111,14 +111,22 @@ bitflags! { pub trait View { fn id(&self) -> Id; - /// This method walk over children and must be implemented if the view has any children. + /// This method walks over children and must be implemented if the view has any children. /// It should return children back to front and should stop if `_for_each` returns `true`. fn for_each_child<'a>(&'a self, _for_each: &mut dyn FnMut(&'a dyn View) -> bool) {} - /// This method walk over children and must be implemented if the view has any children. + /// This method walks over children and must be implemented if the view has any children. /// It should return children back to front and should stop if `_for_each` returns `true`. fn for_each_child_mut<'a>(&'a mut self, _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool) {} + /// This method walks over children and must be implemented if the view has any children. + /// It should return children front to back and should stop if `_for_each` returns `true`. + fn for_each_child_rev_mut<'a>( + &'a mut self, + _for_each: &mut dyn FnMut(&'a mut dyn View) -> bool, + ) { + } + fn view_style(&self) -> Option