2014-02-03 05:01:31 +01:00
|
|
|
local setmetatable = setmetatable
|
2016-06-24 06:46:41 +02:00
|
|
|
local wibox = require( "wibox" )
|
|
|
|
local util = require( "awful.util" )
|
|
|
|
local margins2 = require( "radical.margins" )
|
|
|
|
local common = require( "radical.item.common" )
|
2014-02-03 05:01:31 +01:00
|
|
|
|
|
|
|
local function create_item(item,data,args)
|
2014-02-16 20:46:10 +01:00
|
|
|
|
2016-02-12 05:39:45 +01:00
|
|
|
-- Define the item layout
|
|
|
|
local w = wibox.widget.base.make_widget_declarative {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
id = "main_text" ,
|
|
|
|
align = "center" ,
|
|
|
|
widget = wibox.widget.textbox,
|
|
|
|
},
|
|
|
|
nil,
|
|
|
|
layout = wibox.layout.align.horizontal,
|
|
|
|
},
|
|
|
|
id = "main_margin",
|
2016-06-24 06:46:41 +02:00
|
|
|
layout = wibox.container.margin
|
2016-02-12 05:39:45 +01:00
|
|
|
},
|
2016-06-24 06:46:41 +02:00
|
|
|
widget = wibox.container.background,
|
2016-02-12 05:39:45 +01:00
|
|
|
}
|
2016-03-04 09:21:48 +01:00
|
|
|
item.widget = w
|
2016-02-12 05:39:45 +01:00
|
|
|
item._internal.margin_w = item.widget:get_children_by_id("main_margin")[1]
|
|
|
|
item._internal.text_w = item.widget:get_children_by_id("main_text" )[1]
|
|
|
|
|
|
|
|
-- Margins
|
|
|
|
local mrgns = margins2(
|
|
|
|
item._internal.margin_w,
|
|
|
|
util.table.join(data.item_style.margins,data.default_item_margins)
|
|
|
|
)
|
|
|
|
|
|
|
|
function item:get_margins()
|
|
|
|
return mrgns
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Setup events
|
2016-03-05 08:14:24 +01:00
|
|
|
common.setup_event(data, item, w)
|
2016-02-12 05:39:45 +01:00
|
|
|
|
|
|
|
return w
|
2014-02-03 05:01:31 +01:00
|
|
|
end
|
|
|
|
|
2016-02-12 05:39:45 +01:00
|
|
|
return setmetatable({}, { __call = function(_, ...) return create_item(...) end })
|
|
|
|
-- kate: space-indent on; indent-width 4; replace-tabs on;
|