Add more theme options

This commit is contained in:
Emmanuel Lepage Vallee 2013-07-18 00:03:19 -04:00
parent 2ec8d4bef7
commit 576f6dd576
8 changed files with 36 additions and 45 deletions

View File

@ -17,6 +17,7 @@ local module = {
}}
local function filter(data)
if not data.filter == false then
local fs,visible_counter = data.filter_string:lower(),0
data._internal.visible_item_count = 0
for k,v in pairs(data.items) do
@ -34,6 +35,7 @@ local function filter(data)
data._total_item_height = visible_counter
local w,h = data._internal.layout:fit()
data.height = h
end
end
------------------------------------KEYBOARD HANDLING-----------------------------------
@ -75,21 +77,8 @@ local function activateKeyboard(data)
elseif (key == 'BackSpace') and data.filter_string ~= "" and data.filter == true then
data.filter_string = data.filter_string:sub(1,-2)
filter(data)
-- data:filter(data.filter_string:lower())
-- if getFilterWidget() ~= nil then
-- getFilterWidget().textbox:set_markup(getFilterWidget().textbox._layout.text:sub(1,-2))
-- end
elseif data.filter == true and key:len() == 1 then
data.filter_string = data.filter_string .. key:lower()
-- local fw = getFilterWidget()
-- if fw ~= nil then
-- fw.textbox:set_markup(fw.textbox._layout.text .. key:lower())
-- if data.settings.autoresize and fw.textbox._layout:get_pixel_extents().width > data.settings.itemWidth then
-- data.settings.itemWidth = fw.textbox._layout:get_pixel_extents().width + 40
-- data.hasChanged = true
-- data:set_coords()
-- end
-- end
filter(data)
else
data.visible = false
@ -147,7 +136,7 @@ local function add_item(data,args)
set_map.selected = function(value)
private_data.selected = value
if value == false then
data.item_style(data,item,false--[[ or (item._tmp_menu ~= nil and item._tmp_menu == data._tmp_menu)]],false)
data.item_style(data,item,false,false)
return
end
if data._current_item and data._current_item ~= item then
@ -155,6 +144,7 @@ local function add_item(data,args)
data._current_item._tmp_menu.visible = false
data._current_item._tmp_menu = nil
data._tmp_menu = nil
data.item_style(data,data._current_item,false,false)
end
data._current_item.selected = false
end
@ -242,6 +232,8 @@ local function new(args)
fg = args.fg or beautiful.menu_fg_normal or beautiful.fg_normal or "#ffffff",
bg_focus = args.bg_focus or beautiful.menu_bg_focus or beautiful.bg_focus or "#ffffff",
fg_forcus = args.fg_focus or beautiful.menu_fg_focus or beautiful.fg_focus or "#000000",
bg_alternate = args.bg_alternate or beautiful.menu_bg_alternate or beautiful.bg_alternate or beautiful.bg_normal,
bg_highlight = args.bg_highlight or beautiful.menu_bg_highlight or beautiful.bg_highlight or beautiful.bg_normal,
border_color = args.border_color or beautiful.menu_border_color or beautiful.border_color or "#333333",
border_width = args.border_width or beautiful.menu_border_width or beautiful.border_width or 3,
item_height = args.item_height or beautiful.menu_height or 30,
@ -261,7 +253,7 @@ local function new(args)
screen = args.screen or nil,
style = args.style or nil,
item_style = args.item_style or item_style.basic,
filter = args.filter or true,
filter = args.filter ~= false,
show_filter = args.show_filter or false,
filter_string = args.filter_string or "",
suffix_widget = args.suffix_widget or nil,
@ -295,7 +287,6 @@ local function new(args)
})
internal.get_map,internal.set_map,internal.private_data = get_map,set_map,private_data
data.add_item,data.add_widget,data.add_embeded_menu,data._internal = add_item,add_widget,add_embeded_menu,internal
set_map.parent_geometry = function(value)
private_data.parent_geometry = value
if data._internal.get_direction then
@ -312,6 +303,11 @@ local function new(args)
local fit_w,fit_h = data._internal.layout:fit()
data.width = fit_w
data.height = fit_h
elseif data._tmp_menu and data._current_item then
-- data._tmp_menu = nil
data._current_item._tmp_menu = nil
-- data._current_item.selected = false
data.item_style(data,data._current_item,false,false)
end
if internal.has_changed and data.style then
data.style(data,{arrow_x=20,margin=internal.margin})

View File

@ -11,7 +11,7 @@ local module = {
}
local function draw(data,item,is_focussed,is_pressed)
if is_focussed then
if is_focussed or (item._tmp_menu) then
item.widget:set_bg(data.bg_focus)
else
item.widget:set_bg(nil)

View File

@ -41,7 +41,7 @@ local function draw(data,item,is_focussed,is_pressed,col)
alt[col][ih] = gen(ih,color(col),bc)
end
if is_focussed then
if is_focussed or (item._tmp_menu) then
item.widget:set_bg(focussed[ih])
elseif col then
item.widget:set_bg(alt[col][ih])

View File

@ -42,7 +42,7 @@ local function draw(data,item,is_focussed,is_pressed)
default [ih] = gen(ih,data.bg,bc)
end
if is_focussed then
if is_focussed or (item._tmp_menu) then
item.widget:set_bg(focussed[ih])
else
item.widget:set_bg(default[ih])

View File

@ -56,13 +56,11 @@ local function new(data)
local constraint = mode and data.column or data.row or 2
for i=1,constraint do
local l2 = wibox.layout.fixed[mode and "vertical" or "horizontal"]()
print("adding",(mode and "vertical" or "horizontal"))
l:add(l2)
rows[#rows+1] = l2
end
l.fit = function(a1,a2,a3)
local r1,r2 = data.item_height*math.ceil(data.rowcount/constraint),data.item_height*constraint
print("geo",(mode and r2 or r1),(mode and r1 or r2))
return (mode and r2 or r1),(mode and r1 or r2)
end
l.add = function(l,item)
@ -71,8 +69,6 @@ local function new(data)
end
local rc = data.rowcount+1
for i=1,rc do
-- local r = math.ceil(i/math.ceil(rc/constraint))
-- if r == math.inf or r == 0 then r =1 end
rows[((i-1)%constraint)+1]:add((rc == i and item.widget or data.items[i][1].widget))
end
return true

View File

@ -23,7 +23,7 @@ local function left(data)
end
local function right(data)
if data.parent_geometry.is_menu then
if data.parent_geometry and data.parent_geometry.is_menu then
for k,v in ipairs(data.items) do
if v[1]._tmp_menu == data or v[1].sub_menu_m == data then
v[1].selected = true
@ -293,7 +293,6 @@ local function new(data)
if not data.visible then return 1,1 end
local result,r2 = wibox.layout.fixed.fit(a1,99999,99999)
local total = data._total_item_height
print("salut",compute_geo(data))
return compute_geo(data)
end
real_l.add = function(real_l,item)

View File

@ -11,7 +11,7 @@ local module = {}
local function new(data)
local filter_tb = wibox.widget.textbox()
local bg = wibox.widget.background()
bg:set_bg(beautiful.bg_highlight)
bg:set_bg(data.bg_highlight)
bg:set_widget(filter_tb)
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> ")
filter_tb.fit = function(tb,width,height)

View File

@ -59,12 +59,12 @@ local function new(data)
scroll_w[v] = wibox.widget.background()
scroll_w[v]:set_widget(ib)
scroll_w[v].visible = true
data.item_style(data,{widget=scroll_w[v]},false,false,beautiful.bg_highlight)
data.item_style(data,{widget=scroll_w[v]},false,false,data.bg_highlight)
scroll_w[v]:connect_signal("mouse::enter",function()
data.item_style(data,{widget=scroll_w[v]},false,false,beautiful.bg_alternate or beautiful.bg_focus)
data.item_style(data,{widget=scroll_w[v]},false,false,data.bg_alternate or beautiful.bg_focus)
end)
scroll_w[v]:connect_signal("mouse::leave",function()
data.item_style(data,{widget=scroll_w[v]},false,false,beautiful.bg_highlight)
data.item_style(data,{widget=scroll_w[v]},false,false,data.bg_highlight)
end)
scroll_w[v]:buttons( util.table.join( button({ }, 1, function()
data["scroll_"..v](data)