widget.layout.horizontal: simplify .resize handling

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-08-27 14:21:41 +02:00
parent ddc159f57e
commit 107f1cf1dc
1 changed files with 6 additions and 7 deletions

View File

@ -61,10 +61,13 @@ local function horizontal(direction, bounds, widgets, screen)
height = 0, height = 0,
} }
end end
g.ratio = 1
if g.height > 0 then if v.resize and g.width > 0 and g.height > 0 then
g.ratio = g.width / g.height local ratio = g.width / g.height
g.width = math.floor(bounds.height * ratio)
g.height = bounds.height
end end
if g.width > bounds.width then if g.width > bounds.width then
g.width = bounds.width g.width = bounds.width
end end
@ -76,10 +79,6 @@ local function horizontal(direction, bounds, widgets, screen)
g.y = 0 g.y = 0
end end
if v.resize and g.width > 0 then
g.width = math.floor(g.height * g.ratio)
end
if direction == "leftright" then if direction == "leftright" then
if margins[v] then if margins[v] then
g.x = x + (margins[v].left or 0) g.x = x + (margins[v].left or 0)