feat: add a selected color for text widgets

This commit is contained in:
Kazhnuz 2020-12-04 12:54:57 +01:00
parent 4ff85e2cc1
commit 37fc1fc9be

View file

@ -30,6 +30,18 @@ function TextWidget:new(menu, font, label)
TextWidget.super.new(self, menu)
self.font = font
self.label = label
self:setSelectedColor(1, 1, 1)
end
function TextWidget:setSelectedColor(r, g, b)
self.selectedColor = {}
self.selectedColor.r = r
self.selectedColor.g = g
self.selectedColor.b = b
end
function TextWidget:getSelectedColor()
return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b
end
function TextWidget:drawCanvas()
@ -39,4 +51,11 @@ function TextWidget:drawCanvas()
self.font:draw(self.label, w, h, -1, "center")
end
function TextWidget:drawSelected(x, y, w, h)
local r, g, b = self:getSelectedColor()
love.graphics.setColor(r, g, b, 1)
self:draw(x, y)
utils.graphics.resetColor()
end
return TextWidget