diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-28 15:50:48 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-28 23:54:34 +0100 |
| commit | 3ca5b238238e1128aa7bbfbd5db9e632045d8600 (patch) | |
| tree | 2471f4b340a15695b7f4d518c0b39fabaea676c4 /src/library/spacing.rs | |
| parent | b63c21c91d99a1554a019dc275f955d3e6a34271 (diff) | |
Reorganize library
Diffstat (limited to 'src/library/spacing.rs')
| -rw-r--r-- | src/library/spacing.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/library/spacing.rs b/src/library/spacing.rs deleted file mode 100644 index 6f57c71c..00000000 --- a/src/library/spacing.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! Horizontal and vertical spacing between nodes. - -use super::prelude::*; - -/// Horizontal spacing. -pub struct HNode; - -#[class] -impl HNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Horizontal(args.expect("spacing")?)) - } -} - -/// Vertical spacing. -pub struct VNode; - -#[class] -impl VNode { - fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { - Ok(Template::Vertical(args.expect("spacing")?)) - } -} - -/// Kinds of spacing. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum SpacingKind { - /// A length stated in absolute values and/or relative to the parent's size. - Linear(Linear), - /// A length that is the fraction of the remaining free space in the parent. - Fractional(Fractional), -} - -impl SpacingKind { - /// Whether this is fractional spacing. - pub fn is_fractional(self) -> bool { - matches!(self, Self::Fractional(_)) - } -} - -impl From<Length> for SpacingKind { - fn from(length: Length) -> Self { - Self::Linear(length.into()) - } -} - -castable! { - SpacingKind, - Expected: "linear or fractional", - Value::Length(v) => Self::Linear(v.into()), - Value::Relative(v) => Self::Linear(v.into()), - Value::Linear(v) => Self::Linear(v), - Value::Fractional(v) => Self::Fractional(v), -} |
