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.
reviewable/pr11232/r6^2
hius07 5 months ago committed by GitHub
parent 9d94ab38f3
commit 5a4e70a19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -125,6 +125,9 @@ function FileManagerCollection:onShowColl(collection_name)
covers_fullscreen = true, -- hint for UIManager:_repaint() covers_fullscreen = true, -- hint for UIManager:_repaint()
is_borderless = true, is_borderless = true,
is_popout = false, 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", title_bar_left_icon = "appbar.menu",
onLeftButtonTap = function() self:showCollDialog() end, onLeftButtonTap = function() self:showCollDialog() end,
onMenuChoice = self.onMenuChoice, onMenuChoice = self.onMenuChoice,

@ -81,17 +81,13 @@ function FileManagerHistory:updateItemTable()
self.count[v.status] = self.count[v.status] + 1 self.count[v.status] = self.count[v.status] + 1
end end
end end
local title = self.hist_menu_title local subtitle
local filter_title
if self.search_string then if self.search_string then
filter_title = _("search results") subtitle = T("Search results (%1)", #item_table)
elseif self.filter ~= "all" then 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 end
if filter_title then self.hist_menu:switchItemTable(nil, item_table, select_number, nil, subtitle or "")
title = title .. T(" (%1: %2)", filter_title, #item_table)
end
self.hist_menu:switchItemTable(title, item_table, select_number)
end end
function FileManagerHistory:isItemMatch(item) function FileManagerHistory:isItemMatch(item)
@ -223,6 +219,10 @@ function FileManagerHistory:onShowHist(search_info)
covers_fullscreen = true, -- hint for UIManager:_repaint() covers_fullscreen = true, -- hint for UIManager:_repaint()
is_borderless = true, is_borderless = true,
is_popout = false, 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", title_bar_left_icon = "appbar.menu",
onLeftButtonTap = function() self:showHistDialog() end, onLeftButtonTap = function() self:showHistDialog() end,
onMenuChoice = self.onMenuChoice, onMenuChoice = self.onMenuChoice,

@ -561,7 +561,10 @@ Widget that displays menu
local Menu = FocusManager:extend{ local Menu = FocusManager:extend{
show_parent = nil, show_parent = nil,
title = "No Title", no_title = false,
title = "",
subtitle = nil,
show_path = nil, -- path in titlebar subtitle
-- default width and height -- default width and height
width = nil, width = nil,
-- height will be calculated according to item number if not given -- 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 -- if you want to embed the menu widget into another widget, set
-- this to false -- this to false
is_popout = true, 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 -- set icon to add title bar left button
title_bar_left_icon = nil, title_bar_left_icon = nil,
-- close_callback is a function, which is executed when menu is closed -- 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) bottom_height = math.max(self.page_return_arrow:getSize().h, self.page_info_text:getSize().h)
+ 2 * Size.padding.button + 2 * Size.padding.button
end end
if self.title_bar and not self.no_title then if self.show_path or not self.no_title then
top_height = self.title_bar:getHeight() + self.header_padding top_height = self.title_bar:getHeight()
if not self.title_bar_fm_style then
top_height = top_height + self.header_padding
end
end end
height_dim = self.inner_dimen.h - bottom_height - top_height height_dim = self.inner_dimen.h - bottom_height - top_height
local item_height = math.floor(height_dim / self.perpage) local item_height = math.floor(height_dim / self.perpage)
@ -655,26 +662,39 @@ function Menu:init()
----------------------------------- -----------------------------------
-- start to set up widget layout -- -- start to set up widget layout --
----------------------------------- -----------------------------------
self.title_bar = TitleBar:new{ if self.show_path or not self.no_title then
width = self.dimen.w, if self.subtitle == nil then
fullscreen = "true", if self.show_path then
align = "center", self.subtitle = BD.directory(filemanagerutil.abbreviate(self.path))
with_bottom_line = self.with_bottom_line, elseif self.title_bar_fm_style then
bottom_line_color = self.bottom_line_color, self.subtitle = ""
bottom_line_h_padding = self.bottom_line_h_padding, end
title = self.title, end
title_face = self.title_face, self.title_bar = TitleBar:new{
title_multilines = self.title_multilines, width = self.dimen.w,
title_shrink_font_to_fit = self.title_shrink_font_to_fit, fullscreen = "true",
subtitle = self.show_path and BD.directory(filemanagerutil.abbreviate(self.path)), align = "center",
subtitle_truncate_left = self.show_path, with_bottom_line = self.with_bottom_line,
subtitle_fullwidth = self.show_path, bottom_line_color = self.bottom_line_color,
left_icon = self.title_bar_left_icon, bottom_line_h_padding = self.bottom_line_h_padding,
left_icon_tap_callback = function() self:onLeftButtonTap() end, title = self.title,
left_icon_hold_callback = function() self:onLeftButtonHold() end, title_face = self.title_face,
close_callback = function() self:onClose() end, title_multilines = self.title_multilines,
show_parent = self.show_parent or self, 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 -- group for items
self.item_group = VerticalGroup:new{} self.item_group = VerticalGroup:new{}
@ -1127,9 +1147,14 @@ end
and the page number will be the page containing the first item for and the page number will be the page containing the first item for
which item.key = value which item.key = value
--]] --]]
function Menu:switchItemTable(new_title, new_item_table, itemnumber, itemmatch) function Menu:switchItemTable(new_title, new_item_table, itemnumber, itemmatch, new_subtitle)
if self.title_bar and new_title then if self.title_bar then
self.title_bar:setTitle(new_title) 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 end
if itemnumber == nil then if itemnumber == nil then

@ -434,21 +434,22 @@ function TitleBar:setTitle(title, no_refresh)
self.inner_title_group:resetLayout() self.inner_title_group:resetLayout()
end end
self.title_group:resetLayout() self.title_group:resetLayout()
if no_refresh then if not no_refresh then
return UIManager:setDirty(self.show_parent, "ui", self.dimen)
end end
UIManager:setDirty(self.show_parent, "ui", self.dimen)
end end
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 if self.subtitle_widget and not self.subtitle_multilines then -- no TextBoxWidget:setText() available
self.subtitle_widget:setText(subtitle) self.subtitle_widget:setText(subtitle)
if self.inner_subtitle_group then if self.inner_subtitle_group then
self.inner_subtitle_group:resetLayout() self.inner_subtitle_group:resetLayout()
end end
self.title_group:resetLayout() 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
end end

Loading…
Cancel
Save