|
|
|
@ -59,7 +59,7 @@ end
|
|
|
|
|
TouchMenuBar widget
|
|
|
|
|
--]]
|
|
|
|
|
TouchMenuBar = InputContainer:new{
|
|
|
|
|
height = 70 * Screen:getDPI()/167,
|
|
|
|
|
height = scaleByDPI(70),
|
|
|
|
|
width = Screen:getWidth(),
|
|
|
|
|
icons = {},
|
|
|
|
|
-- touch menu that holds the bar, used for trigger repaint on icons
|
|
|
|
@ -79,12 +79,12 @@ function TouchMenuBar:init()
|
|
|
|
|
|
|
|
|
|
local icon_sep = LineWidget:new{
|
|
|
|
|
dimen = Geom:new{
|
|
|
|
|
w = 2,
|
|
|
|
|
w = scaleByDPI(2),
|
|
|
|
|
h = self.height,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local icon_span = HorizontalSpan:new{ width = 20 }
|
|
|
|
|
local icon_span = HorizontalSpan:new{ width = scaleByDPI(20) }
|
|
|
|
|
|
|
|
|
|
-- build up image widget for menu icon bar
|
|
|
|
|
self.icon_widgets = {}
|
|
|
|
@ -113,7 +113,7 @@ function TouchMenuBar:init()
|
|
|
|
|
self.bar_sep = LineWidget:new{
|
|
|
|
|
dimen = Geom:new{
|
|
|
|
|
w = self.width,
|
|
|
|
|
h = 2,
|
|
|
|
|
h = scaleByDPI(2),
|
|
|
|
|
},
|
|
|
|
|
empty_segments = {
|
|
|
|
|
{
|
|
|
|
@ -159,12 +159,11 @@ TouchMenu widget
|
|
|
|
|
TouchMenu = InputContainer:new{
|
|
|
|
|
tab_item_table = {},
|
|
|
|
|
-- for returnning in multi-level menus
|
|
|
|
|
item_table_stack = {},
|
|
|
|
|
item_table_stack = nil,
|
|
|
|
|
item_table = nil,
|
|
|
|
|
--@TODO replace getDPI call (houqp)
|
|
|
|
|
item_height = 50 * Screen:getDPI()/167,
|
|
|
|
|
bordersize = 2 * Screen:getDPI()/167,
|
|
|
|
|
padding = 5 * Screen:getDPI()/167,
|
|
|
|
|
item_height = scaleByDPI(50),
|
|
|
|
|
bordersize = scaleByDPI(2),
|
|
|
|
|
padding = scaleByDPI(5),
|
|
|
|
|
width = Screen:getWidth(),
|
|
|
|
|
height = nil,
|
|
|
|
|
page = 1,
|
|
|
|
@ -193,6 +192,12 @@ function TouchMenu:init()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.ges_events.Swipe = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "swipe",
|
|
|
|
|
range = self.dimen,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local icons = {}
|
|
|
|
|
for _,v in ipairs(self.tab_item_table) do
|
|
|
|
@ -209,15 +214,20 @@ function TouchMenu:init()
|
|
|
|
|
align = "left",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.footer_page = TextWidget:new{
|
|
|
|
|
face = Font:getFace("ffont", 20),
|
|
|
|
|
text = "",
|
|
|
|
|
}
|
|
|
|
|
self.footer = HorizontalGroup:new{
|
|
|
|
|
IconButton:new{
|
|
|
|
|
invert = true,
|
|
|
|
|
icon_file = "resources/icons/appbar.chevron.left.png",
|
|
|
|
|
icon_file = "resources/icons/appbar.chevron.up.png",
|
|
|
|
|
show_parent = self.show_parent,
|
|
|
|
|
callback = function()
|
|
|
|
|
self:backToUpperMenu()
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
self.footer_page,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
@ -277,7 +287,7 @@ function TouchMenu:updateItems()
|
|
|
|
|
if c ~= self.perpage then
|
|
|
|
|
table.insert(self.item_group, HorizontalGroup:new{
|
|
|
|
|
-- pad with spacing
|
|
|
|
|
HorizontalSpan:new{width = 10},
|
|
|
|
|
HorizontalSpan:new{width = scaleByDPI(10)},
|
|
|
|
|
LineWidget:new{
|
|
|
|
|
style = "dashed",
|
|
|
|
|
dimen = Geom:new{
|
|
|
|
@ -297,8 +307,9 @@ function TouchMenu:updateItems()
|
|
|
|
|
end -- if i <= self.items
|
|
|
|
|
end -- for c=1, self.perpage
|
|
|
|
|
|
|
|
|
|
table.insert(self.item_group, VerticalSpan:new{width = 2})
|
|
|
|
|
table.insert(self.item_group, VerticalSpan:new{width = scaleByDPI(2)})
|
|
|
|
|
table.insert(self.item_group, self.footer)
|
|
|
|
|
self.footer_page.text = "Page "..self.page.."/"..self.page_num
|
|
|
|
|
-- FIXME: this is a dirty hack to clear previous menus
|
|
|
|
|
-- refert to issue #664
|
|
|
|
|
UIManager.repaint_all = true
|
|
|
|
@ -306,6 +317,10 @@ end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:switchMenuTab(tab_num)
|
|
|
|
|
if self.cur_tab ~= tab_num then
|
|
|
|
|
-- it's like getting a new menu everytime we switch tab!
|
|
|
|
|
self.page = 1
|
|
|
|
|
-- clear item table stack
|
|
|
|
|
self.item_table_stack = {}
|
|
|
|
|
self.cur_tab = tab_num
|
|
|
|
|
self.item_table = self.tab_item_table[tab_num]
|
|
|
|
|
self:updateItems()
|
|
|
|
@ -323,6 +338,30 @@ function TouchMenu:closeMenu()
|
|
|
|
|
self.close_callback()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:onNextPage()
|
|
|
|
|
if self.page < self.page_num then
|
|
|
|
|
self.page = self.page + 1
|
|
|
|
|
self:updateItems()
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:onPrevPage()
|
|
|
|
|
if self.page > 1 then
|
|
|
|
|
self.page = self.page - 1
|
|
|
|
|
self:updateItems()
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:onSwipe(arg, ges_ev)
|
|
|
|
|
if ges_ev.direction == "left" then
|
|
|
|
|
self:onNextPage()
|
|
|
|
|
elseif ges_ev.direction == "right" then
|
|
|
|
|
self:onPrevPage()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:onMenuSelect(item)
|
|
|
|
|
if item.sub_item_table == nil then
|
|
|
|
|
if item.callback then
|
|
|
|
|