From f12d8eb9b489288931f8c5f5f6d7246f1656c911 Mon Sep 17 00:00:00 2001 From: chrox Date: Thu, 26 Dec 2013 22:34:00 +0800 Subject: [PATCH] add align field in WidgetContainer --- frontend/ui/widget/container/widgetcontainer.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/container/widgetcontainer.lua b/frontend/ui/widget/container/widgetcontainer.lua index 78226ba19..4ee53cf3d 100644 --- a/frontend/ui/widget/container/widgetcontainer.lua +++ b/frontend/ui/widget/container/widgetcontainer.lua @@ -40,7 +40,20 @@ end function WidgetContainer:paintTo(bb, x, y) -- default to pass request to first child widget if self[1] then - return self[1]:paintTo(bb, x, y) + x = x + (self.dimen.x or 0) + y = y + (self.dimen.y or 0) + if self.align == "top" then + local contentSize = self[1]:getSize() + self[1]:paintTo(bb, + x + math.floor((self.dimen.w - contentSize.w)/2), y) + elseif self.align == "bottom" then + local contentSize = self[1]:getSize() + self[1]:paintTo(bb, + x + math.floor((self.dimen.w - contentSize.w)/2), + y + (self.dimen.h - contentSize.h)) + else + return self[1]:paintTo(bb, x, y) + end end end