naughty: port sizing to the new widget margin code
Signed-off-by: koniu <gkusnierz@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4a81695f8b
commit
58eb27a99b
|
@ -325,8 +325,9 @@ function notify(args)
|
||||||
-- create textbox
|
-- create textbox
|
||||||
local textbox = capi.widget({ type = "textbox", align = "flex" })
|
local textbox = capi.widget({ type = "textbox", align = "flex" })
|
||||||
textbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die)))
|
textbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die)))
|
||||||
textbox:margin({ right = margin, left = margin, bottom = margin, top = margin })
|
layout.margins[textbox] = { right = margin, left = margin, bottom = margin, top = margin }
|
||||||
textbox.text = string.format('<span font_desc="%s"><b>%s</b>%s</span>', font, title, text)
|
textbox.text = string.format('<span font_desc="%s"><b>%s</b>%s</span>', font, title, text)
|
||||||
|
textbox.valign = "middle"
|
||||||
|
|
||||||
-- create iconbox
|
-- create iconbox
|
||||||
local iconbox = nil
|
local iconbox = nil
|
||||||
|
@ -339,6 +340,7 @@ function notify(args)
|
||||||
-- if we have an icon, use it
|
-- if we have an icon, use it
|
||||||
if icon then
|
if icon then
|
||||||
iconbox = capi.widget({ type = "imagebox", align = "left" })
|
iconbox = capi.widget({ type = "imagebox", align = "left" })
|
||||||
|
layout.margins[iconbox] = { right = margin, left = margin, bottom = margin, top = margin }
|
||||||
iconbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die)))
|
iconbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die)))
|
||||||
local img
|
local img
|
||||||
if type(icon) == "string" then
|
if type(icon) == "string" then
|
||||||
|
@ -364,16 +366,16 @@ function notify(args)
|
||||||
|
|
||||||
-- calculate the height
|
-- calculate the height
|
||||||
if not height then
|
if not height then
|
||||||
if iconbox and iconbox:extents().height > textbox:extents().height then
|
if iconbox and iconbox:extents().height + 2 * margin > textbox:extents().height + 2 * margin then
|
||||||
height = iconbox:extents().height
|
height = iconbox:extents().height + 2 * margin
|
||||||
else
|
else
|
||||||
height = textbox:extents().height
|
height = textbox:extents().height + 2 * margin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- calculate the width
|
-- calculate the width
|
||||||
if not width then
|
if not width then
|
||||||
width = textbox:extents().width + (iconbox and iconbox:extents().width or 0)
|
width = textbox:extents().width + (iconbox and iconbox:extents().width or 0) + 2 * margin
|
||||||
end
|
end
|
||||||
|
|
||||||
-- crop to workarea size if too big
|
-- crop to workarea size if too big
|
||||||
|
|
Loading…
Reference in New Issue