CoverBrowser: list mode fixes and tweaks (#5525)
- Use a hardcoded default value of 10 files per page. - Save cover sizetag as "s<nb of items per page>" instead of "s<item height>" so they are stable (and not re-fetched) when switching between FileBrowser and History, which have some small geometry differences. - When showing History in landscape mode, decrease perpage from the set value, so items don't look smaller. - Use a step, larger with big items, when iterating and decreasing font sizes to make text fit, to speed up the process a bit.
This commit is contained in:
parent
f38073c1e9
commit
0ecf42e995
1 changed files with 27 additions and 9 deletions
|
|
@ -194,6 +194,9 @@ function ListMenuItem:update()
|
|||
local font_size = nominal * dimen.h / 64 / scale_by_size
|
||||
return math.floor(font_size)
|
||||
end
|
||||
-- Will speed up a bit if we don't do all font sizes when
|
||||
-- looking for one that make text fit
|
||||
local fontsize_dec_step = math.ceil(_fontSize(100) / 100)
|
||||
|
||||
-- We'll draw a border around cover images, it may not be
|
||||
-- needed with some covers, but it's nicer when cover is
|
||||
|
|
@ -202,7 +205,7 @@ function ListMenuItem:update()
|
|||
local max_img_w = dimen.h - 2*border_size -- width = height, squared
|
||||
local max_img_h = dimen.h - 2*border_size
|
||||
local cover_specs = {
|
||||
sizetag = "s"..max_img_h,
|
||||
sizetag = self.menu.cover_sizetag,
|
||||
max_cover_w = max_img_w,
|
||||
max_cover_h = max_img_h,
|
||||
}
|
||||
|
|
@ -559,12 +562,11 @@ function ListMenuItem:update()
|
|||
end
|
||||
if height < dimen.h then -- we fit !
|
||||
break
|
||||
else
|
||||
logger.dbg(title, "recalculate title/author with", fontsize_title - 1)
|
||||
end
|
||||
-- If we don't fit, decrease both font sizes
|
||||
fontsize_title = fontsize_title - 1
|
||||
fontsize_authors = fontsize_authors - 1
|
||||
fontsize_title = fontsize_title - fontsize_dec_step
|
||||
fontsize_authors = fontsize_authors - fontsize_dec_step
|
||||
logger.dbg(title, "recalculate title/author with", fontsize_title)
|
||||
-- Don't go too low, and get out of this loop
|
||||
if fontsize_title < 3 or fontsize_authors < 3 then
|
||||
break
|
||||
|
|
@ -651,7 +653,7 @@ function ListMenuItem:update()
|
|||
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil,
|
||||
}
|
||||
-- reduce font size for next loop, in case text widget is too large to fit into ListMenuItem
|
||||
fontsize_no_bookinfo = fontsize_no_bookinfo - 1
|
||||
fontsize_no_bookinfo = fontsize_no_bookinfo - fontsize_dec_step
|
||||
until text_widget:getSize().h <= dimen.h
|
||||
widget = LeftContainer:new{
|
||||
dimen = dimen,
|
||||
|
|
@ -786,9 +788,25 @@ function ListMenu:_recalculateDimen()
|
|||
end
|
||||
local available_height = self.dimen.h - self.others_height - Size.line.thin
|
||||
|
||||
-- default is 64px per ListMenuItem, gives 10 items both in filemanager
|
||||
-- and history on kobo glo hd
|
||||
self.perpage = BookInfoManager:getSetting("files_per_page") or math.floor(available_height / scale_by_size / 64)
|
||||
-- (perpage used to be static and computed from a base of 64px per ListMenuItem,
|
||||
-- which gave 10 items both in filemanager and history on kobo glo hd - now that
|
||||
-- we can change the nb of items, let's start with a default of 10 - as it must
|
||||
-- be known as the initial value by the menu selection widget, but there is not
|
||||
-- enough information there to compute it as we could here).
|
||||
-- local default_per_page = math.floor(available_height / scale_by_size / 64)
|
||||
self.perpage = BookInfoManager:getSetting("files_per_page") or 10
|
||||
self.cover_sizetag = "s" .. self.perpage
|
||||
if Screen:getWidth() > Screen:getHeight() then -- landscape mode
|
||||
-- When in landscape mode (only possible with History), adjust
|
||||
-- perpage so items get a chance to have about the same height
|
||||
-- as when in portrait mode.
|
||||
-- This computation is not strictly correct, as "others_height" would
|
||||
-- have a different value in portrait mode. But let's go with that.
|
||||
local portrait_available_height = Screen:getWidth() - self.others_height - Size.line.thin
|
||||
local portrait_item_height = math.floor(portrait_available_height / self.perpage) - Size.line.thin
|
||||
self.perpage = Math.round(available_height / portrait_item_height)
|
||||
end
|
||||
|
||||
self.page_num = math.ceil(#self.item_table / self.perpage)
|
||||
-- fix current page if out of range
|
||||
if self.page_num > 0 and self.page > self.page_num then self.page = self.page_num end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue