From 0f4b6daf73caf19cbebbad726f323a679fa2feea Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 5 Dec 2020 21:20:20 +0100 Subject: [PATCH] feat: add padding to text widgets --- birb/modules/menusystem/menus/widgets/text.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/birb/modules/menusystem/menus/widgets/text.lua b/birb/modules/menusystem/menus/widgets/text.lua index 4453464..4b16ff9 100644 --- a/birb/modules/menusystem/menus/widgets/text.lua +++ b/birb/modules/menusystem/menus/widgets/text.lua @@ -26,10 +26,11 @@ local TextWidget = BaseWidget:extend() -- TEXT WIDGET -- Simple text widget -function TextWidget:new(menuName, font, label, position) +function TextWidget:new(menuName, font, label, position, padding) TextWidget.super.new(self, menuName) self.font = font self.labels = {} + self.padding = padding or 0 -- We add the first label local position = position or "center" @@ -59,15 +60,14 @@ function TextWidget:drawCanvas() local w, h local font = self.assets:getFont(self.font) 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 = 0 + w = self.padding elseif (complexLabel.position == "right") then - w = math.floor(self.width) + w = math.floor(self.width - self.padding) end font:draw(complexLabel.label, w, h, -1, complexLabel.position) end