diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-02-12 22:55:26 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-02-12 22:55:26 +0100 |
| commit | 790dc9e6670b0d90c9ff68a0981cdbfb7d9c536a (patch) | |
| tree | af12c6da8b32a0e54c9dfe005b6076d764804d9c /src/layout | |
| parent | a2fcc1bf288c5162de7b2158166de62cb0610083 (diff) | |
Cleaning 🧹
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/background.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/layout/background.rs b/src/layout/background.rs index 07248e02..6b605d7f 100644 --- a/src/layout/background.rs +++ b/src/layout/background.rs @@ -1,11 +1,11 @@ use super::*; -/// A node that represents a rectangular box. +/// A node that places a rectangular filled background behind another node. #[derive(Debug, Clone, PartialEq)] pub struct NodeBackground { /// The background fill. pub fill: Fill, - /// The child node to be filled in. + /// The child node to be filled. pub child: Node, } @@ -13,17 +13,12 @@ impl Layout for NodeBackground { fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Layouted { let mut layouted = self.child.layout(ctx, areas); - if let Some(first) = layouted.frames_mut().first_mut() { - first.elements.insert( - 0, - ( - Point::ZERO, - Element::Geometry(Geometry { - shape: Shape::Rect(first.size), - fill: self.fill.clone(), - }), - ), - ) + for frame in layouted.frames_mut() { + let element = Element::Geometry(Geometry { + shape: Shape::Rect(frame.size), + fill: self.fill.clone(), + }); + frame.elements.insert(0, (Point::ZERO, element)) } layouted |
