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.
This commit is contained in:
NiLuJe
2021-04-15 02:46:44 +02:00
parent 3274183466
commit 97b81a7eb6
4 changed files with 8 additions and 8 deletions

View File

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