Add :set_tooltip() method to all wibox.widgets
This commit is contained in:
parent
4e54b38991
commit
55f1b2a0c1
19
README.md
19
README.md
|
@ -65,9 +65,9 @@ be created by beautiful themes. The current ones are:
|
||||||
|
|
||||||
Arrow also have a few types:
|
Arrow also have a few types:
|
||||||
|
|
||||||
* radical.base.NONE
|
* radical.base.arrow_type.NONE
|
||||||
* radical.base.PRETTY
|
* radical.base.arrow_type.PRETTY
|
||||||
* radical.base.CENTERED
|
* radical.base.arrow_type.CENTERED
|
||||||
|
|
||||||
### Item style
|
### Item style
|
||||||
|
|
||||||
|
@ -97,6 +97,18 @@ On top of each styles, menu can also have different layouts to display items:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Tooltip
|
||||||
|
|
||||||
|
Radical also have its own styled tooltip widget. It can be used in menus, but
|
||||||
|
also in every widgets using the `set_tooltip` method:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
|
||||||
|
local mytextbox = wibox.widget.textbox()
|
||||||
|
mytextbox:set_tooltip("foo bar")
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
Radical offer a (very, very) wide range of options to allow the creation of rich
|
Radical offer a (very, very) wide range of options to allow the creation of rich
|
||||||
|
@ -164,6 +176,7 @@ Multiple items can have multiple sets of options.
|
||||||
| underlay | Text to render at the far-right of the item | string |
|
| underlay | Text to render at the far-right of the item | string |
|
||||||
| prefix_widget | Widget to append at the begenning of the item| widget |
|
| prefix_widget | Widget to append at the begenning of the item| widget |
|
||||||
| suffix_widget | Widget to append at the end of the item | widget |
|
| suffix_widget | Widget to append at the end of the item | widget |
|
||||||
|
| tooltip | A tooltip shown on the side or bottom | string |
|
||||||
| button1 | Left mouse button action | function |
|
| button1 | Left mouse button action | function |
|
||||||
| button2 | Mid mouse button action | function |
|
| button2 | Mid mouse button action | function |
|
||||||
| button3 | Right mouse button action | function |
|
| button3 | Right mouse button action | function |
|
||||||
|
|
3
bar.lua
3
bar.lua
|
@ -103,6 +103,9 @@ local function create_item(item,data)
|
||||||
item.widget = bg
|
item.widget = bg
|
||||||
tb:set_text("bob")
|
tb:set_text("bob")
|
||||||
|
|
||||||
|
-- Tooltip
|
||||||
|
item.widget:set_tooltip(item.tooltip)
|
||||||
|
|
||||||
-- Draw
|
-- Draw
|
||||||
data.item_style(data,item,false,false)
|
data.item_style(data,item,false,false)
|
||||||
item.widget:set_fg(item._private_data.fg)
|
item.widget:set_fg(item._private_data.fg)
|
||||||
|
|
3
base.lua
3
base.lua
|
@ -135,8 +135,9 @@ local function add_item(data,args)
|
||||||
sub_menu_f = (args.sub_menu and type(args.sub_menu) == "function") and args.sub_menu or nil,
|
sub_menu_f = (args.sub_menu and type(args.sub_menu) == "function") and args.sub_menu or nil,
|
||||||
selected = false,
|
selected = false,
|
||||||
checkable = args.checkable or (args.checked ~= nil) or false,
|
checkable = args.checkable or (args.checked ~= nil) or false,
|
||||||
checked = args.checked or false,
|
checked = args.checked or false,
|
||||||
underlay = args.underlay or nil,
|
underlay = args.underlay or nil,
|
||||||
|
tooltip = args.tooltip or nil,
|
||||||
},
|
},
|
||||||
force_private = {
|
force_private = {
|
||||||
visible = true,
|
visible = true,
|
||||||
|
|
|
@ -203,6 +203,7 @@ local function setup_item(data,item,args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
item.widget:buttons( util.table.join(unpack(buttons)))
|
item.widget:buttons( util.table.join(unpack(buttons)))
|
||||||
|
item.widget:set_tooltip(item.tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new(args)
|
local function new(args)
|
||||||
|
|
45
init.lua
45
init.lua
|
@ -1,14 +1,33 @@
|
||||||
|
local base = require( "wibox.widget.base" )
|
||||||
|
local tooltip = require( "radical.tooltip" )
|
||||||
|
|
||||||
|
-- Define some wibox.widget extensions
|
||||||
|
local function set_tooltip(self, text)
|
||||||
|
print("HERE",text)
|
||||||
|
if not text then return end
|
||||||
|
self._tooltip = tooltip(self,text)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Do some monkey patching to extend all wibox.widget
|
||||||
|
base._make_widget =base.make_widget
|
||||||
|
base.make_widget = function(...)
|
||||||
|
local ret = base._make_widget(...)
|
||||||
|
ret.set_tooltip = set_tooltip
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
layout = require( "radical.layout" ),
|
layout = require( "radical.layout" ),
|
||||||
object = require( "radical.object" ),
|
object = require( "radical.object" ),
|
||||||
base = require( "radical.base" ),
|
base = require( "radical.base" ),
|
||||||
radial = require( "radical.radial" ),
|
radial = require( "radical.radial" ),
|
||||||
context = require( "radical.context" ),
|
context = require( "radical.context" ),
|
||||||
embed = require( "radical.embed" ),
|
embed = require( "radical.embed" ),
|
||||||
box = require( "radical.box" ),
|
box = require( "radical.box" ),
|
||||||
bar = require( "radical.bar" ),
|
bar = require( "radical.bar" ),
|
||||||
style = require( "radical.style" ),
|
style = require( "radical.style" ),
|
||||||
item_style = require( "radical.item_style" ),
|
item_style = require( "radical.item_style" ),
|
||||||
widgets = require( "radical.widgets" ),
|
widgets = require( "radical.widgets" ),
|
||||||
tooltip = require( "radical.tooltip" )
|
tooltip = tooltip
|
||||||
}
|
}
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||||
|
|
|
@ -190,6 +190,9 @@ function module:setup_item(data,item,args)
|
||||||
icon:set_image(value)
|
icon:set_image(value)
|
||||||
end
|
end
|
||||||
item._internal.set_map.text(item._private_data.text)
|
item._internal.set_map.text(item._private_data.text)
|
||||||
|
|
||||||
|
-- Setup tooltip
|
||||||
|
item.widget:set_tooltip(item.tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get preferred item geometry
|
--Get preferred item geometry
|
||||||
|
|
|
@ -225,7 +225,7 @@ function module:setup_item(data,item,args)
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
item._internal.set_map.f_key = function(value)
|
item._internal.set_map.f_key = function(value)
|
||||||
item._internal.has_changed = true
|
item._internal.has_changed = true
|
||||||
item._internal.f_key = value
|
item._internal.f_key = value
|
||||||
|
@ -236,17 +236,20 @@ function module:setup_item(data,item,args)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
item._internal.get_map.f_key = function() return item._internal.f_key end
|
item._internal.get_map.f_key = function() return item._internal.f_key end
|
||||||
|
|
||||||
item._internal.set_map.icon = function (value)
|
item._internal.set_map.icon = function (value)
|
||||||
icon:set_image(value)
|
icon:set_image(value)
|
||||||
end
|
end
|
||||||
item._internal.set_map.text(item._private_data.text)
|
item._internal.set_map.text(item._private_data.text)
|
||||||
|
|
||||||
if data._internal.scroll_w and data.rowcount > data.max_items then
|
if data._internal.scroll_w and data.rowcount > data.max_items then
|
||||||
data._internal.scroll_w.visible = true
|
data._internal.scroll_w.visible = true
|
||||||
data._internal.scroll_w["up"]:emit_signal("widget::updated")
|
data._internal.scroll_w["up"]:emit_signal("widget::updated")
|
||||||
data._internal.scroll_w["down"]:emit_signal("widget::updated")
|
data._internal.scroll_w["down"]:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Setup tooltip
|
||||||
|
item.widget:set_tooltip(item.tooltip)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compute_geo(data)
|
local function compute_geo(data)
|
||||||
|
|
Loading…
Reference in New Issue