From 73fc3160ddc796f292ec7bed05a239e8fd786263 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 30 Aug 2021 14:59:28 +0200 Subject: [PATCH] improvement(textmenu): better padding --- .../birb/modules/gui/menus/widgets/text.lua | 12 ++++++++++-- .../birb/modules/gui/textmenu/init.lua | 9 +++++++++ .../birb/modules/gui/textmenu/widgets/basic.lua | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/sonic-radiance.love/birb/modules/gui/menus/widgets/text.lua b/sonic-radiance.love/birb/modules/gui/menus/widgets/text.lua index 9ecfb42..5d784dd 100644 --- a/sonic-radiance.love/birb/modules/gui/menus/widgets/text.lua +++ b/sonic-radiance.love/birb/modules/gui/menus/widgets/text.lua @@ -83,6 +83,14 @@ function TextWidget:getPadding() return self.padding end +function TextWidget:getPaddingLeft() + return self.paddingLeft or self:getPadding() +end + +function TextWidget:getPaddingRight() + return self.paddingRight or self:getPadding() +end + function TextWidget:drawCanvas() local w, h local font = self:getFont() @@ -92,9 +100,9 @@ function TextWidget:drawCanvas() if (complexLabel.position == "center") then w = math.floor(self.width / 2) elseif (complexLabel.position == "left") then - w = self:getPadding() + w = self:getPaddingLeft() elseif (complexLabel.position == "right") then - w = math.floor(self.width - self:getPadding()) + w = math.floor(self.width - self:getPaddingRight()) else error("Position " .. complexLabel.position .. " is unknown for label " .. complexLabel.label) end diff --git a/sonic-radiance.love/birb/modules/gui/textmenu/init.lua b/sonic-radiance.love/birb/modules/gui/textmenu/init.lua index 290b548..6370ea0 100644 --- a/sonic-radiance.love/birb/modules/gui/textmenu/init.lua +++ b/sonic-radiance.love/birb/modules/gui/textmenu/init.lua @@ -86,6 +86,15 @@ function TextMenu:getPadding() return self.padding end +function TextMenu:getPaddingLeft() + return self.paddingLeft or self:getPadding() +end + +function TextMenu:getPaddingRight() + return self.paddingRight or self:getPadding() +end + + function TextMenu:addSubmenu(pageName, label, parent, backWidget) local label = label or pageName local parent = parent or "main" diff --git a/sonic-radiance.love/birb/modules/gui/textmenu/widgets/basic.lua b/sonic-radiance.love/birb/modules/gui/textmenu/widgets/basic.lua index ae1d8ac..a69470e 100644 --- a/sonic-radiance.love/birb/modules/gui/textmenu/widgets/basic.lua +++ b/sonic-radiance.love/birb/modules/gui/textmenu/widgets/basic.lua @@ -49,4 +49,12 @@ function TextMenuWidget:getPadding() return self.menu:getPadding() end +function TextWidget:getPaddingLeft() + return self.menu:getPaddingLeft() or self:getPadding() +end + +function TextWidget:getPaddingRight() + return self.menu:getPaddingRight() or self:getPadding() +end + return TextMenuWidget \ No newline at end of file