Skip to content

Commit

Permalink
Page turn animations
Browse files Browse the repository at this point in the history
Kindle PW5 (MTK) with hardware support
Currently only in Crengine
  • Loading branch information
yparitcher committed May 4, 2022
1 parent 86c35ad commit 46e3f87
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base
6 changes: 6 additions & 0 deletions frontend/apps/reader/modules/readerrolling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,9 @@ function ReaderRolling:_gotoPos(new_pos, do_dim_area)
else
self.view.dim_area:clear()
end
if self.current_pos and not UIManager.currently_scrolling then
self.ui:handleEvent(Event:new("PageChangeAnimation", new_pos > self.current_pos))
end
self.ui.document:gotoPos(new_pos)
-- The current page we get in scroll mode may be a bit innacurate,
-- but we give it anyway to onPosUpdate so footer and statistics can
Expand Down Expand Up @@ -1038,6 +1041,9 @@ function ReaderRolling:_gotoPage(new_page, free_first_page, internal)
end
end
end
if self.current_page then
self.ui:handleEvent(Event:new("PageChangeAnimation", new_page > self.current_page))
end
self.ui.document:gotoPage(new_page, internal)
if self.view.view_mode == "page" then
self.ui:handleEvent(Event:new("PageUpdate", self.ui.document:getCurrentPage()))
Expand Down
8 changes: 8 additions & 0 deletions frontend/apps/reader/modules/readerview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,14 @@ function ReaderView:onRotationUpdate(rotation)
self:recalculate()
end

function ReaderView:onPageChangeAnimation(forward)
if Device:canDoSwipeAnimation() and G_reader_settings:isTrue("swipe_animations") then
if self.inverse_reading_order then forward = not forward end
Screen:setSwipeAnimations(true)
Screen:setSwipeDirection(forward)
end
end

function ReaderView:onReaderFooterVisibilityChange()
-- Don't bother ReaderRolling with this nonsense, the footer's height is NOT handled via visible_area there ;)
if self.ui.paging and self.state.page then
Expand Down
1 change: 1 addition & 0 deletions frontend/device/generic/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ local Device = {
hasExternalSD = no, -- or other storage volume that cannot be accessed using the File Manager
canHWDither = no,
canHWInvert = no,
canDoSwipeAnimation = no,
canModifyFBInfo = no, -- some NTX boards do wonky things with the rotate flag after a FBIOPUT_VSCREENINFO ioctl
canUseCBB = yes, -- The C BB maintains a 1:1 feature parity with the Lua BB, except that is has NO support for BB4, and limited support for BBRGB24
hasColorScreen = no,
Expand Down
1 change: 1 addition & 0 deletions frontend/device/kindle/device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ local KindlePaperWhite5 = Kindle:new{
touch_dev = "/dev/input/by-path/platform-1001e000.i2c-event",
-- NOTE: While hardware dithering (via MDP) should be a thing, it doesn't appear to do anything right now :/.
canHWDither = no,
canDoSwipeAnimation = yes,
}

function Kindle2:init()
Expand Down
13 changes: 13 additions & 0 deletions frontend/ui/elements/page_turns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ When enabled the UI direction for the Table of Contents, Book Map, and Page Brow
}
}

if Device:canDoSwipeAnimation() then
table.insert(PageTurns.sub_item_table, {
text =_("Page Turn Animations"),
checked_func = function()
return G_reader_settings:isTrue("swipe_animations")
end,
callback = function()
G_reader_settings:flipNilOrFalse("swipe_animations")
end,
separator = true,
})
end

if Device:hasKeys() then
table.insert(PageTurns.sub_item_table, {
text = _("Invert page turn buttons"),
Expand Down

0 comments on commit 46e3f87

Please sign in to comment.