radical/bar.lua

62 lines
2.2 KiB
Lua
Raw Normal View History

2014-02-06 03:43:06 +01:00
local setmetatable,unpack,table = setmetatable,unpack,table
local base = require( "radical.base" )
local color = require( "gears.color" )
local wibox = require( "wibox" )
local beautiful = require( "beautiful" )
2014-02-23 05:59:03 +01:00
local item_style = require( "radical.item.style.arrow_single" )
local item_layout= require( "radical.item.layout.horizontal" )
local common = require( "radical.common" )
2014-01-04 06:49:20 +01:00
local module = {}
2014-01-04 06:49:20 +01:00
local function setup_drawable(data)
local internal = data._internal
2014-01-04 06:49:20 +01:00
internal.layout = internal.layout_func or wibox.layout.fixed.horizontal()
internal.margin = wibox.layout.margin(internal.layout)
internal.layout._data = data
2014-12-25 07:10:55 +01:00
if internal.layout.set_spacing and data.spacing then
internal.layout:set_spacing(data.spacing)
2014-01-04 06:49:20 +01:00
end
2014-01-05 23:35:23 +01:00
--Getters
data.get_visible = function() return true end
data.get_margins = common.get_margins
2014-01-05 23:35:23 +01:00
if data.style then
data.style(data)
end
2014-01-05 23:35:23 +01:00
common.setup_item_move_events(data)
2014-01-05 23:35:23 +01:00
end
2014-01-04 06:49:20 +01:00
local function new(args)
local args = args or {}
args.internal = args.internal or {}
2014-01-04 06:49:20 +01:00
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
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
2014-01-04 06:49:20 +01:00
local ret = base(args)
2014-03-12 05:31:50 +01:00
return ret,ret._internal.margin
2014-01-04 06:49:20 +01:00
end
function module.flex(args)
local args = args or {}
args.internal = args.internal or {}
args.internal.layout_func = wibox.layout.flex.horizontal()
local data = new(args)
function data._internal.text_fit(self,width,height) return width,height end
return data,data._internal.margin
end
2014-01-04 06:49:20 +01:00
return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 4; replace-tabs on;