summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-01 19:15:55 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-01 19:15:55 +0200
commit659248d52ff9e6be4dad7c4555bd62899671ad55 (patch)
tree610f382adc09524a08c5cbb941e46103117a88e5 /src/layout/mod.rs
parent04c05502bee50f7657dc2d88c60eb935b068a284 (diff)
Raw lengths 🚲
Replace unitless length with raw f64 and introduce length type with unit.
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 8bcceda6..a6af0f82 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -5,7 +5,7 @@ use smallvec::SmallVec;
use serde::Serialize;
use fontdock::FaceId;
-use crate::length::{Length, Size, Margins};
+use crate::geom::{Size, Margins};
use self::prelude::*;
pub mod line;
@@ -219,8 +219,8 @@ impl Direction {
///
/// - `1` if the direction is positive.
/// - `-1` if the direction is negative.
- pub fn factor(self) -> i32 {
- if self.is_positive() { 1 } else { -1 }
+ pub fn factor(self) -> f64 {
+ if self.is_positive() { 1.0 } else { -1.0 }
}
/// The inverse axis.
@@ -368,17 +368,17 @@ enum LastSpacing {
/// The last item was hard spacing.
Hard,
/// The last item was soft spacing with the given width and level.
- Soft(Length, u32),
+ Soft(f64, u32),
/// The last item was not spacing.
None,
}
impl LastSpacing {
- /// The length of the soft space if this is a soft space or zero otherwise.
- fn soft_or_zero(self) -> Length {
+ /// The width of the soft space if this is a soft space or zero otherwise.
+ fn soft_or_zero(self) -> f64 {
match self {
LastSpacing::Soft(space, _) => space,
- _ => Length::ZERO,
+ _ => 0.0,
}
}
}