diff options
author | 2019-11-10 06:05:20 +0100 | |
---|---|---|
committer | 2019-11-11 03:08:00 +0100 | |
commit | 0240c3981b716c82ecb3364945815335b420a63e (patch) | |
tree | 441eebaa9441649a4e878bde71cdec20d4a67391 /native/src/size.rs | |
parent | 2303111e09d806ef2a652bddc2b73be6dccf6ae2 (diff) | |
download | iced-0240c3981b716c82ecb3364945815335b420a63e.tar.gz iced-0240c3981b716c82ecb3364945815335b420a63e.tar.bz2 iced-0240c3981b716c82ecb3364945815335b420a63e.zip |
Draft custom layout engine based on `druid`
Diffstat (limited to 'native/src/size.rs')
-rw-r--r-- | native/src/size.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/native/src/size.rs b/native/src/size.rs new file mode 100644 index 00000000..bd909292 --- /dev/null +++ b/native/src/size.rs @@ -0,0 +1,25 @@ +use std::f32; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Size { + /// The width. + pub width: f32, + /// The height. + pub height: f32, +} + +impl Size { + pub const ZERO: Size = Size::new(0., 0.); + pub const INFINITY: Size = Size::new(f32::INFINITY, f32::INFINITY); + + pub const fn new(width: f32, height: f32) -> Self { + Size { width, height } + } + + pub fn pad(&self, padding: f32) -> Self { + Size { + width: self.width + padding * 2.0, + height: self.height + padding * 2.0, + } + } +} |