[UX] Footer - add option chapter markers width (#5708)

reviewable/pr5711/r1
Robert 4 years ago committed by Frans de Jonge
parent c3a0bd4def
commit dd0c6c0bb8

@ -9,7 +9,7 @@ echo -e "\n${ANSI_GREEN}shellcheck results"
echo -e "\\n${ANSI_GREEN}Checking for unscaled sizes"
# stick `|| true` at the end to prevent Travis exit on failed command
unscaled_size_check=$(grep -nr --include=*.lua --exclude=koptoptions.lua --exclude-dir=base --exclude-dir=luajit-rocks --exclude-dir=install --exclude-dir=keyboardlayouts --exclude-dir=*arm* "\\(padding\\|margin\\|bordersize\\|width\\|height\\|radius\\|linesize\\) = [0-9]\\{1,2\\}" | grep -v '= 0' | grep -v '= [0-9]/[0-9]' | grep -Ev '(default_option_height|default_option_padding)' | grep -v scaleBySize || true)
unscaled_size_check=$(grep -nr --include=*.lua --exclude=koptoptions.lua --exclude-dir=base --exclude-dir=luajit-rocks --exclude-dir=install --exclude-dir=keyboardlayouts --exclude-dir=*arm* "\\(padding\\|margin\\|bordersize\\|width\\|height\\|radius\\|linesize\\) = [0-9]\\{1,2\\}" | grep -v '= 0' | grep -v '= [0-9]/[0-9]' | grep -Ev '(default_option_height|default_option_padding)' | grep -v scaleBySize | grep -v 'unscaled_size_check: ignore' || true)
# Also check Geom objects; for legibility two regular expressions rather than
# one enormous indecipharable blob.
unscaled_size_check_geom=$(grep -E -nr --include=*.lua --exclude=gesturerange_spec.lua --exclude-dir=base --exclude-dir=luajit-rocks --exclude-dir=*arm* 'Geom:new{.+ [wh] = [0-9]{1,4}' | grep -Ev '[wh] = 0' | grep -v '= [0-9]/[0-9]' | grep -v scaleBySize || true)

@ -108,7 +108,6 @@ read_globals = {
"DCREREADER_CONFIG_WORD_SPACING_SMALL",
"DCREREADER_CONFIG_WORD_SPACING_MEDIUM",
"DCREREADER_CONFIG_WORD_SPACING_LARGE",
"DMINIBAR_TOC_MARKER_WIDTH",
"DMINIBAR_CONTAINER_HEIGHT",
"DMINIBAR_FONT_SIZE",
"DGESDETECT_DISABLE_DOUBLE_TAP",

@ -189,7 +189,8 @@ DCREREADER_CONFIG_WORD_SPACING_LARGE = {100, 90}
--DCREREADER_PROGRESS_BAR = 1
-- configure "mini" progress bar
DMINIBAR_TOC_MARKER_WIDTH = 2 -- Looses usefulness > 3
-- no longer needed
--DMINIBAR_TOC_MARKER_WIDTH = 2 -- Looses usefulness > 3
DMINIBAR_CONTAINER_HEIGHT = 14 -- Larger means more padding at the bottom, at the risk of eating into the last line
DMINIBAR_FONT_SIZE = 14
-- no longer needed

@ -91,6 +91,7 @@ end
local PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT = 7
local PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT = 3
local DMINIBAR_TOC_MARKER_WIDTH = 2
-- functions that generates footer text for each mode
local footerTextGeneratorMap = {
@ -270,7 +271,8 @@ function ReaderFooter:init()
frontlight = false,
mem_usage = false,
wifi_status = false,
item_prefix = "icons"
item_prefix = "icons",
toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH,
}
if not self.settings.order then
@ -300,6 +302,9 @@ function ReaderFooter:init()
if not self.settings.progress_margin_width then
self.settings.progress_margin_width = Screen:scaleBySize(10)
end
if not self.settings.toc_markers_width then
self.settings.toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH
end
self.mode_list = {}
for i = 0, #self.mode_index do
self.mode_list[self.mode_index[i]] = i
@ -330,7 +335,7 @@ function ReaderFooter:init()
width = nil,
height = nil,
percentage = self.progress_percentage,
tick_width = DMINIBAR_TOC_MARKER_WIDTH,
tick_width = Screen:scaleBySize(self.settings.toc_markers_width),
ticks = nil, -- ticks will be populated in self:updateFooterText
last = nil, -- last will be initialized in self:updateFooterText
}
@ -1160,10 +1165,58 @@ function ReaderFooter:addToMainMenu(menu_items)
callback = function()
self.settings.toc_markers = not self.settings.toc_markers
self:setTocMarkers()
self:updateFooter()
UIManager:setDirty(nil, "ui")
self:refreshFooter(true)
end
},
{
text_func = function()
local markers_width_text = _("thick")
if self.settings.toc_markers_width == 1 then
markers_width_text = _("thin")
elseif self.settings.toc_markers_width == 2 then
markers_width_text = _("medium")
end
return T(_("Chapter marker width (%1)"), markers_width_text)
end,
enabled_func = function()
return not self.settings.progress_style_thin and self.settings.toc_markers
end,
sub_item_table = {
{
text = _("Thin"),
checked_func = function()
return self.settings.toc_markers_width == 1
end,
callback = function()
self.settings.toc_markers_width = 1 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Medium"),
checked_func = function()
return self.settings.toc_markers_width == 2
end,
callback = function()
self.settings.toc_markers_width = 2 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end,
},
{
text = _("Thick"),
checked_func = function()
return self.settings.toc_markers_width == 3
end,
callback = function()
self.settings.toc_markers_width = 3 -- unscaled_size_check: ignore
self:setTocMarkers()
self:refreshFooter(true)
end
},
},
},
},
},
{
@ -1274,6 +1327,7 @@ function ReaderFooter:setTocMarkers(reset)
self.pages = self.view.document:getPageCount()
end
if self.settings.toc_markers then
self.progress_bar.tick_width = Screen:scaleBySize(self.settings.toc_markers_width)
if self.progress_bar.ticks ~= nil then return end
local ticks_candidates = {}
if self.ui.toc then

@ -8,7 +8,7 @@ describe("defaults module", function()
it("should load all defaults from defaults.lua", function()
Defaults:init()
assert.is_same(107, #Defaults.defaults_name)
assert.is_same(106, #Defaults.defaults_name)
end)
it("should save changes to defaults.persistent.lua", function()
@ -19,12 +19,12 @@ describe("defaults module", function()
Defaults.changed[20] = true
Defaults.changed[47] = true
Defaults.changed[54] = true
Defaults.changed[86] = true
Defaults.changed[102] = true
Defaults.changed[85] = true
Defaults.changed[101] = true
Defaults:saveSettings()
assert.is_same(107, #Defaults.defaults_name)
assert.is_same("SEARCH_LIBRARY_PATH", Defaults.defaults_name[102])
assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[86])
assert.is_same(106, #Defaults.defaults_name)
assert.is_same("SEARCH_LIBRARY_PATH", Defaults.defaults_name[101])
assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[85])
assert.is_same("DCREREADER_CONFIG_WORD_SPACING_LARGE", Defaults.defaults_name[47])
assert.is_same("DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE", Defaults.defaults_name[20])
local fd = io.open(persistent_filename, "r")
@ -54,8 +54,8 @@ DGLOBALGAMMA = 1
Defaults:init()
Defaults.changed[54] = true
Defaults.defaults_value[54] = 2
Defaults.changed[86] = true
Defaults.defaults_value[86] = {
Defaults.changed[85] = true
Defaults.defaults_value[85] = {
y = 10,
x = 10.125,
h = 20.25,

Loading…
Cancel
Save