inputcontainer: handle horizontal center alignment

This commit is contained in:
Benoit Pierre authored and Frans de Jonge committed 2025-11-28 08:43:41 +01:00
1 parent 9ee84c33a6
commit 6ce4b5d8ee
1 file changed
+8 -5
@@ -46,6 +46,7 @@ local Screen = Device.screen
local _ = require("gettext")
local InputContainer = WidgetContainer:extend{
align = "left",
vertical_align = "top",
}
@@ -80,12 +81,14 @@ function InputContainer:paintTo(bb, x, y)
self.dimen.x = x
self.dimen.y = y
end
if self.vertical_align == "center" then
local content_size = self[1]:getSize()
self[1]:paintTo(bb, x, y + math.floor((self.dimen.h - content_size.h)/2))
else
self[1]:paintTo(bb, x, y)
local content_size = self[1]:getSize()
if self.align == "center" then
x = x + math.floor((self.dimen.w - content_size.w)/2)
end
if self.vertical_align == "center" then
y = y + math.floor((self.dimen.h - content_size.h)/2)
end
self[1]:paintTo(bb, x, y)
end
--[[--