diff options
-rw-r--r-- | core/src/mouse/click.rs | 17 | ||||
-rw-r--r-- | core/src/mouse/cursor.rs | 17 |
2 files changed, 32 insertions, 2 deletions
diff --git a/core/src/mouse/click.rs b/core/src/mouse/click.rs index dd1c84cd..12039d79 100644 --- a/core/src/mouse/click.rs +++ b/core/src/mouse/click.rs @@ -1,7 +1,9 @@ //! Track mouse clicks. use crate::mouse::Button; use crate::time::Instant; -use crate::Point; +use crate::{Point, Transformation}; + +use std::ops::Mul; /// A mouse click. #[derive(Debug, Clone, Copy)] @@ -88,3 +90,16 @@ impl Click { .unwrap_or(false) } } + +impl Mul<Transformation> for Click { + type Output = Click; + + fn mul(self, transformation: Transformation) -> Click { + Click { + kind: self.kind, + button: self.button, + position: self.position * transformation, + time: self.time, + } + } +} diff --git a/core/src/mouse/cursor.rs b/core/src/mouse/cursor.rs index 203526e9..616cd315 100644 --- a/core/src/mouse/cursor.rs +++ b/core/src/mouse/cursor.rs @@ -1,4 +1,6 @@ -use crate::{Point, Rectangle, Vector}; +use crate::{Point, Rectangle, Transformation, Vector}; + +use std::ops::Mul; /// The mouse cursor state. #[derive(Debug, Clone, Copy, PartialEq, Default)] @@ -50,3 +52,16 @@ impl Cursor { self.position_over(bounds).is_some() } } + +impl Mul<Transformation> for Cursor { + type Output = Self; + + fn mul(self, transformation: Transformation) -> Self { + match self { + Cursor::Unavailable => Cursor::Unavailable, + Cursor::Available(point) => { + Cursor::Available(point * transformation) + } + } + } +} |