2014-01-05 00:51:07 +01:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local color = require( "gears.color")
|
|
|
|
local wibox = require( "wibox" )
|
|
|
|
local beautiful = require( "beautiful" )
|
|
|
|
|
2014-03-12 05:31:50 +01:00
|
|
|
local module = {HORIZONTAL=1,VERTICAL=2}
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function draw(self, context, cr, width, height)
|
2014-01-05 00:51:07 +01:00
|
|
|
cr:save()
|
|
|
|
cr:set_source(self._color)
|
2014-03-12 05:31:50 +01:00
|
|
|
if self.direction == module.VERTICAL then
|
|
|
|
cr:rectangle(2,2,1,height-4)
|
|
|
|
else
|
|
|
|
cr:rectangle(5,2,width-10,1)
|
|
|
|
end
|
2014-01-05 00:51:07 +01:00
|
|
|
cr:fill()
|
|
|
|
cr:restore()
|
|
|
|
end
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function fit(box, context, w, h)
|
2014-03-24 00:00:43 +01:00
|
|
|
local direction = box.direction or w > h and module.HORIZONTAL or module.VERTICAL
|
|
|
|
return direction == module.VERTICAL and 5 or w,direction == module.VERTICAL and h or 5
|
2014-01-05 00:51:07 +01:00
|
|
|
end
|
|
|
|
|
2014-03-12 05:31:50 +01:00
|
|
|
local function new(menu,direction)
|
2014-01-05 00:51:07 +01:00
|
|
|
local bg = wibox.widget.base.make_widget()
|
2014-03-12 05:31:50 +01:00
|
|
|
bg.direction = direction or module.HORIZONTAL
|
2014-01-05 00:51:07 +01:00
|
|
|
bg.fit = fit
|
2014-11-15 05:46:06 +01:00
|
|
|
bg._color = color( menu and menu.separator_color or beautiful.menu_border_color or beautiful.menu_fg or beautiful.fg_normal)
|
2014-01-05 00:51:07 +01:00
|
|
|
bg.draw = draw
|
|
|
|
bg._force_fit = true
|
|
|
|
return bg
|
|
|
|
end
|
|
|
|
|
2014-03-12 05:31:50 +01:00
|
|
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
2014-01-05 00:51:07 +01:00
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|