2014-11-03 05:27:52 +01:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local beautiful = require("beautiful" )
|
|
|
|
local color = require("gears.color" )
|
2016-02-11 07:36:50 +01:00
|
|
|
local theme = require( "radical.theme" )
|
2014-11-03 05:27:52 +01:00
|
|
|
|
|
|
|
local module = {
|
|
|
|
margins = {
|
|
|
|
TOP = 0,
|
|
|
|
BOTTOM = 0,
|
|
|
|
RIGHT = 0,
|
|
|
|
LEFT = 0
|
2016-01-09 10:25:46 +01:00
|
|
|
},
|
|
|
|
need_full_repaint = true
|
2014-11-03 05:27:52 +01:00
|
|
|
}
|
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
local function prefix_before_draw_children(self, context, cr, width, height)
|
2014-11-03 05:27:52 +01:00
|
|
|
cr:save()
|
|
|
|
|
|
|
|
-- This item style require negative padding, this is a little dangerous to
|
|
|
|
-- do as it can corrupt area outside of the widget
|
|
|
|
local col = self._item.bg_prefix or beautiful.icon_grad or beautiful.fg_normal
|
|
|
|
cr:set_source(color(col))
|
|
|
|
cr:move_to(0,0)
|
|
|
|
cr:line_to(width,0)
|
|
|
|
cr:line_to(width-height/2-height/4,height)
|
|
|
|
cr:line_to(-height/2-height/4,height)
|
|
|
|
cr:close_path()
|
|
|
|
cr:reset_clip()
|
|
|
|
cr:fill()
|
|
|
|
cr:restore()
|
2015-12-29 11:19:23 +01:00
|
|
|
|
2014-11-03 05:27:52 +01:00
|
|
|
end
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function prefix_fit(box,context,w,h)
|
|
|
|
local width,height = box._fit(box,context,w,h)
|
2014-11-03 05:27:52 +01:00
|
|
|
return width + h/2,height
|
|
|
|
end
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function suffix_fit(box,context,w,h)
|
|
|
|
local width,height = box._fit(box,context,w,h)
|
2014-11-03 05:27:52 +01:00
|
|
|
return width + h/2 + h/6,height
|
|
|
|
end
|
|
|
|
|
2016-06-24 22:53:47 +02:00
|
|
|
local function draw(item)
|
2014-11-03 05:27:52 +01:00
|
|
|
|
|
|
|
if not item.widget._overlay_init then
|
|
|
|
item.widget._drawprefix = item.widget.draw
|
|
|
|
item.widget._overlay_init = true
|
|
|
|
end
|
|
|
|
|
|
|
|
if not item._internal.align._setup then
|
|
|
|
item._internal.align._setup = true
|
|
|
|
|
|
|
|
-- Replace prefix function
|
|
|
|
item._internal.align.first._item = item
|
|
|
|
item._internal.align.first._fit = item._internal.align.first.fit
|
|
|
|
item._internal.align.first.fit = prefix_fit
|
2016-02-11 07:36:50 +01:00
|
|
|
item._internal.align.first.before_draw_children = prefix_before_draw_children
|
2014-11-03 05:27:52 +01:00
|
|
|
|
|
|
|
-- Replace suffix function
|
|
|
|
item._internal.align.third._item = item
|
|
|
|
item._internal.align.third._fit = item._internal.align.third.fit
|
|
|
|
item._internal.align.third.fit = suffix_fit
|
|
|
|
end
|
|
|
|
|
2016-02-11 07:36:50 +01:00
|
|
|
theme.update_colors(item)
|
2014-11-03 05:27:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(module, { __call = function(_, ...) return draw(...) end })
|
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|