ReaderToc: option to show a dotted line (#7669)

A dotted line joining the ToC entry text to the
page number may make it easier to use.
(This replaces the menu item separator from d879062e.)
Also fix baselines aligment, which could be a bit off.
This commit is contained in:
poire-z
2021-05-13 01:55:35 +02:00
committed by GitHub
parent a20cac6904
commit f0ecbeb1d5
4 changed files with 96 additions and 18 deletions

View File

@@ -643,7 +643,7 @@ function ReaderToc:onShowToc()
local items_per_page = G_reader_settings:readSetting("toc_items_per_page") or self.toc_items_per_page_default
local items_font_size = G_reader_settings:readSetting("toc_items_font_size") or Menu.getItemFontSize(items_per_page)
local items_show_separator = G_reader_settings:isTrue("toc_items_show_separator")
local items_with_dots = G_reader_settings:nilOrTrue("toc_items_with_dots")
-- Estimate expand/collapse icon size
-- *2/5 to acount for Menu top title and bottom icons, and add some space between consecutive icons
local icon_size = math.floor(Screen:getHeight() / items_per_page * 2/5)
@@ -703,10 +703,11 @@ function ReaderToc:onShowToc()
cface = Font:getFace("x_smallinfofont"),
single_line = true,
align_baselines = true,
with_dots = items_with_dots,
items_per_page = items_per_page,
items_font_size = items_font_size,
items_padding = can_collapse and math.floor(Size.padding.fullscreen / 2) or nil, -- c.f., note above. Menu's default is twice that.
line_color = items_show_separator and Blitbuffer.COLOR_DARK_GRAY or Blitbuffer.COLOR_WHITE,
line_color = Blitbuffer.COLOR_WHITE,
on_close_ges = {
GestureRange:new{
ges = "two_finger_swipe",
@@ -1062,14 +1063,14 @@ Enabling this option will restrict display to the chapter titles of progress bar
UIManager:show(items_font)
end,
}
menu_items.toc_items_show_separator = {
text = _("Add a separator between ToC entries"),
menu_items.toc_items_with_dots = {
text = _("With dots"),
keep_menu_open = true,
checked_func = function()
return G_reader_settings:isTrue("toc_items_show_separator")
return G_reader_settings:nilOrTrue("toc_items_with_dots")
end,
callback = function()
G_reader_settings:flipNilOrFalse("toc_items_show_separator")
G_reader_settings:flipNilOrTrue("toc_items_with_dots")
end
}
end