mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
History, Collection: title bar in FM style (#11243)
These changes make the title bar in File manager, History and Collection windows of the same height. The items and book covers thumbnail dimensions in Mosaic and Detailed list display modes are now equal, and up/down scaling of the thumbnails is not needed when switching between File manager, History and Collection.
This commit is contained in:
@@ -125,6 +125,9 @@ function FileManagerCollection:onShowColl(collection_name)
|
||||
covers_fullscreen = true, -- hint for UIManager:_repaint()
|
||||
is_borderless = true,
|
||||
is_popout = false,
|
||||
-- item and book cover thumbnail dimensions in Mosaic and Detailed list display modes
|
||||
-- must be equal in File manager, History and Collection windows to avoid image scaling
|
||||
title_bar_fm_style = true,
|
||||
title_bar_left_icon = "appbar.menu",
|
||||
onLeftButtonTap = function() self:showCollDialog() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
|
||||
@@ -81,17 +81,13 @@ function FileManagerHistory:updateItemTable()
|
||||
self.count[v.status] = self.count[v.status] + 1
|
||||
end
|
||||
end
|
||||
local title = self.hist_menu_title
|
||||
local filter_title
|
||||
local subtitle
|
||||
if self.search_string then
|
||||
filter_title = _("search results")
|
||||
subtitle = T("Search results (%1)", #item_table)
|
||||
elseif self.filter ~= "all" then
|
||||
filter_title = filter_text[self.filter]:lower()
|
||||
subtitle = T("Status: %1 (%2)", filter_text[self.filter]:lower(), #item_table)
|
||||
end
|
||||
if filter_title then
|
||||
title = title .. T(" (%1: %2)", filter_title, #item_table)
|
||||
end
|
||||
self.hist_menu:switchItemTable(title, item_table, select_number)
|
||||
self.hist_menu:switchItemTable(nil, item_table, select_number, nil, subtitle or "")
|
||||
end
|
||||
|
||||
function FileManagerHistory:isItemMatch(item)
|
||||
@@ -223,6 +219,10 @@ function FileManagerHistory:onShowHist(search_info)
|
||||
covers_fullscreen = true, -- hint for UIManager:_repaint()
|
||||
is_borderless = true,
|
||||
is_popout = false,
|
||||
title = self.hist_menu_title,
|
||||
-- item and book cover thumbnail dimensions in Mosaic and Detailed list display modes
|
||||
-- must be equal in File manager, History and Collection windows to avoid image scaling
|
||||
title_bar_fm_style = true,
|
||||
title_bar_left_icon = "appbar.menu",
|
||||
onLeftButtonTap = function() self:showHistDialog() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
|
||||
@@ -561,7 +561,10 @@ Widget that displays menu
|
||||
local Menu = FocusManager:extend{
|
||||
show_parent = nil,
|
||||
|
||||
title = "No Title",
|
||||
no_title = false,
|
||||
title = "",
|
||||
subtitle = nil,
|
||||
show_path = nil, -- path in titlebar subtitle
|
||||
-- default width and height
|
||||
width = nil,
|
||||
-- height will be calculated according to item number if not given
|
||||
@@ -596,6 +599,7 @@ local Menu = FocusManager:extend{
|
||||
-- if you want to embed the menu widget into another widget, set
|
||||
-- this to false
|
||||
is_popout = true,
|
||||
title_bar_fm_style = nil, -- set to true to build increased title bar like in FileManager
|
||||
-- set icon to add title bar left button
|
||||
title_bar_left_icon = nil,
|
||||
-- close_callback is a function, which is executed when menu is closed
|
||||
@@ -615,8 +619,11 @@ function Menu:_recalculateDimen()
|
||||
bottom_height = math.max(self.page_return_arrow:getSize().h, self.page_info_text:getSize().h)
|
||||
+ 2 * Size.padding.button
|
||||
end
|
||||
if self.title_bar and not self.no_title then
|
||||
top_height = self.title_bar:getHeight() + self.header_padding
|
||||
if self.show_path or not self.no_title then
|
||||
top_height = self.title_bar:getHeight()
|
||||
if not self.title_bar_fm_style then
|
||||
top_height = top_height + self.header_padding
|
||||
end
|
||||
end
|
||||
height_dim = self.inner_dimen.h - bottom_height - top_height
|
||||
local item_height = math.floor(height_dim / self.perpage)
|
||||
@@ -655,26 +662,39 @@ function Menu:init()
|
||||
-----------------------------------
|
||||
-- start to set up widget layout --
|
||||
-----------------------------------
|
||||
self.title_bar = TitleBar:new{
|
||||
width = self.dimen.w,
|
||||
fullscreen = "true",
|
||||
align = "center",
|
||||
with_bottom_line = self.with_bottom_line,
|
||||
bottom_line_color = self.bottom_line_color,
|
||||
bottom_line_h_padding = self.bottom_line_h_padding,
|
||||
title = self.title,
|
||||
title_face = self.title_face,
|
||||
title_multilines = self.title_multilines,
|
||||
title_shrink_font_to_fit = self.title_shrink_font_to_fit,
|
||||
subtitle = self.show_path and BD.directory(filemanagerutil.abbreviate(self.path)),
|
||||
subtitle_truncate_left = self.show_path,
|
||||
subtitle_fullwidth = self.show_path,
|
||||
left_icon = self.title_bar_left_icon,
|
||||
left_icon_tap_callback = function() self:onLeftButtonTap() end,
|
||||
left_icon_hold_callback = function() self:onLeftButtonHold() end,
|
||||
close_callback = function() self:onClose() end,
|
||||
show_parent = self.show_parent or self,
|
||||
}
|
||||
if self.show_path or not self.no_title then
|
||||
if self.subtitle == nil then
|
||||
if self.show_path then
|
||||
self.subtitle = BD.directory(filemanagerutil.abbreviate(self.path))
|
||||
elseif self.title_bar_fm_style then
|
||||
self.subtitle = ""
|
||||
end
|
||||
end
|
||||
self.title_bar = TitleBar:new{
|
||||
width = self.dimen.w,
|
||||
fullscreen = "true",
|
||||
align = "center",
|
||||
with_bottom_line = self.with_bottom_line,
|
||||
bottom_line_color = self.bottom_line_color,
|
||||
bottom_line_h_padding = self.bottom_line_h_padding,
|
||||
title = self.title,
|
||||
title_face = self.title_face,
|
||||
title_multilines = self.title_multilines,
|
||||
title_shrink_font_to_fit = self.title_shrink_font_to_fit,
|
||||
subtitle = self.subtitle,
|
||||
subtitle_truncate_left = self.show_path,
|
||||
subtitle_fullwidth = self.show_path,
|
||||
title_top_padding = self.title_bar_fm_style and Screen:scaleBySize(6),
|
||||
button_padding = self.title_bar_fm_style and Screen:scaleBySize(5),
|
||||
left_icon = self.title_bar_left_icon,
|
||||
left_icon_size_ratio = self.title_bar_fm_style and 1,
|
||||
left_icon_tap_callback = function() self:onLeftButtonTap() end,
|
||||
left_icon_hold_callback = function() self:onLeftButtonHold() end,
|
||||
right_icon_size_ratio = self.title_bar_fm_style and 1,
|
||||
close_callback = function() self:onClose() end,
|
||||
show_parent = self.show_parent or self,
|
||||
}
|
||||
end
|
||||
|
||||
-- group for items
|
||||
self.item_group = VerticalGroup:new{}
|
||||
@@ -1127,9 +1147,14 @@ end
|
||||
and the page number will be the page containing the first item for
|
||||
which item.key = value
|
||||
--]]
|
||||
function Menu:switchItemTable(new_title, new_item_table, itemnumber, itemmatch)
|
||||
if self.title_bar and new_title then
|
||||
self.title_bar:setTitle(new_title)
|
||||
function Menu:switchItemTable(new_title, new_item_table, itemnumber, itemmatch, new_subtitle)
|
||||
if self.title_bar then
|
||||
if new_title then
|
||||
self.title_bar:setTitle(new_title, true)
|
||||
end
|
||||
if new_subtitle then
|
||||
self.title_bar:setSubTitle(new_subtitle, true)
|
||||
end
|
||||
end
|
||||
|
||||
if itemnumber == nil then
|
||||
|
||||
@@ -434,21 +434,22 @@ function TitleBar:setTitle(title, no_refresh)
|
||||
self.inner_title_group:resetLayout()
|
||||
end
|
||||
self.title_group:resetLayout()
|
||||
if no_refresh then
|
||||
return
|
||||
if not no_refresh then
|
||||
UIManager:setDirty(self.show_parent, "ui", self.dimen)
|
||||
end
|
||||
UIManager:setDirty(self.show_parent, "ui", self.dimen)
|
||||
end
|
||||
end
|
||||
|
||||
function TitleBar:setSubTitle(subtitle)
|
||||
function TitleBar:setSubTitle(subtitle, no_refresh)
|
||||
if self.subtitle_widget and not self.subtitle_multilines then -- no TextBoxWidget:setText() available
|
||||
self.subtitle_widget:setText(subtitle)
|
||||
if self.inner_subtitle_group then
|
||||
self.inner_subtitle_group:resetLayout()
|
||||
end
|
||||
self.title_group:resetLayout()
|
||||
UIManager:setDirty(self.show_parent, "ui", self.dimen)
|
||||
if not no_refresh then
|
||||
UIManager:setDirty(self.show_parent, "ui", self.dimen)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user