Fil multiple minor issues related to fg and underlay colors

This commit is contained in:
Emmanuel Lepage Vallee 2014-03-13 01:14:52 -04:00
parent 5d21035698
commit 2c9bd9107f
8 changed files with 22 additions and 10 deletions

View File

@ -34,7 +34,7 @@ local module = {
URGENT = 2 , -- Need attention URGENT = 2 , -- Need attention
SELECTED = 3 , -- Single item selected [[FOCUS]] SELECTED = 3 , -- Single item selected [[FOCUS]]
PRESSED = 4 , -- Mouse pressed PRESSED = 4 , -- Mouse pressed
HOVERED = 5 , -- Mouse hover HOVERED = -1 , -- Mouse hover
CHANGED = 6 , -- The item changed, need attention CHANGED = 6 , -- The item changed, need attention
USED = 7 , -- Common flag USED = 7 , -- Common flag
CHECKED = 8 , -- When checkbox isn't enough CHECKED = 8 , -- When checkbox isn't enough

View File

@ -25,7 +25,7 @@ local module = {
DISABLED = 1 , -- Cannot be interacted with DISABLED = 1 , -- Cannot be interacted with
URGENT = 2 , -- Need attention URGENT = 2 , -- Need attention
SELECTED = 3 , -- Single item selected [[FOCUS]] SELECTED = 3 , -- Single item selected [[FOCUS]]
HOVERED = 5 , -- Mouse hover HOVERED = -1 , -- Mouse hover
PRESSED = 4 , -- Mouse pressed PRESSED = 4 , -- Mouse pressed
USED = 6 , -- Common flag USED = 6 , -- Common flag
CHECKED = 7 , -- When checkbox isn't enough CHECKED = 7 , -- When checkbox isn't enough

View File

@ -6,6 +6,7 @@ local wibox = require( "wibox" )
local checkbox = require( "radical.widgets.checkbox" ) local checkbox = require( "radical.widgets.checkbox" )
local fkey = require( "radical.widgets.fkey" ) 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 = {} local module = {}
@ -27,7 +28,10 @@ end
-- Like an overlay, but under -- Like an overlay, but under
function module.paint_underlay(data,item,cr,width,height) function module.paint_underlay(data,item,cr,width,height)
cr:save() 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:set_source_surface(udl,width-udl:get_width()-3)
cr:paint_with_alpha(data.underlay_alpha) cr:paint_with_alpha(data.underlay_alpha)
cr:restore() cr:restore()
@ -86,7 +90,7 @@ end
function module:setup_hover(item,data) function module:setup_hover(item,data)
item.set_hover = function(_,value) item.set_hover = function(_,value)
local item_style = item.item_style or data.item_style 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,{}) item_style(item,{})
end end
end end

View File

@ -52,7 +52,7 @@ local function draw(item,args)
item.widget:set_fg( item["fg_"..state_name]) item.widget:set_fg( item["fg_"..state_name])
else else
item.widget:set_bg(args.color or nil) item.widget:set_bg(args.color or nil)
-- item.widget:set_fg(item["fg"]) item.widget:set_fg(item["fg"])
end end
end end

View File

@ -41,7 +41,7 @@ local function draw(item,args)
item.widget:set_fg( item["fg_"..state_name]) item.widget:set_fg( item["fg_"..state_name])
else else
item.widget:set_bg(args.color or nil) 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
end end

View File

@ -71,7 +71,7 @@ local function draw(item,args)
item.widget:set_fg(item["fg_"..state_name]) item.widget:set_fg(item["fg_"..state_name])
else else
item.widget:set_bg(default[ih]) item.widget:set_bg(default[ih])
-- item.widget:set_fg(item["fg_normal"]) item.widget:set_fg(item["fg"])
end end
end end

View File

@ -20,9 +20,15 @@ local function change_data(tab, key,value)
end end
end end
rawset(tab,"_current_key",win ~= math.huge and win or nil) 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() tab._item:style()
elseif value and (rawget(tab,"_current_key") or math.huge) > key then elseif value and (rawget(tab,"_current_key") or math.huge) > key then
rawset(tab,"_current_key",key) 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() tab._item:style()
end end
tab._real_table[key] = value tab._real_table[key] = value
@ -43,6 +49,7 @@ function module.setup_colors(data,args)
for k,v in pairs(theme_colors) do 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["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["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
end end
@ -54,14 +61,14 @@ function module.setup_item_colors(data,item,args)
priv["fg_"..k] = args["fg_"..k] priv["fg_"..k] = args["fg_"..k]
else else
rawset(item,"get_fg_"..k,function() rawset(item,"get_fg_"..k,function()
return data["fg_"..k] return priv["fg_"..k] or data["fg_"..k]
end) end)
end end
if args["bg_"..k] then if args["bg_"..k] then
priv["bg_"..k] = args["bg_"..k] priv["bg_"..k] = args["bg_"..k]
else else
rawset(item,"get_bg_"..k, function() rawset(item,"get_bg_"..k, function()
return data["bg_"..k] return priv["bg_"..k] or data["bg_"..k]
end) end)
end end
end end

View File

@ -64,6 +64,7 @@ function module.draw(text,args)
desc:set_family("Verdana") desc:set_family("Verdana")
desc:set_weight(pango.Weight.BOLD) desc:set_weight(pango.Weight.BOLD)
desc:set_size((height-padding*2) * pango.SCALE) desc:set_size((height-padding*2) * pango.SCALE)
-- desc:set_variant(pango.Variant.SMALL_CAPS)
pango_l[height]:set_font_description(desc) pango_l[height]:set_font_description(desc)
end end