diff options
author | 2019-07-23 10:49:24 +0200 | |
---|---|---|
committer | 2019-07-23 10:49:24 +0200 | |
commit | e55ac637a9c4422b2fccfcc56c25449160e56e02 (patch) | |
tree | dabc064bf3668d3a3fb9f9e1e6ad30051ea2a522 /src/layout.rs | |
parent | eb45c51a7b8b9a595e318048712362c8d65d77b3 (diff) | |
download | iced-e55ac637a9c4422b2fccfcc56c25449160e56e02.tar.gz iced-e55ac637a9c4422b2fccfcc56c25449160e56e02.tar.bz2 iced-e55ac637a9c4422b2fccfcc56c25449160e56e02.zip |
Add `Runtime` concept to abstract caching
Diffstat (limited to 'src/layout.rs')
-rw-r--r-- | src/layout.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/layout.rs b/src/layout.rs index 011f859a..481b4166 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -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) + }) } } |