[UX] Footer: add option to set font size (#5736)

This commit is contained in:
Robert
2020-01-05 00:09:27 +01:00
committed by poire-z
parent 51ed411ee4
commit 8a0ce98149
4 changed files with 51 additions and 13 deletions

View File

@@ -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()