mirror of
https://github.com/koreader/koreader.git
synced 2025-12-18 12:02:09 +01:00
Swipe down or tap on top left/right to access left/right reader menu tab directly (#3595)
This commit is contained in:
@@ -262,11 +262,15 @@ function ReaderMenu:exitOrRestart(callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReaderMenu:onShowReaderMenu()
|
function ReaderMenu:onShowReaderMenu(tab_index)
|
||||||
if self.tab_item_table == nil then
|
if self.tab_item_table == nil then
|
||||||
self:setUpdateItemTable()
|
self:setUpdateItemTable()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not tab_index then
|
||||||
|
tab_index = self.last_tab_index
|
||||||
|
end
|
||||||
|
|
||||||
local menu_container = CenterContainer:new{
|
local menu_container = CenterContainer:new{
|
||||||
ignore = "height",
|
ignore = "height",
|
||||||
dimen = Screen:getSize(),
|
dimen = Screen:getSize(),
|
||||||
@@ -277,7 +281,7 @@ function ReaderMenu:onShowReaderMenu()
|
|||||||
local TouchMenu = require("ui/widget/touchmenu")
|
local TouchMenu = require("ui/widget/touchmenu")
|
||||||
main_menu = TouchMenu:new{
|
main_menu = TouchMenu:new{
|
||||||
width = Screen:getWidth(),
|
width = Screen:getWidth(),
|
||||||
last_index = self.last_tab_index,
|
last_index = tab_index,
|
||||||
tab_item_table = self.tab_item_table,
|
tab_item_table = self.tab_item_table,
|
||||||
show_parent = menu_container,
|
show_parent = menu_container,
|
||||||
}
|
}
|
||||||
@@ -303,7 +307,6 @@ function ReaderMenu:onShowReaderMenu()
|
|||||||
-- maintain a reference to menu_container
|
-- maintain a reference to menu_container
|
||||||
self.menu_container = menu_container
|
self.menu_container = menu_container
|
||||||
UIManager:show(menu_container)
|
UIManager:show(menu_container)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -314,22 +317,38 @@ function ReaderMenu:onCloseReaderMenu()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ReaderMenu:_getTabIndexFromLocation(ges)
|
||||||
|
if self.tab_item_table == nil then
|
||||||
|
self:setUpdateItemTable()
|
||||||
|
end
|
||||||
|
-- if the start position is far right
|
||||||
|
if ges.pos.x > 2 * Screen:getWidth() / 3 then
|
||||||
|
return #self.tab_item_table
|
||||||
|
-- if the start position is far left
|
||||||
|
elseif ges.pos.x < Screen:getWidth() / 3 then
|
||||||
|
return 1
|
||||||
|
-- if center return the last index
|
||||||
|
else
|
||||||
|
return self.last_tab_index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ReaderMenu:onSwipeShowMenu(ges)
|
function ReaderMenu:onSwipeShowMenu(ges)
|
||||||
if self.activation_menu ~= "tap" and ges.direction == "south" then
|
if self.activation_menu ~= "tap" and ges.direction == "south" then
|
||||||
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
||||||
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
||||||
end
|
end
|
||||||
self.ui:handleEvent(Event:new("ShowReaderMenu"))
|
self.ui:handleEvent(Event:new("ShowReaderMenu", self:_getTabIndexFromLocation(ges)))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReaderMenu:onTapShowMenu()
|
function ReaderMenu:onTapShowMenu(ges)
|
||||||
if self.activation_menu ~= "swipe" then
|
if self.activation_menu ~= "swipe" then
|
||||||
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
if G_reader_settings:nilOrTrue("show_bottom_menu") then
|
||||||
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
||||||
end
|
end
|
||||||
self.ui:handleEvent(Event:new("ShowReaderMenu"))
|
self.ui:handleEvent(Event:new("ShowReaderMenu", self:_getTabIndexFromLocation(ges)))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user