feat(textwidget): extend API
This commit is contained in:
parent
92c10440a1
commit
772becc1a8
1 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue