Fix footer, stats, TOC position with cre in scroll mode (#3304)

This gives the page position to these modules even in scroll mode.
Also, in readerrolling: don't query battery/charging status
when crengine does not need it (used only when it shows its top
progress bar).
pull/3306/head
poire-z 7 years ago committed by Frans de Jonge
parent ac7119c433
commit b483c54be8

@ -568,9 +568,14 @@ function ReaderFooter:onPageUpdate(pageno)
self:updateFooterPage()
end
function ReaderFooter:onPosUpdate(pos)
function ReaderFooter:onPosUpdate(pos, pageno)
self.position = pos
self.doc_height = self.view.document.info.doc_height
if pageno then
self.pageno = pageno
self.pages = self.view.document:getPageCount()
self.ui.doc_settings:saveSetting("doc_pages", self.pages) -- for Book information
end
self:updateFooterPos()
end

@ -43,6 +43,7 @@ local ReaderRolling = InputContainer:new{
panning_steps = ReaderPanning.panning_steps,
show_overlap_enable = nil,
overlap = 20,
cre_top_bar_enabled = false,
}
function ReaderRolling:init()
@ -145,6 +146,8 @@ function ReaderRolling:onReadSettings(config)
self.show_overlap_enable = DSHOWOVERLAP
end
self.inverse_reading_order = config:readSetting("inverse_reading_order") or false
self:onSetStatusLine(config:readSetting("copt_status_line") or DCREREADER_PROGRESS_BAR)
end
-- in scroll mode percent_finished must be save before close document
@ -555,7 +558,10 @@ function ReaderRolling:_gotoPos(new_pos)
self.view.dim_area.y = 0
end
end
self.ui:handleEvent(Event:new("PosUpdate", new_pos))
-- The current page we get in scroll mode may be a bit innacurate,
-- but we give it anyway to onPosUpdate so footer and statistics can
-- keep up with page.
self.ui:handleEvent(Event:new("PosUpdate", new_pos, self.ui.document:getCurrentPage()))
end
function ReaderRolling:_gotoPercent(new_percent)
@ -585,9 +591,13 @@ function ReaderRolling:updatePageLink()
self.view.links = links
end
function ReaderRolling:onSetStatusLine(status_line)
self.cre_top_bar_enabled = status_line == 0
end
function ReaderRolling:updateBatteryState()
logger.dbg("update battery state")
if self.view.view_mode == "page" then
if self.view.view_mode == "page" and self.cre_top_bar_enabled then
logger.dbg("update battery state")
local powerd = Device:getPowerDevice()
-- -1 is CR_BATTERY_STATE_CHARGING @ crengine/crengine/include/lvdocview.h
local state = powerd:isCharging() and -1 or powerd:getCapacity()

@ -72,6 +72,10 @@ function ReaderToc:onPageUpdate(pageno)
self.pageno = pageno
end
function ReaderToc:onPosUpdate(pos, pageno)
self.pageno = pageno
end
function ReaderToc:fillToc()
if self.toc and #self.toc > 0 then return end
self.toc = self.ui.document:getToc()

@ -1568,6 +1568,10 @@ function ReaderStatistics:deleteBook(id_book)
conn:close()
end
function ReaderStatistics:onPageUpdate(pos, pageno)
self:onPageUpdate(pageno)
end
function ReaderStatistics:onPageUpdate(pageno)
if self:isDocless() or not self.is_enabled then
return

Loading…
Cancel
Save