margin: Accept individual margins

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-10-08 17:22:00 +02:00
parent 97d62c86ac
commit 38d4602425
3 changed files with 11 additions and 12 deletions

View File

@ -52,14 +52,9 @@ function common.list_update(w, buttons, label, data, objects)
local ib = wibox.widget.imagebox()
local tb = wibox.widget.textbox()
local bgb = wibox.widget.background()
local m = wibox.layout.margin()
local m = wibox.layout.margin(tb, 4, 4)
local l = wibox.layout.fixed.horizontal()
-- The textbox gets a margin to look better
m:set_left(4)
m:set_right(4)
m:set_widget(tb)
-- All of this is added in a fixed widget
l:fill_space(true)
l:add(ib)

View File

@ -383,9 +383,7 @@ function notify(args)
-- if we have an icon, use it
if icon then
iconbox = wibox.widget.imagebox()
iconmargin = wibox.layout.margin()
iconmargin:set_widget(iconbox)
iconmargin:set_margins(margin)
iconmargin = wibox.layout.margin(iconbox, margin, margin, margin, margin)
local img = icon
if type(icon) == "string" then
img = capi.oocairo.image_surface_create_from_png(icon)

View File

@ -99,8 +99,11 @@ end
--- Returns a new margin layout.
-- @param widget A widget to use (optional)
-- @param margin A margin to use on every side of the widget (optional)
local function new(widget, margin)
-- @param left A margin to use on the left side of the widget (optional)
-- @param right A margin to use on the right side of the widget (optional)
-- @param top A margin to use on the top side of the widget (optional)
-- @param bottom A margin to use on the bottom side of the widget (optional)
local function new(widget, left, right, top, bottom)
local ret = widget_base.make_widget()
for k, v in pairs(_M) do
@ -113,7 +116,10 @@ local function new(widget, margin)
ret:emit_signal("widget::updated")
end
ret:set_margins(margin or 0)
ret:set_left(left or 0)
ret:set_right(right or 0)
ret:set_top(top or 0)
ret:set_bottom(bottom or 0)
if widget then
ret:set_widget(widget)