From bf8274d47c67edf4669e9c5a2824fff94e0c80d3 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sun, 23 Nov 2025 08:48:17 +0200 Subject: [PATCH] Show next locations in Book map and Page browser (#14643) --- frontend/apps/reader/modules/readerlink.lua | 24 +++++++++++++-------- frontend/ui/widget/bookmapwidget.lua | 19 ++++++++++++---- frontend/ui/widget/pagebrowserwidget.lua | 8 +++++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 158b73322..6a67eaa18 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -809,19 +809,25 @@ function ReaderLink:onClearForwardLocationStack() return true end -function ReaderLink:getPreviousLocationPages() - local previous_locations = {} - if #self.location_stack > 0 then - for num, location in ipairs(self.location_stack) do - if self.ui.rolling and location.xpointer then - previous_locations[self.document:getPageFromXPointer(location.xpointer)] = num +function ReaderLink:getLocationPages(forward_location) + local location_stack = forward_location and self.forward_location_stack or self.location_stack + local location_pages = {} + if #location_stack > 0 then + if self.ui.rolling then + for i, location in ipairs(location_stack) do + if location.xpointer then + location_pages[self.document:getPageFromXPointer(location.xpointer)] = i + end end - if self.ui.paging and location[1] and location[1].page then - previous_locations[location[1].page] = num + else + for i, location in ipairs(location_stack) do + if location[1] and location[1].page then + location_pages[location[1].page] = i + end end end end - return previous_locations + return location_pages end --- Goes to link. diff --git a/frontend/ui/widget/bookmapwidget.lua b/frontend/ui/widget/bookmapwidget.lua index 083065086..bb27ae38a 100644 --- a/frontend/ui/widget/bookmapwidget.lua +++ b/frontend/ui/widget/bookmapwidget.lua @@ -553,10 +553,18 @@ function BookMapRow:init() -- Indicator for previous locations if self.previous_locations[page] and page ~= self.cur_page then local x, y = self:getIndicatorXY(page, self.bookmarked_pages[page] or page == self.pinned_page) - local num = self.previous_locations[page] + local num = math.min(self.previous_locations[page], 20) table.insert(self.indicators, { - c = 0x2775 + (num < 10 and num or 10), -- number in solid black circle - -- c = 0x245F + (num < 20 and num or 20), -- number in white circle + c = (num <= 10 and 0x2775 or 0x24E0) + num, -- number in solid black circle, 1 to 20 + x = x, y = y, + }) + end + -- Indicator for next locations + if self.next_locations[page] and page ~= self.cur_page then + local x, y = self:getIndicatorXY(page, self.bookmarked_pages[page] or page == self.pinned_page) + local num = math.min(self.next_locations[page], 20) + table.insert(self.indicators, { + c = 0x245F + num, -- number in white circle, 1 to 20 x = x, y = y, }) end @@ -862,7 +870,8 @@ function BookMapWidget:init() self.page_labels = self.ui.document:getPageMap() end -- Location stack - self.previous_locations = self.ui.link:getPreviousLocationPages() + self.previous_locations = self.ui.link:getLocationPages() + self.next_locations = self.ui.link:getLocationPages(true) self.pinned_page = self.ui.gotopage:getPinnedPageNumber() -- Update stuff that may be updated by the user while in PageBrowser @@ -1251,6 +1260,7 @@ function BookMapWidget:update() bookmarked_pages = self.bookmarked_pages, pinned_page = self.pinned_page, previous_locations = self.previous_locations, + next_locations = self.next_locations, extra_symbols_pages = self.extra_symbols_pages, hidden_flows = self.hidden_flows, read_pages = self.read_pages, @@ -1497,6 +1507,7 @@ Book map provides a summary of a book's content, showing chapters and pages visu Map legend: ▲ current page ❶ ❷ … previous locations +① ② … next locations ▒ highlighted text  highlighted text with notes  bookmarked page diff --git a/frontend/ui/widget/pagebrowserwidget.lua b/frontend/ui/widget/pagebrowserwidget.lua index b2479c9df..dcc0af331 100644 --- a/frontend/ui/widget/pagebrowserwidget.lua +++ b/frontend/ui/widget/pagebrowserwidget.lua @@ -180,7 +180,8 @@ function PageBrowserWidget:init() self.page_labels = self.ui.document:getPageMap() end -- Location stack - self.previous_locations = self.ui.link:getPreviousLocationPages() + self.previous_locations = self.ui.link:getLocationPages() + self.next_locations = self.ui.link:getLocationPages(true) self.pinned_page = self.ui.gotopage:getPinnedPageNumber() -- Update stuff that may be updated by the user while in PageBrowser @@ -502,7 +503,8 @@ function PageBrowserWidget:update() local show_at_bottom if p >= next_p then -- Only show a page text if there is no indicator on that slot - if p ~= self.cur_page and not self.bookmarked_pages[p] and not self.previous_locations[p] then + if p ~= self.cur_page and not self.bookmarked_pages[p] + and not self.previous_locations[p] and not self.next_locations[p] then show_at_bottom = true end end @@ -666,6 +668,7 @@ function PageBrowserWidget:update() bookmarked_pages = self.bookmarked_pages, pinned_page = self.pinned_page, previous_locations = self.previous_locations, + next_locations = self.next_locations, hidden_flows = self.hidden_flows, read_pages = self.read_pages, current_session_duration = self.current_session_duration, @@ -1151,6 +1154,7 @@ Chapters are indicated above the pages they cover. Below the pages, the following indicators may appear: ▲ current page ❶ ❷ … previous locations +① ② … next locations ▒ highlighted text  highlighted text with notes  bookmarked page