beatiful.theme_assets: recolor titlebar icons for `active` and `inactive` states

This commit is contained in:
Alphonse Mariya 2019-02-18 18:28:32 +01:00
parent 052f6fb89d
commit 00d38b1a2d
No known key found for this signature in database
GPG Key ID: 5771D46E051EAF79
1 changed files with 14 additions and 13 deletions

View File

@ -213,21 +213,22 @@ end
-- @tparam color color Icons' color. -- @tparam color color Icons' color.
-- @tparam string state `"normal"` or `"focus"`. -- @tparam string state `"normal"` or `"focus"`.
-- @tparam string postfix `nil`, `"hover"` or `"press"`. -- @tparam string postfix `nil`, `"hover"` or `"press"`.
-- @tparam string toggle_state `nil`, `"active"` or `"inactive"`.
-- @treturn table Beautiful theme table with the images recolored. -- @treturn table Beautiful theme table with the images recolored.
function theme_assets.recolor_titlebar(theme, color, state, postfix) function theme_assets.recolor_titlebar(theme, color, state, postfix, toggle_state)
if postfix then postfix='_'..postfix end if postfix then postfix='_'..postfix end
for _, titlebar_icon_name in ipairs({ if toggle_state then toggle_state='_'..toggle_state end
'titlebar_close_button_'..state..'', local titlebar_icon_names = toggle_state and {} or {
'titlebar_minimize_button_'..state..'', 'titlebar_close_button_'..state,
'titlebar_ontop_button_'..state..'_inactive', 'titlebar_minimize_button_'..state,
'titlebar_ontop_button_'..state..'_active', }
'titlebar_sticky_button_'..state..'_inactive', for _, ts in ipairs(toggle_state and {toggle_state} or {"_active", "_inactive"}) do
'titlebar_sticky_button_'..state..'_active', table.insert(titlebar_icon_names, 'titlebar_ontop_button_'..state..ts)
'titlebar_floating_button_'..state..'_inactive', table.insert(titlebar_icon_names, 'titlebar_sticky_button_'..state..ts)
'titlebar_floating_button_'..state..'_active', table.insert(titlebar_icon_names, 'titlebar_floating_button_'..state..ts)
'titlebar_maximized_button_'..state..'_inactive', table.insert(titlebar_icon_names, 'titlebar_maximized_button_'..state..ts)
'titlebar_maximized_button_'..state..'_active', end
}) do for _, titlebar_icon_name in ipairs(titlebar_icon_names) do
local full_name = postfix and ( local full_name = postfix and (
titlebar_icon_name .. postfix titlebar_icon_name .. postfix
) or titlebar_icon_name ) or titlebar_icon_name