From dd80c013c888f3823db35a2814f530aa8cef296d Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Sat, 12 Oct 2024 01:31:41 +0200 Subject: [PATCH] Reposition child on padding resize --- gfx/padding.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gfx/padding.lua b/gfx/padding.lua index faa6a53..f3f5821 100644 --- a/gfx/padding.lua +++ b/gfx/padding.lua @@ -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