diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-05 19:48:37 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-05 19:48:37 +0100 |
| commit | 72a9631b038d1a60e4e4a78e92cd69e6f8ce4316 (patch) | |
| tree | 17614efc2e21dd0b8caa24beaaaee7c40c150281 /src/size.rs | |
| parent | f72b1505bebf8d2fe1a60d386a3a3c3b67d4f903 (diff) | |
Move arg parser into `FuncArgs` and create (incomplete) consistent map ðŸ§
Diffstat (limited to 'src/size.rs')
| -rw-r--r-- | src/size.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/size.rs b/src/size.rs index a9c3198c..d415be3f 100644 --- a/src/size.rs +++ b/src/size.rs @@ -35,6 +35,19 @@ pub struct SizeBox { pub bottom: Size, } +/// A size or scale. +#[derive(Copy, Clone, PartialEq)] +pub enum ScaleSize { + Absolute(Size), + Scaled(f32), +} + +/// A size that is possibly scaled by the font size. +pub type FSize = ScaleSize; + +/// A size that is possibly scaled by the size of the padded parent container. +pub type PSize = ScaleSize; + impl Size { /// Create a zeroed size. #[inline] @@ -241,7 +254,7 @@ debug_display!(Size); pub struct ParseSizeError; error_type! { - err: ParseSizeError, + self: ParseSizeError, show: f => write!(f, "failed to parse size"), } @@ -469,3 +482,16 @@ impl Display for SizeBox { } debug_display!(SizeBox); + +//------------------------------------------------------------------------------------------------// + +impl Display for ScaleSize { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + ScaleSize::Absolute(size) => write!(f, "{}", size), + ScaleSize::Scaled(scale) => write!(f, "x{}", scale), + } + } +} + +debug_display!(ScaleSize); |
