cre highlights: draw segments instead of word boxes

It gives a cleaner drawing of multi-lines selected text.
Bump base and crengine.
pull/4265/head
poire-z 6 years ago
parent 9377be7e8c
commit 6ab34c6d1d

@ -1 +1 @@
Subproject commit 0e7a6dcfb58aa706f6fa231930c7ef58d8e9b3cb
Subproject commit 79574a5a40ab4648af9e4bba733ad6ef5eddf299

@ -192,6 +192,10 @@ function ReaderHighlight:onTapPageSavedHighlight(ges)
end
function ReaderHighlight:onTapXPointerSavedHighlight(ges)
-- Getting screen boxes is done for each tap on screen (changing pages,
-- showing menu...). We might want to cache these boxes per page (and
-- clear that cache when page layout change or highlights are added
-- or removed).
local cur_page
-- In scroll mode, we'll need to check for highlights in previous or next
-- page too as some parts of them may be displayed

@ -473,6 +473,10 @@ function ReaderView:drawPageSavedHighlight(bb, x, y)
end
function ReaderView:drawXPointerSavedHighlight(bb, x, y)
-- Getting screen boxes is done for each tap on screen (changing pages,
-- showing menu...). We might want to cache these boxes per page (and
-- clear that cache when page layout change or highlights are added
-- or removed).
local cur_page
-- In scroll mode, we'll need to check for highlights in previous or next
-- page too as some parts of them may be displayed
@ -499,7 +503,7 @@ function ReaderView:drawXPointerSavedHighlight(bb, x, y)
-- (A highlight starting on cur_page-17 and ending on cur_page+13 is
-- a highlight to consider)
if start_page <= cur_page + neighbour_pages and end_page >= cur_page - neighbour_pages then
local boxes = self.ui.document:getScreenBoxesFromPositions(pos0, pos1)
local boxes = self.ui.document:getScreenBoxesFromPositions(pos0, pos1, true) -- get_segments=true
if boxes then
for _, box in pairs(boxes) do
local rect = self:pageToScreenTransform(page, box)

@ -274,10 +274,10 @@ function CreDocument:getTextFromPositions(pos0, pos1)
end
end
function CreDocument:getScreenBoxesFromPositions(pos0, pos1)
function CreDocument:getScreenBoxesFromPositions(pos0, pos1, get_segments)
local line_boxes = {}
if pos0 and pos1 then
local word_boxes = self._document:getWordBoxesFromPositions(pos0, pos1)
local word_boxes = self._document:getWordBoxesFromPositions(pos0, pos1, get_segments)
for i = 1, #word_boxes do
local line_box = word_boxes[i]
table.insert(line_boxes, Geom:new{
@ -303,6 +303,10 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
-- But it is all fine if we use TYPE_BBRGB16.
self.buffer = Blitbuffer.new(rect.w, rect.h, self.render_color and Blitbuffer.TYPE_BBRGB16 or nil)
end
-- TODO: self.buffer could be re-used when no page/layout/highlights
-- change has been made, to avoid having crengine redraw the exact
-- same buffer.
-- And it could only change when some other methods from here are called
self._document:drawCurrentPage(self.buffer, self.render_color)
target:blitFrom(self.buffer, x, y, 0, 0, rect.w, rect.h)
end

Loading…
Cancel
Save