mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
add go back button to touchmenu
This commit is contained in:
@@ -65,14 +65,22 @@ function ReaderMenu:onShowMenu()
|
||||
self:setUpdateItemTable()
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
name = "haha",
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
local main_menu = nil
|
||||
if Device:isTouchDevice() then
|
||||
main_menu = TouchMenu:new{
|
||||
name = "wocao",
|
||||
tab_item_table = {
|
||||
self.tab_item_table.navi,
|
||||
self.tab_item_table.typeset,
|
||||
self.tab_item_table.main,
|
||||
},
|
||||
parent = menu_container,
|
||||
}
|
||||
else
|
||||
main_menu = Menu:new{
|
||||
@@ -88,19 +96,13 @@ function ReaderMenu:onShowMenu()
|
||||
end
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
main_menu,
|
||||
}
|
||||
|
||||
main_menu.parent = menu_container
|
||||
main_menu.close_callback = function ()
|
||||
UIManager:close(menu_container)
|
||||
end
|
||||
|
||||
menu_container[1] = main_menu
|
||||
-- maintain a reference to menu_container
|
||||
self.menu_container = menu_container
|
||||
|
||||
UIManager:show(menu_container)
|
||||
|
||||
return true
|
||||
|
||||
@@ -40,11 +40,12 @@ end
|
||||
function IconButton:onTapClickButton()
|
||||
self.image.invert = true
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
-- make sure button reacts before doing callback
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.callback()
|
||||
self.image.invert = false
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
end)
|
||||
self.callback()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -205,13 +205,28 @@ function TouchMenu:init()
|
||||
menu = self,
|
||||
}
|
||||
|
||||
self.item_group = VerticalGroup:new{}
|
||||
self.item_group = VerticalGroup:new{
|
||||
align = "left",
|
||||
}
|
||||
|
||||
self.footer = HorizontalGroup:new{
|
||||
IconButton:new{
|
||||
invert = true,
|
||||
icon_file = "resources/icons/appbar.chevron.left.png",
|
||||
parent = self.parent,
|
||||
callback = function()
|
||||
self:backToUpperMenu()
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
self[1] = FrameContainer:new{
|
||||
padding = self.padding,
|
||||
bordersize = self.bordersize,
|
||||
background = 0,
|
||||
self.item_group
|
||||
-- menubar and footer will be inserted in
|
||||
-- item_group in updateItems
|
||||
self.item_group,
|
||||
}
|
||||
|
||||
self:switchMenuTab(1)
|
||||
@@ -260,23 +275,30 @@ function TouchMenu:updateItems()
|
||||
table.insert(self.item_group, item_tmp)
|
||||
-- insert split line
|
||||
if c ~= self.perpage then
|
||||
table.insert(self.item_group, LineWidget:new{
|
||||
style = "dashed",
|
||||
dimen = Geom:new{
|
||||
w = item_width - 20,
|
||||
h = 1,
|
||||
table.insert(self.item_group, HorizontalGroup:new{
|
||||
-- pad with spacing
|
||||
HorizontalSpan:new{width = 10},
|
||||
LineWidget:new{
|
||||
style = "dashed",
|
||||
dimen = Geom:new{
|
||||
w = item_width - 20,
|
||||
h = 1,
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
else
|
||||
-- item not enough to fill the whole page, break out of loop
|
||||
table.insert(self.item_group,
|
||||
VerticalSpan:new{
|
||||
width = self.item_height
|
||||
})
|
||||
break
|
||||
--table.insert(self.item_group,
|
||||
--VerticalSpan:new{
|
||||
--width = self.item_height
|
||||
--})
|
||||
--break
|
||||
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, self.footer)
|
||||
-- FIXME: this is a dirty hack to clear previous menus
|
||||
-- refert to issue #664
|
||||
UIManager.repaint_all = true
|
||||
@@ -288,7 +310,13 @@ function TouchMenu:switchMenuTab(tab_num)
|
||||
self.item_table = self.tab_item_table[tab_num]
|
||||
self:updateItems()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function TouchMenu:backToUpperMenu()
|
||||
if #self.item_table_stack ~= 0 then
|
||||
self.item_table = table.remove(self.item_table_stack)
|
||||
self:updateItems()
|
||||
end
|
||||
end
|
||||
|
||||
function TouchMenu:closeMenu()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 422 B After Width: | Height: | Size: 750 B |
5
resources/icons/src/appbar.chevron.left.svg
Normal file
5
resources/icons/src/appbar.chevron.left.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
|
||||
<path fill="#000000" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 35.8724,37.6042L 39.0391,40.7708L 50.5182,51.8542L 40.2266,51.8542L 25.1849,37.6041L 40.2266,23.3542L 50.5182,23.3542L 39.0391,34.4375L 35.8724,37.6042 Z "/>
|
||||
</svg>
|
||||
Reference in New Issue
Block a user