summaryrefslogtreecommitdiff
path: root/src/geom/align.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-03 11:44:53 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-03 13:35:39 +0100
commit37a7afddfaffd44cb9bc013c9506599267e08983 (patch)
tree20e7d62d3c5418baff01a21d0406b91bf3096214 /src/geom/align.rs
parent56342bd972a13ffe21beaf2b87ab7eb1597704b4 (diff)
Split crates
Diffstat (limited to 'src/geom/align.rs')
-rw-r--r--src/geom/align.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/geom/align.rs b/src/geom/align.rs
index a7ee2763..25409e3a 100644
--- a/src/geom/align.rs
+++ b/src/geom/align.rs
@@ -78,3 +78,40 @@ impl Debug for Align {
})
}
}
+
+/// The generic alignment representation.
+#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
+pub enum GenAlign {
+ /// Align at the start side of the text direction.
+ Start,
+ /// Align at the end side of the text direction.
+ End,
+ /// Align at a specific alignment.
+ Specific(Align),
+}
+
+impl GenAlign {
+ /// The axis this alignment belongs to.
+ pub const fn axis(self) -> Axis {
+ match self {
+ Self::Start | Self::End => Axis::X,
+ Self::Specific(align) => align.axis(),
+ }
+ }
+}
+
+impl From<Align> for GenAlign {
+ fn from(align: Align) -> Self {
+ Self::Specific(align)
+ }
+}
+
+impl Debug for GenAlign {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self {
+ Self::Start => f.pad("start"),
+ Self::End => f.pad("end"),
+ Self::Specific(align) => align.fmt(f),
+ }
+ }
+}