Fix footnotes and markers with full status bar

Take full/top status bar's height into account when
computing coordinates.
Also wrap getPageMargins() in CreDocument, so we
don't use cre.cpp _document directly anywhere else.
pull/4273/head
poire-z 6 years ago
parent e869b40625
commit 9d8531a4b5

@ -1 +1 @@
Subproject commit 01a39e9c5a4a83f4b215a638f7fe44ed4ba8d2d9
Subproject commit 3488223893d76a3ec045ed92003cdf4322474c43

@ -257,11 +257,15 @@ end
--- Check if a xpointer to <a> node really points to itself
function ReaderLink:isXpointerCoherent(a_xpointer)
-- Get screen coordinates of xpointer
local doc_margins = self.ui.document._document:getPageMargins()
local doc_margins = self.ui.document:getPageMargins()
local header_height = self.ui.document:getHeaderHeight() -- top full status bar (0 when bottom mini bar used)
local doc_y, doc_x = self.ui.document:getPosFromXPointer(a_xpointer)
local top_y = self.ui.document:getCurrentPos()
-- (strange, but using doc_margins.top is accurate even in scroll mode)
local screen_y = doc_y - top_y + doc_margins["top"]
local screen_y = doc_y - top_y
if self.view.view_mode == "page" then
screen_y = screen_y + doc_margins["top"] + header_height
end
local screen_x = doc_x + doc_margins["left"]
-- Get again link and a_xpointer from this position
local re_link_xpointer, re_a_xpointer = self.ui.document:getLinkFromPosition({x = screen_x, y = screen_y}) -- luacheck: no unused
@ -1045,7 +1049,7 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location)
popup = FootnoteWidget:new{
html = html,
doc_font_size = Screen:scaleBySize(self.ui.font.font_size),
doc_margins = self.ui.document._document:getPageMargins(),
doc_margins = self.ui.document:getPageMargins(),
close_callback = close_callback,
follow_callback = function() -- follow the link on swipe west
UIManager:close(popup)

@ -476,9 +476,10 @@ function ReaderRolling:onGotoXPointer(xp, marker_xp)
local doc_y = self.ui.document:getPosFromXPointer(marker_xp)
local top_y = self.ui.document:getCurrentPos()
local screen_y = doc_y - top_y
local doc_margins = self.ui.document._document:getPageMargins()
local doc_margins = self.ui.document:getPageMargins()
local header_height = self.ui.document:getHeaderHeight() -- top full status bar (0 when bottom mini bar used)
if self.view.view_mode == "page" then
screen_y = screen_y + doc_margins["top"]
screen_y = screen_y + doc_margins["top"] + header_height
end
local marker_h = Screen:scaleBySize(self.ui.font.font_size * 1.1 * self.ui.font.line_space_percent/100.0)
-- Make it 4/5 of left margin wide (and bigger when huge margin)

@ -330,6 +330,14 @@ end
function CreDocument:renderPage(pageno, rect, zoom, rotation)
end
function CreDocument:getPageMargins()
return self._document:getPageMargins()
end
function CreDocument:getHeaderHeight()
return self._document:getHeaderHeight()
end
function CreDocument:gotoXPointer(xpointer)
logger.dbg("CreDocument: goto xpointer", xpointer)
self._document:gotoXPointer(xpointer)

Loading…
Cancel
Save