2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/ui/reader/readerkopt.lua
2013-03-10 14:23:26 +08:00

39 lines
1.3 KiB
Lua

ReaderKoptListener = EventListener:new{}
function ReaderKoptListener:setZoomMode(zoom_mode)
if self.document.configurable.text_wrap == 1 then
-- in reflow mode only "page" zoom mode is valid so override any other zoom mode
self.ui:handleEvent(Event:new("SetZoomMode", "page", "koptlistener"))
else
self.ui:handleEvent(Event:new("SetZoomMode", zoom_mode, "koptlistener"))
end
end
function ReaderKoptListener:onReadSettings(config)
-- normal zoom mode is zoom mode used in non-reflow mode.
self.normal_zoom_mode = config:readSetting("normal_zoom_mode") or "page"
self:setZoomMode(self.normal_zoom_mode)
end
function ReaderKoptListener:onCloseDocument()
self.ui.doc_settings:saveSetting("normal_zoom_mode", self.normal_zoom_mode)
end
function ReaderKoptListener:onRestoreZoomMode()
-- "RestoreZoomMode" event is sent when reflow mode on/off is toggled
self:setZoomMode(self.normal_zoom_mode)
return true
end
function ReaderKoptListener:onSetZoomMode(zoom_mode, orig)
if orig == "koptlistener" then return end
-- capture zoom mode set outside of koptlistener which should always be normal zoom mode
self.normal_zoom_mode = zoom_mode
self:setZoomMode(self.normal_zoom_mode)
end
function ReaderKoptListener:onSetDimensions(dimensions)
-- called later than reader zooming
self.ui:handleEvent(Event:new("InitScrollPageStates"))
end