mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1124 from chrox/remember_menutab
remember menu tab index when showing reader menu
This commit is contained in:
@@ -157,6 +157,8 @@ function TouchMenuBar:init()
|
||||
self.icon_widgets = {}
|
||||
-- hold icon seperators
|
||||
self.icon_seps = {}
|
||||
-- hold all icon buttons
|
||||
self.icon_buttons = {}
|
||||
-- the start_seg for first icon_widget should be 0
|
||||
-- we asign negative here to offset it in the loop
|
||||
local start_seg = -icon_sep_width
|
||||
@@ -172,6 +174,8 @@ function TouchMenuBar:init()
|
||||
spacing, ib, spacing,
|
||||
})
|
||||
|
||||
table.insert(self.icon_buttons, ib)
|
||||
|
||||
-- we have to use local variable here for closure callback
|
||||
local _start_seg = end_seg + icon_sep_width
|
||||
local _end_seg = _start_seg + self.icon_widgets[k]:getSize().w
|
||||
@@ -234,6 +238,9 @@ function TouchMenuBar:init()
|
||||
self.dimen = Geom:new{ w = self.width, h = self.height }
|
||||
end
|
||||
|
||||
function TouchMenuBar:switchToTab(index)
|
||||
self.icon_buttons[index].callback()
|
||||
end
|
||||
|
||||
--[[
|
||||
TouchMenu widget for hierarchical menus
|
||||
@@ -377,7 +384,7 @@ function TouchMenu:init()
|
||||
self.item_group,
|
||||
}
|
||||
|
||||
self:switchMenuTab(1)
|
||||
self.bar:switchToTab(self.last_index or 1)
|
||||
self:updateItems()
|
||||
end
|
||||
|
||||
@@ -471,6 +478,9 @@ function TouchMenu:netToggle()
|
||||
end
|
||||
|
||||
function TouchMenu:switchMenuTab(tab_num)
|
||||
if self.tab_item_table[tab_num].remember ~= false then
|
||||
self.last_index = tab_num
|
||||
end
|
||||
if self.touch_menu_callback then
|
||||
self.touch_menu_callback()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user