2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Two-line footer (#5405)

Close: #1933

New option that moves progress bar to separate line in footer.
This commit is contained in:
Robert 2019-09-20 09:33:29 +02:00 committed by Frans de Jonge
parent d456a076af
commit e2c771dd2d

View File

@ -273,14 +273,6 @@ function ReaderFooter:init()
self.footer_text,
}
local margin_span = HorizontalSpan:new{ width = self.horizontal_margin }
self.horizontal_group = HorizontalGroup:new{
margin_span,
self.progress_bar,
self.text_container,
margin_span,
}
self:updateFooterContainer()
self.mode = G_reader_settings:readSetting("reader_footer_mode") or self.mode
@ -301,6 +293,37 @@ function ReaderFooter:init()
end
function ReaderFooter:updateFooterContainer()
local margin_span = HorizontalSpan:new{ width = self.horizontal_margin }
self.vertical_frame = VerticalGroup:new{}
if self.settings.bottom_horizontal_separator then
self.separator_line = LineWidget:new{
dimen = Geom:new{
w = 0,
h = Size.line.medium,
}
}
local vertical_span = VerticalSpan:new{width = self.bottom_padding *2}
table.insert(self.vertical_frame, self.separator_line)
table.insert(self.vertical_frame, vertical_span)
end
if self.settings.progress_bar_separate_line and not self.settings.disable_progress_bar then
self.horizontal_group = HorizontalGroup:new{
margin_span,
self.text_container,
margin_span,
}
local vertical_span = VerticalSpan:new{width = self.bottom_padding *2}
table.insert(self.vertical_frame, self.progress_bar)
table.insert(self.vertical_frame, vertical_span)
else
self.horizontal_group = HorizontalGroup:new{
margin_span,
self.progress_bar,
self.text_container,
margin_span,
}
end
if self.settings.align == "left" then
self.footer_container = LeftContainer:new{
dimen = Geom:new{ w = 0, h = self.height },
@ -318,24 +341,7 @@ function ReaderFooter:updateFooterContainer()
}
end
if self.settings.bottom_horizontal_separator then
self.separator_line = LineWidget:new{
dimen = Geom:new{
w = 0,
h = Size.line.medium,
}
}
local vertical_span = VerticalSpan:new{width = self.bottom_padding *2}
self.vertical_frame = VerticalGroup:new{
self.separator_line,
vertical_span,
self.footer_container,
}
else
self.vertical_frame = VerticalGroup:new{
self.footer_container,
}
end
table.insert(self.vertical_frame, self.footer_container)
self.footer_content = FrameContainer:new{
self.vertical_frame,
@ -404,6 +410,8 @@ function ReaderFooter:resetLayout(force_reset)
if self.settings.disable_progress_bar then
self.progress_bar.width = 0
elseif self.settings.progress_bar_separate_line then
self.progress_bar.width = math.floor(new_screen_width - self.horizontal_margin*2)
else
self.progress_bar.width = math.floor(
new_screen_width - self.text_width - self.horizontal_margin*2)
@ -643,9 +651,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end,
callback = function()
self.settings.bottom_horizontal_separator = not self.settings.bottom_horizontal_separator
self:updateFooterContainer()
self:resetLayout(true)
self:updateFooter()
self:refreshFooter()
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
UIManager:setDirty(nil, "ui")
end,
@ -653,7 +659,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{
text = _("Alignment"),
enabled_func = function()
return self.settings.disable_progress_bar == true
return self.settings.disable_progress_bar or self.settings.progress_bar_separate_line
end,
sub_item_table = {
{
@ -663,9 +669,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end,
callback = function()
self.settings.align = "center"
self:updateFooterContainer()
self:resetLayout(true)
self:updateFooter()
self:refreshFooter()
UIManager:setDirty(nil, "ui")
end,
},
@ -676,9 +680,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end,
callback = function()
self.settings.align = "left"
self:updateFooterContainer()
self:resetLayout(true)
self:updateFooter()
self:refreshFooter()
UIManager:setDirty(nil, "ui")
end,
},
@ -689,9 +691,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end,
callback = function()
self.settings.align = "right"
self:updateFooterContainer()
self:resetLayout(true)
self:updateFooter()
self:refreshFooter()
UIManager:setDirty(nil, "ui")
end,
},
@ -911,7 +911,10 @@ function ReaderFooter:addToMainMenu(menu_items)
end,
callback = function()
self.settings.disable_progress_bar = not self.settings.disable_progress_bar
self:updateFooter()
self:refreshFooter()
if self.settings.progress_bar_separate_line then
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
end
UIManager:setDirty(nil, "ui")
end,
},
@ -930,6 +933,21 @@ function ReaderFooter:addToMainMenu(menu_items)
UIManager:setDirty(nil, "ui")
end,
},
{
text = _("Progress bar on separate line"),
checked_func = function()
return self.settings.progress_bar_separate_line
end,
enabled_func = function()
return not self.settings.disable_progress_bar
end,
callback = function()
self.settings.progress_bar_separate_line = not self.settings.progress_bar_separate_line
self:refreshFooter()
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
UIManager:setDirty(nil, "ui")
end,
},
}
})
table.insert(sub_items, getMinibarOption("page_progress"))
@ -1053,6 +1071,9 @@ function ReaderFooter:_updateFooterText(force_repaint)
self.text_width = self.footer_text:getSize().w
end
self.progress_bar.width = 0
elseif self.settings.progress_bar_separate_line then
self.progress_bar.width = math.floor(self._saved_screen_width - self.horizontal_margin*2)
self.text_width = self.footer_text:getSize().w
else
if self.has_no_mode or not text then
self.text_width = 0
@ -1212,6 +1233,12 @@ function ReaderFooter:setVisible(visible)
end
end
function ReaderFooter:refreshFooter()
self:updateFooterContainer()
self:resetLayout(true)
self:updateFooter()
end
function ReaderFooter:onResume()
self:updateFooter()
if self.settings.auto_refresh_time then