@ -194,6 +194,9 @@ function ListMenuItem:update()
local font_size = nominal * dimen.h / 64 / scale_by_size
local font_size = nominal * dimen.h / 64 / scale_by_size
return math.floor ( font_size )
return math.floor ( font_size )
end
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
-- We'll draw a border around cover images, it may not be
-- needed with some covers, but it's nicer when cover is
-- 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_w = dimen.h - 2 * border_size -- width = height, squared
local max_img_h = dimen.h - 2 * border_size
local max_img_h = dimen.h - 2 * border_size
local cover_specs = {
local cover_specs = {
sizetag = " s " .. max_img_h ,
sizetag = self.menu . cover_sizetag ,
max_cover_w = max_img_w ,
max_cover_w = max_img_w ,
max_cover_h = max_img_h ,
max_cover_h = max_img_h ,
}
}
@ -559,12 +562,11 @@ function ListMenuItem:update()
end
end
if height < dimen.h then -- we fit !
if height < dimen.h then -- we fit !
break
break
else
logger.dbg ( title , " recalculate title/author with " , fontsize_title - 1 )
end
end
-- If we don't fit, decrease both font sizes
-- If we don't fit, decrease both font sizes
fontsize_title = fontsize_title - 1
fontsize_title = fontsize_title - fontsize_dec_step
fontsize_authors = fontsize_authors - 1
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
-- Don't go too low, and get out of this loop
if fontsize_title < 3 or fontsize_authors < 3 then
if fontsize_title < 3 or fontsize_authors < 3 then
break
break
@ -651,7 +653,7 @@ function ListMenuItem:update()
fgcolor = self.file_deleted and Blitbuffer.COLOR_DARK_GRAY or nil ,
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
-- 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
until text_widget : getSize ( ) . h <= dimen.h
widget = LeftContainer : new {
widget = LeftContainer : new {
dimen = dimen ,
dimen = dimen ,
@ -786,9 +788,25 @@ function ListMenu:_recalculateDimen()
end
end
local available_height = self.dimen . h - self.others_height - Size.line . thin
local available_height = self.dimen . h - self.others_height - Size.line . thin
-- default is 64px per ListMenuItem, gives 10 items both in filemanager
-- (perpage used to be static and computed from a base of 64px per ListMenuItem,
-- and history on kobo glo hd
-- which gave 10 items both in filemanager and history on kobo glo hd - now that
self.perpage = BookInfoManager : getSetting ( " files_per_page " ) or math.floor ( available_height / scale_by_size / 64 )
-- 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 )
self.page_num = math.ceil ( # self.item_table / self.perpage )
-- fix current page if out of range
-- 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
if self.page_num > 0 and self.page > self.page_num then self.page = self.page_num end