diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-11 20:28:22 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-11 20:28:22 +0200 |
| commit | 6f22e4f13c42f06b686a01fbdd28a0163e88ae77 (patch) | |
| tree | a78145f5f9d84325529a8529875c9ef6ca5b9a1a /src/layout/boxed.rs | |
| parent | c0e4fd55e6fa738cfc5dcc851d0fc3ee2d0f2cd2 (diff) | |
Render debug boxes ðŸ§
Diffstat (limited to 'src/layout/boxed.rs')
| -rw-r--r-- | src/layout/boxed.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/layout/boxed.rs b/src/layout/boxed.rs index 5bd909d4..7ea9e4fb 100644 --- a/src/layout/boxed.rs +++ b/src/layout/boxed.rs @@ -1,9 +1,9 @@ //! Block-style layouting of boxes. use std::io::{self, Write}; -use crate::doc::{Document, Page, LayoutAction}; +use crate::doc::{Document, Page}; use crate::size::{Size, Size2D}; -use super::{ActionList, LayoutSpace, Alignment, LayoutResult, LayoutError}; +use super::*; /// A box layout has a fixed width and height and composes of actions. @@ -13,6 +13,8 @@ pub struct BoxLayout { pub dimensions: Size2D, /// The actions composing this layout. pub actions: Vec<LayoutAction>, + /// Whether to debug-render this box. + pub debug_render: bool, } impl BoxLayout { @@ -49,7 +51,7 @@ pub struct BoxContext { #[derive(Debug)] pub struct BoxLayouter { pub ctx: BoxContext, - actions: ActionList, + actions: LayoutActionList, dimensions: Size2D, usable: Size2D, cursor: Size2D, @@ -59,9 +61,10 @@ impl BoxLayouter { /// Create a new box layouter. pub fn new(ctx: BoxContext) -> BoxLayouter { let space = ctx.space; + BoxLayouter { ctx, - actions: ActionList::new(), + actions: LayoutActionList::new(), dimensions: match ctx.space.alignment { Alignment::Left => Size2D::zero(), Alignment::Right => Size2D::with_x(space.usable().x), @@ -109,7 +112,7 @@ impl BoxLayouter { /// Add a sublayout at an absolute position. pub fn add_box_absolute(&mut self, position: Size2D, layout: BoxLayout) { - self.actions.add_box_absolute(position, layout); + self.actions.add_box(position, layout); } /// Add some space in between two boxes. @@ -148,6 +151,7 @@ impl BoxLayouter { self.ctx.space.dimensions }, actions: self.actions.into_vec(), + debug_render: true, } } |
