Allow lenient Container dimensions
This commit is contained in:
parent
9ac62319fd
commit
3a46e08f37
@ -4,6 +4,40 @@ local Element = require("gfx.element")
|
|||||||
|
|
||||||
local Container = Prop.attach(Element:new(), Children)
|
local Container = Prop.attach(Element:new(), Children)
|
||||||
|
|
||||||
|
function Container:getHeight()
|
||||||
|
if self:isStrict() then
|
||||||
|
return Element.getHeight(self)
|
||||||
|
end
|
||||||
|
local max = 0
|
||||||
|
for _,child in self:_iterateChildren() do
|
||||||
|
max = math.max(max, child:getY() + child:getHeight())
|
||||||
|
end
|
||||||
|
return max
|
||||||
|
end
|
||||||
|
|
||||||
|
function Container:getWidth()
|
||||||
|
if self:isStrict() then
|
||||||
|
return Element.getWidth(self)
|
||||||
|
end
|
||||||
|
local max = 0
|
||||||
|
for _,child in self:_iterateChildren() do
|
||||||
|
max = math.max(max, child:getX() + child:getWidth())
|
||||||
|
end
|
||||||
|
return max
|
||||||
|
end
|
||||||
|
|
||||||
|
function Container:isStrict()
|
||||||
|
return self.strict == true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Container:setStrict(strict)
|
||||||
|
local needReload = (not not self.strict) ~= strict
|
||||||
|
self.strict = strict
|
||||||
|
if needReload then
|
||||||
|
self:_reload()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Container:_reload()
|
function Container:_reload()
|
||||||
Element._reload(self)
|
Element._reload(self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user