Highlights: add strikeout style, fix pdf highlights (#8725)

- Add new strikeout highlight style.
- Fix highlight style in pdf documents (save_document enabled)
not updated when KOReader highlight style changed.
- Fix ugly combination of mupdf and KOReader highlights
reviewable/pr8733/r1
hius07 2 years ago committed by GitHub
parent bc400e94e8
commit b7a2a27590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -278,6 +278,7 @@ end
local highlight_style = {
{_("Lighten"), "lighten"},
{_("Underline"), "underscore"},
{_("Strikeout"), "strikeout"},
{_("Invert"), "invert"},
}
@ -1670,13 +1671,14 @@ end
function ReaderHighlight:editHighlightStyle(page, i)
local item = self.view.highlight.saved[page][i]
local save_document = self.ui.paging and G_reader_settings:readSetting("save_document") ~= "disable"
local radio_buttons = {}
for _, v in ipairs(highlight_style) do
table.insert(radio_buttons, {
{
text = v[1],
checked = item.drawer == v[2],
provider = v[2],
text = v[1],
checked = item.drawer == v[2],
provider = v[2],
},
})
end
@ -1688,11 +1690,17 @@ function ReaderHighlight:editHighlightStyle(page, i)
default_provider = self.view.highlight.saved_drawer or
G_reader_settings:readSetting("highlight_drawing_style", "lighten"),
callback = function(radio)
if save_document then
self.ui.document:deleteHighlight(page, item)
end
item.drawer = radio.provider
if save_document then
self.ui.document:saveHighlight(page, item)
end
UIManager:setDirty(self.dialog, "ui")
self.ui:handleEvent(Event:new("BookmarkUpdated",
self.ui.bookmark:getBookmarkForHighlight({
page = self.ui.paging and item.pos0.page or item.pos0,
page = self.ui.paging and page or item.pos0,
datetime = item.datetime,
})))
end,

@ -37,7 +37,7 @@ local ReaderView = OverlapGroup:extend{
bbox = nil,
},
outer_page_color = Blitbuffer.gray(DOUTER_PAGE_COLOR / 15),
-- highlight with "lighten" or "underscore" or "invert"
-- highlight with "lighten" or "underscore" or "strikeout" or "invert"
highlight = {
lighten_factor = G_reader_settings:readSetting("highlight_lighten_factor", 0.2),
temp_drawer = "invert",
@ -542,15 +542,16 @@ end
function ReaderView:drawHighlightRect(bb, _x, _y, rect, drawer)
local x, y, w, h = rect.x, rect.y, rect.w, rect.h
if drawer == "underscore" then
self.highlight.line_width = self.highlight.line_width or 2
self.highlight.line_color = self.highlight.line_color or Blitbuffer.COLOR_GRAY
bb:paintRect(x, y+h-1, w,
self.highlight.line_width,
self.highlight.line_color)
elseif drawer == "lighten" then
if drawer == "lighten" then
bb:lightenRect(x, y, w, h, self.highlight.lighten_factor)
elseif drawer == "underscore" then
bb:paintRect(x, y + h - 1, w, 2, Blitbuffer.COLOR_GRAY)
elseif drawer == "strikeout" then
local line_y = y + math.floor(h / 2) + 1
if self.ui.paging then
line_y = line_y + 2
end
bb:paintRect(x, line_y, w, 2, Blitbuffer.COLOR_BLACK)
elseif drawer == "invert" then
bb:invertRect(x, y, w, h)
end

@ -239,7 +239,7 @@ function PdfDocument:saveHighlight(pageno, item)
elseif item.drawer == "underscore" then
annot_type = C.PDF_ANNOT_UNDERLINE
elseif item.drawer == "strikeout" then
annot_type = C.PDF_ANNOT_STRIKEOUT
annot_type = C.PDF_ANNOT_STRIKE_OUT
end
page:addMarkupAnnotation(quadpoints, n, annot_type) -- may update/adjust quadpoints
-- Update pboxes with the possibly adjusted coordinates (this will have it updated

Loading…
Cancel
Save