radical/item/style/line_3d.lua

43 lines
1.2 KiB
Lua
Raw Normal View History

2015-01-02 23:52:36 +01:00
local setmetatable = setmetatable
local beautiful = require( "beautiful" )
local color = require( "gears.color" )
local cairo = require( "lgi" ).cairo
local theme = require( "radical.theme" )
2015-01-02 23:52:36 +01:00
local module = {
margins = {
TOP = 2,
BOTTOM = 2,
RIGHT = 2,
LEFT = 4
}
}
local function after_draw_children(self, context, cr, width, height)
2015-01-02 23:52:36 +01:00
cr:set_source(self.col1)
cr:rectangle(0,3,1,height-6)
cr:fill()
cr:set_source(self.col2)
cr:rectangle(width-1,3,1,height-6)
cr:fill()
end
local function draw(item)
2015-01-02 23:52:36 +01:00
if not item.widget._overlay_init then
item.widget.after_draw_children = after_draw_children
2015-01-02 23:52:36 +01:00
item.widget._overlay_init = true
2015-01-02 23:52:36 +01:00
-- Build the 2 item border colors, this item_style doesn't support gradient
-- or patterns
item.widget.col1 = color(item.item_border_color or item.border_color or beautiful.border_color)
local _,r,g,b,a = item.widget.col1:get_rgba()
2015-01-02 23:52:36 +01:00
r,g,b = r-.2,g-.2,b-.2
item.widget.col2 = cairo.Pattern.create_rgba(r,g,b,a)
end
theme.update_colors(item)
2015-01-02 23:52:36 +01:00
end
return setmetatable(module, { __call = function(_, ...) return draw(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;