2013-05-11 21:02:42 +02:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local print = print
|
2014-01-08 06:59:57 +01:00
|
|
|
local pairs=pairs
|
|
|
|
local base = require( "radical.base" )
|
2013-05-11 21:02:42 +02:00
|
|
|
|
|
|
|
local module = {
|
|
|
|
margins = {
|
|
|
|
TOP = 2,
|
|
|
|
BOTTOM = 2,
|
|
|
|
RIGHT = 2,
|
|
|
|
LEFT = 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-15 05:35:53 +01:00
|
|
|
local function widget_draw(self, w, cr, width, height)
|
|
|
|
self:_draw(w, cr, width, height)
|
|
|
|
local overlay = self._item and self._item.overlay
|
|
|
|
if overlay then
|
|
|
|
overlay(self._item._menu,self._item,cr,width,height)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-08 06:59:57 +01:00
|
|
|
local function draw(data,item,args)
|
|
|
|
local args,flags = args or {},{}
|
2014-01-13 06:46:33 +01:00
|
|
|
for _,v in pairs(args) do flags[v] = true end
|
2014-01-08 06:59:57 +01:00
|
|
|
|
2014-02-15 05:35:53 +01:00
|
|
|
if not item.widget._overlay_init then
|
|
|
|
item.widget._draw = item.widget.draw
|
|
|
|
item.widget.draw = widget_draw
|
|
|
|
item.widget._overlay_init = true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-01-08 06:59:57 +01:00
|
|
|
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
|
|
|
item.widget:set_bg(args.color or data.bg_focus)
|
2013-05-11 21:02:42 +02:00
|
|
|
else
|
2014-01-08 06:59:57 +01:00
|
|
|
item.widget:set_bg(args.color or nil)
|
2013-05-11 21:02:42 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(module, { __call = function(_, ...) return draw(...) end })
|
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|