diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-03 13:23:59 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-03 13:23:59 +0200 |
| commit | 0fc25d732d7cbc37cf801645849d1060f2cec4a3 (patch) | |
| tree | 706aa8d1bf4135d1dd3ac17a5023bc5e24ded69d /src/layout/elements.rs | |
| parent | 8dbc5b60cc4a88f68ee82607af3a3c454cd8f68b (diff) | |
Port to kurbo 🎋
Diffstat (limited to 'src/layout/elements.rs')
| -rw-r--r-- | src/layout/elements.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/layout/elements.rs b/src/layout/elements.rs index dd148a24..b5f83bfe 100644 --- a/src/layout/elements.rs +++ b/src/layout/elements.rs @@ -5,11 +5,11 @@ use std::fmt::{self, Debug, Formatter}; use fontdock::FaceId; use ttf_parser::GlyphId; -use crate::geom::Size; +use crate::geom::Point; /// A collection of absolutely positioned layout elements. #[derive(Debug, Default, Clone, PartialEq)] -pub struct LayoutElements(pub Vec<(Size, LayoutElement)>); +pub struct LayoutElements(pub Vec<(Point, LayoutElement)>); impl LayoutElements { /// Create an new empty collection. @@ -18,16 +18,15 @@ impl LayoutElements { } /// Add an element at a position. - pub fn push(&mut self, pos: Size, element: LayoutElement) { + pub fn push(&mut self, pos: Point, element: LayoutElement) { self.0.push((pos, element)); } - /// Add all elements of another collection, offsetting each by the given - /// `offset`. This can be used to place a sublayout at a position in another - /// layout. - pub fn extend_offset(&mut self, offset: Size, more: Self) { + /// Add all elements of another collection, placing them relative to the + /// given position. + pub fn push_elements(&mut self, pos: Point, more: Self) { for (subpos, element) in more.0 { - self.0.push((subpos + offset, element)); + self.0.push((pos + subpos.to_vec2(), element)); } } } |
