summaryrefslogtreecommitdiffstats
path: root/native/src/size.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-14 06:46:50 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-14 06:46:50 +0100
commitbc8d347736ec997ec0e0c401289e2bc09e212b8a (patch)
treeb98798c09a3aa914b7d0869fba0cfd3efff7754f /native/src/size.rs
parent839e039dbf2fb89dcb8c141503740777d2af2eb3 (diff)
parent73f3c900071f950ea914652ca3f0002c1e173f61 (diff)
downloadiced-bc8d347736ec997ec0e0c401289e2bc09e212b8a.tar.gz
iced-bc8d347736ec997ec0e0c401289e2bc09e212b8a.tar.bz2
iced-bc8d347736ec997ec0e0c401289e2bc09e212b8a.zip
Merge pull request #52 from hecrj/custom-layout-engine
Custom layout engine
Diffstat (limited to 'native/src/size.rs')
-rw-r--r--native/src/size.rs25
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,
+ }
+ }
+}