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,23 +17,25 @@ local module = {
}} }}
local function filter(data) local function filter(data)
local fs,visible_counter = data.filter_string:lower(),0 if not data.filter == false then
data._internal.visible_item_count = 0 local fs,visible_counter = data.filter_string:lower(),0
for k,v in pairs(data.items) do data._internal.visible_item_count = 0
local tmp = v[1]._filter_out for k,v in pairs(data.items) do
v[1]._filter_out = (v[1].text:lower():find(fs) == nil)-- or (fs ~= "") local tmp = v[1]._filter_out
if tmp ~= v[1]._filter_out then v[1]._filter_out = (v[1].text:lower():find(fs) == nil)-- or (fs ~= "")
v[1].widget:emit_signal("widget::updated") if tmp ~= v[1]._filter_out then
end v[1].widget:emit_signal("widget::updated")
if not v[1]._filter_out then end
visible_counter = visible_counter + v[1].height if not v[1]._filter_out then
data._internal.visible_item_count = data._internal.visible_item_count +1 visible_counter = visible_counter + v[1].height
v[1].f_key = data._internal.visible_item_count data._internal.visible_item_count = data._internal.visible_item_count +1
v[1].f_key = data._internal.visible_item_count
end
end end
data._total_item_height = visible_counter
local w,h = data._internal.layout:fit()
data.height = h
end end
data._total_item_height = visible_counter
local w,h = data._internal.layout:fit()
data.height = h
end end
------------------------------------KEYBOARD HANDLING----------------------------------- ------------------------------------KEYBOARD HANDLING-----------------------------------
@ -75,21 +77,8 @@ local function activateKeyboard(data)
elseif (key == 'BackSpace') and data.filter_string ~= "" and data.filter == true then elseif (key == 'BackSpace') and data.filter_string ~= "" and data.filter == true then
data.filter_string = data.filter_string:sub(1,-2) data.filter_string = data.filter_string:sub(1,-2)
filter(data) 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 elseif data.filter == true and key:len() == 1 then
data.filter_string = data.filter_string .. key:lower() 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) filter(data)
else else
data.visible = false data.visible = false
@ -147,7 +136,7 @@ local function add_item(data,args)
set_map.selected = function(value) set_map.selected = function(value)
private_data.selected = value private_data.selected = value
if value == false then 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 return
end end
if data._current_item and data._current_item ~= item then 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.visible = false
data._current_item._tmp_menu = nil data._current_item._tmp_menu = nil
data._tmp_menu = nil data._tmp_menu = nil
data.item_style(data,data._current_item,false,false)
end end
data._current_item.selected = false data._current_item.selected = false
end end
@ -242,6 +232,8 @@ local function new(args)
fg = args.fg or beautiful.menu_fg_normal or beautiful.fg_normal or "#ffffff", 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", 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", 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_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, 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, item_height = args.item_height or beautiful.menu_height or 30,
@ -261,7 +253,7 @@ local function new(args)
screen = args.screen or nil, screen = args.screen or nil,
style = args.style or nil, style = args.style or nil,
item_style = args.item_style or item_style.basic, 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, show_filter = args.show_filter or false,
filter_string = args.filter_string or "", filter_string = args.filter_string or "",
suffix_widget = args.suffix_widget or nil, 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 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 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) set_map.parent_geometry = function(value)
private_data.parent_geometry = value private_data.parent_geometry = value
if data._internal.get_direction then if data._internal.get_direction then
@ -312,6 +303,11 @@ local function new(args)
local fit_w,fit_h = data._internal.layout:fit() local fit_w,fit_h = data._internal.layout:fit()
data.width = fit_w data.width = fit_w
data.height = fit_h 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 end
if internal.has_changed and data.style then if internal.has_changed and data.style then
data.style(data,{arrow_x=20,margin=internal.margin}) data.style(data,{arrow_x=20,margin=internal.margin})

View File

@ -11,10 +11,10 @@ local module = {
} }
local function draw(data,item,is_focussed,is_pressed) 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) item.widget:set_bg(data.bg_focus)
else else
item.widget:set_bg(nil) item.widget:set_bg(nil)
end end
end end

View File

@ -41,7 +41,7 @@ local function draw(data,item,is_focussed,is_pressed,col)
alt[col][ih] = gen(ih,color(col),bc) alt[col][ih] = gen(ih,color(col),bc)
end end
if is_focussed then if is_focussed or (item._tmp_menu) then
item.widget:set_bg(focussed[ih]) item.widget:set_bg(focussed[ih])
elseif col then elseif col then
item.widget:set_bg(alt[col][ih]) 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) default [ih] = gen(ih,data.bg,bc)
end end
if is_focussed then if is_focussed or (item._tmp_menu) then
item.widget:set_bg(focussed[ih]) item.widget:set_bg(focussed[ih])
else else
item.widget:set_bg(default[ih]) 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 local constraint = mode and data.column or data.row or 2
for i=1,constraint do for i=1,constraint do
local l2 = wibox.layout.fixed[mode and "vertical" or "horizontal"]() local l2 = wibox.layout.fixed[mode and "vertical" or "horizontal"]()
print("adding",(mode and "vertical" or "horizontal"))
l:add(l2) l:add(l2)
rows[#rows+1] = l2 rows[#rows+1] = l2
end end
l.fit = function(a1,a2,a3) l.fit = function(a1,a2,a3)
local r1,r2 = data.item_height*math.ceil(data.rowcount/constraint),data.item_height*constraint 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) return (mode and r2 or r1),(mode and r1 or r2)
end end
l.add = function(l,item) l.add = function(l,item)
@ -71,8 +69,6 @@ local function new(data)
end end
local rc = data.rowcount+1 local rc = data.rowcount+1
for i=1,rc do 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)) rows[((i-1)%constraint)+1]:add((rc == i and item.widget or data.items[i][1].widget))
end end
return true return true

View File

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

View File

@ -11,7 +11,7 @@ local module = {}
local function new(data) local function new(data)
local filter_tb = wibox.widget.textbox() local filter_tb = wibox.widget.textbox()
local bg = wibox.widget.background() local bg = wibox.widget.background()
bg:set_bg(beautiful.bg_highlight) bg:set_bg(data.bg_highlight)
bg:set_widget(filter_tb) bg:set_widget(filter_tb)
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> ") filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> ")
filter_tb.fit = function(tb,width,height) 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] = wibox.widget.background()
scroll_w[v]:set_widget(ib) scroll_w[v]:set_widget(ib)
scroll_w[v].visible = true 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() 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) end)
scroll_w[v]:connect_signal("mouse::leave",function() 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) end)
scroll_w[v]:buttons( util.table.join( button({ }, 1, function() scroll_w[v]:buttons( util.table.join( button({ }, 1, function()
data["scroll_"..v](data) data["scroll_"..v](data)