From 790dc9e6670b0d90c9ff68a0981cdbfb7d9c536a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 12 Feb 2021 22:55:26 +0100 Subject: =?UTF-8?q?Cleaning=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/background.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/layout') 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 -- cgit v1.2.3