2016-03-06 09:30:30 +01:00
|
|
|
local setmetatable = setmetatable
|
2016-02-21 08:34:05 +01:00
|
|
|
local base = require( "radical.base" )
|
|
|
|
local wibox = require( "wibox" )
|
2014-02-23 05:59:03 +01:00
|
|
|
local item_style = require( "radical.item.style.arrow_single" )
|
2016-02-21 08:34:05 +01:00
|
|
|
local item_layout= require( "radical.item.layout.horizontal" )
|
|
|
|
local common = require( "radical.common" )
|
2016-03-06 09:30:30 +01:00
|
|
|
local shape = require( "gears.shape" )
|
2014-01-04 06:49:20 +01:00
|
|
|
|
2016-02-21 08:34:05 +01:00
|
|
|
local module = {}
|
2014-01-04 06:49:20 +01:00
|
|
|
|
2016-06-29 22:01:14 +02:00
|
|
|
local function new(args)
|
|
|
|
args = args or {}
|
|
|
|
args.border_width = args.border_width or 0
|
|
|
|
args.internal = args.internal or {}
|
|
|
|
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
|
|
|
args.item_style = args.item_style or item_style
|
|
|
|
args.item_layout = args.item_layout or item_layout
|
|
|
|
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
|
|
|
|
|
|
|
local data = base(args)
|
|
|
|
|
2016-02-21 08:34:05 +01:00
|
|
|
local internal = data._internal
|
2014-01-04 06:49:20 +01:00
|
|
|
|
2016-03-06 09:30:30 +01:00
|
|
|
-- Use a background to make the border work
|
|
|
|
internal.widget = wibox.widget.base.make_widget_declarative {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id = "main_layout" ,
|
|
|
|
spacing = data.spacing or nil,
|
|
|
|
_data = data ,
|
|
|
|
layout = internal.layout_func or wibox.layout.fixed.horizontal
|
|
|
|
},
|
|
|
|
id = "main_margin" ,
|
2016-06-24 06:46:41 +02:00
|
|
|
layout = wibox.container.margin,
|
2016-03-06 09:30:30 +01:00
|
|
|
},
|
|
|
|
shape = data.shape or shape.rectangle or nil,
|
|
|
|
shape_border_width = data.border_width ,
|
|
|
|
shape_border_color = data.border_color ,
|
2016-06-24 06:46:41 +02:00
|
|
|
widget = wibox.container.background ,
|
2016-03-06 09:30:30 +01:00
|
|
|
}
|
|
|
|
internal.layout = internal.widget:get_children_by_id("main_layout")[1]
|
|
|
|
internal.margin = internal.widget:get_children_by_id("main_margin")[1]
|
2014-01-05 23:35:23 +01:00
|
|
|
|
2016-02-21 08:34:05 +01:00
|
|
|
--Getters
|
|
|
|
data.get_visible = function() return true end
|
|
|
|
data.get_margins = common.get_margins
|
2016-06-24 08:02:40 +02:00
|
|
|
|
|
|
|
function data.get_widget()
|
2016-03-06 09:30:30 +01:00
|
|
|
return internal.widget
|
|
|
|
end
|
|
|
|
|
|
|
|
data:get_margins()
|
2014-01-05 23:35:23 +01:00
|
|
|
|
2016-02-21 08:34:05 +01:00
|
|
|
if data.style then
|
|
|
|
data.style(data)
|
2014-02-17 05:55:44 +01:00
|
|
|
end
|
2014-01-05 23:35:23 +01:00
|
|
|
|
2016-02-21 08:34:05 +01:00
|
|
|
common.setup_item_move_events(data)
|
2014-03-12 05:31:50 +01:00
|
|
|
|
2016-06-29 22:01:14 +02:00
|
|
|
return data, data._internal.widget
|
2014-01-04 06:49:20 +01:00
|
|
|
end
|
|
|
|
|
2014-02-07 05:47:24 +01:00
|
|
|
function module.flex(args)
|
2016-06-24 08:02:40 +02:00
|
|
|
args = args or {}
|
2016-02-21 08:34:05 +01:00
|
|
|
args.internal = args.internal or {}
|
|
|
|
args.internal.layout_func = wibox.layout.flex.horizontal()
|
|
|
|
|
|
|
|
local data = new(args)
|
|
|
|
|
|
|
|
return data,data._internal.margin
|
2014-02-07 05:47:24 +01:00
|
|
|
end
|
|
|
|
|
2014-01-04 06:49:20 +01:00
|
|
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
2016-02-21 08:34:05 +01:00
|
|
|
-- kate: space-indent on; indent-width 4; replace-tabs on;
|