diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-01 19:18:06 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-01 19:18:38 +0100 |
| commit | ace57c34206a13b4bc3885b944cc51e274f30b0f (patch) | |
| tree | 2f1e1e8e4ac5c3867492d5a59c49045058e16123 /src/layout/mod.rs | |
| parent | 5782b82770f6923677942c3b4e2bf4f7258e47d8 (diff) | |
First half of stack update 🌓
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 31064d40..f45ed10a 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -59,7 +59,7 @@ pub struct LayoutContext<'a, 'p> { pub spaces: LayoutSpaces, /// The initial axes along which content is laid out. pub axes: LayoutAxes, - /// The alignment for the two axes. + /// The alignment of the finished layout. pub alignment: LayoutAlignment, } @@ -71,12 +71,12 @@ pub type LayoutSpaces = SmallVec<[LayoutSpace; 2]>; pub struct LayoutSpace { /// The maximum size of the box to layout in. pub dimensions: Size2D, + /// Padding that should be respected on each side. + pub padding: SizeBox, /// Whether to expand the dimensions of the resulting layout to the full /// dimensions of this space or to shrink them to fit the content for the /// vertical and horizontal axis. pub expand: (bool, bool), - /// Padding that should be respected on each side. - pub padding: SizeBox, } impl LayoutSpace { @@ -95,8 +95,8 @@ impl LayoutSpace { pub fn usable_space(&self) -> LayoutSpace { LayoutSpace { dimensions: self.usable(), - expand: (false, false), padding: SizeBox::zero(), + expand: (false, false), } } } @@ -110,6 +110,10 @@ pub struct LayoutAxes { impl LayoutAxes { pub fn new(primary: Axis, secondary: Axis) -> LayoutAxes { + if primary.is_horizontal() == secondary.is_horizontal() { + panic!("LayoutAxes::new: invalid parallel axes {:?} and {:?}", primary, secondary); + } + LayoutAxes { primary, secondary } } @@ -134,6 +138,13 @@ impl LayoutAxes { } } +/// The two kinds of axes. +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub enum AxisKind { + Primary, + Secondary, +} + /// Directions along which content is laid out. #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Axis { |
