diff --git a/frontend/ui/reader/readermenu.lua b/frontend/ui/reader/readermenu.lua index df92458c7..42c25c58c 100644 --- a/frontend/ui/reader/readermenu.lua +++ b/frontend/ui/reader/readermenu.lua @@ -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 diff --git a/frontend/ui/widget/iconbutton.lua b/frontend/ui/widget/iconbutton.lua index 1faeeddf5..760b98463 100644 --- a/frontend/ui/widget/iconbutton.lua +++ b/frontend/ui/widget/iconbutton.lua @@ -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 diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 540a437f8..c524c63fb 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -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() diff --git a/resources/icons/appbar.chevron.left.png b/resources/icons/appbar.chevron.left.png index 7c96681b0..d479e024e 100644 Binary files a/resources/icons/appbar.chevron.left.png and b/resources/icons/appbar.chevron.left.png differ diff --git a/resources/icons/src/appbar.chevron.left.svg b/resources/icons/src/appbar.chevron.left.svg new file mode 100644 index 000000000..fd888a110 --- /dev/null +++ b/resources/icons/src/appbar.chevron.left.svg @@ -0,0 +1,5 @@ + + + + +