@ -104,6 +104,12 @@ function PageBrowserWidget:init()
title = self.title ,
left_icon = " info " ,
left_icon_tap_callback = function ( ) self : showHelp ( ) end ,
left_icon_hold_callback = function ( )
-- Cycle nb of toc span levels shown in bottom row
if self : updateNbTocSpans ( - 1 , true ) then
self : updateLayout ( )
end
end ,
close_callback = function ( ) self : onClose ( ) end ,
close_hold_callback = function ( ) self : onClose ( true ) end ,
show_parent = self ,
@ -128,16 +134,48 @@ function PageBrowserWidget:init()
self.min_nb_cols = 1
self.max_nb_cols = 6
-- Get some info that shouldn't change across calls to update() and updateLayout()
self.ui . toc : fillToc ( )
self.max_toc_depth = self.ui . toc.toc_depth
-- We show the toc depth chosen in BookMapWidget, or all of it if not set
-- (nothing in this PageBrowserWidget to allow changing it)
self.nb_toc_spans = self.ui . doc_settings : readSetting ( " book_map_toc_depth " , self.max_toc_depth )
self.nb_pages = self.ui . document : getPageCount ( )
self.cur_page = self.ui . toc.pageno
-- Get bookmarks and highlights from ReaderBookmark
self.bookmarked_pages = self.ui . bookmark : getBookmarkedPages ( )
-- Get read page from the statistics plugin if enabled
self.read_pages = self.ui . statistics and self.ui . statistics : getCurrentBookReadPages ( )
self.current_session_duration = self.ui . statistics and ( os.time ( ) - self.ui . statistics.start_current_period )
-- Hidden flows, for first page display, and to draw them gray
self.has_hidden_flows = self.ui . document : hasHiddenFlows ( )
if self.has_hidden_flows and # self.ui . document.flows > 0 then
self.hidden_flows = { }
-- Pick into credocument internal data to build a table
-- of {first_page_number, last_page_number) for each flow
for flow , tab in ipairs ( self.ui . document.flows ) do
table.insert ( self.hidden_flows , { tab [ 1 ] , tab [ 1 ] + tab [ 2 ] - 1 } )
end
end
-- Reference page numbers, for first row page display
self.page_labels = nil
if self.ui . pagemap and self.ui . pagemap : wantsPageLabels ( ) then
self.page_labels = self.ui . document : getPageMap ( )
end
-- Location stack
self.previous_locations = self.ui . link : getPreviousLocationPages ( )
-- Compute settings-dependant sizes and options, and build the inner widgets
-- (this will call self:update())
self : updateLayout ( )
end
function PageBrowserWidget : updateLayout ( )
-- We start with showing all toc levels (we could use book_map_toc_depth,
-- but we might want to have it different here).
self.nb_toc_spans = self.ui . doc_settings : readSetting ( " page_browser_toc_depth " ) or self.max_toc_depth
-- Row will contain: nb_toc_spans + page slots + spacing (+ some borders)
self.statistics_enabled = self.ui . statistics and self.ui . statistics : isEnabled ( )
local statistics_enabled = self.ui . statistics and self.ui . statistics : isEnabled ( )
local page_slots_height_ratio = 1 -- default to 1 * span_height
if not self.statistics_enabled and self.nb_toc_spans > 0 then
if not s tatistics_enabled and self.nb_toc_spans > 0 then
-- Just enough to show page separators below toc spans
page_slots_height_ratio = 0.2
end
@ -155,6 +193,9 @@ function PageBrowserWidget:init()
-- And put its bottom rounded corner outside of screen
self.view_finder_h = self.row_height + 2 * self.view_finder_bw + Size.radius . window
if self.grid then
self.grid : free ( )
end
self.grid = OverlapGroup : new {
dimen = Geom : new {
w = self.grid_width ,
@ -162,6 +203,9 @@ function PageBrowserWidget:init()
} ,
allow_mirroring = false ,
}
if self.row then
self.row : free ( )
end
self.row = CenterContainer : new {
dimen = Geom : new {
w = self.dimen . w ,
@ -185,39 +229,6 @@ function PageBrowserWidget:init()
}
}
-- Get some info that shouldn't change across calls to update() and updateLayout()
self.nb_pages = self.ui . document : getPageCount ( )
self.cur_page = self.ui . toc.pageno
-- Get bookmarks and highlights from ReaderBookmark
self.bookmarked_pages = self.ui . bookmark : getBookmarkedPages ( )
-- Get read page from the statistics plugin if enabled
self.read_pages = self.ui . statistics and self.ui . statistics : getCurrentBookReadPages ( )
self.current_session_duration = self.ui . statistics and ( os.time ( ) - self.ui . statistics.start_current_period )
-- Hidden flows, for first page display, and to draw them gray
self.has_hidden_flows = self.ui . document : hasHiddenFlows ( )
if self.has_hidden_flows and # self.ui . document.flows > 0 then
self.hidden_flows = { }
-- Pick into credocument internal data to build a table
-- of {first_page_number, last_page_number) for each flow
for flow , tab in ipairs ( self.ui . document.flows ) do
table.insert ( self.hidden_flows , { tab [ 1 ] , tab [ 1 ] + tab [ 2 ] - 1 } )
end
end
-- Reference page numbers, for first row page display
self.page_labels = nil
if self.ui . pagemap and self.ui . pagemap : wantsPageLabels ( ) then
self.page_labels = self.ui . document : getPageMap ( )
end
-- Location stack
self.previous_locations = self.ui . link : getPreviousLocationPages ( )
-- Compute settings-dependant sizes and options, and build the inner widgets
-- (this will call self:update())
self : updateLayout ( )
end
function PageBrowserWidget : updateLayout ( )
self.nb_rows = self.ui . doc_settings : readSetting ( " page_browser_nb_rows " )
or G_reader_settings : readSetting ( " page_browser_nb_rows " )
self.nb_cols = self.ui . doc_settings : readSetting ( " page_browser_nb_cols " )
@ -609,7 +620,8 @@ Swipe along the top or left screen edge to change the number of columns or rows
Swipe vertically to move one row , horizontally to move one page .
Swipe horizontally in the bottom ribbon to move by the full stripe .
Tap in the bottom ribbon on a page to focus thumbnails on this page .
Tap on a thumbnail to go read this page .
Tap on a thumbnail to read this page .
Long - press on ⓘ to decrease or reset the number of chapter levels shown in the bottom ribbon .
Any multiswipe will close the page browser . ] ] ) ,
} )
end
@ -651,17 +663,41 @@ end
function PageBrowserWidget : saveSettings ( reset )
if reset then
self.nb_toc_spans = nil
self.nb_rows = nil
self.nb_cols = nil
end
self.ui . doc_settings : saveSetting ( " page_browser_toc_depth " , self.nb_toc_spans )
self.ui . doc_settings : saveSetting ( " page_browser_nb_rows " , self.nb_rows )
self.ui . doc_settings : saveSetting ( " page_browser_nb_cols " , self.nb_cols )
-- We also save them as global settings, so they will apply on other books
-- We also save nb_rows/nb_cols as global settings, so they will apply on other books
-- where they were not already set
G_reader_settings : saveSetting ( " page_browser_nb_rows " , self.nb_rows )
G_reader_settings : saveSetting ( " page_browser_nb_cols " , self.nb_cols )
end
function PageBrowserWidget : updateNbTocSpans ( value , relative )
local new_nb_toc_spans
if relative then
new_nb_toc_spans = self.nb_toc_spans + value
else
new_nb_toc_spans = value
end
-- We don't cap, we cycle
if new_nb_toc_spans < 0 then
new_nb_toc_spans = self.max_toc_depth
end
if new_nb_toc_spans > self.max_toc_depth then
new_nb_toc_spans = 0
end
if new_nb_toc_spans == self.nb_toc_spans then
return false
end
self.nb_toc_spans = new_nb_toc_spans
self : saveSettings ( )
return true
end
function PageBrowserWidget : updateNbCols ( value , relative )
local new_nb_cols
if relative then