2013-02-19 11:16:42 +00:00
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
ReaderKoptListener = EventListener:new{}
|
2013-02-19 11:16:42 +00:00
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
function ReaderKoptListener:setZoomMode(zoom_mode)
|
2013-02-19 11:16:42 +00:00
|
|
|
if self.document.configurable.text_wrap == 1 then
|
2013-02-20 11:29:14 +00:00
|
|
|
-- in reflow mode only "page" zoom mode is valid so override any other zoom mode
|
2013-02-20 03:50:36 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "page", "koptlistener"))
|
2013-02-19 11:16:42 +00:00
|
|
|
else
|
2013-02-20 11:29:14 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", zoom_mode, "koptlistener"))
|
2013-02-19 11:16:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
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
|
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
function ReaderKoptListener:onCloseDocument()
|
|
|
|
self.ui.doc_settings:saveSetting("normal_zoom_mode", self.normal_zoom_mode)
|
|
|
|
end
|
|
|
|
|
2013-02-20 11:29:14 +00:00
|
|
|
function ReaderKoptListener:onRestoreZoomMode()
|
|
|
|
-- "RestoreZoomMode" event is sent when reflow mode on/off is toggled
|
|
|
|
self:setZoomMode(self.normal_zoom_mode)
|
2013-02-19 11:16:42 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2013-02-20 03:50:36 +00:00
|
|
|
function ReaderKoptListener:onSetZoomMode(zoom_mode, orig)
|
2013-02-20 11:29:14 +00:00
|
|
|
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)
|
2013-02-19 11:16:42 +00:00
|
|
|
end
|
2013-03-10 06:23:26 +00:00
|
|
|
|
|
|
|
function ReaderKoptListener:onSetDimensions(dimensions)
|
|
|
|
-- called later than reader zooming
|
|
|
|
self.ui:handleEvent(Event:new("InitScrollPageStates"))
|
|
|
|
end
|