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