Menu: Don't share the `dimen` object across Menu instances (!)

The object was never re-assigned, so closing a smaller menu (e.g.,
Calibre metadata search) made the underlying one (e.g., CoverBrowser's
ListMenu) inherit the smaller dimensions...

Instead of creating the object in the Class constructor, create it in the
instance constructor (i.e., :init).

Similar cleanups in other Menu* related classes.
reviewable/pr7557/r1
NiLuJe 3 years ago
parent 3274183466
commit 97b81a7eb6

@ -88,7 +88,7 @@ local MenuCloseButton = InputContainer:new{
overlap_align = "right", overlap_align = "right",
padding_right = 0, padding_right = 0,
menu = nil, menu = nil,
dimen = Geom:new{}, dimen = nil,
} }
function MenuCloseButton:init() function MenuCloseButton:init()
@ -544,8 +544,8 @@ local Menu = FocusManager:new{
-- height will be calculated according to item number if not given -- height will be calculated according to item number if not given
height = nil, height = nil,
header_padding = Size.padding.large, header_padding = Size.padding.large,
dimen = Geom:new{}, dimen = nil,
item_table = {}, item_table = nil, -- NOT mandatory (will be empty)
item_shortcuts = { item_shortcuts = {
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
"A", "S", "D", "F", "G", "H", "J", "K", "L", "Del", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Del",
@ -605,9 +605,9 @@ end
function Menu:init() function Menu:init()
self.show_parent = self.show_parent or self self.show_parent = self.show_parent or self
self.item_table = self.item_table or {}
self.item_table_stack = {} self.item_table_stack = {}
self.dimen.w = self.width self.dimen = Geom:new{ w = self.width, h = self.height or Screen:getHeight() }
self.dimen.h = self.height or Screen:getHeight()
if self.dimen.h > Screen:getHeight() or self.dimen.h == nil then if self.dimen.h > Screen:getHeight() or self.dimen.h == nil then
self.dimen.h = Screen:getHeight() self.dimen.h = Screen:getHeight()
end end

@ -149,7 +149,7 @@ local SortWidget = InputContainer:new{
-- index for the first item to show -- index for the first item to show
show_page = 1, show_page = 1,
-- table of items to sort -- table of items to sort
item_table = {}, item_table = nil, -- mandatory
callback = nil, callback = nil,
} }

@ -417,7 +417,7 @@ end
TouchMenu widget for hierarchical menus TouchMenu widget for hierarchical menus
--]] --]]
local TouchMenu = FocusManager:new{ local TouchMenu = FocusManager:new{
tab_item_table = {}, tab_item_table = nil, -- mandatory
-- for returning in multi-level menus -- for returning in multi-level menus
item_table_stack = nil, item_table_stack = nil,
item_table = nil, item_table = nil,

@ -331,7 +331,7 @@ function CalibreSearch:find(option)
local result = self:bookCatalog(books) local result = self:bookCatalog(books)
self:showresults(result) self:showresults(result)
else else
self:browse(option,1) self:browse(option, 1)
end end
logger.info(string.format("search done in %.3f milliseconds (%s, %s, %s, %s, %s)", logger.info(string.format("search done in %.3f milliseconds (%s, %s, %s, %s, %s)",
(TimeVal:now() - start):tomsecs(), (TimeVal:now() - start):tomsecs(),

Loading…
Cancel
Save