From e2cdda67dc0e16b9a482aa3a4bfd5991db06d143 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 15 Jun 2021 16:34:41 +0200 Subject: Refactor grid row layout --- src/layout/frame.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/layout/frame.rs') diff --git a/src/layout/frame.rs b/src/layout/frame.rs index 119aeea6..55f7f99a 100644 --- a/src/layout/frame.rs +++ b/src/layout/frame.rs @@ -6,7 +6,7 @@ use crate::image::ImageId; use serde::{Deserialize, Serialize}; /// A finished layout with elements at fixed positions. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Frame { /// The size of the frame. pub size: Size, @@ -31,8 +31,12 @@ impl Frame { /// Add all elements of another frame, placing them relative to the given /// position. pub fn push_frame(&mut self, pos: Point, subframe: Self) { - for (subpos, element) in subframe.elements { - self.push(pos + subpos, element); + if pos == Point::zero() && self.elements.is_empty() { + self.elements = subframe.elements; + } else { + for (subpos, element) in subframe.elements { + self.push(pos + subpos, element); + } } } } -- cgit v1.2.3