Move element graphics reload to dedicated method

This commit is contained in:
Gabriel Tofvesson 2024-10-01 15:58:52 +00:00
parent 4e171aabed
commit 3e17d0af7d

View File

@ -30,6 +30,10 @@ function Element:new(o)
setmetatable(obj, self)
obj.__index = self
if obj.render and obj.render.parent then
self:_reload()
end
return obj
end
@ -51,7 +55,7 @@ function Element:setPos(x, y)
self.x = x or self.x
self.y = y or self.y
self.render.window = createWindow(self)
self:_reload()
end
end
@ -59,7 +63,7 @@ function Element:setX(x)
if self.x ~= x then
self:setDirty()
self.x = x
self.render.window = createWindow(self)
self:_reload()
end
end
@ -67,7 +71,7 @@ function Element:setY(y)
if self.y ~= y then
self:setDirty()
self.y = y
self.render.window = createWindow(self)
self:_reload()
end
end
@ -103,7 +107,7 @@ function Element:resize(opts)
self:setDirty()
self.width = opts.width or self.width
self.height = opts.height or self.height
self.render.window = createWindow(self)
self:_reload()
end
end
@ -111,7 +115,7 @@ function Element:setWidth(width)
if width ~= self.width then
self:setDirty()
self.width = width
self.render.window = createWindow(self)
self:_reload()
end
end
@ -119,7 +123,7 @@ function Element:setHeight(height)
if height ~= self.height then
self:setDirty()
self.height = height
self.render.window = createWindow(self)
self:_reload()
end
end
@ -171,4 +175,8 @@ function Element:setOnClick(onClick)
self.onClick = onClick
end
function Element:_reload()
self.render.window = createWindow(self)
end
return Element