From 651b5e5f70bc9103ad9a7c6dd5a1c3e28d7572d7 Mon Sep 17 00:00:00 2001 From: koniu Date: Sat, 15 Nov 2008 20:08:17 +0000 Subject: [PATCH] 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 --- lib/naughty.lua.in | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index b44d1609..448965eb 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -29,11 +29,12 @@ module("naughty") -- @field position Corner of the workarea the popups will appear. -- Valid values: 'top_right', 'top_left', 'bottom_right', 'bottom_left'. -- 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 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 margin Space between popup edge and content. Default: 10 -- @field font Popup font. Default: beautiful.font or "Verdana 8" -- @field icon Popup icon. Default: nil -- @field icon_size Size of the icon in pixels. Default: 16 @@ -50,11 +51,12 @@ config = {} config.timeout = 5 config.screen = 1 config.position = "top_right" -config.margin = 4 +config.padding = 4 config.height = 16 config.width = 300 -config.gap = 1 +config.spacing = 1 config.ontop = true +config.margin = 10 config.font = beautiful.font or "Verdana 8" config.icon = nil config.icon_size = 16 @@ -91,22 +93,22 @@ local function get_offset(idx, position, height) -- calculate x if position:match("left") then - v.x = ws.x + config.margin + v.x = ws.x + config.padding 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 -- calculate existing popups' height local existing = 0 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 -- calculate y if position:match("top") then - v.y = ws.y + config.margin + existing + v.y = ws.y + config.padding + existing 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 -- if positioned outside workarea, destroy oldest popup and recalculate @@ -188,11 +190,10 @@ function notify(args) -- create textbox local textbox = widget({ type = "textbox", name = "text", align = "flex" }) - textbox.margin = 20 textbox:buttons({ button({ }, 1, run), button({ }, 3, die) }) - textbox.text = string.format('%s%s', - config.font, title, text) + textbox.text = string.format('%s%s', + config.font, title, text) if config.hover_timeout then textbox.mouse_enter = hover_destroy end -- create iconbox