add following page link in reflowed page

This commit is contained in:
chrox
2014-01-21 11:59:17 +08:00
parent b613fc71ff
commit d24d5e413e
3 changed files with 42 additions and 26 deletions

View File

@@ -746,6 +746,41 @@ function KoptInterface:getWordFromNativePosition(doc, boxes, pos)
return word_box
end
--[[
get link from position in screen page
]]--
function KoptInterface:getLinkFromPosition(doc, pageno, pos)
local function inside_box(pos, box)
if pos then
local x, y = pos.x, pos.y
if box.x <= x and box.y <= y
and box.x + box.w >= x
and box.y + box.h >= y then
return true
end
end
end
local page_links = doc:getPageLinks(pageno)
if page_links then
if doc.configurable.text_wrap == 1 then
pos = self:reflowToNativePosTransform(doc, pageno, pos, {x=0.5, y=0.5})
end
for i = 1, #page_links do
local link = page_links[i]
-- enlarge tappable link box
local lbox = Geom:new{
x = link.x0 - Screen:scaleByDPI(15),
y = link.y0 - Screen:scaleByDPI(15),
w = link.x1 - link.x0 + Screen:scaleByDPI(30),
h = link.y1 - link.y0 + Screen:scaleByDPI(30)
}
if inside_box(pos, lbox) and link.page then
return link
end
end
end
end
--[[
transform position in native page to reflowed page
]]--