summaryrefslogtreecommitdiff
path: root/src/geom
diff options
context:
space:
mode:
Diffstat (limited to 'src/geom')
-rw-r--r--src/geom/align.rs3
-rw-r--r--src/geom/dir.rs3
-rw-r--r--src/geom/gen.rs10
-rw-r--r--src/geom/mod.rs5
-rw-r--r--src/geom/point.rs4
-rw-r--r--src/geom/size.rs4
-rw-r--r--src/geom/spec.rs13
7 files changed, 15 insertions, 27 deletions
diff --git a/src/geom/align.rs b/src/geom/align.rs
index e13da378..422624d8 100644
--- a/src/geom/align.rs
+++ b/src/geom/align.rs
@@ -1,8 +1,5 @@
use super::*;
-/// The alignments of a layout in its parent.
-pub type LayoutAligns = Gen<Align>;
-
/// Where to align something along a directed axis.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Align {
diff --git a/src/geom/dir.rs b/src/geom/dir.rs
index 3eddd7d3..cfcb4c09 100644
--- a/src/geom/dir.rs
+++ b/src/geom/dir.rs
@@ -1,8 +1,5 @@
use super::*;
-/// The directions along which layouts are placed in their parent.
-pub type LayoutDirs = Gen<Dir>;
-
/// The four directions into which content can be laid out.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Dir {
diff --git a/src/geom/gen.rs b/src/geom/gen.rs
index c80cc21b..7e021412 100644
--- a/src/geom/gen.rs
+++ b/src/geom/gen.rs
@@ -50,8 +50,8 @@ impl<T> Get<GenAxis> for Gen<T> {
impl<T> Switch for Gen<T> {
type Other = Spec<T>;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
- match dirs.main.axis() {
+ fn switch(self, main: SpecAxis) -> Self::Other {
+ match main {
SpecAxis::Horizontal => Spec::new(self.main, self.cross),
SpecAxis::Vertical => Spec::new(self.cross, self.main),
}
@@ -86,10 +86,10 @@ impl GenAxis {
impl Switch for GenAxis {
type Other = SpecAxis;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
+ fn switch(self, main: SpecAxis) -> Self::Other {
match self {
- Self::Main => dirs.main.axis(),
- Self::Cross => dirs.cross.axis(),
+ Self::Main => main,
+ Self::Cross => main.other(),
}
}
}
diff --git a/src/geom/mod.rs b/src/geom/mod.rs
index 5099c6b0..0031c6df 100644
--- a/src/geom/mod.rs
+++ b/src/geom/mod.rs
@@ -53,7 +53,6 @@ pub trait Switch {
/// The type of the other version.
type Other;
- /// The other version of this type based on the current layouting
- /// directions.
- fn switch(self, dirs: LayoutDirs) -> Self::Other;
+ /// The other version of this type based on the current main axis.
+ fn switch(self, main: SpecAxis) -> Self::Other;
}
diff --git a/src/geom/point.rs b/src/geom/point.rs
index cf8bc1a9..29298565 100644
--- a/src/geom/point.rs
+++ b/src/geom/point.rs
@@ -45,8 +45,8 @@ impl Get<SpecAxis> for Point {
impl Switch for Point {
type Other = Gen<Length>;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
- match dirs.main.axis() {
+ fn switch(self, main: SpecAxis) -> Self::Other {
+ match main {
SpecAxis::Horizontal => Gen::new(self.x, self.y),
SpecAxis::Vertical => Gen::new(self.y, self.x),
}
diff --git a/src/geom/size.rs b/src/geom/size.rs
index 2feaa950..1ba2f04b 100644
--- a/src/geom/size.rs
+++ b/src/geom/size.rs
@@ -74,8 +74,8 @@ impl Get<SpecAxis> for Size {
impl Switch for Size {
type Other = Gen<Length>;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
- match dirs.main.axis() {
+ fn switch(self, main: SpecAxis) -> Self::Other {
+ match main {
SpecAxis::Horizontal => Gen::new(self.width, self.height),
SpecAxis::Vertical => Gen::new(self.height, self.width),
}
diff --git a/src/geom/spec.rs b/src/geom/spec.rs
index 510bac84..546eac7b 100644
--- a/src/geom/spec.rs
+++ b/src/geom/spec.rs
@@ -66,8 +66,8 @@ impl<T> Get<SpecAxis> for Spec<T> {
impl<T> Switch for Spec<T> {
type Other = Gen<T>;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
- match dirs.main.axis() {
+ fn switch(self, main: SpecAxis) -> Self::Other {
+ match main {
SpecAxis::Horizontal => Gen::new(self.horizontal, self.vertical),
SpecAxis::Vertical => Gen::new(self.vertical, self.horizontal),
}
@@ -102,13 +102,8 @@ impl SpecAxis {
impl Switch for SpecAxis {
type Other = GenAxis;
- fn switch(self, dirs: LayoutDirs) -> Self::Other {
- if self == dirs.main.axis() {
- GenAxis::Main
- } else {
- debug_assert_eq!(self, dirs.cross.axis());
- GenAxis::Cross
- }
+ fn switch(self, main: SpecAxis) -> Self::Other {
+ if self == main { GenAxis::Main } else { GenAxis::Cross }
}
}