[UX] Footer: add option to set progress bar min width (#5757)

Allow progress bar to be seen when "Show all at once" enabled
and many items selected (text part will then be truncated).
reviewable/pr5765/r1
Robert 4 years ago committed by poire-z
parent 72fd93c4dd
commit 4a6b8587d7

@ -306,6 +306,9 @@ function ReaderFooter:init()
if not self.settings.toc_markers_width then
self.settings.toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH
end
if not self.settings.progress_bar_min_width_pct then
self.settings.progress_bar_min_width_pct = 20
end
self.mode_list = {}
for i = 0, #self.mode_index do
self.mode_list[self.mode_index[i]] = i
@ -1271,7 +1274,6 @@ function ReaderFooter:addToMainMenu(menu_items)
enabled_func = function()
return not self.settings.disable_progress_bar
end,
separator = true,
sub_item_table = {
{
text = _("No margins (0)"),
@ -1320,6 +1322,35 @@ function ReaderFooter:addToMainMenu(menu_items)
},
},
},
{
text_func = function()
return T(_("Minimal width (%1%)"), self.settings.progress_bar_min_width_pct)
end,
enabled_func = function()
return not self.settings.progress_bar_position and not self.settings.disable_progress_bar
and self.settings.all_at_once
end,
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{
width = Screen:getWidth() * 0.6,
value = self.settings.progress_bar_min_width_pct,
value_min = 20,
value_step = 5,
value_hold_step = 20,
value_max = 50,
title_text = _("Minimal width"),
text = _("Minimal progress bar width in percentage of screen width"),
callback = function(spin)
self.settings.progress_bar_min_width_pct = spin.value
self:refreshFooter(true, true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
end,
keep_menu_open = true,
}
}
})
table.insert(sub_items, getMinibarOption("page_progress"))
@ -1442,11 +1473,11 @@ function ReaderFooter:_updateFooterText(force_repaint, force_recompute)
return
end
local text = self:genFooterText()
if text then
self.footer_text:setText(text)
end
if not text then text = "" end
self.footer_text:setText(text)
self.footer_text:setMaxWidth(math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width))
if self.settings.disable_progress_bar then
if self.has_no_mode or not text or text == "" then
if self.has_no_mode or text == "" then
self.text_width = 0
self.footer_container.dimen.h = 0
self.footer_text.height = 0
@ -1462,9 +1493,11 @@ function ReaderFooter:_updateFooterText(force_repaint, force_recompute)
self.progress_bar.width = math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width)
self.text_width = self.footer_text:getSize().w
else
if self.has_no_mode or not text or text == "" then
if self.has_no_mode or text == "" then
self.text_width = 0
else
local text_max_available_ratio = (100 - self.settings.progress_bar_min_width_pct) / 100
self.footer_text:setMaxWidth(math.floor(text_max_available_ratio * self._saved_screen_width - 2 * self.settings.progress_margin_width))
self.text_width = self.footer_text:getSize().w + self.text_left_margin
end
self.progress_bar.width = math.floor(

Loading…
Cancel
Save