summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/widget')
-rw-r--r--wgpu/src/widget/canvas/cursor.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/wgpu/src/widget/canvas/cursor.rs b/wgpu/src/widget/canvas/cursor.rs
index a559782a..7ab58b87 100644
--- a/wgpu/src/widget/canvas/cursor.rs
+++ b/wgpu/src/widget/canvas/cursor.rs
@@ -24,23 +24,23 @@ impl Cursor {
}
}
- pub fn relative_position(&self, bounds: &Rectangle) -> Option<Point> {
- match self {
- Cursor::Available(position) => {
- Some(Point::new(position.x - bounds.x, position.y - bounds.y))
- }
- _ => None,
- }
- }
-
- pub fn internal_position(&self, bounds: &Rectangle) -> Option<Point> {
+ pub fn position_in(&self, bounds: &Rectangle) -> Option<Point> {
if self.is_over(bounds) {
- self.relative_position(bounds)
+ self.position_from(bounds.position())
} else {
None
}
}
+ pub fn position_from(&self, origin: Point) -> Option<Point> {
+ match self {
+ Cursor::Available(position) => {
+ Some(Point::new(position.x - origin.x, position.y - origin.y))
+ }
+ Cursor::Unavailable => None,
+ }
+ }
+
pub fn is_over(&self, bounds: &Rectangle) -> bool {
match self {
Cursor::Available(position) => bounds.contains(*position),