mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 09:25:01 +00:00
Add non-boxed wrap_impl! macro
Although maybe sized_view should rather use a box internally.
This commit is contained in:
parent
c8136c67e0
commit
191c2899ea
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -19,13 +19,7 @@ impl<T: View> SizedView<T> {
|
||||
}
|
||||
|
||||
impl <T: View> ViewWrapper for SizedView<T> {
|
||||
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);
|
||||
|
@ -44,7 +44,21 @@ impl <T: ViewWrapper> 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
|
||||
|
Loading…
Reference in New Issue
Block a user