diff --git a/README.md b/README.md index 4ac78f1..c3713ab 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/bar.lua b/bar.lua index 82334f0..4e09f2d 100644 --- a/bar.lua +++ b/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) diff --git a/base.lua b/base.lua index 15b81ad..2d6ae6d 100644 --- a/base.lua +++ b/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", diff --git a/impl/tasklist/init.lua b/impl/tasklist/init.lua index ff6a378..faa99e2 100644 --- a/impl/tasklist/init.lua +++ b/impl/tasklist/init.lua @@ -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) diff --git a/item_layout/horizontal.lua b/item_layout/horizontal.lua index 838c795..cb57c1d 100644 --- a/item_layout/horizontal.lua +++ b/item_layout/horizontal.lua @@ -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 diff --git a/item_style/arrow_prefix.lua b/item_style/arrow_prefix.lua index dcc4c56..76be4d3 100644 --- a/item_style/arrow_prefix.lua +++ b/item_style/arrow_prefix.lua @@ -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 diff --git a/item_style/arrow_single.lua b/item_style/arrow_single.lua index 3ae6b5e..ec1d64d 100644 --- a/item_style/arrow_single.lua +++ b/item_style/arrow_single.lua @@ -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 diff --git a/layout/vertical.lua b/layout/vertical.lua index c4b6ff5..b1177e2 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -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)