feat(textwidget): extend API

This commit is contained in:
Kazhnuz 2021-01-23 18:30:30 +01:00
parent 92c10440a1
commit 772becc1a8

View file

@ -52,22 +52,30 @@ function TextWidget:setSelectedColor(r, g, b)
self.selectedColor.b = b
end
function TextWidget:getFont()
return self.assets:getFont(self.font)
end
function TextWidget:getSelectedColor()
return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b
end
function TextWidget:getPadding()
return self.padding
end
function TextWidget:drawCanvas()
local w, h
local font = self.assets:getFont(self.font)
local font = self:getFont()
h = math.floor(self.height / 2) - (font:getHeight() / 2)
for _, complexLabel in pairs(self.labels) do
if (complexLabel.position == "center") then
w = math.floor(self.width / 2)
elseif (complexLabel.position == "left") then
w = self.padding
w = self:getPadding()
elseif (complexLabel.position == "right") then
w = math.floor(self.width - self.padding)
w = math.floor(self.width - self:getPadding())
end
font:draw(complexLabel.label, w, h, -1, complexLabel.position)
end