Implement freeform container
This commit is contained in:
parent
bbc528988f
commit
a96102dc48
43
gfx/container.lua
Normal file
43
gfx/container.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local Prop = require("gfx.prop")
|
||||
local Children = require("gfx.prop.children")
|
||||
local Element = require("gfx.element")
|
||||
|
||||
local Container = Prop.attach(Element:new(), Children)
|
||||
|
||||
function Container:draw()
|
||||
local dirty = Element.draw(self)
|
||||
if dirty then
|
||||
self:_getWindow().clear()
|
||||
for _,child in self:_iterateChildren() do
|
||||
child:draw()
|
||||
end
|
||||
end
|
||||
return dirty
|
||||
end
|
||||
|
||||
function Container:_isDirty()
|
||||
if Element._isDirty(self) then
|
||||
return true
|
||||
end
|
||||
|
||||
for _,child in self:_iterateChildren() do
|
||||
if child:_isDirty() then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Container:_reload()
|
||||
Element._reload(self)
|
||||
|
||||
-- Reload child windows
|
||||
local win = self:_getWindow()
|
||||
for _,child in self:_iterateChildren() do
|
||||
if child:_getWindow() ~= win then
|
||||
child:setParent(win)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Container
|
Loading…
x
Reference in New Issue
Block a user