summaryrefslogtreecommitdiffstats
path: root/core/src/pixels.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-02-17 11:45:34 -0800
committerLibravatar Bingus <shankern@protonmail.com>2023-02-17 11:45:34 -0800
commit744cef5608a91fe55cbbe1adb73a9a0b5e266668 (patch)
treef88ca6ae3c481e2de74178bb3f0d1f1b685e1740 /core/src/pixels.rs
parent8da098330b58542cc929f4f24d02e26bd654bae4 (diff)
parent7dc1fb488ddbd12519571b51d75ae0c28875911d (diff)
downloadiced-744cef5608a91fe55cbbe1adb73a9a0b5e266668.tar.gz
iced-744cef5608a91fe55cbbe1adb73a9a0b5e266668.tar.bz2
iced-744cef5608a91fe55cbbe1adb73a9a0b5e266668.zip
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # winit/src/window.rs
Diffstat (limited to 'core/src/pixels.rs')
-rw-r--r--core/src/pixels.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/pixels.rs b/core/src/pixels.rs
new file mode 100644
index 00000000..e42cd9f9
--- /dev/null
+++ b/core/src/pixels.rs
@@ -0,0 +1,22 @@
+/// An amount of logical pixels.
+///
+/// Normally used to represent an amount of space, or the size of something.
+///
+/// This type is normally asked as an argument in a generic way
+/// (e.g. `impl Into<Pixels>`) and, since `Pixels` implements `From` both for
+/// `f32` and `u16`, you should be able to provide both integers and float
+/// literals as needed.
+#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
+pub struct Pixels(pub f32);
+
+impl From<f32> for Pixels {
+ fn from(amount: f32) -> Self {
+ Self(amount)
+ }
+}
+
+impl From<u16> for Pixels {
+ fn from(amount: u16) -> Self {
+ Self(f32::from(amount))
+ }
+}