wibox.layout.align: make the middle widget really centered

Centers the middle widget in the align layout in the remaining space
left by the widgets on the sides.

Signed-off-by: Lukáš Hrázký <lukkash@email.cz>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Lukáš Hrázký 2013-01-05 16:12:50 +01:00 committed by Uli Schlachter
parent e38651bafb
commit 8560de597c
2 changed files with 7 additions and 3 deletions

View File

@ -560,7 +560,7 @@ function menu.entry(parent, args)
left:add(margin)
local layout = wibox.layout.align.horizontal()
layout:set_middle(left)
layout:set_left(left)
if submenu then
layout:set_right(submenu)
end

View File

@ -56,11 +56,15 @@ function align:draw(wibox, cr, width, height)
if self.second and size_first + size_third < size_limit then
local x, y, w, h
if self.dir == "y" then
x, y = 0, size_first
w, h = width, size_limit - size_first - size_third
local real_w, real_h = self.second:fit(w, h)
x, y = 0, size_first + h / 2 - real_h / 2
w, h = real_w, real_h
else
x, y = size_first, 0
w, h = size_limit - size_first - size_third, height
local real_w, real_h = self.second:fit(w, h)
x, y = size_first + w / 2 - real_w / 2, 0
w, h = real_w, real_h
end
base.draw_widget(wibox, cr, self.second, x, y, w, h)
end