Fix issue #7
This commit is contained in:
parent
fd835fdbeb
commit
9148c48dd1
20
base.lua
20
base.lua
|
@ -172,6 +172,7 @@ local function add_item(data,args)
|
|||
item_layout = args.item_layout or nil ,
|
||||
selected = false ,
|
||||
overlay = args.overlay or data.overlay or nil ,
|
||||
state = {} ,
|
||||
},
|
||||
force_private = {
|
||||
visible = true,
|
||||
|
@ -211,19 +212,22 @@ local function add_item(data,args)
|
|||
data.item_style(data,item,{})
|
||||
return
|
||||
end
|
||||
if data._current_item and data._current_item ~= item then
|
||||
if data._current_item._tmp_menu then
|
||||
data._current_item._tmp_menu.visible = false
|
||||
data._current_item._tmp_menu = nil
|
||||
local current_item = data._current_item
|
||||
if current_item and current_item ~= item then
|
||||
current_item.state[module.item_flags.SELECTED] = nil
|
||||
if current_item._tmp_menu then
|
||||
current_item._tmp_menu.visible = false
|
||||
current_item._tmp_menu = nil
|
||||
data._tmp_menu = nil
|
||||
data.item_style(data,data._current_item,{})
|
||||
end
|
||||
data._current_item.selected = false
|
||||
data.item_style(data,current_item,{})
|
||||
current_item.selected = false
|
||||
end
|
||||
if data.sub_menu_on == module.event.SELECTED and data._current_item ~= item then
|
||||
if data.sub_menu_on == module.event.SELECTED and current_item ~= item then
|
||||
execute_sub_menu(data,item)
|
||||
end
|
||||
data.item_style(data,item,{module.item_flags.SELECTED})
|
||||
item.state[module.item_flags.SELECTED] = true
|
||||
data.item_style(data,item,{})
|
||||
data._current_item = item
|
||||
end
|
||||
if args.selected == true then
|
||||
|
|
|
@ -86,6 +86,7 @@ end
|
|||
function module:setup_hover(item,data)
|
||||
item._internal.set_map.hover = function(value)
|
||||
local item_style = item.item_style or data.item_style
|
||||
item.state[2] = value and true or nil
|
||||
item_style(data,item,{value and 2--[[HOVER]] or nil,item.selected and 1 or nil})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -102,8 +102,7 @@ local function get_prev(data,item)
|
|||
end
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
local args = args or {}
|
||||
if item.widget.draw ~= draw_real then
|
||||
item.widget.draw = draw_real
|
||||
item.widget:emit_signal("widget::updated")
|
||||
|
@ -115,8 +114,10 @@ local function draw(data,item,args)
|
|||
local prev_color = item.widget.next_color
|
||||
item.widget.next_color = hcode[next_idx]
|
||||
|
||||
local state = item.state or {}
|
||||
|
||||
local prev_item = get_prev(data,item)
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
if prev_item and prev_item.widget.next_color ~= (args.color or data.bg_focus) then
|
||||
prev_item.widget.next_color = args.color or data.bg_focus
|
||||
prev_item.widget:emit_signal("widget::updated")
|
||||
|
|
|
@ -54,8 +54,7 @@ local function widget_draw(self, w, cr, width, height)
|
|||
end
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
local args = args or {}
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._drawprefix = item.widget.draw
|
||||
|
@ -81,9 +80,11 @@ local function draw(data,item,args)
|
|||
item._internal.align.third.draw = suffix_draw
|
||||
end
|
||||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
local state = item.state or {}
|
||||
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(args.color or data.bg_focus)
|
||||
elseif flags[base.item_flags.HOVERED] then
|
||||
elseif state[base.item_flags.HOVERED] then
|
||||
item.widget:set_bg(args.color or data.bg_hover)
|
||||
else
|
||||
item.widget:set_bg(args.color or nil)
|
||||
|
|
|
@ -37,14 +37,15 @@ end
|
|||
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
local args = args or {}
|
||||
|
||||
item.widget.draw = suffix_draw
|
||||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
local state = item.state or {}
|
||||
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(args.color or data.bg_focus)
|
||||
elseif flags[base.item_flags.HOVERED] then
|
||||
elseif state[base.item_flags.HOVERED] then
|
||||
item.widget:set_bg(args.color or data.bg_hover)
|
||||
else
|
||||
item.widget:set_bg(args.color or nil)
|
||||
|
|
|
@ -21,8 +21,7 @@ local function widget_draw23(self, w, cr, width, height)
|
|||
end
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
local args = args or {}
|
||||
|
||||
if not item.widget._overlay_init and not item.widget._draw then
|
||||
item.widget.__drawbasic = item.widget.draw
|
||||
|
@ -30,8 +29,9 @@ local function draw(data,item,args)
|
|||
item.widget._overlay_init = true
|
||||
end
|
||||
|
||||
local state = item.state or {}
|
||||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(args.color or data.bg_focus)
|
||||
else
|
||||
item.widget:set_bg(args.color or nil)
|
||||
|
|
|
@ -36,9 +36,8 @@ local function widget_draw(self, w, cr, width, height)
|
|||
end
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
local args = args or {}
|
||||
local col = args.color
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._draw2 = item.widget.draw
|
||||
|
@ -60,7 +59,9 @@ local function draw(data,item,args)
|
|||
alt[col][ih] = gen(ih,color(col),bc)
|
||||
end
|
||||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
local state = item.state or {}
|
||||
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(focussed[ih])
|
||||
elseif col then
|
||||
item.widget:set_bg(alt[col][ih])
|
||||
|
|
|
@ -41,8 +41,7 @@ local function widget_draw(self, w, cr, width, height)
|
|||
end
|
||||
|
||||
local function draw(data,item,args)
|
||||
local args,flags = args or {},{}
|
||||
for _,v in pairs(args) do flags[v] = true end
|
||||
local args = args or {}
|
||||
|
||||
if not item.widget._overlay_init then
|
||||
item.widget._drawrounded = item.widget.draw
|
||||
|
@ -60,7 +59,9 @@ local function draw(data,item,args)
|
|||
default [ih] = gen(ih,data.bg,bc)
|
||||
end
|
||||
|
||||
if flags[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
local state = item.state or {}
|
||||
|
||||
if state[base.item_flags.SELECTED] or (item._tmp_menu) then
|
||||
item.widget:set_bg(focussed[ih])
|
||||
else
|
||||
item.widget:set_bg(default[ih])
|
||||
|
|
Loading…
Reference in New Issue