mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[UX] Footer: add option to set font size (#5736)
This commit is contained in:
@@ -109,7 +109,6 @@ read_globals = {
|
||||
"DCREREADER_CONFIG_WORD_SPACING_MEDIUM",
|
||||
"DCREREADER_CONFIG_WORD_SPACING_LARGE",
|
||||
"DMINIBAR_CONTAINER_HEIGHT",
|
||||
"DMINIBAR_FONT_SIZE",
|
||||
"DGESDETECT_DISABLE_DOUBLE_TAP",
|
||||
"FRONTLIGHT_SENSITIVITY_DECREASE",
|
||||
"DALPHA_SORT_CASE_INSENSITIVE",
|
||||
|
||||
@@ -192,7 +192,8 @@ DCREREADER_CONFIG_WORD_SPACING_LARGE = {100, 90}
|
||||
-- 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
|
||||
--DMINIBAR_FONT_SIZE = 14
|
||||
-- no longer needed
|
||||
--DMINIBAR_HEIGHT = 7 -- Should be smaller than DMINIBAR_CONTAINER_HEIGHT
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ end
|
||||
local PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT = 7
|
||||
local PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT = 3
|
||||
local DMINIBAR_TOC_MARKER_WIDTH = 2
|
||||
local DMINIBAR_FONT_SIZE = 14
|
||||
|
||||
-- functions that generates footer text for each mode
|
||||
local footerTextGeneratorMap = {
|
||||
@@ -243,7 +244,6 @@ local ReaderFooter = WidgetContainer:extend{
|
||||
progress_percentage = 0.0,
|
||||
footer_text = nil,
|
||||
text_font_face = "ffont",
|
||||
text_font_size = DMINIBAR_FONT_SIZE,
|
||||
height = Screen:scaleBySize(DMINIBAR_CONTAINER_HEIGHT),
|
||||
horizontal_margin = Screen:scaleBySize(10),
|
||||
text_left_margin = Screen:scaleBySize(10),
|
||||
@@ -273,6 +273,7 @@ function ReaderFooter:init()
|
||||
wifi_status = false,
|
||||
item_prefix = "icons",
|
||||
toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH,
|
||||
text_font_size = DMINIBAR_FONT_SIZE,
|
||||
}
|
||||
|
||||
if not self.settings.order then
|
||||
@@ -325,9 +326,12 @@ function ReaderFooter:init()
|
||||
end
|
||||
end
|
||||
|
||||
if not self.settings.text_font_size then
|
||||
self.settings.text_font_size = DMINIBAR_FONT_SIZE
|
||||
end
|
||||
self.footer_text = TextWidget:new{
|
||||
text = '',
|
||||
face = Font:getFace(self.text_font_face, self.text_font_size),
|
||||
face = Font:getFace(self.text_font_face, self.settings.text_font_size),
|
||||
}
|
||||
-- all width related values will be initialized in self:resetLayout()
|
||||
self.text_width = 0
|
||||
@@ -757,7 +761,6 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
},
|
||||
{
|
||||
text = _("Show footer separator"),
|
||||
separator = true,
|
||||
checked_func = function()
|
||||
return self.settings.bottom_horizontal_separator
|
||||
end,
|
||||
@@ -766,6 +769,41 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
self:refreshFooter(true, true)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Font size (%1)"), self.settings.text_font_size)
|
||||
end,
|
||||
separator = true,
|
||||
callback = function(touchmenu_instance)
|
||||
local SpinWidget = require("ui/widget/spinwidget")
|
||||
local font_size = self.settings.text_font_size
|
||||
local items_font = SpinWidget:new{
|
||||
width = Screen:getWidth() * 0.6,
|
||||
value = font_size,
|
||||
value_min = 10,
|
||||
value_max = 18,
|
||||
default_value = 14,
|
||||
ok_text = _("Set size"),
|
||||
title_text = _("Footer font size"),
|
||||
callback = function(spin)
|
||||
self.settings.text_font_size = spin.value
|
||||
local text = self.footer_text.text
|
||||
self.footer_text = TextWidget:new{
|
||||
text = text,
|
||||
face = Font:getFace(self.text_font_face, self.settings.text_font_size)
|
||||
}
|
||||
self.text_container = RightContainer:new{
|
||||
dimen = Geom:new{ w = 0, h = self.height },
|
||||
self.footer_text,
|
||||
}
|
||||
self:refreshFooter(true, true)
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end,
|
||||
}
|
||||
UIManager:show(items_font)
|
||||
end,
|
||||
keep_menu_open = true,
|
||||
},
|
||||
{
|
||||
text = _("Alignment"),
|
||||
enabled_func = function()
|
||||
|
||||
@@ -8,7 +8,7 @@ describe("defaults module", function()
|
||||
|
||||
it("should load all defaults from defaults.lua", function()
|
||||
Defaults:init()
|
||||
assert.is_same(106, #Defaults.defaults_name)
|
||||
assert.is_same(105, #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[85] = true
|
||||
Defaults.changed[101] = true
|
||||
Defaults.changed[84] = true
|
||||
Defaults.changed[100] = true
|
||||
Defaults:saveSettings()
|
||||
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(105, #Defaults.defaults_name)
|
||||
assert.is_same("SEARCH_LIBRARY_PATH", Defaults.defaults_name[100])
|
||||
assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[84])
|
||||
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[85] = true
|
||||
Defaults.defaults_value[85] = {
|
||||
Defaults.changed[84] = true
|
||||
Defaults.defaults_value[84] = {
|
||||
y = 10,
|
||||
x = 10.125,
|
||||
h = 20.25,
|
||||
|
||||
Reference in New Issue
Block a user