2013-05-11 21:02:42 +02:00
|
|
|
local setmetatable = setmetatable
|
2016-02-11 07:36:50 +01:00
|
|
|
local theme = require( "radical.theme" )
|
|
|
|
local shape = require( "gears.shape" )
|
|
|
|
local color = require( "gears.color" )
|
2013-05-11 21:02:42 +02:00
|
|
|
|
|
|
|
local module = {
|
|
|
|
margins = {
|
|
|
|
TOP = 4,
|
|
|
|
BOTTOM = 4,
|
|
|
|
RIGHT = 4,
|
|
|
|
LEFT = 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
local function widget_draw(self, context, cr, width, height)
|
2013-05-11 21:02:42 +02:00
|
|
|
|
2016-06-25 08:13:56 +02:00
|
|
|
if not self._private.background then
|
2016-02-11 07:36:50 +01:00
|
|
|
cr:set_source_rgba(0,0,0,0)
|
|
|
|
else
|
2016-06-25 08:13:56 +02:00
|
|
|
cr:set_source(color(self._private.background))
|
2016-02-11 07:36:50 +01:00
|
|
|
end
|
2015-01-11 05:59:51 +01:00
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
shape.rounded_rect(cr ,width, height, 3)
|
2015-01-11 05:59:51 +01:00
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
if self._item.item_border_color then
|
2015-01-02 23:52:36 +01:00
|
|
|
cr:fill_preserve()
|
2016-02-11 07:36:50 +01:00
|
|
|
cr:set_line_width(self._item.border_width or 1)
|
|
|
|
cr:set_source(color(self._item.item_border_color))
|
2015-01-02 23:52:36 +01:00
|
|
|
cr:stroke()
|
|
|
|
else
|
|
|
|
cr:fill()
|
|
|
|
end
|
2014-10-06 00:01:54 +02:00
|
|
|
|
2014-02-15 05:35:53 +01:00
|
|
|
end
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function draw_width_shadow(self, context, cr, width, height)
|
2016-06-25 08:13:56 +02:00
|
|
|
if not self._private.background then return end
|
2014-02-15 05:35:53 +01:00
|
|
|
|
2015-01-11 05:59:51 +01:00
|
|
|
cr:save()
|
|
|
|
cr:reset_clip()
|
|
|
|
cr:set_source_rgba(0,0,0,.1)
|
|
|
|
cr:set_line_width(1)
|
|
|
|
cr:translate(3,3)
|
|
|
|
for i=1,3 do
|
|
|
|
cr:translate(-1,-1)
|
2016-02-11 07:36:50 +01:00
|
|
|
shape.rounded_rect(cr, width, height, 3)
|
2015-01-11 05:59:51 +01:00
|
|
|
cr:fill()
|
2013-05-11 21:02:42 +02:00
|
|
|
end
|
2015-01-11 05:59:51 +01:00
|
|
|
cr:restore()
|
|
|
|
end
|
2013-05-11 21:02:42 +02:00
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
local function draw(item)
|
|
|
|
item.widget._item = item
|
2015-12-29 11:19:23 +01:00
|
|
|
item.widget.draw = widget_draw
|
2016-02-11 07:36:50 +01:00
|
|
|
theme.update_colors(item)
|
2015-01-11 05:59:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Same as the default, but also draw a shadow
|
2016-02-11 07:36:50 +01:00
|
|
|
local function shadow(item)
|
|
|
|
item.widget.draw = widget_draw
|
|
|
|
item.widget.before_draw_children = draw_width_shadow
|
|
|
|
theme.update_colors(item)
|
2015-01-11 05:59:51 +01:00
|
|
|
end
|
2016-02-11 07:36:50 +01:00
|
|
|
|
2016-06-25 08:13:56 +02:00
|
|
|
module.shadow = {need_full_repaint = true}
|
2015-01-11 05:59:51 +01:00
|
|
|
setmetatable(module.shadow, { __call = function(_, ...) return shadow(...) end })
|
|
|
|
|
2013-05-11 21:02:42 +02:00
|
|
|
return setmetatable(module, { __call = function(_, ...) return draw(...) end })
|
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|