diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-06-22 12:25:01 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-06-22 12:25:01 +0200 |
| commit | f6fe3b5cdd2805f3975985752f9cb0e04e3daf49 (patch) | |
| tree | daddf46ba6add0b7cead1f9015b8f24364672138 /src/layout/boxed.rs | |
| parent | e39a6efccff7ba2b5dd546ddf86f23d2714161e7 (diff) | |
Implement function layouting ✒
Diffstat (limited to 'src/layout/boxed.rs')
| -rw-r--r-- | src/layout/boxed.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/layout/boxed.rs b/src/layout/boxed.rs index 89c641bc..e712f650 100644 --- a/src/layout/boxed.rs +++ b/src/layout/boxed.rs @@ -86,6 +86,15 @@ impl BoxLayouter { Ok(()) } + /// Add a sublayout at an absolute position. + pub fn add_box_absolute(&mut self, position: Size2D, layout: BoxLayout) { + // Move all actions into this layout and translate absolute positions. + self.actions.reset_origin(); + self.actions.add(TextAction::MoveAbsolute(position)); + self.actions.set_origin(position); + self.actions.extend(layout.actions); + } + /// Add some space in between two boxes. pub fn add_space(&mut self, space: Size) -> LayoutResult<()> { // Check whether this space fits. @@ -100,20 +109,6 @@ impl BoxLayouter { Ok(()) } - /// Add a sublayout at an absolute position. - pub fn add_box_absolute(&mut self, position: Size2D, layout: BoxLayout) { - // Move all actions into this layout and translate absolute positions. - self.actions.reset_origin(); - self.actions.add(TextAction::MoveAbsolute(position)); - self.actions.set_origin(position); - self.actions.extend(layout.actions); - } - - /// Whether this layouter contains any items. - pub fn is_empty(&self) -> bool { - self.actions.is_empty() - } - /// The remaining space for new boxes. pub fn remaining(&self) -> Size2D { Size2D { @@ -122,6 +117,11 @@ impl BoxLayouter { } } + /// Whether this layouter contains any items. + pub fn is_empty(&self) -> bool { + self.actions.is_empty() + } + /// Finish the layouting and create a box layout from this. pub fn finish(self) -> BoxLayout { BoxLayout { |
