diff --git a/base.lua b/base.lua index 4491de1..275b111 100644 --- a/base.lua +++ b/base.lua @@ -17,23 +17,25 @@ local module = { }} local function filter(data) - local fs,visible_counter = data.filter_string:lower(),0 - data._internal.visible_item_count = 0 - for k,v in pairs(data.items) do - local tmp = v[1]._filter_out - v[1]._filter_out = (v[1].text:lower():find(fs) == nil)-- or (fs ~= "") - if tmp ~= v[1]._filter_out then - v[1].widget:emit_signal("widget::updated") - end - if not v[1]._filter_out then - visible_counter = visible_counter + v[1].height - data._internal.visible_item_count = data._internal.visible_item_count +1 - v[1].f_key = data._internal.visible_item_count + 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 + local tmp = v[1]._filter_out + v[1]._filter_out = (v[1].text:lower():find(fs) == nil)-- or (fs ~= "") + if tmp ~= v[1]._filter_out then + v[1].widget:emit_signal("widget::updated") + end + if not v[1]._filter_out then + visible_counter = visible_counter + v[1].height + data._internal.visible_item_count = data._internal.visible_item_count +1 + v[1].f_key = data._internal.visible_item_count + end end + data._total_item_height = visible_counter + local w,h = data._internal.layout:fit() + data.height = h end - data._total_item_height = visible_counter - local w,h = data._internal.layout:fit() - data.height = h 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}) diff --git a/item_style/basic.lua b/item_style/basic.lua index 4d32572..95372b0 100644 --- a/item_style/basic.lua +++ b/item_style/basic.lua @@ -11,10 +11,10 @@ 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) + item.widget:set_bg(nil) end end diff --git a/item_style/classic.lua b/item_style/classic.lua index 68524e2..d48e64c 100644 --- a/item_style/classic.lua +++ b/item_style/classic.lua @@ -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]) diff --git a/item_style/rounded.lua b/item_style/rounded.lua index fc5b24e..5b17477 100644 --- a/item_style/rounded.lua +++ b/item_style/rounded.lua @@ -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]) diff --git a/layout/grid.lua b/layout/grid.lua index 2684df0..fd6024e 100644 --- a/layout/grid.lua +++ b/layout/grid.lua @@ -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 diff --git a/layout/vertical.lua b/layout/vertical.lua index cc0bc33..8012663 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -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) diff --git a/widgets/filter.lua b/widgets/filter.lua index cb782cf..09a6b16 100644 --- a/widgets/filter.lua +++ b/widgets/filter.lua @@ -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(" ".. data.filter_prefix .." ") filter_tb.fit = function(tb,width,height) diff --git a/widgets/scroll.lua b/widgets/scroll.lua index 0c3a632..98fe6cb 100644 --- a/widgets/scroll.lua +++ b/widgets/scroll.lua @@ -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)