Reposition child on padding resize

This commit is contained in:
Gabriel Tofvesson 2024-10-12 01:31:41 +02:00
parent 8197d0a6f6
commit dd80c013c8

View File

@ -8,13 +8,17 @@ local Padding = Element:new{
element = nil
}
function Padding:_repositionElement()
self.element:setPos(self:getPaddingLeft() + 1, self:getPaddingTop() + 1)
self:resize{
width = self:getWidth(),
height = self:getHeight()
}
end
function Padding:new(opts)
local obj = Element.new(self, opts)
obj.element:setPos(obj:getPaddingLeft() + 1, obj:getPaddingTop() + 1)
obj:resize{
width = obj:getWidth(),
height = obj:getHeight()
}
obj:_repositionElement()
obj.element:setParent(obj:_getWindow())
return obj
end
@ -77,6 +81,7 @@ function Padding:setPadding(opts)
if changed then
self:_reload()
self:_repositionElement()
end
end