Partially implement issue #8
This commit is contained in:
parent
8fa38c2a2c
commit
c0c57eff16
|
@ -180,7 +180,8 @@ Multiple items can have multiple sets of options.
|
||||||
| disable_markup | Disable pango markup in items text | boolean |
|
| disable_markup | Disable pango markup in items text | boolean |
|
||||||
| x | X position (absolute) | number |
|
| x | X position (absolute) | number |
|
||||||
| y | Y position (absolute) | number |
|
| y | Y position (absolute) | number |
|
||||||
| sub_menu_on | Show submenu on selection or when clicking | see "sub_menu_on" enum |
|
| sub_menu_on | Show submenu on selection or when clicking | see "event" enum |
|
||||||
|
| select_on | The event used to trigger item selection | see "event" enum |
|
||||||
|
|
||||||
###Item options
|
###Item options
|
||||||
|
|
||||||
|
@ -229,8 +230,8 @@ here is the list:
|
||||||
| remove | Remove the item | the item | --- |
|
| remove | Remove the item | the item | --- |
|
||||||
|
|
||||||
|
|
||||||
Menu also emit many signals, the syntax is usually `PROPERTY_NAME::changed`. The exeptions are
|
Menu also emit many signals, the syntax is usually `PROPERTY_NAME::changed`. The
|
||||||
`item::moved`, `item::swapped`, `item::removed`
|
exeptions are `item::moved`, `item::swapped`, `item::removed`
|
||||||
|
|
||||||
###Beautiful options
|
###Beautiful options
|
||||||
|
|
||||||
|
|
10
bar.lua
10
bar.lua
|
@ -82,7 +82,7 @@ local function setup_buttons(data,item,args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup sub_menu
|
-- Setup sub_menu
|
||||||
if (item.sub_menu_m or item.sub_menu_f) and data.sub_menu_on >= base.sub_menu_on.BUTTON1 and data.sub_menu_on <= base.sub_menu_on.BUTTON3 then
|
if (item.sub_menu_m or item.sub_menu_f) and data.sub_menu_on >= base.event.BUTTON1 and data.sub_menu_on <= base.event.BUTTON3 then
|
||||||
buttons[data.sub_menu_on] = item.widget:set_menu(item.sub_menu_m or item.sub_menu_f,data.sub_menu_on)
|
buttons[data.sub_menu_on] = item.widget:set_menu(item.sub_menu_m or item.sub_menu_f,data.sub_menu_on)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,8 +105,10 @@ end
|
||||||
local function setup_item(data,item,args)
|
local function setup_item(data,item,args)
|
||||||
-- Add widgets
|
-- Add widgets
|
||||||
data._internal.layout:add(item_layout(item,data,args))
|
data._internal.layout:add(item_layout(item,data,args))
|
||||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
if data.select_on == base.event.HOVER then
|
||||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||||
|
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||||
|
end
|
||||||
|
|
||||||
-- Setup buttons
|
-- Setup buttons
|
||||||
setup_buttons(data,item,args)
|
setup_buttons(data,item,args)
|
||||||
|
@ -121,7 +123,7 @@ local function new(args)
|
||||||
args.internal.setup_item = args.internal.setup_item or setup_item
|
args.internal.setup_item = args.internal.setup_item or setup_item
|
||||||
-- args.style = args.style or arrow_style
|
-- args.style = args.style or arrow_style
|
||||||
args.item_style = item_style
|
args.item_style = item_style
|
||||||
args.sub_menu_on = base.sub_menu_on.BUTTON1
|
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
||||||
local ret = base(args)
|
local ret = base(args)
|
||||||
ret:connect_signal("clear::menu",function(_,vis)
|
ret:connect_signal("clear::menu",function(_,vis)
|
||||||
ret._internal.layout:reset()
|
ret._internal.layout:reset()
|
||||||
|
|
11
base.lua
11
base.lua
|
@ -17,12 +17,14 @@ local module = {
|
||||||
PRETTY = 1,
|
PRETTY = 1,
|
||||||
CENTERED = 2,
|
CENTERED = 2,
|
||||||
},
|
},
|
||||||
sub_menu_on ={
|
event ={
|
||||||
NEVER = 0,
|
NEVER = 0,
|
||||||
BUTTON1 = 1,
|
BUTTON1 = 1,
|
||||||
BUTTON2 = 2,
|
BUTTON2 = 2,
|
||||||
BUTTON3 = 3,
|
BUTTON3 = 3,
|
||||||
SELECTED = 100,
|
SELECTED = 100,
|
||||||
|
HOVER = 1000,
|
||||||
|
LEAVE = 1001,
|
||||||
},
|
},
|
||||||
item_flags = {
|
item_flags = {
|
||||||
SELECTED = 1,
|
SELECTED = 1,
|
||||||
|
@ -101,7 +103,7 @@ local function activateKeyboard(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
||||||
if data.sub_menu_on == module.sub_menu_on.BUTTON1 then
|
if data.sub_menu_on == module.event.BUTTON1 then
|
||||||
execute_sub_menu(data,data._current_item)
|
execute_sub_menu(data,data._current_item)
|
||||||
else
|
else
|
||||||
data._current_item.button1()
|
data._current_item.button1()
|
||||||
|
@ -199,7 +201,7 @@ local function add_item(data,args)
|
||||||
end
|
end
|
||||||
data._current_item.selected = false
|
data._current_item.selected = false
|
||||||
end
|
end
|
||||||
if data.sub_menu_on == module.sub_menu_on.SELECTED and data._current_item ~= item then
|
if data.sub_menu_on == module.event.SELECTED and data._current_item ~= item then
|
||||||
execute_sub_menu(data,item)
|
execute_sub_menu(data,item)
|
||||||
end
|
end
|
||||||
data.item_style(data,item,{module.item_flags.SELECTED})
|
data.item_style(data,item,{module.item_flags.SELECTED})
|
||||||
|
@ -315,7 +317,8 @@ local function new(args)
|
||||||
disable_markup = args.disable_markup or false,
|
disable_markup = args.disable_markup or false,
|
||||||
x = args.x or 0,
|
x = args.x or 0,
|
||||||
y = args.y or 0,
|
y = args.y or 0,
|
||||||
sub_menu_on = args.sub_menu_on or module.sub_menu_on.SELECTED,
|
sub_menu_on = args.sub_menu_on or module.event.SELECTED,
|
||||||
|
select_on = args.select_on or module.event.HOVER,
|
||||||
},
|
},
|
||||||
get_map = {
|
get_map = {
|
||||||
is_menu = function() return true end,
|
is_menu = function() return true end,
|
||||||
|
|
|
@ -183,7 +183,7 @@ local function setup_buttons(data,item,args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Click to open sub_menu
|
-- Click to open sub_menu
|
||||||
if not buttons[1] and data.sub_menu_on == base.sub_menu_on.BUTTON1 then
|
if not buttons[1] and data.sub_menu_on == base.event.BUTTON1 then
|
||||||
buttons[#buttons+1] = button({},1,function() base._execute_sub_menu(data,item) end)
|
buttons[#buttons+1] = button({},1,function() base._execute_sub_menu(data,item) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ local button = require( "awful.button" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local item_layout = require("radical.item_layout.icon")
|
local item_layout = require("radical.item_layout.icon")
|
||||||
|
local base = nil
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
|
@ -51,8 +52,10 @@ end
|
||||||
|
|
||||||
local function setup_event(data,item,args)
|
local function setup_event(data,item,args)
|
||||||
--Event handling
|
--Event handling
|
||||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
if data.select_on == base.event.HOVER then
|
||||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||||
|
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||||
|
end
|
||||||
data._internal.layout:add(item)
|
data._internal.layout:add(item)
|
||||||
local buttons = {}
|
local buttons = {}
|
||||||
for i=1,10 do
|
for i=1,10 do
|
||||||
|
@ -133,6 +136,9 @@ local function item_fit(data,item,...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new(data)
|
local function new(data)
|
||||||
|
if not base then
|
||||||
|
base = require( "radical.base" )
|
||||||
|
end
|
||||||
local l = wibox.layout.fixed.horizontal()
|
local l = wibox.layout.fixed.horizontal()
|
||||||
l.fit = function(a1,a2,a3)
|
l.fit = function(a1,a2,a3)
|
||||||
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
|
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
|
||||||
|
|
|
@ -3,7 +3,8 @@ local print,ipairs = print,ipairs
|
||||||
local scroll = require( "radical.widgets.scroll" )
|
local scroll = require( "radical.widgets.scroll" )
|
||||||
local filter = require( "radical.widgets.filter" )
|
local filter = require( "radical.widgets.filter" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local cairo = require( "lgi" ).cairo
|
local cairo = require( "lgi" ).cairo
|
||||||
|
local base = nil
|
||||||
local horizontal_item_layout= require( "radical.item_layout.horizontal" )
|
local horizontal_item_layout= require( "radical.item_layout.horizontal" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
@ -123,8 +124,10 @@ function module:setup_item(data,item,args)
|
||||||
cache_pixmap(item)
|
cache_pixmap(item)
|
||||||
|
|
||||||
--Event handling
|
--Event handling
|
||||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
if data.select_on == base.event.HOVER then
|
||||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||||
|
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||||
|
end
|
||||||
data._internal.layout:add(item)
|
data._internal.layout:add(item)
|
||||||
|
|
||||||
--Be sure to always hide sub menus, even when data.visible is set manually
|
--Be sure to always hide sub menus, even when data.visible is set manually
|
||||||
|
@ -202,6 +205,9 @@ local function compute_geo(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new(data)
|
local function new(data)
|
||||||
|
if not base then
|
||||||
|
base = require( "radical.base" )
|
||||||
|
end
|
||||||
local l,real_l = wibox.layout.fixed.vertical(),nil
|
local l,real_l = wibox.layout.fixed.vertical(),nil
|
||||||
real_l = wibox.layout.fixed.vertical()
|
real_l = wibox.layout.fixed.vertical()
|
||||||
if data.max_items then
|
if data.max_items then
|
||||||
|
|
Loading…
Reference in New Issue