awful.menu: fix wibox height computing
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
68148167ef
commit
24a614f8d0
|
@ -197,12 +197,12 @@ local function add_item(data, num, item_info)
|
||||||
local iconbox
|
local iconbox
|
||||||
if item_info[3] then
|
if item_info[3] then
|
||||||
local icon = type(item_info[3]) == "string" and image(item_info[3]) or item_info[3]
|
local icon = type(item_info[3]) == "string" and image(item_info[3]) or item_info[3]
|
||||||
if icon.width > tonumber(data.h) or icon.height > tonumber(data.h) then
|
if icon.width > data.h or icon.height > data.h then
|
||||||
local width, height
|
local width, height
|
||||||
if ((data.h/icon.height) * icon.width) > tonumber(data.h) then
|
if ((data.h/icon.height) * icon.width) > data.h then
|
||||||
width, height = data.h, (tonumber(data.h) / icon.width) * icon.height
|
width, height = data.h, (data.h / icon.width) * icon.height
|
||||||
else
|
else
|
||||||
width, height = (tonumber(data.h) / icon.height) * icon.width, data.h
|
width, height = (data.h / icon.height) * icon.width, data.h
|
||||||
end
|
end
|
||||||
icon = icon:crop_and_scale(0, 0, icon.width, icon.height, width, height)
|
icon = icon:crop_and_scale(0, 0, icon.width, icon.height, width, height)
|
||||||
end
|
end
|
||||||
|
@ -242,7 +242,7 @@ local function add_item(data, num, item_info)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
item.height = label:extents().height + 2
|
||||||
item.ontop = true
|
item.ontop = true
|
||||||
|
|
||||||
return { wibox = item, cmd = item_info[2] }
|
return { wibox = item, cmd = item_info[2] }
|
||||||
|
@ -366,13 +366,19 @@ function new(menu, parent, num)
|
||||||
data.auto_expand = true
|
data.auto_expand = true
|
||||||
end
|
end
|
||||||
data.h = parent and parent.h or data.theme.menu_height
|
data.h = parent and parent.h or data.theme.menu_height
|
||||||
|
if type(data.h) ~= 'number' then data.h = tonumber(data.h) end
|
||||||
data.w = parent and parent.w or data.theme.menu_width
|
data.w = parent and parent.w or data.theme.menu_width
|
||||||
|
if type(data.w) ~= 'number' then data.w = tonumber(data.w) end
|
||||||
|
|
||||||
-- Create items
|
-- Create items
|
||||||
for k, v in pairs(menu.items) do
|
for k, v in pairs(menu.items) do
|
||||||
table.insert(data.items, add_item(data, k, v))
|
table.insert(data.items, add_item(data, k, v))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if #data.items > 0 and data.h < data.items[1].wibox.height then
|
||||||
|
data.h = data.items[1].wibox.height
|
||||||
|
end
|
||||||
|
|
||||||
-- Set methods
|
-- Set methods
|
||||||
data.hide = hide
|
data.hide = hide
|
||||||
data.show = show
|
data.show = show
|
||||||
|
|
Loading…
Reference in New Issue