Rename Cursor::*_position methods in canvas

This commit is contained in:
Héctor Ramón Jiménez 2020-04-29 20:58:59 +02:00
parent 70f86f998b
commit 5d12e194f4
3 changed files with 16 additions and 17 deletions

View file

@ -24,20 +24,20 @@ 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 position_in(&self, bounds: &Rectangle) -> Option<Point> {
if self.is_over(bounds) {
self.position_from(bounds.position())
} else {
None
}
}
pub fn internal_position(&self, bounds: &Rectangle) -> Option<Point> {
if self.is_over(bounds) {
self.relative_position(bounds)
} 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,
}
}