wibox: Improve constructor functions for some layouts

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2013-03-10 13:46:28 +01:00
parent 23b30be106
commit 4c3bac07ec
3 changed files with 14 additions and 2 deletions

View File

@ -98,7 +98,9 @@ end
-- :set_widget() to set the widget and -- :set_widget() to set the widget and
-- :set_horizontal() and :set_vertical() for the direction. -- :set_horizontal() and :set_vertical() for the direction.
-- horizontal and vertical are by default false which doesn't change anything. -- horizontal and vertical are by default false which doesn't change anything.
local function new() -- @param widget The widget to display (optional)
-- @param reflection A table describing the reflection to apply (optional)
local function new(widget, reflection)
local ret = widget_base.make_widget() local ret = widget_base.make_widget()
ret.horizontal = false ret.horizontal = false
ret.vertical = false ret.vertical = false
@ -113,6 +115,9 @@ local function new()
ret:emit_signal("widget::updated") ret:emit_signal("widget::updated")
end end
ret:set_widget(widget)
ret:set_reflection(reflection or {})
return ret return ret
end end

View File

@ -99,6 +99,8 @@ end
--- Returns a new rotate layout. A rotate layout rotates a given widget. Use --- Returns a new rotate layout. A rotate layout rotates a given widget. Use
-- :set_widget() to set the widget and :set_direction() for the direction. -- :set_widget() to set the widget and :set_direction() for the direction.
-- The default direction is "north" which doesn't change anything. -- The default direction is "north" which doesn't change anything.
-- @param widget The widget to display (optional)
-- @param dir The direction to rotate to (optional)
local function new(widget, dir) local function new(widget, dir)
local ret = widget_base.make_widget() local ret = widget_base.make_widget()

View File

@ -94,7 +94,11 @@ function background:set_bgimage(image)
self._emit_updated() self._emit_updated()
end end
local function new(widget) --- Returns a new background layout. A background layout applies a background
-- and foreground color to another widget.
-- @param widget The widget to display (optional)
-- @param bg The background to use for that widget (optional)
local function new(widget, bg)
local ret = base.make_widget() local ret = base.make_widget()
for k, v in pairs(background) do for k, v in pairs(background) do
@ -108,6 +112,7 @@ local function new(widget)
end end
ret:set_widget(widget) ret:set_widget(widget)
ret:set_bg(bg)
return ret return ret
end end