|
@@ -43,25 +43,28 @@ class Area(Positionable, Logger):
|
|
|
if not self.parent:
|
|
if not self.parent:
|
|
|
return self.get_position()
|
|
return self.get_position()
|
|
|
|
|
|
|
|
- return self.get_position() + self.parent.get_screen_position()
|
|
|
|
|
|
|
+ ox, oy = self.parent.get_screen_position()
|
|
|
|
|
+ return ox + self.x, oy + self.y
|
|
|
|
|
|
|
|
def get_root_position(self):
|
|
def get_root_position(self):
|
|
|
"""
|
|
"""
|
|
|
Get the position relative to the root area.
|
|
Get the position relative to the root area.
|
|
|
"""
|
|
"""
|
|
|
if not self.parent:
|
|
if not self.parent:
|
|
|
- return Positionable(0, 0)
|
|
|
|
|
|
|
+ return 0, 0
|
|
|
|
|
|
|
|
- return self.get_position() + self.parent.get_root_position()
|
|
|
|
|
|
|
+ ox, oy = self.parent.get_root_position()
|
|
|
|
|
+ return ox + self.x, oy + self.y
|
|
|
|
|
|
|
|
def get_offset(self, offset_area):
|
|
def get_offset(self, offset_area):
|
|
|
"""
|
|
"""
|
|
|
Get the position relative to an ancestor area.
|
|
Get the position relative to an ancestor area.
|
|
|
"""
|
|
"""
|
|
|
- if self.parent == offset_area:
|
|
|
|
|
- return self.get_position()
|
|
|
|
|
|
|
+ if self == offset_area:
|
|
|
|
|
+ return 0, 0
|
|
|
|
|
|
|
|
- return self.get_position() + self.parent.get_offset(offset_area)
|
|
|
|
|
|
|
+ ox, oy = self.parent.get_offset(offset_area)
|
|
|
|
|
+ return ox + self.x, oy + self.y
|
|
|
|
|
|
|
|
def add_area(self, area):
|
|
def add_area(self, area):
|
|
|
"""
|
|
"""
|
|
@@ -178,11 +181,11 @@ class Area(Positionable, Logger):
|
|
|
child_found = False
|
|
child_found = False
|
|
|
|
|
|
|
|
if self.children:
|
|
if self.children:
|
|
|
- event.set_area(self)
|
|
|
|
|
-
|
|
|
|
|
# Delegate to children in reverse order because areas that are
|
|
# Delegate to children in reverse order because areas that are
|
|
|
# added later, should be placed over previously added siblings
|
|
# added later, should be placed over previously added siblings
|
|
|
for child in reversed(self.children):
|
|
for child in reversed(self.children):
|
|
|
|
|
+ event.set_area(self)
|
|
|
|
|
+
|
|
|
if child.contains_event(event):
|
|
if child.contains_event(event):
|
|
|
child_found = True
|
|
child_found = True
|
|
|
child.delegate_event(event)
|
|
child.delegate_event(event)
|