Fix footer with no_mode/disabled progress bar (#5491)

pull/5488/head
Robert 5 years ago committed by Frans de Jonge
parent ebcefe1c98
commit 40ba01fd72

@ -288,10 +288,17 @@ function ReaderFooter:init()
self.mode = self.mode_list.off self.mode = self.mode_list.off
self.view.footer_visible = false self.view.footer_visible = false
self:resetLayout() self:resetLayout()
self.footer_container.dimen.h = 0
self.footer_text.height = 0
end end
if self.settings.all_at_once then if self.settings.all_at_once then
self.view.footer_visible = (self.mode ~= self.mode_list.off) self.view.footer_visible = (self.mode ~= self.mode_list.off)
self:updateFooterTextGenerator() self:updateFooterTextGenerator()
if self.settings.progress_bar_position and self.has_no_mode then
self.footer_container.dimen.h = 0
self.footer_text.height = 0
end
else else
self:applyFooterMode() self:applyFooterMode()
end end
@ -586,10 +593,18 @@ function ReaderFooter:addToMainMenu(menu_items)
self.reclaim_height = self.settings.reclaim_height or false self.reclaim_height = self.settings.reclaim_height or false
-- refresh margins position -- refresh margins position
if self.has_no_mode then if self.has_no_mode then
self.footer_container.dimen.h = 0
self.footer_text.height = 0
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin)) self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
self.genFooterText = footerTextGeneratorMap.empty self.genFooterText = footerTextGeneratorMap.empty
self.mode = self.mode_list.off self.mode = self.mode_list.off
elseif prev_has_no_mode then elseif prev_has_no_mode then
self.footer_container.dimen.h = self.height
self.footer_text.height = self.height
if self.settings.all_at_once then
self.mode = self.mode_list.page_progress
self:applyFooterMode()
end
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin)) self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
G_reader_settings:saveSetting("reader_footer_mode", first_enabled_mode_num) G_reader_settings:saveSetting("reader_footer_mode", first_enabled_mode_num)
elseif self.reclaim_height ~= prev_reclaim_height then elseif self.reclaim_height ~= prev_reclaim_height then
@ -612,8 +627,7 @@ function ReaderFooter:addToMainMenu(menu_items)
self:applyFooterMode() self:applyFooterMode()
end end
if should_update then if should_update then
self:updateFooter() self:refreshFooter(true, true)
UIManager:setDirty(nil, "ui")
end end
end, end,
} }
@ -930,12 +944,14 @@ function ReaderFooter:addToMainMenu(menu_items)
end, end,
callback = function() callback = function()
self.settings.disable_progress_bar = not self.settings.disable_progress_bar self.settings.disable_progress_bar = not self.settings.disable_progress_bar
self:setTocMarkers() if not self.settings.disable_progress_bar then
if self.settings.progress_bar_position == "above" then self.footer_container.dimen.h = self.height
self:refreshFooter(true, true) self.footer_text.height = self.height
else self:setTocMarkers()
self:refreshFooter(true) self.mode = self.mode_list.page_progress
self:applyFooterMode()
end end
self:refreshFooter(true, true)
end, end,
}, },
{ {
@ -1264,11 +1280,17 @@ function ReaderFooter:_updateFooterText(force_repaint)
if self.settings.disable_progress_bar then if self.settings.disable_progress_bar then
if self.has_no_mode or not text then if self.has_no_mode or not text then
self.text_width = 0 self.text_width = 0
self.footer_container.dimen.h = 0
self.footer_text.height = 0
else else
self.text_width = self.footer_text:getSize().w self.text_width = self.footer_text:getSize().w
end end
self.progress_bar.width = 0 self.progress_bar.width = 0
elseif self.settings.progress_bar_position then elseif self.settings.progress_bar_position then
if text == "" then
self.footer_container.dimen.h = 0
self.footer_text.height = 0
end
self.progress_bar.width = math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width) self.progress_bar.width = math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width)
self.text_width = self.footer_text:getSize().w self.text_width = self.footer_text:getSize().w
else else

@ -504,7 +504,7 @@ function ReaderTypeset:onSetPageMargins(margins, refresh_callback)
local top = Screen:scaleBySize(margins[2]) local top = Screen:scaleBySize(margins[2])
local right = Screen:scaleBySize(margins[3]) local right = Screen:scaleBySize(margins[3])
local bottom local bottom
if self.view.footer.has_no_mode or self.view.footer.reclaim_height then if self.view.footer.reclaim_height then
bottom = Screen:scaleBySize(margins[4]) bottom = Screen:scaleBySize(margins[4])
else else
bottom = Screen:scaleBySize(margins[4]) + self.view.footer:getHeight() bottom = Screen:scaleBySize(margins[4]) + self.view.footer:getHeight()

Loading…
Cancel
Save