mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -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
|
||||
|
||||
@@ -149,7 +149,7 @@ local SortWidget = InputContainer:new{
|
||||
-- index for the first item to show
|
||||
show_page = 1,
|
||||
-- table of items to sort
|
||||
item_table = {},
|
||||
item_table = nil, -- mandatory
|
||||
callback = nil,
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ end
|
||||
TouchMenu widget for hierarchical menus
|
||||
--]]
|
||||
local TouchMenu = FocusManager:new{
|
||||
tab_item_table = {},
|
||||
tab_item_table = nil, -- mandatory
|
||||
-- for returning in multi-level menus
|
||||
item_table_stack = nil,
|
||||
item_table = nil,
|
||||
|
||||
@@ -331,7 +331,7 @@ function CalibreSearch:find(option)
|
||||
local result = self:bookCatalog(books)
|
||||
self:showresults(result)
|
||||
else
|
||||
self:browse(option,1)
|
||||
self:browse(option, 1)
|
||||
end
|
||||
logger.info(string.format("search done in %.3f milliseconds (%s, %s, %s, %s, %s)",
|
||||
(TimeVal:now() - start):tomsecs(),
|
||||
|
||||
Reference in New Issue
Block a user