From 8560de597c3a1f349907e6ef94cf343c86f63c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Sat, 5 Jan 2013 16:12:50 +0100 Subject: [PATCH] wibox.layout.align: make the middle widget really centered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ý Signed-off-by: Uli Schlachter --- lib/awful/menu.lua.in | 2 +- lib/wibox/layout/align.lua.in | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index 772d8316..ba92da74 100644 --- a/lib/awful/menu.lua.in +++ b/lib/awful/menu.lua.in @@ -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 diff --git a/lib/wibox/layout/align.lua.in b/lib/wibox/layout/align.lua.in index d4a95176..5a4766ad 100644 --- a/lib/wibox/layout/align.lua.in +++ b/lib/wibox/layout/align.lua.in @@ -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