From c1b1dbcc0925ba1730fabbfbca3c8b99831c5561 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 11 Mar 2021 10:48:29 +0100 Subject: =?UTF-8?q?Better=20expansion=20behaviour=20=F0=9F=90=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes expansion behaviour inheritable by placing it into the area and passing it down during layouting instead of computing some approximation of what we want during execution. --- src/layout/stack.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/layout/stack.rs') diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 7d1d7a12..73bd49c1 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -10,8 +10,6 @@ pub struct NodeStack { pub dirs: LayoutDirs, /// How to align this stack in _its_ parent. pub align: ChildAlign, - /// Whether to expand the axes to fill the area or to fit the content. - pub expand: Spec, /// The nodes to be stacked. pub children: Vec, } @@ -40,8 +38,7 @@ impl From for NodeAny { } } -struct StackLayouter<'a> { - stack: &'a NodeStack, +struct StackLayouter { main: SpecAxis, dirs: LayoutDirs, areas: Areas, @@ -51,10 +48,9 @@ struct StackLayouter<'a> { ruler: Align, } -impl<'a> StackLayouter<'a> { - fn new(stack: &'a NodeStack, areas: Areas) -> Self { +impl StackLayouter { + fn new(stack: &NodeStack, areas: Areas) -> Self { Self { - stack, main: stack.dirs.main.axis(), dirs: stack.dirs, areas, @@ -97,7 +93,7 @@ impl<'a> StackLayouter<'a> { fn finish_area(&mut self) { let full_size = { - let expand = self.stack.expand.switch(self.dirs); + let expand = self.areas.expand.switch(self.dirs); let full = self.areas.full.switch(self.dirs); Gen::new( expand.main.resolve(self.used.main.min(full.main), full.main), -- cgit v1.2.3