From b4f453eb583ebf8617edc83aaf4990480a3b770d Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sun, 7 May 2023 20:28:18 +0300 Subject: [PATCH] Page overlap: add "Horizontal line" marker (#10401) --- frontend/apps/reader/modules/readerview.lua | 9 ++++++--- frontend/ui/elements/page_overlap.lua | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/apps/reader/modules/readerview.lua b/frontend/apps/reader/modules/readerview.lua index 0628ac508..3805b815b 100644 --- a/frontend/apps/reader/modules/readerview.lua +++ b/frontend/apps/reader/modules/readerview.lua @@ -211,6 +211,9 @@ function ReaderView:paintTo(bb, x, y) local center_offset = bit.rshift(self.arrow.height, 1) -- Paint at the proper y origin depending on wheter we paged forward (dim_area.y == 0) or backward self.arrow:paintTo(bb, 0, self.dim_area.y == 0 and self.dim_area.h - center_offset or self.dim_area.y - center_offset) + elseif self.page_overlap_style == "line" then + bb:paintRect(0, self.dim_area.y == 0 and self.dim_area.h or self.dim_area.y, + self.dim_area.w, Size.line.medium, Blitbuffer.COLOR_BLACK) end end -- draw saved highlight @@ -616,19 +619,19 @@ function ReaderView:drawHighlightRect(bb, _x, _y, rect, drawer, draw_note_mark) 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) + bb:paintRect(x, y + h - 1, w, Size.line.medium, 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) + bb:paintRect(x, line_y, w, Size.line.medium, Blitbuffer.COLOR_BLACK) elseif drawer == "invert" then bb:invertRect(x, y, w, h) end if draw_note_mark then if self.highlight.note_mark == "underline" then - bb:paintRect(x, y + h - 1, w, 2, Blitbuffer.COLOR_BLACK) + bb:paintRect(x, y + h - 1, w, Size.line.medium, Blitbuffer.COLOR_BLACK) else local note_mark_pos_x if self.ui.paging or diff --git a/frontend/ui/elements/page_overlap.lua b/frontend/ui/elements/page_overlap.lua index fd1f94d2b..37468a45b 100644 --- a/frontend/ui/elements/page_overlap.lua +++ b/frontend/ui/elements/page_overlap.lua @@ -1,7 +1,8 @@ +local FFIUtil = require("ffi/util") local ReaderUI = require("apps/reader/readerui") local UIManager = require("ui/uimanager") local _ = require("gettext") -local T = require("ffi/util").template +local T = FFIUtil.template local PageOverlap = { text = _("Page overlap"), @@ -72,8 +73,9 @@ You can set how many lines are shown.]]), local page_overlap_styles = { arrow = _("Arrow"), dim = _("Gray out"), + line = _("Horizontal line"), } -for k, v in pairs(page_overlap_styles) do +for k, v in FFIUtil.orderedPairs(page_overlap_styles) do table.insert(PageOverlap.sub_item_table, { text_func = function() local text = v