From 2c9bd9107fa943275b8210b286d45c19d76a6dd6 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 13 Mar 2014 01:14:52 -0400 Subject: [PATCH] Fil multiple minor issues related to fg and underlay colors --- base.lua | 2 +- item/init.lua | 2 +- item/layout/horizontal.lua | 10 +++++++--- item/style/arrow_single.lua | 2 +- item/style/basic.lua | 2 +- item/style/classic.lua | 2 +- theme/init.lua | 11 +++++++++-- widgets/underlay.lua | 1 + 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/base.lua b/base.lua index c770ebe..b9fcb74 100644 --- a/base.lua +++ b/base.lua @@ -34,7 +34,7 @@ local module = { URGENT = 2 , -- Need attention SELECTED = 3 , -- Single item selected [[FOCUS]] PRESSED = 4 , -- Mouse pressed - HOVERED = 5 , -- Mouse hover + HOVERED = -1 , -- Mouse hover CHANGED = 6 , -- The item changed, need attention USED = 7 , -- Common flag CHECKED = 8 , -- When checkbox isn't enough diff --git a/item/init.lua b/item/init.lua index 21b7f42..4b4854d 100644 --- a/item/init.lua +++ b/item/init.lua @@ -25,7 +25,7 @@ local module = { DISABLED = 1 , -- Cannot be interacted with URGENT = 2 , -- Need attention SELECTED = 3 , -- Single item selected [[FOCUS]] - HOVERED = 5 , -- Mouse hover + HOVERED = -1 , -- Mouse hover PRESSED = 4 , -- Mouse pressed USED = 6 , -- Common flag CHECKED = 7 , -- When checkbox isn't enough diff --git a/item/layout/horizontal.lua b/item/layout/horizontal.lua index efda9c2..b1d2e41 100644 --- a/item/layout/horizontal.lua +++ b/item/layout/horizontal.lua @@ -5,7 +5,8 @@ local cairo = require( "lgi" ).cairo local wibox = require( "wibox" ) local checkbox = require( "radical.widgets.checkbox" ) local fkey = require( "radical.widgets.fkey" ) -local underlay = require( "radical.widgets.underlay" ) +local underlay = require( "radical.widgets.underlay" ) +local theme = require( "radical.theme" ) local module = {} @@ -27,7 +28,10 @@ end -- Like an overlay, but under function module.paint_underlay(data,item,cr,width,height) cr:save() - local udl = underlay.draw(item.underlay,{style=data.underlay_style,height=height}) + local state = item.state or {} + local current_state = state._current_key or nil + local state_name = theme.colors_by_id[current_state] or "" + local udl = underlay.draw(item.underlay,{style=data.underlay_style,height=height,bg=data["underlay_bg_"..state_name]}) cr:set_source_surface(udl,width-udl:get_width()-3) cr:paint_with_alpha(data.underlay_alpha) cr:restore() @@ -86,7 +90,7 @@ end function module:setup_hover(item,data) item.set_hover = function(_,value) local item_style = item.item_style or data.item_style - item.state[5] = value and true or nil + item.state[-1] = value and true or nil item_style(item,{}) end end diff --git a/item/style/arrow_single.lua b/item/style/arrow_single.lua index 7d06825..475efb4 100644 --- a/item/style/arrow_single.lua +++ b/item/style/arrow_single.lua @@ -52,7 +52,7 @@ local function draw(item,args) item.widget:set_fg( item["fg_"..state_name]) else item.widget:set_bg(args.color or nil) --- item.widget:set_fg(item["fg"]) + item.widget:set_fg(item["fg"]) end end diff --git a/item/style/basic.lua b/item/style/basic.lua index c7239ee..62973bb 100644 --- a/item/style/basic.lua +++ b/item/style/basic.lua @@ -41,7 +41,7 @@ local function draw(item,args) item.widget:set_fg( item["fg_"..state_name]) else item.widget:set_bg(args.color or nil) --- item.widget:set_fg(item["fg_normal"] or data["fg_normal"]) + item.widget:set_fg(item["fg"]) end end diff --git a/item/style/classic.lua b/item/style/classic.lua index 694f19b..cc3a786 100644 --- a/item/style/classic.lua +++ b/item/style/classic.lua @@ -71,7 +71,7 @@ local function draw(item,args) item.widget:set_fg(item["fg_"..state_name]) else item.widget:set_bg(default[ih]) --- item.widget:set_fg(item["fg_normal"]) + item.widget:set_fg(item["fg"]) end end diff --git a/theme/init.lua b/theme/init.lua index c7c73bb..8323b0b 100644 --- a/theme/init.lua +++ b/theme/init.lua @@ -20,9 +20,15 @@ local function change_data(tab, key,value) end end rawset(tab,"_current_key",win ~= math.huge and win or nil) + if tab._item._internal.text_w and tab._item._internal.text_w.cache then + tab._item._internal.text_w.cache = {} + end tab._item:style() elseif value and (rawget(tab,"_current_key") or math.huge) > key then rawset(tab,"_current_key",key) + if tab._item._internal.text_w and tab._item._internal.text_w.cache then + tab._item._internal.text_w.cache = {} + end tab._item:style() end tab._real_table[key] = value @@ -43,6 +49,7 @@ function module.setup_colors(data,args) for k,v in pairs(theme_colors) do priv["fg_"..k] = args["fg_"..k] or beautiful["menu_fg_"..v.beautiful_name] or beautiful["fg_"..v.beautiful_name] or (v.fallback and beautiful.fg_normal) priv["bg_"..k] = args["bg_"..k] or beautiful["menu_bg_"..v.beautiful_name] or beautiful["bg_"..v.beautiful_name] or (v.fallback and beautiful.bg_normal) + priv["underlay_bg_"..k] = args["underlay_bg_"..k] or beautiful["menu_underlay_bg_"..v.beautiful_name] or beautiful["underlay_bg_"..v.beautiful_name] end end @@ -54,14 +61,14 @@ function module.setup_item_colors(data,item,args) priv["fg_"..k] = args["fg_"..k] else rawset(item,"get_fg_"..k,function() - return data["fg_"..k] + return priv["fg_"..k] or data["fg_"..k] end) end if args["bg_"..k] then priv["bg_"..k] = args["bg_"..k] else rawset(item,"get_bg_"..k, function() - return data["bg_"..k] + return priv["bg_"..k] or data["bg_"..k] end) end end diff --git a/widgets/underlay.lua b/widgets/underlay.lua index 58a478f..0a8116a 100644 --- a/widgets/underlay.lua +++ b/widgets/underlay.lua @@ -64,6 +64,7 @@ function module.draw(text,args) desc:set_family("Verdana") desc:set_weight(pango.Weight.BOLD) desc:set_size((height-padding*2) * pango.SCALE) +-- desc:set_variant(pango.Variant.SMALL_CAPS) pango_l[height]:set_font_description(desc) end