Add color highlight menu (#11044)

This commit is contained in:
Rowan Decker
2024-08-30 13:10:43 -07:00
committed by GitHub
parent 89fdb5516b
commit 60e0e3ef45
10 changed files with 303 additions and 37 deletions

View File

@@ -1,3 +1,4 @@
local BlitBuffer = require("ffi/blitbuffer")
local CacheItem = require("cacheitem")
local CanvasContext = require("document/canvascontext")
local DocCache = require("document/doccache")
@@ -244,6 +245,7 @@ function PdfDocument:saveHighlight(pageno, item)
local quadpoints, n = _quadpointsFromPboxes(item.pboxes)
local page = self._document:openPage(pageno)
local annot_type = C.PDF_ANNOT_HIGHLIGHT
local annot_color = BlitBuffer.colorFromName(item.color)
if item.drawer == "lighten" then
annot_type = C.PDF_ANNOT_HIGHLIGHT
elseif item.drawer == "underscore" then
@@ -251,7 +253,9 @@ function PdfDocument:saveHighlight(pageno, item)
elseif item.drawer == "strikeout" then
annot_type = C.PDF_ANNOT_STRIKE_OUT
end
page:addMarkupAnnotation(quadpoints, n, annot_type) -- may update/adjust quadpoints
-- NOTE: For highlights, display style may differ compared to ReaderView:drawHighlightRect...
-- (e.g., we do a MUL blend, MuPDF currently appears to do an OVER blend).
page:addMarkupAnnotation(quadpoints, n, annot_type, annot_color) -- may update/adjust quadpoints
-- Update pboxes with the possibly adjusted coordinates (this will have it updated
-- in self.view.highlight.saved[page])
item.pboxes = _quadpointsToPboxes(quadpoints, n)