@ -295,9 +295,9 @@ local ReaderFooter = WidgetContainer:extend{
footer_text = nil ,
text_font_face = " ffont " ,
height = Screen : scaleBySize ( DMINIBAR_CONTAINER_HEIGHT ) ,
horizontal_margin = S creen: scaleBySize ( 10 ) ,
text_left_margin = S creen: scaleBySize ( 10 ) ,
bottom_padding = S creen: scaleBySize ( 1 ) ,
horizontal_margin = S ize.span. horizontal_default ,
text_left_margin = S ize.span. horizontal_default ,
bottom_padding = S ize.padding. tiny ,
settings = { } ,
-- added to expose them to unit tests
textGeneratorMap = footerTextGeneratorMap ,
@ -327,6 +327,8 @@ function ReaderFooter:init()
toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH ,
text_font_size = DMINIBAR_FONT_SIZE ,
text_font_bold = false ,
container_height = DMINIBAR_CONTAINER_HEIGHT ,
container_bottom_padding = 1 , -- unscaled_size_check: ignore
}
-- Remove items not supported by the current device
@ -377,6 +379,16 @@ function ReaderFooter:init()
end
-- require("logger").dbg(self.mode_nb, self.mode_index)
-- Container settings
if not self.settings . container_height then
self.settings . container_height = DMINIBAR_CONTAINER_HEIGHT
end
self.height = Screen : scaleBySize ( self.settings . container_height )
if not self.settings . container_bottom_padding then
self.settings . container_bottom_padding = 1 -- unscaled_size_check: ignore
end
self.bottom_padding = Screen : scaleBySize ( self.settings . container_bottom_padding )
-- default margin (like self.horizontal_margin)
if not self.settings . progress_margin_width then
local defaults = Device : isAndroid ( ) and material_pixels or 10
@ -452,7 +464,6 @@ function ReaderFooter:init()
self : resetLayout ( )
self.footer_container . dimen.h = 0
self.footer_text . height = 0
end
if self.settings . all_at_once then
self.view . footer_visible = ( self.mode ~= self.mode_list . off )
@ -479,7 +490,7 @@ function ReaderFooter:updateFooterContainer()
h = Size.line . medium ,
}
}
local vertical_span = VerticalSpan : new { width = self.bottom_padding * 2 }
local vertical_span = VerticalSpan : new { width = Size.span. vertical_default }
table.insert ( self.vertical_frame , self.separator_line )
table.insert ( self.vertical_frame , vertical_span )
end
@ -515,7 +526,7 @@ function ReaderFooter:updateFooterContainer()
}
end
local vertical_span = VerticalSpan : new { width = self.bottom_padding * 2 }
local vertical_span = VerticalSpan : new { width = Size.span. vertical_default }
if self.settings . progress_bar_position == " above " and not self.settings . disable_progress_bar then
table.insert ( self.vertical_frame , self.progress_bar )
@ -932,6 +943,60 @@ function ReaderFooter:addToMainMenu(menu_items)
} ,
}
} ,
{
text_func = function ( )
return T ( _ ( " Container height (%1) " ) , self.settings . container_height )
end ,
callback = function ( touchmenu_instance )
local SpinWidget = require ( " ui/widget/spinwidget " )
local container_height = self.settings . container_height
local items_font = SpinWidget : new {
width = Screen : getWidth ( ) * 0.6 ,
value = container_height ,
value_min = 7 ,
value_max = 98 ,
default_value = DMINIBAR_CONTAINER_HEIGHT ,
ok_text = _ ( " Set height " ) ,
title_text = _ ( " Container height " ) ,
keep_shown_on_apply = true ,
callback = function ( spin )
self.settings . container_height = spin.value
self.height = Screen : scaleBySize ( self.settings . container_height )
self : refreshFooter ( true , true )
if touchmenu_instance then touchmenu_instance : updateItems ( ) end
end ,
}
UIManager : show ( items_font )
end ,
keep_menu_open = true ,
} ,
{
text_func = function ( )
return T ( _ ( " Container bottom margin (%1) " ) , self.settings . container_bottom_padding )
end ,
callback = function ( touchmenu_instance )
local SpinWidget = require ( " ui/widget/spinwidget " )
local container_bottom_padding = self.settings . container_bottom_padding
local items_font = SpinWidget : new {
width = Screen : getWidth ( ) * 0.6 ,
value = container_bottom_padding ,
value_min = 0 ,
value_max = 49 ,
default_value = 1 ,
ok_text = _ ( " Set margin " ) ,
title_text = _ ( " Container bottom margin " ) ,
keep_shown_on_apply = true ,
callback = function ( spin )
self.settings . container_bottom_padding = spin.value
self.bottom_padding = Screen : scaleBySize ( self.settings . container_bottom_padding )
self : refreshFooter ( true , true )
if touchmenu_instance then touchmenu_instance : updateItems ( ) end
end ,
}
UIManager : show ( items_font )
end ,
keep_menu_open = true ,
} ,
{
text = _ ( " Maximum width of items " ) ,
sub_item_table = {
@ -991,6 +1056,7 @@ function ReaderFooter:addToMainMenu(menu_items)
} ,
{
text = _ ( " Alignment " ) ,
separator = true ,
enabled_func = function ( )
return self.settings . disable_progress_bar or self.settings . progress_bar_position ~= nil
end ,
@ -1043,8 +1109,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . item_prefix = " icons "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1060,8 +1125,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . item_prefix = " letters "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
} ,
@ -1076,8 +1140,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . items_separator = " bar "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1087,8 +1150,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . items_separator = " bullet "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1098,8 +1160,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . items_separator = " none "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
} ,
@ -1116,8 +1177,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . progress_pct_format = " 0 "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1129,8 +1189,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . progress_pct_format = " 1 "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1142,8 +1201,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . progress_pct_format = " 2 "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
} ,
@ -1164,8 +1222,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . time_format = " 24 "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1181,8 +1238,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . time_format = " 12 "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
}
@ -1204,8 +1260,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . duration_format = " modern "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
{
@ -1222,8 +1277,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end ,
callback = function ( )
self.settings . duration_format = " classic "
self : updateFooter ( )
UIManager : setDirty ( nil , " ui " )
self : refreshFooter ( true )
end ,
} ,
}
@ -1293,7 +1347,7 @@ function ReaderFooter:addToMainMenu(menu_items)
callback = function ( )
if self.settings . progress_margin then
self.settings . progress_margin = false
self.settings . progress_margin_width = S creen: scaleBySize ( 10 )
self.settings . progress_margin_width = S ize.span. horizontal_default
end
self.settings . progress_bar_position = nil
self : refreshFooter ( true , true )
@ -1346,12 +1400,12 @@ function ReaderFooter:addToMainMenu(menu_items)
default_value = PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT
value = self.settings . progress_style_thin_height or default_value
value_min = 1
value_max = 4
value_max = 12
else
default_value = PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT
value = self.settings . progress_style_thick_height or default_value
value_min = 5
value_max = 14
value_max = 28
end
local SpinWidget = require ( " ui/widget/spinwidget " )
local items = SpinWidget : new {
@ -1447,7 +1501,7 @@ function ReaderFooter:addToMainMenu(menu_items)
text_func = function ( )
local text = _ ( " static margins (10) " )
local cur_width = self.settings . progress_margin_width
if cur_width == Screen : scaleBySize ( 0 ) then
if cur_width == 0 then
text = _ ( " no margins (0) " )
elseif cur_width == Screen : scaleBySize ( material_pixels ) then
text = T ( _ ( " static margins (%1) " ) , material_pixels )
@ -1465,11 +1519,11 @@ function ReaderFooter:addToMainMenu(menu_items)
{
text = _ ( " No margins (0) " ) ,
checked_func = function ( )
return self.settings . progress_margin_width == Screen : scaleBySize ( 0 )
return self.settings . progress_margin_width == 0
and not self.settings . progress_margin
end ,
callback = function ( )
self.settings . progress_margin_width = Screen : scaleBySize ( 0 )
self.settings . progress_margin_width = 0
self.settings . progress_margin = false
self : refreshFooter ( true )
end ,
@ -1746,7 +1800,7 @@ function ReaderFooter:onReaderReady()
self : setupTouchZones ( )
-- if same as book margins is selected in document with pages (pdf) we enforce static margins
if self.ui . document.info . has_pages and self.settings . progress_margin then
self.settings . progress_margin_width = S creen: scaleBySize ( 10 )
self.settings . progress_margin_width = S ize.span. horizontal_default
self : updateFooterContainer ( )
-- set progress bar margins for current book
elseif self.settings . progress_margin then
@ -1786,24 +1840,35 @@ function ReaderFooter:applyFooterMode(mode)
-- 12 for current chapter
if mode ~= nil then self.mode = mode end
local prev_visible_state = self.view . footer_visible
self.view . footer_visible = ( self.mode ~= self.mode_list . off )
-- If all-at-once is enabled, just hide, but the text will keep being processed...
if self.settings . all_at_once then
return
end
-- We're not in all-at-once mode, disable text generation entirely when we're hidden
-- NOTE: _updateFooterText won't actually run the text generator(s) when hidden ;).
-- We're hidden, disable text generation entirely
if not self.view . footer_visible then
self.genFooterText = footerTextGeneratorMap.empty
return
else
if self.settings . all_at_once then
-- If all-at-once is enabled, we only have toggle from empty to All.
self.genFooterText = self.genAllFooterText
else
-- Otherwise, switch to the right text generator for the new mode
local mode_name = self.mode_index [ self.mode ]
if not self.settings [ mode_name ] or self.has_no_mode then
-- all modes disabled, only show progress bar
mode_name = " empty "
end
self.genFooterText = footerTextGeneratorMap [ mode_name ]
end
end
local mode_name = self.mode_index [ self.mode ]
if not self.settings [ mode_name ] or self.has_no_mode then
-- all modes disabled, only show progress bar
mode_name = " empty "
-- If we changed visibility state at runtime (as opposed to during init), better make sure the layout has been reset...
if prev_visible_state ~= nil and self.view . footer_visible ~= prev_visible_state then
self : updateFooterContainer ( )
-- NOTE: _updateFooterText does a resetLayout, but not a forced one!
self : resetLayout ( true )
end
self.genFooterText = footerTextGeneratorMap [ mode_name ]
end
function ReaderFooter : onEnterFlippingMode ( )