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 |
|
| fg | Foreground (text) color | String/gradient/pattern |
|
||||||
| bg_focus | Background of focussed items | String/gradient/pattern |
|
| bg_focus | Background of focussed items | String/gradient/pattern |
|
||||||
| fg_focus | Foreground 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_alternate | Alternate background color | String/gradient/pattern |
|
||||||
| bg_highlight | Highlight background color | String/gradient/pattern |
|
| bg_highlight | Highlight background color | String/gradient/pattern |
|
||||||
| bg_header | Header (see widgets section) 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
|
if data.select_on == base.event.HOVER then
|
||||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||||
item.widget:connect_signal("mouse::leave", function() item.selected = false 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
|
end
|
||||||
|
|
||||||
-- Setup buttons
|
-- Setup buttons
|
||||||
|
@ -126,7 +129,7 @@ local function new(args)
|
||||||
args.internal.set_position = args.internal.set_position or set_position
|
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_drawable = args.internal.setup_drawable or setup_drawable
|
||||||
args.internal.setup_item = args.internal.setup_item or setup_item
|
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
|
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)
|
||||||
|
|
27
base.lua
27
base.lua
|
@ -27,11 +27,26 @@ local module = {
|
||||||
LEAVE = 1001,
|
LEAVE = 1001,
|
||||||
},
|
},
|
||||||
item_flags = {
|
item_flags = {
|
||||||
SELECTED = 1,
|
NONE = 0,
|
||||||
HOVERED = 2,
|
SELECTED = 1, -- Single item selected
|
||||||
PRESSED = 3,
|
HOVERED = 2, -- Mouse hover
|
||||||
URGENT = 4,
|
PRESSED = 3, -- Mouse pressed
|
||||||
USED = 5,
|
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_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_header = args.bg_header or beautiful.menu_bg_header or beautiful.fg_normal,
|
||||||
bg_prefix = args.bg_prefix or nil,
|
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_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,
|
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",
|
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
|
end
|
||||||
|
|
||||||
local function new(screen)
|
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
|
-- Clear the menu and repopulate it
|
||||||
local function load_clients(t)
|
local function load_clients(t)
|
||||||
|
|
|
@ -71,6 +71,14 @@ function module:setup_checked(item,data)
|
||||||
end
|
end
|
||||||
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
|
-- Create sub_menu arrows
|
||||||
local sub_arrow = nil
|
local sub_arrow = nil
|
||||||
function module:setup_sub_menu_arrow(item,data)
|
function module:setup_sub_menu_arrow(item,data)
|
||||||
|
@ -153,6 +161,9 @@ local function create_item(item,data,args)
|
||||||
right:add(ck)
|
right:add(ck)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Hover
|
||||||
|
module:setup_hover(item,data)
|
||||||
|
|
||||||
-- Sub_arrow
|
-- Sub_arrow
|
||||||
local ar = module:setup_sub_menu_arrow(item,data)
|
local ar = module:setup_sub_menu_arrow(item,data)
|
||||||
if ar then
|
if ar then
|
||||||
|
|
|
@ -69,6 +69,8 @@ local function draw(data,item,args)
|
||||||
|
|
||||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||||
item.widget:set_bg(args.color or data.bg_focus)
|
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
|
else
|
||||||
item.widget:set_bg(args.color or nil)
|
item.widget:set_bg(args.color or nil)
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,10 @@ local function draw(data,item,args)
|
||||||
|
|
||||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||||
item.widget:set_bg(args.color or data.bg_focus)
|
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
|
else
|
||||||
item.widget:set_bg(args.color or nil)
|
item.widget:set_bg(args.color or nil)
|
||||||
end
|
end
|
||||||
|
|
|
@ -127,6 +127,9 @@ function module:setup_item(data,item,args)
|
||||||
if data.select_on == base.event.HOVER then
|
if data.select_on == base.event.HOVER then
|
||||||
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
item.widget:connect_signal("mouse::enter", function() item.selected = true end)
|
||||||
item.widget:connect_signal("mouse::leave", function() item.selected = false 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
|
end
|
||||||
data._internal.layout:add(item)
|
data._internal.layout:add(item)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue