Introduce Layer trait

This commit is contained in:
Héctor Ramón Jiménez 2020-04-16 13:22:00 +02:00
parent c901f40fd6
commit f064f0482b
12 changed files with 252 additions and 54 deletions

View file

@ -2,8 +2,8 @@
use std::hash::Hash;
use crate::{
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Widget,
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Overlay,
Point, Widget,
};
use std::u32;
@ -204,6 +204,17 @@ where
child.widget.hash_layout(state);
}
}
fn overlay(
&mut self,
layout: Layout<'_>,
) -> Option<Overlay<'a, Message, Renderer>> {
self.children
.iter_mut()
.zip(layout.children())
.filter_map(|(child, layout)| child.widget.overlay(layout))
.next()
}
}
/// The renderer of a [`Column`].

View file

@ -2,8 +2,8 @@
use std::hash::Hash;
use crate::{
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
Rectangle, Widget,
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Overlay,
Point, Rectangle, Widget,
};
use std::u32;
@ -214,6 +214,13 @@ where
self.content.hash_layout(state);
}
fn overlay(
&mut self,
layout: Layout<'_>,
) -> Option<Overlay<'a, Message, Renderer>> {
self.content.overlay(layout.children().next().unwrap())
}
}
/// The renderer of a [`Container`].