mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix bug in multi-level menu support
The size of framecontainer is not reset after content changed.
This commit is contained in:
@@ -200,17 +200,21 @@ function Menu:init()
|
||||
text = self.title,
|
||||
face = self.tface,
|
||||
}
|
||||
|
||||
-- group for items
|
||||
self.item_group = VerticalGroup:new{}
|
||||
self.page_info = TextWidget:new{
|
||||
face = self.fface,
|
||||
}
|
||||
} -- VerticalGroup
|
||||
|
||||
-- group for menu layout
|
||||
local content = VerticalGroup:new{
|
||||
name = "haha",
|
||||
self.menu_title,
|
||||
self.item_group,
|
||||
self.page_info,
|
||||
} -- VerticalGroup
|
||||
self.content_group = content
|
||||
|
||||
if not self.is_borderless then
|
||||
self[1] = CenterContainer:new{
|
||||
@@ -242,8 +246,8 @@ function Menu:init()
|
||||
end
|
||||
|
||||
function Menu:updateItems(select_number)
|
||||
self.layout = {}
|
||||
self.item_group:clear()
|
||||
self.content_group:resetLayout()
|
||||
|
||||
for c = 1, self.perpage do
|
||||
local i = (self.page - 1) * self.perpage + c
|
||||
@@ -270,8 +274,6 @@ function Menu:updateItems(select_number)
|
||||
shortcut_style = shortcut_style,
|
||||
}
|
||||
table.insert(self.item_group, item_tmp)
|
||||
table.insert(self.layout, {item_tmp})
|
||||
--self.last_shortcut = c
|
||||
end -- if i <= self.items
|
||||
end -- for c=1, self.perpage
|
||||
if self.item_group[1] then
|
||||
|
||||
@@ -139,6 +139,7 @@ FrameContainer = WidgetContainer:new{
|
||||
|
||||
function FrameContainer:getSize()
|
||||
local content_size = WidgetContainer.getSize(self)
|
||||
|
||||
return {
|
||||
w = content_size.w + ( self.margin + self.bordersize + self.padding ) * 2,
|
||||
h = content_size.h + ( self.margin + self.bordersize + self.padding ) * 2
|
||||
@@ -393,9 +394,18 @@ function HorizontalGroup:paintTo(bb, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
function HorizontalGroup:free()
|
||||
function HorizontalGroup:clear()
|
||||
self:free()
|
||||
WidgetContainer.clear(self)
|
||||
end
|
||||
|
||||
function HorizontalGroup:resetLayout()
|
||||
self._size = nil
|
||||
self._offsets = {}
|
||||
end
|
||||
|
||||
function HorizontalGroup:free()
|
||||
self:resetLayout()
|
||||
WidgetContainer.free(self)
|
||||
end
|
||||
|
||||
@@ -452,9 +462,18 @@ function VerticalGroup:paintTo(bb, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
function VerticalGroup:free()
|
||||
function VerticalGroup:clear()
|
||||
self:free()
|
||||
WidgetContainer.clear(self)
|
||||
end
|
||||
|
||||
function VerticalGroup:resetLayout()
|
||||
self._size = nil
|
||||
self._offsets = {}
|
||||
end
|
||||
|
||||
function VerticalGroup:free()
|
||||
self:resetLayout()
|
||||
WidgetContainer.free(self)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user