diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-11-17 11:11:53 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-11-17 11:11:53 +0100 |
| commit | bd66ebd68344f0d02f5dc6163f7d2aa0b4ded79d (patch) | |
| tree | 72fa8e5df0835b8a2312a0040cecb6cbb1ae0dd1 /src/layout | |
| parent | 796c2486cee82f6e5aefc2d7d02f82a7eeb35a07 (diff) | |
Prepare axis setting for flex layouter ♟
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/flex.rs | 17 | ||||
| -rw-r--r-- | src/layout/tree.rs | 4 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/layout/flex.rs b/src/layout/flex.rs index 20686e9f..01086c32 100644 --- a/src/layout/flex.rs +++ b/src/layout/flex.rs @@ -48,6 +48,7 @@ enum FlexUnit { Space(Size), /// A forced break of the current flex run. Break, + SetAxes(LayoutAxes), } #[derive(Debug, Clone)] @@ -97,6 +98,11 @@ impl FlexLayouter { self.units.push(FlexUnit::Break); } + /// Update the axes in use by this flex layouter. + pub fn set_axes(&self, axes: LayoutAxes) { + self.units.push(FlexUnit::SetAxes(axes)); + } + /// Compute the justified layout. /// /// The layouter is not consumed by this to prevent ownership problems @@ -117,6 +123,8 @@ impl FlexLayouter { self.space = None; self.finish_run()?; }, + + FlexUnit::SetAxes(axes) => self.layout_set_axes(axes), } } @@ -162,6 +170,10 @@ impl FlexLayouter { Ok(()) } + fn layout_set_axes(&mut self, axes: LayoutAxes) { + // TODO + } + /// Finish the current flex run. fn finish_run(&mut self) -> LayoutResult<()> { let mut actions = LayoutActionList::new(); @@ -183,11 +195,6 @@ impl FlexLayouter { Ok(()) } - /// Update the axes in use by this flex layouter. - pub fn set_axes(&self, axes: LayoutAxes) { - - } - /// This layouter's context. pub fn ctx(&self) -> FlexContext { self.ctx diff --git a/src/layout/tree.rs b/src/layout/tree.rs index 9cbcd641..89e47c91 100644 --- a/src/layout/tree.rs +++ b/src/layout/tree.rs @@ -100,8 +100,10 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { Command::SetStyle(style) => *self.style.to_mut() = style, Command::SetAxes(axes) => { - self.stack.set_axes(axes); self.flex.set_axes(axes); + if axes.secondary != self.ctx.axes.secondary { + self.stack.set_axes(axes); + } self.ctx.axes = axes; } } |
