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.
This commit is contained in:
poire-z
2018-10-12 17:51:58 +02:00
parent e869b40625
commit 9d8531a4b5
4 changed files with 19 additions and 6 deletions

View File

@@ -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)