Add support for mouse over colors
This commit is contained in:
parent
1170ac0cc4
commit
cbb39935db
|
@ -148,6 +148,8 @@ Multiple items can have multiple sets of options.
|
|||
| fg | Foreground (text) color | String/gradient/pattern |
|
||||
| bg_focus | Background of focussed items | String/gradient/pattern |
|
||||
| fg_focus | Foreground of focussed items | String/gradient/pattern |
|
||||
| bg_hover | Background of hoverred items | String/gradient/pattern |
|
||||
| fg_hover | Foreground of hoverred items | String/gradient/pattern |
|
||||
| bg_alternate | Alternate background color | String/gradient/pattern |
|
||||
| bg_highlight | Highlight background color | String/gradient/pattern |
|
||||
| bg_header | Header (see widgets section) color | String/gradient/pattern |
|
||||
|
|
5
bar.lua
5
bar.lua
|
@ -113,6 +113,9 @@ local function setup_item(data,item,args)
|
|||
if data.select_on == base.event.HOVER then
|
||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||
else
|
||||
item.widget:connect_signal("mouse::enter", function() item.hover = true end)
|
||||
item.widget:connect_signal("mouse::leave", function() item.hover = false end)
|
||||
end
|
||||
|
||||
-- Setup buttons
|
||||
|
@ -126,7 +129,7 @@ local function new(args)
|
|||
args.internal.set_position = args.internal.set_position or set_position
|
||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or setup_item
|
||||
args.item_style = item_style
|
||||
args.item_style = args.item_style or item_style
|
||||
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
||||
local ret = base(args)
|
||||
ret:connect_signal("clear::menu",function(_,vis)
|
||||
|
|
27
base.lua
27
base.lua
|
@ -27,11 +27,26 @@ local module = {
|
|||
LEAVE = 1001,
|
||||
},
|
||||
item_flags = {
|
||||
SELECTED = 1,
|
||||
HOVERED = 2,
|
||||
PRESSED = 3,
|
||||
URGENT = 4,
|
||||
USED = 5,
|
||||
NONE = 0,
|
||||
SELECTED = 1, -- Single item selected
|
||||
HOVERED = 2, -- Mouse hover
|
||||
PRESSED = 3, -- Mouse pressed
|
||||
URGENT = 4, -- Need attention
|
||||
USED = 5, -- Common flag
|
||||
DISABLED = 6, -- Cannot be interacted with
|
||||
CHECKED = 7, -- When checkbox isn't enough
|
||||
|
||||
-- Implementation defined flags
|
||||
USR1 = 101,
|
||||
USR2 = 102,
|
||||
USR3 = 103,
|
||||
USR4 = 104,
|
||||
USR5 = 105,
|
||||
USR6 = 106,
|
||||
USR7 = 107,
|
||||
USR8 = 108,
|
||||
USR9 = 109,
|
||||
USR10 = 110,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,6 +299,8 @@ local function new(args)
|
|||
bg_highlight = args.bg_highlight or beautiful.menu_bg_highlight or beautiful.bg_highlight or beautiful.bg_normal,
|
||||
bg_header = args.bg_header or beautiful.menu_bg_header or beautiful.fg_normal,
|
||||
bg_prefix = args.bg_prefix or nil,
|
||||
bg_hover = args.bg_hover or nil,
|
||||
fg_hover = args.fg_hover or nil,
|
||||
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",
|
||||
|
|
|
@ -104,7 +104,11 @@ local function focus(c)
|
|||
end
|
||||
|
||||
local function new(screen)
|
||||
local cache,menu = setmetatable({}, { __mode = 'k' }),radical.flexbar{select_on=radical.base.event.NEVER,fg=beautiful.fg_normal,bg_focus=beautiful.taglist_bg_image_selected2}
|
||||
local cache,menu = setmetatable({}, { __mode = 'k' }),radical.flexbar {
|
||||
select_on=radical.base.event.NEVER,
|
||||
fg = beautiful.fg_normal,
|
||||
bg_focus = beautiful.taglist_bg_image_selected2 or beautiful.bg_focus
|
||||
}
|
||||
|
||||
-- Clear the menu and repopulate it
|
||||
local function load_clients(t)
|
||||
|
|
|
@ -71,6 +71,14 @@ function module:setup_checked(item,data)
|
|||
end
|
||||
end
|
||||
|
||||
-- Setup hover
|
||||
function module:setup_hover(item,data)
|
||||
item._internal.set_map.hover = function(value)
|
||||
local item_style = item.item_style or data.item_style
|
||||
item_style(data,item,{value and 2--[[HOVER]] or nil,item.selected and 1 or nil})
|
||||
end
|
||||
end
|
||||
|
||||
-- Create sub_menu arrows
|
||||
local sub_arrow = nil
|
||||
function module:setup_sub_menu_arrow(item,data)
|
||||
|
@ -153,6 +161,9 @@ local function create_item(item,data,args)
|
|||
right:add(ck)
|
||||
end
|
||||
|
||||
-- Hover
|
||||
module:setup_hover(item,data)
|
||||
|
||||
-- Sub_arrow
|
||||
local ar = module:setup_sub_menu_arrow(item,data)
|
||||
if ar then
|
||||
|
|
|
@ -69,6 +69,8 @@ local function draw(data,item,args)
|
|||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(args.color or data.bg_focus)
|
||||
elseif flags[base.item_flags.HOVERED] then
|
||||
item.widget:set_bg(args.color or data.bg_hover)
|
||||
else
|
||||
item.widget:set_bg(args.color or nil)
|
||||
end
|
||||
|
|
|
@ -40,6 +40,10 @@ local function draw(data,item,args)
|
|||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(args.color or data.bg_focus)
|
||||
elseif #flags > 0 then
|
||||
if flags[base.item_flags.HOVERED] then
|
||||
item.widget:set_bg(args.color or data.bg_hover)
|
||||
end
|
||||
else
|
||||
item.widget:set_bg(args.color or nil)
|
||||
end
|
||||
|
|
|
@ -127,6 +127,9 @@ function module:setup_item(data,item,args)
|
|||
if data.select_on == base.event.HOVER then
|
||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||
item.widget:connect_signal("mouse::leave", function() item.selected = false end)
|
||||
else
|
||||
item.widget:connect_signal("mouse::enter", function() item.hover = true end)
|
||||
item.widget:connect_signal("mouse::leave", function() item.hover = false end)
|
||||
end
|
||||
data._internal.layout:add(item)
|
||||
|
||||
|
|
Loading…
Reference in New Issue