[fix] cre: fix position and page number after window resize (#4754)

pull/4771/head v2019.03
poire-z 5 years ago committed by Frans de Jonge
parent 7c2df53808
commit 658f513512

@ -665,21 +665,34 @@ function ReaderRolling:onRedrawCurrentView()
end
function ReaderRolling:onSetDimensions(dimen)
self.ui.document:setViewDimen(Screen:getSize())
if self.ui.postReaderCallback ~= nil then
-- ReaderUI:init() not yet done: just set document dimensions
self.ui.document:setViewDimen(Screen:getSize())
-- (what's done in the following else is done elsewhere by
-- the initialization code)
else
-- Initialization done: we are called on orientation change
-- or on window resize (SDL, Android possibly).
-- We need to temporarily re-enable internal history as crengine
-- uses it to reposition after resize
self.ui.document:enableInternalHistory(true)
-- Set document dimensions
self.ui.document:setViewDimen(Screen:getSize())
-- Re-setup previous position
self:onChangeViewMode()
self:onUpdatePos()
-- Re-disable internal history, with required redraw
self.ui.document:enableInternalHistory(false)
self:onRedrawCurrentView()
end
end
function ReaderRolling:onChangeScreenMode(mode, rotation)
-- We need to temporarily re-enable internal history as crengine
-- uses it to reposition after resize
self.ui.document:enableInternalHistory(true)
-- Flag it as interactive so we can properly swap to Inverted orientations (we usurp the second argument, which usually means rotation)
-- Flag it as interactive so we can properly swap to Inverted orientations
-- (we usurp the second argument, which usually means rotation)
self.ui:handleEvent(Event:new("SetScreenMode", mode, rotation or true))
self.ui.document:setViewDimen(Screen:getSize())
self:onChangeViewMode()
self:onUpdatePos()
-- Re-disable internal history, with required redraw
self.ui.document:enableInternalHistory(false)
self:onRedrawCurrentView()
-- (This had the above ReaderRolling:onSetDimensions() called to resize
-- document dimensions and keep up with current position)
end
function ReaderRolling:onColorRenderingUpdate()

Loading…
Cancel
Save