diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-15 16:34:41 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-15 16:34:41 +0200 |
| commit | e2cdda67dc0e16b9a482aa3a4bfd5991db06d143 (patch) | |
| tree | 7a3ee517b7417c08888eac105ca1431b9d3817cf /src/layout/frame.rs | |
| parent | a61ee46ed2d39d7b7b0c14e6c36d224e03532bac (diff) | |
Refactor grid row layout
Diffstat (limited to 'src/layout/frame.rs')
| -rw-r--r-- | src/layout/frame.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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); + } } } } |
