2014-01-25 07:33:50 +01:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local base = require( "radical.base" )
|
|
|
|
local beautiful = require("beautiful" )
|
|
|
|
local color = require("gears.color" )
|
|
|
|
local cairo = require("lgi" ).cairo
|
|
|
|
local wibox = require("wibox" )
|
2014-02-23 05:59:03 +01:00
|
|
|
local arrow_alt = require("radical.item.style.arrow_alt")
|
2014-01-25 07:33:50 +01:00
|
|
|
|
|
|
|
local module = {
|
|
|
|
margins = {
|
|
|
|
TOP = 0,
|
|
|
|
BOTTOM = 0,
|
2014-02-07 05:47:24 +01:00
|
|
|
RIGHT = 15,
|
|
|
|
LEFT = 15
|
2014-01-25 07:33:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function suffix_draw(self, context, cr, width, height)
|
2014-01-25 07:33:50 +01:00
|
|
|
cr:save()
|
|
|
|
cr:move_to(height/2,0)
|
|
|
|
cr:line_to(width-height/2,0)
|
|
|
|
cr:line_to(width,height/2)
|
|
|
|
cr:line_to(width-height/2,height)
|
|
|
|
cr:line_to(height/2,height)
|
|
|
|
cr:line_to(0,height/2)
|
|
|
|
cr:line_to(height/2,0)
|
|
|
|
cr:close_path()
|
|
|
|
cr:clip()
|
2015-12-29 11:19:23 +01:00
|
|
|
|
|
|
|
if wibox.widget.background.draw then
|
|
|
|
wibox.widget.background.draw(self, context, cr, width, height)
|
|
|
|
end
|
|
|
|
|
2014-01-25 07:33:50 +01:00
|
|
|
cr:restore()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-03-02 22:28:30 +01:00
|
|
|
local function draw(item,args)
|
2014-02-21 04:29:40 +01:00
|
|
|
local args = args or {}
|
2014-01-25 07:33:50 +01:00
|
|
|
|
|
|
|
item.widget.draw = suffix_draw
|
|
|
|
|
2014-02-21 04:29:40 +01:00
|
|
|
local state = item.state or {}
|
2014-02-22 04:22:13 +01:00
|
|
|
local current_state = state._current_key or nil
|
|
|
|
local state_name = base.colors_by_id[current_state]
|
|
|
|
if current_state == base.item_flags.SELECTED or (item._tmp_menu) then
|
2014-03-02 22:28:30 +01:00
|
|
|
item.widget:set_bg(args.color or item.bg_focus)
|
|
|
|
item.widget:set_fg(item.fg_focus)
|
2014-02-22 04:22:13 +01:00
|
|
|
elseif state_name then
|
2014-03-02 22:28:30 +01:00
|
|
|
item.widget:set_bg(args.color or item["bg_"..state_name])
|
|
|
|
item.widget:set_fg( item["fg_"..state_name])
|
2014-01-25 07:33:50 +01:00
|
|
|
else
|
|
|
|
item.widget:set_bg(args.color or nil)
|
2014-03-13 06:14:52 +01:00
|
|
|
item.widget:set_fg(item["fg"])
|
2014-01-25 07:33:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(module, { __call = function(_, ...) return draw(...) end })
|
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|