From cbbc46215fe0a0ad8a50e991ec442890b8eadc0a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 2 Aug 2020 21:17:42 +0200 Subject: =?UTF-8?q?Layout=20elements=20and=20pure=20rust=20rendering=20?= =?UTF-8?q?=F0=9F=A5=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/stack.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/layout/stack.rs') diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 48c7b40a..4f4d3d8b 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -48,9 +48,6 @@ pub struct StackContext { pub align: LayoutAlign, /// Whether to have repeated spaces or to use only the first and only once. pub repeat: bool, - /// Whether to output a command which renders a debugging box showing the - /// extent of the layout. - pub debug: bool, } /// A layout space composed of subspaces which can have different axes and @@ -139,7 +136,7 @@ impl StackLayouter { self.space.layouts.push((self.ctx.axes, Layout { dimensions: dimensions.specialized(self.ctx.axes), align: LayoutAlign::new(Start, Start), - actions: vec![] + elements: LayoutElements::new(), })); self.space.last_spacing = LastSpacing::Hard; @@ -367,13 +364,9 @@ impl StackLayouter { // Step 4: Align each layout in its bounding box and collect everything // into a single finished layout. - let mut actions = LayoutActions::new(); + let mut elements = LayoutElements::new(); - if self.ctx.debug { - actions.add(LayoutAction::DebugBox(dimensions)); - } - - let layouts = std::mem::replace(&mut self.space.layouts, vec![]); + let layouts = std::mem::take(&mut self.space.layouts); for ((axes, layout), bound) in layouts.into_iter().zip(bounds) { let size = layout.dimensions.specialized(axes); let align = layout.align; @@ -387,13 +380,13 @@ impl StackLayouter { let local = usable.anchor(align, axes) - size.anchor(align, axes); let pos = Size::new(bound.left, bound.top) + local.specialized(axes); - actions.add_layout(pos, layout); + elements.extend_offset(pos, layout.elements); } self.layouts.push(Layout { dimensions, align: self.ctx.align, - actions: actions.into_vec(), + elements, }); // ------------------------------------------------------------------ // -- cgit v1.2.3