naughty: new config option 'margin' + 2 renamed

* Renamed config.margin to config.padding. Controls spacing between popup and
  workarea border.

* Renamed config.gap to config.spacing. Controls spacing between popups.

* Added config.margin. Controls spacing between popup wibox and text.

Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
koniu 2008-11-15 20:08:17 +00:00
parent e536dbe2ea
commit 651b5e5f70
1 changed files with 13 additions and 12 deletions

View File

@ -29,11 +29,12 @@ module("naughty")
-- @field position Corner of the workarea the popups will appear. -- @field position Corner of the workarea the popups will appear.
-- Valid values: 'top_right', 'top_left', 'bottom_right', 'bottom_left'. -- Valid values: 'top_right', 'top_left', 'bottom_right', 'bottom_left'.
-- Default: 'top_right' -- Default: 'top_right'
-- @field margin Space between popups and edge of the workarea. Default: 4 -- @field padding Space between popups and edge of the workarea. Default: 4
-- @field height Height of a single line of text. Default: 16 -- @field height Height of a single line of text. Default: 16
-- @field width Width of a popup. Default: 300 -- @field width Width of a popup. Default: 300
-- @field gap Spacing between popups. Default: 1 -- @field spacing Spacing between popups. Default: 1
-- @field ontop Boolean forcing popups to display on top. Default: true -- @field ontop Boolean forcing popups to display on top. Default: true
-- @field margin Space between popup edge and content. Default: 10
-- @field font Popup font. Default: beautiful.font or "Verdana 8" -- @field font Popup font. Default: beautiful.font or "Verdana 8"
-- @field icon Popup icon. Default: nil -- @field icon Popup icon. Default: nil
-- @field icon_size Size of the icon in pixels. Default: 16 -- @field icon_size Size of the icon in pixels. Default: 16
@ -50,11 +51,12 @@ config = {}
config.timeout = 5 config.timeout = 5
config.screen = 1 config.screen = 1
config.position = "top_right" config.position = "top_right"
config.margin = 4 config.padding = 4
config.height = 16 config.height = 16
config.width = 300 config.width = 300
config.gap = 1 config.spacing = 1
config.ontop = true config.ontop = true
config.margin = 10
config.font = beautiful.font or "Verdana 8" config.font = beautiful.font or "Verdana 8"
config.icon = nil config.icon = nil
config.icon_size = 16 config.icon_size = 16
@ -91,22 +93,22 @@ local function get_offset(idx, position, height)
-- calculate x -- calculate x
if position:match("left") then if position:match("left") then
v.x = ws.x + config.margin v.x = ws.x + config.padding
else else
v.x = ws.x + ws.width - (config.width + config.border_width*2 + config.margin) v.x = ws.x + ws.width - (config.width + config.border_width*2 + config.padding)
end end
-- calculate existing popups' height -- calculate existing popups' height
local existing = 0 local existing = 0
for i = 1, idx-1, 1 do for i = 1, idx-1, 1 do
existing = existing + notifications[position][i].height + config.gap + config.border_width*2 existing = existing + notifications[position][i].height + config.spacing + config.border_width*2
end end
-- calculate y -- calculate y
if position:match("top") then if position:match("top") then
v.y = ws.y + config.margin + existing v.y = ws.y + config.padding + existing
else else
v.y = ws.y + ws.height - (config.margin + config.border_width + height + existing) v.y = ws.y + ws.height - (config.padding + config.border_width + height + existing)
end end
-- if positioned outside workarea, destroy oldest popup and recalculate -- if positioned outside workarea, destroy oldest popup and recalculate
@ -188,10 +190,9 @@ function notify(args)
-- create textbox -- create textbox
local textbox = widget({ type = "textbox", name = "text", align = "flex" }) local textbox = widget({ type = "textbox", name = "text", align = "flex" })
textbox.margin = 20
textbox:buttons({ button({ }, 1, run), textbox:buttons({ button({ }, 1, run),
button({ }, 3, die) }) button({ }, 3, die) })
textbox.text = string.format('<margin left="10"/><span font_desc="%s"><b>%s</b>%s</span>', textbox.text = string.format('<margin right="'..config.margin..'" left="'..config.margin..'"/><span font_desc="%s"><b>%s</b>%s</span>',
config.font, title, text) config.font, title, text)
if config.hover_timeout then textbox.mouse_enter = hover_destroy end if config.hover_timeout then textbox.mouse_enter = hover_destroy end