Add Runtime concept to abstract caching
This commit is contained in:
parent
eb45c51a7b
commit
e55ac637a9
5 changed files with 123 additions and 89 deletions
|
|
@ -19,8 +19,16 @@ pub struct Layout<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Layout<'a> {
|
||||
pub(crate) fn new(layout: &'a result::Layout, parent_position: Point) -> Self {
|
||||
let position = parent_position + Vector::new(layout.location.x, layout.location.y);
|
||||
pub(crate) fn new(layout: &'a result::Layout) -> Self {
|
||||
Self::with_parent_position(layout, Point::new(0.0, 0.0))
|
||||
}
|
||||
|
||||
fn with_parent_position(
|
||||
layout: &'a result::Layout,
|
||||
parent_position: Point,
|
||||
) -> Self {
|
||||
let position =
|
||||
parent_position + Vector::new(layout.location.x, layout.location.y);
|
||||
|
||||
Layout { layout, position }
|
||||
}
|
||||
|
|
@ -47,9 +55,8 @@ impl<'a> Layout<'a> {
|
|||
/// [`Layout`]: struct.Layout.html
|
||||
/// [`Node`]: struct.Node.html
|
||||
pub fn children(&'a self) -> impl Iterator<Item = Layout<'a>> {
|
||||
self.layout
|
||||
.children
|
||||
.iter()
|
||||
.map(move |layout| Layout::new(layout, self.position))
|
||||
self.layout.children.iter().map(move |layout| {
|
||||
Layout::with_parent_position(layout, self.position)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue