diff --git a/frontend/cache.lua b/frontend/cache.lua index 88e922a6a..9d51b2b42 100644 --- a/frontend/cache.lua +++ b/frontend/cache.lua @@ -30,6 +30,7 @@ Cache = { } function Cache:insert(key, object) + --@TODO add cache for different types of item 09.01 2013 (houqp) -- guarantee that we have enough memory in cache if(object.size > self.max_memsize) then -- we're not allowed to claim this much at all diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index f6ef05b56..c51dffbe8 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -147,7 +147,7 @@ function CreDocument:init() -- @TODO check the default view_mode to a global user configurable -- variable 22.12 2012 (houqp) - ok, self._document = pcall(cre.openDocument, self.file, style_sheet, + ok, self._document = pcall(cre.newDocView, style_sheet, Screen:getWidth(), Screen:getHeight(), self.PAGE_VIEW_MODE) if not ok then self.error_message = self.doc -- will contain error message @@ -162,6 +162,10 @@ function CreDocument:init() --self._document:setDefaultInterlineSpace(self.line_space_percent) end +function CreDocument:loadDocument() + self._document:loadDocument(self.file) +end + function CreDocument:drawCurrentView(target, x, y, rect, pos) tile_bb = Blitbuffer.new(rect.w, rect.h) self._document:drawCurrentPage(tile_bb) diff --git a/frontend/ui/reader/readerfont.lua b/frontend/ui/reader/readerfont.lua index 8235498dd..a29c0b527 100644 --- a/frontend/ui/reader/readerfont.lua +++ b/frontend/ui/reader/readerfont.lua @@ -59,20 +59,25 @@ function ReaderFont:onReadSettings(config) self.font_size = config:readSetting("font_size") if not self.font_size then - self.font_size = self.ui.document:getFontSize() + --@TODO change this! 12.01 2013 (houqp) + self.font_size = 29 end self.ui.document:setFontSize(self.font_size) self.line_space_percent = config:readSetting("line_space_percent") if not self.line_space_percent then self.line_space_percent = 100 + else + --@TODO set line space here 13.01 2013 (houqp) end -- Dirty hack: we have to add folloing call in order to set -- m_is_rendered(member of LVDocView) to true. Otherwise position inside -- document will be reset to 0 on first view render. -- So far, I don't know why this call will alter the value of m_is_rendered. - self.ui:handleEvent(Event:new("UpdatePos")) + table.insert(self.ui.postInitCallback, function() + self.ui:handleEvent(Event:new("UpdatePos")) + end) end function ReaderFont:onShowFontMenu() diff --git a/frontend/ui/reader/readerrolling.lua b/frontend/ui/reader/readerrolling.lua index 892066332..afca73e2e 100644 --- a/frontend/ui/reader/readerrolling.lua +++ b/frontend/ui/reader/readerrolling.lua @@ -94,20 +94,26 @@ function ReaderRolling:onReadSettings(config) if not soe then self.show_overlap_enable = soe end - -- we read last_percent just for backward compatibility - local last_per = config:readSetting("last_percent") - if last_per then - self:gotoPercent(last_per) - -- we have to do a real pos change in self.ui.document._document to - -- update status information in CREngine. - self.ui.document:gotoPos(self.current_pos) - end local last_xp = config:readSetting("last_xpointer") if last_xp then - self:gotoXPointer(last_xp) - -- we have to do a real jump in self.ui.document._document to - -- update status information in CREngine. - self.ui.document:gotoXPointer(last_xp) + table.insert(self.ui.postInitCallback, function() + self:gotoXPointer(last_xp) + -- we have to do a real jump in self.ui.document._document to + -- update status information in CREngine. + self.ui.document:gotoXPointer(last_xp) + end) + end + -- we read last_percent just for backward compatibility + if not last_xp then + local last_per = config:readSetting("last_percent") + if last_per then + table.insert(self.ui.postInitCallback, function() + self:gotoPercent(last_per) + -- we have to do a real pos change in self.ui.document._document + -- to update status information in CREngine. + self.ui.document:gotoPos(self.current_pos) + end) + end end if self.view_mode == "page" then self.ui:handleEvent(Event:new("PageUpdate", self.ui.document:getCurrentPage())) diff --git a/frontend/ui/readerui.lua b/frontend/ui/readerui.lua index 220725677..246d6580f 100644 --- a/frontend/ui/readerui.lua +++ b/frontend/ui/readerui.lua @@ -34,6 +34,8 @@ ReaderUI = InputContainer:new{ start_pos = nil, -- password for document unlock password = nil, + + postInitCallback = {}, } function ReaderUI:init() @@ -109,6 +111,10 @@ function ReaderUI:init() } table.insert(self, panner) else + -- make sure we load document first before calling any callback + table.insert(self.postInitCallback, function() + self.document:loadDocument() + end) -- rolling controller local roller = ReaderRolling:new{ dialog = self.dialog, @@ -144,6 +150,11 @@ function ReaderUI:init() self:handleEvent(Event:new("ReadSettings", self.doc_settings)) -- notify childs of dimensions self:handleEvent(Event:new("SetDimensions", self.dimen)) + + for _,v in ipairs(self.postInitCallback) do + v() + end + self.postInitCallback = {} end function ReaderUI:onSetDimensions(dimen)