Figure out (finally!) the mouse coordinates in the MapWindow

This commit is contained in:
Eryn Wells 2023-03-10 23:53:08 -08:00
parent 1018febeab
commit 078520678d
4 changed files with 112 additions and 58 deletions

View file

@ -205,6 +205,16 @@ class Rect:
'''Maximum y-value that is still within the bounds of this rectangle.'''
return self.origin.y + self.size.height - 1
@property
def end_x(self) -> int:
'''X-value beyond the end of the rectangle.'''
return self.origin.x + self.size.width
@property
def end_y(self) -> int:
'''Y-value beyond the end of the rectangle.'''
return self.origin.y + self.size.height
@property
def width(self) -> int:
'''The width of the rectangle. A convenience property for accessing `self.size.width`.'''
@ -299,8 +309,7 @@ class Rect:
raise TypeError(f'{self.__class__.__name__} cannot contain value of type {other.__class__.__name__}')
def __contains_point(self, pt: Point) -> bool:
return (pt.x >= self.min_x and pt.x <= self.max_x
and pt.y >= self.min_y and pt.y <= self.max_y)
return self.min_x <= pt.x <= self.max_x and self.min_y <= pt.y <= self.max_y
def __contains_rect(self, other: 'Rect') -> bool:
return (self.min_x <= other.min_x