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:
parent
e38651bafb
commit
8560de597c
|
@ -560,7 +560,7 @@ function menu.entry(parent, args)
|
||||||
left:add(margin)
|
left:add(margin)
|
||||||
|
|
||||||
local layout = wibox.layout.align.horizontal()
|
local layout = wibox.layout.align.horizontal()
|
||||||
layout:set_middle(left)
|
layout:set_left(left)
|
||||||
if submenu then
|
if submenu then
|
||||||
layout:set_right(submenu)
|
layout:set_right(submenu)
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,11 +56,15 @@ function align:draw(wibox, cr, width, height)
|
||||||
if self.second and size_first + size_third < size_limit then
|
if self.second and size_first + size_third < size_limit then
|
||||||
local x, y, w, h
|
local x, y, w, h
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
x, y = 0, size_first
|
|
||||||
w, h = width, size_limit - size_first - size_third
|
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
|
else
|
||||||
x, y = size_first, 0
|
|
||||||
w, h = size_limit - size_first - size_third, height
|
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
|
end
|
||||||
base.draw_widget(wibox, cr, self.second, x, y, w, h)
|
base.draw_widget(wibox, cr, self.second, x, y, w, h)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue