2014-01-05 00:10:35 +01:00
|
|
|
local type = type
|
|
|
|
local base = require( "wibox.widget.base" )
|
|
|
|
local tooltip = require( "radical.tooltip" )
|
2014-03-12 05:31:50 +01:00
|
|
|
local underlay = require( "radical.widgets.underlay")
|
2014-01-05 00:10:35 +01:00
|
|
|
local aw_button = require( "awful.button" )
|
2014-03-12 05:31:50 +01:00
|
|
|
local beautiful = require( "beautiful" )
|
2014-01-04 22:51:50 +01:00
|
|
|
|
|
|
|
-- Define some wibox.widget extensions
|
|
|
|
local function set_tooltip(self, text)
|
|
|
|
if not text then return end
|
|
|
|
self._tooltip = tooltip(self,text)
|
|
|
|
end
|
|
|
|
|
2014-01-05 00:10:35 +01:00
|
|
|
local function set_menu(self,menu,button)
|
|
|
|
if not menu then return end
|
2014-01-09 05:32:42 +01:00
|
|
|
local b = button or 1
|
|
|
|
local current,bt = self:buttons(),aw_button({},b,function(geo)
|
2014-01-05 00:10:35 +01:00
|
|
|
local m = menu
|
|
|
|
if type(menu) == "function" then
|
|
|
|
if self._tmp_menu and self._tmp_menu.visible then
|
|
|
|
self._tmp_menu.visible = false
|
|
|
|
self._tmp_menu = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
m = menu(self)
|
|
|
|
end
|
|
|
|
if not m then return end
|
|
|
|
m.parent_geometry = geo
|
|
|
|
m.visible = not m.visible
|
|
|
|
end)
|
|
|
|
for k, v in pairs(bt) do
|
|
|
|
current[type(k) == "number" and (#current+1) or k] = v
|
|
|
|
end
|
2014-01-05 23:35:23 +01:00
|
|
|
self._menu = menu
|
|
|
|
return bt
|
2014-01-05 00:10:35 +01:00
|
|
|
end
|
|
|
|
|
2015-12-29 11:19:23 +01:00
|
|
|
local function _underlay_draw(self, context, cr, width, height)
|
2014-03-12 05:31:50 +01:00
|
|
|
cr:save()
|
2014-03-13 03:56:56 +01:00
|
|
|
local udl = underlay.draw(self._underlay,{height=height,style = self._underlay_style,bg=self._underlay_color})
|
2014-03-12 05:31:50 +01:00
|
|
|
cr:set_source_surface(udl,width-udl:get_width()-3)
|
|
|
|
cr:paint_with_alpha(self._underlay_alpha or beautiful.underlay_alpha or 0.7)
|
|
|
|
cr:restore()
|
2015-12-29 11:19:23 +01:00
|
|
|
self._draw_underlay(self, context, cr, width, height)
|
2014-03-12 05:31:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local function set_underlay(self,udl,args)
|
|
|
|
local args = args or {}
|
|
|
|
if not self._draw_underlay then
|
|
|
|
self._draw_underlay = self.draw
|
|
|
|
self.draw = _underlay_draw
|
|
|
|
end
|
|
|
|
self._underlay = udl
|
|
|
|
self._underlay_style = args.style
|
|
|
|
self._underlay_alpha = args.alpha
|
2014-03-13 03:56:56 +01:00
|
|
|
self._underlay_color = args.color
|
2014-03-12 05:31:50 +01:00
|
|
|
self:emit_signal("widget::updated")
|
|
|
|
end
|
|
|
|
|
2014-01-04 22:51:50 +01:00
|
|
|
-- Do some monkey patching to extend all wibox.widget
|
|
|
|
base._make_widget =base.make_widget
|
|
|
|
base.make_widget = function(...)
|
|
|
|
local ret = base._make_widget(...)
|
2014-03-12 05:31:50 +01:00
|
|
|
ret.set_tooltip = set_tooltip
|
|
|
|
ret.set_menu = set_menu
|
|
|
|
ret.set_underlay = set_underlay
|
2014-01-04 22:51:50 +01:00
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2014-02-23 05:59:03 +01:00
|
|
|
local bar = require( "radical.bar" )
|
2014-02-07 05:47:24 +01:00
|
|
|
|
2013-05-11 21:02:42 +02:00
|
|
|
return {
|
2014-02-23 05:59:03 +01:00
|
|
|
layout = require( "radical.layout" ),
|
|
|
|
object = require( "radical.object" ),
|
|
|
|
base = require( "radical.base" ),
|
|
|
|
radial = require( "radical.radial" ),
|
|
|
|
context = require( "radical.context" ),
|
|
|
|
embed = require( "radical.embed" ),
|
|
|
|
box = require( "radical.box" ),
|
|
|
|
style = require( "radical.style" ),
|
|
|
|
widgets = require( "radical.widgets" ),
|
|
|
|
item = require( "radical.item" ),
|
2014-07-28 01:20:30 +02:00
|
|
|
dock = require( "radical.dock" ),
|
2014-02-23 05:59:03 +01:00
|
|
|
bar = bar,
|
|
|
|
flexbar = bar.flex,
|
|
|
|
tooltip = tooltip
|
2014-01-04 22:51:50 +01:00
|
|
|
}
|
|
|
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|