[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 end
function ReaderRolling:onSetDimensions(dimen) 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 end
function ReaderRolling:onChangeScreenMode(mode, rotation) function ReaderRolling:onChangeScreenMode(mode, rotation)
-- We need to temporarily re-enable internal history as crengine -- Flag it as interactive so we can properly swap to Inverted orientations
-- uses it to reposition after resize -- (we usurp the second argument, which usually means rotation)
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)
self.ui:handleEvent(Event:new("SetScreenMode", mode, rotation or true)) self.ui:handleEvent(Event:new("SetScreenMode", mode, rotation or true))
self.ui.document:setViewDimen(Screen:getSize()) -- (This had the above ReaderRolling:onSetDimensions() called to resize
self:onChangeViewMode() -- document dimensions and keep up with current position)
self:onUpdatePos()
-- Re-disable internal history, with required redraw
self.ui.document:enableInternalHistory(false)
self:onRedrawCurrentView()
end end
function ReaderRolling:onColorRenderingUpdate() function ReaderRolling:onColorRenderingUpdate()

Loading…
Cancel
Save