Add separator widget

This commit is contained in:
Emmanuel Lepage Vallee 2014-01-04 18:51:07 -05:00
parent 4af6f6387b
commit 9aab9b0d3c
4 changed files with 40 additions and 6 deletions

View File

@ -40,6 +40,10 @@ The most simple kind of menus, contexts one, can be created like this:
smenu:add_item({text="item 2"})
return smenu
end})
-- To add the menu to a widget:
local mytextbox = wibox.widget.textbox()
mytextbox:set_menu(m,3) -- 3 = right mouse button, 1 = left mouse button
```
In this example, a simple 3 item menu is created with a dynamically generated
@ -47,6 +51,9 @@ submenu. Please note that generating submenus using function will generate it
every time it is being shown. For static menus, it is faster to simply create
them once and passing the submenu object to the "sub_menu" item property.
`:set_menu` can also take a lazy-loading function instead of a
menu. The second parameter is not mandatory, the default is `1`.
### Menu types
The current valid types are:
@ -95,14 +102,8 @@ On top of each styles, menu can also have different layouts to display items:
item_style = radical.item_style.classic ,
layout = radical.layout.vertical })
-- To add the menu to a widget:
local mytextbox = wibox.widget.textbox()
mytextbox:set_menu(m,3) -- 3 = right mouse button, 1 = left mouse button
```
Please note that `:set_menu` can also take a lazy-loading function instead of a
menu. The second parameter is not mandatory, the default is "1".
### Tooltip
@ -205,3 +206,4 @@ Radical also use the some of the same theme options as awful.menu, plus some:
* menu_bg_normal
* menu_bg_highlight
* menu_submenu_icon
* menu_separator_color

View File

@ -258,6 +258,7 @@ local function new(args)
bg_header = args.bg_header or beautiful.menu_bg_header or beautiful.fg_normal,
border_color = args.border_color or beautiful.menu_border_color or beautiful.border_color or "#333333",
border_width = args.border_width or beautiful.menu_border_width or beautiful.border_width or 3,
separator_color = args.separator_color or beautiful.menu_separator_color or args.border_color or beautiful.menu_border_color or beautiful.border_color or "#333333",
item_height = args.item_height or beautiful.menu_height or 30,
item_width = args.item_width or nil,
width = args.width or beautiful.menu_width or 130,

View File

@ -6,4 +6,5 @@ return {
table = require( "radical.widgets.table" ),
header = require( "radical.widgets.header" ),
piechart = require( "radical.widgets.piechart" ),
separator= require( "radical.widgets.separator"),
}

30
widgets/separator.lua Normal file
View File

@ -0,0 +1,30 @@
local setmetatable = setmetatable
local print = print
local color = require( "gears.color")
local cairo = require( "lgi" ).cairo
local wibox = require( "wibox" )
local beautiful = require( "beautiful" )
local function draw(self, w, cr, width, height)
cr:save()
cr:set_source(self._color)
cr:rectangle(5,2,width-10,1)
cr:fill()
cr:restore()
end
local function fit(box, w, h)
return w,5
end
local function new(menu)
local bg = wibox.widget.base.make_widget()
bg.fit = fit
bg._color = color( menu and menu.separator_color or beautiful.border_color or beautiful.fg_normal)
bg.draw = draw
bg._force_fit = true
return bg
end
return setmetatable({}, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;