Merge pull request #690 from WS64/master

Go to next/prev chapter plus configurable swipe directions
pull/696/head
Huang Xin 10 years ago
commit 33d8cce4a3

@ -71,6 +71,12 @@ DTAP_ZONE_FORWARD = {x = 1/4, y = 0, w = 3/4, h = 1}
DTAP_ZONE_BACKWARD = {x = 0, y = 0, w = 1/4, h = 1}
DTAP_ZONE_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8}
DTAP_ZONE_FLIPPING = {x = 0, y = 0, w = 1/8, h = 1/8}
DDOUBLE_TAP_ZONE_NEXT_CHAPTER = {x = 6/8, y = 0, w = 2/8, h = 2/8}
DDOUBLE_TAP_ZONE_PREV_CHAPTER = {x = 0, y = 0, w = 2/8, h = 2/8}
-- behaviour of swipes
DCHANGE_WEST_SWIPE_TO_EAST = false
DCHANGE_EAST_SWIPE_TO_WEST = false
-- koptreader config defaults
DKOPTREADER_CONFIG_FONT_SIZE = 1.0 -- range from 0.1 to 3.0

@ -134,9 +134,9 @@ function ReaderFooter:updateFooterPage()
else
if self.mode == 1 then
self.progress_text.text = string.format("%d / %d", self.pageno, self.pages)
end if self.mode == 2 then
elseif self.mode == 2 then
self.progress_text.text = os.date("%H:%M")
end if self.mode == 3 then
elseif self.mode == 3 then
self.progress_text.text = "=> " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages)
end
end

@ -284,9 +284,17 @@ function ReaderPaging:onSwipe(arg, ges)
elseif self.page_flipping_mode and self.original_page then
self:gotoPage(self.original_page)
elseif ges.direction == "west" then
self:onPagingRel(1)
if DCHANGE_WEST_SWIPE_TO_EAST then
self:onPagingRel(-1)
else
self:onPagingRel(1)
end
elseif ges.direction == "east" then
self:onPagingRel(-1)
if DCHANGE_EAST_SWIPE_TO_WEST then
self:onPagingRel(1)
else
self:onPagingRel(-1)
end
else
UIManager.full_refresh = true
end

@ -121,6 +121,28 @@ function ReaderRolling:initGesListener()
rate = 4.0,
}
},
DoubleTapForward = {
GestureRange:new{
ges = "double_tap",
range = Geom:new{
x = Screen:getWidth()*DDOUBLE_TAP_ZONE_NEXT_CHAPTER.x,
y = Screen:getHeight()*DDOUBLE_TAP_ZONE_NEXT_CHAPTER.y,
w = Screen:getWidth()*DDOUBLE_TAP_ZONE_NEXT_CHAPTER.w,
h = Screen:getHeight()*DDOUBLE_TAP_ZONE_NEXT_CHAPTER.h,
}
}
},
DoubleTapBackward = {
GestureRange:new{
ges = "double_tap",
range = Geom:new{
x = Screen:getWidth()*DDOUBLE_TAP_ZONE_PREV_CHAPTER.x,
y = Screen:getHeight()*DDOUBLE_TAP_ZONE_PREV_CHAPTER.y,
w = Screen:getWidth()*DDOUBLE_TAP_ZONE_PREV_CHAPTER.w,
h = Screen:getHeight()*DDOUBLE_TAP_ZONE_PREV_CHAPTER.h,
}
}
},
}
end
@ -184,9 +206,17 @@ end
function ReaderRolling:onSwipe(arg, ges)
if ges.direction == "west" or ges.direction == "north" then
self:onGotoViewRel(1)
if DCHANGE_WEST_SWIPE_TO_EAST then
self:onGotoViewRel(-1)
else
self:onGotoViewRel(1)
end
elseif ges.direction == "east" or ges.direction == "south" then
self:onGotoViewRel(-1)
if DCHANGE_EAST_SWIPE_TO_WEST then
self:onGotoViewRel(1)
else
self:onGotoViewRel(-1)
end
end
end
@ -215,6 +245,22 @@ function ReaderRolling:onResume()
self:updateBatteryState()
end
function ReaderRolling:onDoubleTapForward()
local i = self.ui.toc:_getChapterPagesLeft(self.current_page,-1)
if i ~= "" then
self:onGotoViewRel(i+1)
end
return true
end
function ReaderRolling:onDoubleTapBackward()
local i = self.ui.toc:_getChapterPagesDone(self.current_page)
if i ~= "" then
self:onGotoViewRel(i)
end
return true
end
function ReaderRolling:onNotCharging()
self:updateBatteryState()
end
@ -238,8 +284,7 @@ function ReaderRolling:onGotoViewRel(diff)
end
self:gotoPos(self.current_pos + pan_diff)
elseif self.view.view_mode == "page" then
local page_count = self.ui.document:getVisiblePageCount()
self:gotoPage(self.current_page + diff*page_count)
self:gotoPage(self.current_page + diff)
end
return true
end

@ -99,6 +99,8 @@ function ReaderToc:getTocTitleOfCurrentPage()
end
function ReaderToc:_getChapterPagesLeft(pageno,pages)
local i
local j = 0
if not self.toc then
-- build toc when needed.
self:fillToc()
@ -109,9 +111,8 @@ function ReaderToc:_getChapterPagesLeft(pageno,pages)
return ""
end
j=0
if #self.toc > 0 then
for i=1, #self.toc do
for i = 1, #self.toc do
v = self.toc[i]
if v.page > pageno then
j = v.page
@ -119,13 +120,46 @@ function ReaderToc:_getChapterPagesLeft(pageno,pages)
end
end
end
if j==0 then
return pages-pageno
if j == 0 then
if pages > 0 then
return pages-pageno
else
return ""
end
else
return j-pageno-1
end
end
function ReaderToc:_getChapterPagesDone(pageno)
local i
local j = 0
if not self.toc then
-- build toc when needed.
self:fillToc()
end
-- no table of content
if #self.toc == 0 then
return ""
end
if #self.toc > 0 then
for i = 1, #self.toc do
v = self.toc[i]
if v.page >= pageno then
break
end
j = v.page
end
end
if j < 2 then
return ""
else
return j-pageno
end
end
function ReaderToc:onShowToc()
if not self.toc then

Loading…
Cancel
Save