Merge pull request #1901 from actionless/xresources-titlebar-hover-press
feat(beatiful: theme_assets; themes: xresources): recolor titlebar icons for `hover` and `press` states
This commit is contained in:
commit
bb26c32726
|
@ -12,7 +12,7 @@ env:
|
|||
matrix:
|
||||
- LUA=5.2 LUANAME=lua5.2 DO_COVERAGE=coveralls
|
||||
# Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it.
|
||||
- LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov
|
||||
- LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov AWESOME_THEME=xresources
|
||||
# luajit: installed from source.
|
||||
- LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.5 TEST_PREV_COMMITS=1
|
||||
# Note: luarocks does not work with Lua 5.0.
|
||||
|
@ -148,6 +148,10 @@ install:
|
|||
}
|
||||
script:
|
||||
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true"
|
||||
- |
|
||||
if [ ! -z "$AWESOME_THEME" ]; then
|
||||
sed awesomerc.lua -i -e "s/default\/theme/$AWESOME_THEME\/theme/g"
|
||||
fi
|
||||
- |
|
||||
if [ "$DO_COVERAGE" = "codecov" ]; then
|
||||
export CXXFLAGS="-fprofile-arcs -ftest-coverage"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
----------------------------------------------------------------------------
|
||||
|
||||
local cairo = require("lgi").cairo
|
||||
local surface = require("gears.surface")
|
||||
local gears_color = require("gears.color")
|
||||
local recolor_image = gears_color.recolor_image
|
||||
local screen = screen
|
||||
|
@ -207,48 +208,57 @@ function theme_assets.wallpaper(bg, fg, alt_fg, s)
|
|||
return img
|
||||
end
|
||||
|
||||
--- Recolor unfocused titlebar icons.
|
||||
-- @tparam table theme Beautiful theme table
|
||||
--- Recolor titlebar icons.
|
||||
-- @tparam table theme Beautiful theme table.
|
||||
-- @tparam color color Icons' color.
|
||||
-- @tparam string state `"normal"` or `"focus"`.
|
||||
-- @tparam string postfix `nil`, `"hover"` or `"press"`.
|
||||
-- @treturn table Beautiful theme table with the images recolored.
|
||||
function theme_assets.recolor_titlebar_normal(theme, color)
|
||||
for _, titlebar_icon in ipairs({
|
||||
'titlebar_close_button_normal',
|
||||
'titlebar_minimize_button_normal',
|
||||
'titlebar_ontop_button_normal_inactive',
|
||||
'titlebar_ontop_button_normal_active',
|
||||
'titlebar_sticky_button_normal_inactive',
|
||||
'titlebar_sticky_button_normal_active',
|
||||
'titlebar_floating_button_normal_inactive',
|
||||
'titlebar_floating_button_normal_active',
|
||||
'titlebar_maximized_button_normal_inactive',
|
||||
'titlebar_maximized_button_normal_active',
|
||||
function theme_assets.recolor_titlebar(theme, color, state, postfix)
|
||||
if postfix then postfix='_'..postfix end
|
||||
for _, titlebar_icon_name in ipairs({
|
||||
'titlebar_close_button_'..state..'',
|
||||
'titlebar_minimize_button_'..state..'',
|
||||
'titlebar_ontop_button_'..state..'_inactive',
|
||||
'titlebar_ontop_button_'..state..'_active',
|
||||
'titlebar_sticky_button_'..state..'_inactive',
|
||||
'titlebar_sticky_button_'..state..'_active',
|
||||
'titlebar_floating_button_'..state..'_inactive',
|
||||
'titlebar_floating_button_'..state..'_active',
|
||||
'titlebar_maximized_button_'..state..'_inactive',
|
||||
'titlebar_maximized_button_'..state..'_active',
|
||||
}) do
|
||||
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], color)
|
||||
local full_name = postfix and (
|
||||
titlebar_icon_name .. postfix
|
||||
) or titlebar_icon_name
|
||||
local image = theme[full_name] or theme[titlebar_icon_name]
|
||||
if image then
|
||||
image = surface.duplicate_surface(image)
|
||||
theme[full_name] = recolor_image(image, color)
|
||||
end
|
||||
end
|
||||
return theme
|
||||
end
|
||||
|
||||
--- Recolor focused titlebar icons.
|
||||
|
||||
--- Recolor unfocused titlebar icons.
|
||||
-- This method is deprecated. Use a `beautiful.theme_assets.recolor_titlebar`.
|
||||
-- @tparam table theme Beautiful theme table
|
||||
-- @tparam color color Icons' color.
|
||||
-- @treturn table Beautiful theme table with the images recolored.
|
||||
-- @deprecated recolor_titlebar_normal
|
||||
function theme_assets.recolor_titlebar_normal(theme, color)
|
||||
return theme_assets.recolor_titlebar(theme, color, "normal")
|
||||
end
|
||||
|
||||
--- Recolor focused titlebar icons.
|
||||
-- This method is deprecated. Use a `beautiful.theme_assets.recolor_titlebar`.
|
||||
-- @tparam table theme Beautiful theme table
|
||||
-- @tparam color color Icons' color.
|
||||
-- @treturn table Beautiful theme table with the images recolored.
|
||||
-- @deprecated recolor_titlebar_focus
|
||||
function theme_assets.recolor_titlebar_focus(theme, color)
|
||||
for _, titlebar_icon in ipairs({
|
||||
'titlebar_close_button_focus',
|
||||
'titlebar_minimize_button_focus',
|
||||
'titlebar_ontop_button_focus_inactive',
|
||||
'titlebar_ontop_button_focus_active',
|
||||
'titlebar_sticky_button_focus_inactive',
|
||||
'titlebar_sticky_button_focus_active',
|
||||
'titlebar_floating_button_focus_inactive',
|
||||
'titlebar_floating_button_focus_active',
|
||||
'titlebar_maximized_button_focus_inactive',
|
||||
'titlebar_maximized_button_focus_active',
|
||||
}) do
|
||||
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], color)
|
||||
end
|
||||
return theme
|
||||
return theme_assets.recolor_titlebar(theme, color, "focus")
|
||||
end
|
||||
|
||||
--- Recolor layout icons.
|
||||
|
|
|
@ -47,10 +47,11 @@ local steps = {
|
|||
-- Everything should be done by now
|
||||
local geom = test_client2:geometry()
|
||||
local bw = test_client2.border_width
|
||||
assert(geom.x == 100, geom.x)
|
||||
assert(geom.y == 110, geom.y)
|
||||
assert(geom.width + 2*bw == 600, geom.width + 2*bw)
|
||||
assert(geom.height + 2*bw == 610, geom.height + 2*bw)
|
||||
local ug = test_client2:tags()[1].gap
|
||||
assert(geom.x - 2*ug == 100, geom.x - 2*ug)
|
||||
assert(geom.y - 2*ug == 110, geom.y - 2*ug)
|
||||
assert(geom.width + 2*bw + 4*ug == 600, geom.width + 2*bw + 4*ug)
|
||||
assert(geom.height + 2*bw + 4*ug == 610, geom.height + 2*bw + 4*ug)
|
||||
|
||||
local wb = fake_screen.mywibox
|
||||
assert(wb.screen == fake_screen, tostring(wb.screen) .. " ~= " .. tostring(fake_screen))
|
||||
|
|
|
@ -59,11 +59,40 @@ theme.menu_width = dpi(100)
|
|||
-- beautiful.variable in your rc.lua
|
||||
--theme.bg_widget = "#cc0000"
|
||||
|
||||
-- Recolor titlebar icons:
|
||||
theme = theme_assets.recolor_titlebar_normal(theme, theme.fg_normal)
|
||||
theme = theme_assets.recolor_titlebar_focus(theme, theme.fg_focus)
|
||||
-- Recolor Layout icons:
|
||||
theme = theme_assets.recolor_layout(theme, theme.fg_normal)
|
||||
|
||||
-- Recolor titlebar icons:
|
||||
--
|
||||
local function darker(color_value, darker_n)
|
||||
local result = "#"
|
||||
for s in color_value:gmatch("[a-fA-F0-9][a-fA-F0-9]") do
|
||||
local bg_numeric_value = tonumber("0x"..s) - darker_n
|
||||
if bg_numeric_value < 0 then bg_numeric_value = 0 end
|
||||
if bg_numeric_value > 255 then bg_numeric_value = 255 end
|
||||
result = result .. string.format("%2.2x", bg_numeric_value)
|
||||
end
|
||||
return result
|
||||
end
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, theme.fg_normal, "normal"
|
||||
)
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, darker(theme.fg_normal, -60), "normal", "hover"
|
||||
)
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, xrdb.color1, "normal", "press"
|
||||
)
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, theme.fg_focus, "focus"
|
||||
)
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, darker(theme.fg_focus, -60), "focus", "hover"
|
||||
)
|
||||
theme = theme_assets.recolor_titlebar(
|
||||
theme, xrdb.color1, "focus", "press"
|
||||
)
|
||||
|
||||
-- Define the icon theme for application icons. If not set then the icons
|
||||
-- from /usr/share/icons and /usr/share/icons/hicolor will be used.
|
||||
theme.icon_theme = nil
|
||||
|
|
Loading…
Reference in New Issue