feat(menubar): expose menubar styling to beautiful (#2375)

This commit is contained in:
Yauhen Kirylau 2018-09-28 06:35:10 +02:00 committed by Emmanuel Lepage Vallée
parent bed42a10ed
commit 3931ae370c
1 changed files with 33 additions and 7 deletions

View File

@ -39,6 +39,27 @@ local function get_screen(s)
return s and capi.screen[s] return s and capi.screen[s]
end end
--- Menubar normal text color.
-- @beautiful beautiful.menubar_fg_normal
--- Menubar normal background color.
-- @beautiful beautiful.menubar_bg_normal
--- Menubar border width.
-- @beautiful beautiful.menubar_border_width
-- @tparam[opt=0] number menubar_border_width
--- Menubar border color.
-- @beautiful beautiful.menubar_border_color
--- Menubar selected item text color.
-- @beautiful beautiful.menubar_fg_normal
--- Menubar selected item background color.
-- @beautiful beautiful.menubar_bg_normal
-- menubar -- menubar
local menubar = { menu_entries = {} } local menubar = { menu_entries = {} }
menubar.menu_gen = require("menubar.menu_gen") menubar.menu_gen = require("menubar.menu_gen")
@ -115,11 +136,11 @@ end
-- @param o The menu item. -- @param o The menu item.
-- @return item name, item background color, background image, item icon. -- @return item name, item background color, background image, item icon.
local function label(o) local function label(o)
local fg_color = theme.menu_fg_normal or theme.fg_normal local fg_color = theme.menubar_fg_normal or theme.menu_fg_normal or theme.fg_normal
local bg_color = theme.menu_bg_normal or theme.bg_normal local bg_color = theme.menubar_bg_normal or theme.menu_bg_normal or theme.bg_normal
if o.focused then if o.focused then
fg_color = theme.menu_fg_focus or theme.fg_focus fg_color = theme.menubar_fg_focus or theme.menu_fg_focus or theme.fg_focus
bg_color = theme.menu_bg_focus or theme.bg_focus bg_color = theme.menubar_bg_focus or theme.menu_bg_focus or theme.bg_focus
end end
return colortext(o.name, fg_color), return colortext(o.name, fg_color),
bg_color, bg_color,
@ -399,6 +420,11 @@ end
-- @param[opt] scr Screen. -- @param[opt] scr Screen.
function menubar.show(scr) function menubar.show(scr)
scr = get_screen(scr or awful.screen.focused() or 1) scr = get_screen(scr or awful.screen.focused() or 1)
local fg_color = theme.menubar_fg_normal or theme.menu_fg_normal or theme.fg_normal
local bg_color = theme.menubar_bg_normal or theme.menu_bg_normal or theme.bg_normal
local border_width = theme.menubar_border_width or theme.menu_border_width or 0
local border_color = theme.menubar_border_color or theme.menu_border_color
if not instance then if not instance then
-- Add to each category the name of its key in all_categories -- Add to each category the name of its key in all_categories
for k, v in pairs(menubar.menu_gen.all_categories) do for k, v in pairs(menubar.menu_gen.all_categories) do
@ -409,13 +435,13 @@ function menubar.show(scr)
menubar.refresh(scr) menubar.refresh(scr)
end end
local fg_color = theme.menu_fg_normal or theme.fg_normal
local bg_color = theme.menu_bg_normal or theme.bg_normal
instance = { instance = {
wibox = wibox{ wibox = wibox{
ontop = true, ontop = true,
bg = bg_color, bg = bg_color,
fg = fg_color, fg = fg_color,
border_width = border_width,
border_color = border_color,
}, },
widget = common_args.w, widget = common_args.w,
prompt = awful.widget.prompt(), prompt = awful.widget.prompt(),
@ -440,7 +466,7 @@ function menubar.show(scr)
instance.geometry = {x = geometry.x or scrgeom.x, instance.geometry = {x = geometry.x or scrgeom.x,
y = geometry.y or scrgeom.y, y = geometry.y or scrgeom.y,
height = geometry.height or gmath.round(theme.get_font_height() * 1.5), height = geometry.height or gmath.round(theme.get_font_height() * 1.5),
width = geometry.width or scrgeom.width} width = (geometry.width or scrgeom.width) - border_width * 2}
instance.wibox:geometry(instance.geometry) instance.wibox:geometry(instance.geometry)
current_item = 1 current_item = 1