diff --git a/src/view/box_view.rs b/src/view/box_view.rs index 239e248..0dc2540 100644 --- a/src/view/box_view.rs +++ b/src/view/box_view.rs @@ -27,7 +27,7 @@ impl BoxView { impl ViewWrapper for BoxView { - wrap_impl!(content); + wrap_impl_box!(self.content); fn wrap_get_min_size(&self, _: SizeRequest) -> Vec2 { self.size diff --git a/src/view/key_event_view.rs b/src/view/key_event_view.rs index 87181a6..cf5fa4e 100644 --- a/src/view/key_event_view.rs +++ b/src/view/key_event_view.rs @@ -34,7 +34,7 @@ impl KeyEventView { impl ViewWrapper for KeyEventView { - wrap_impl!(content); + wrap_impl_box!(self.content); fn wrap_on_key_event(&mut self, ch: i32) -> EventResult { match self.content.on_key_event(ch) { diff --git a/src/view/sized_view.rs b/src/view/sized_view.rs index a62a978..6fd8fa4 100644 --- a/src/view/sized_view.rs +++ b/src/view/sized_view.rs @@ -19,13 +19,7 @@ impl SizedView { } impl ViewWrapper for SizedView { - fn get_view(&self) -> &View { - &self.view - } - - fn get_view_mut(&mut self) -> &mut View { - &mut self.view - } + wrap_impl!(self.view); fn wrap_layout(&mut self, size: Vec2) { self.view.layout(size); diff --git a/src/view/view_wrapper.rs b/src/view/view_wrapper.rs index bb1d019..cad32a5 100644 --- a/src/view/view_wrapper.rs +++ b/src/view/view_wrapper.rs @@ -44,7 +44,21 @@ impl View for T { #[macro_export] macro_rules! wrap_impl { - ($v:ident) => { + (self.$v:ident) => { + + fn get_view(&self) -> &View { + &self.$v + } + + fn get_view_mut(&mut self) -> &mut View { + &mut self.$v + } + }; +} + +#[macro_export] +macro_rules! wrap_impl_box { + (self.$v:ident) => { fn get_view(&self) -> &View { &*self.$v