2
-- A subview is a view that steals lives inside a parent view. It's useful for
3
-- things like a pause overlay or inventory screen, which don't interact with a main view
4
-- directly and are useful when they're sectioned off into their own world.
6
-- A subview should not interact much with its parent view, if at all. It's important
7
-- to, if a subview calls a method on its parent, that it set the.view to the parent,
8
-- and then restore it to itself afterwards.
10
-- A subview is modal, meaning that although the parent view is visible underneath
11
-- its subview, it does not receive any update-related events. If you want to display
12
-- something on top of a view while it still is visible and updating, use a <Group>
16
-- onActivate - Called when the subview activates.
17
-- onDeactivate - Called when the subview deactivates.
24
-- Property: drawParent
25
-- Draw the parent view underneath this one? Defaults to true.
28
-- Property: activated
29
-- Is this subview currently visible and active? This property is read-only.
30
-- To change the status of the subview, use either the <activate()> or
31
-- <deactivate()> methods.
43
activate = function (self)
44
if the.view == self then
46
local info = debug.getinfo(2, 'Sl')
47
print('Warning: treid to activate an already active subview (' ..
48
info.short_src .. ', line ' .. info.currentline .. ')')
54
self.parentView = the.view
57
if self.onActivate then self:onActivate() end
69
deactivate = function (self)
70
the.app.view = self.parentView
71
self.activated = false
72
if self.onDeactivate then self:onDeactivate() end
75
draw = function (self, x, y)
76
if self.drawParent and self.parentView then self.parentView:draw(x, y) end