Menu widget: draw focus on focused item (#12583)

This commit is contained in:
hius07
2024-10-13 18:02:51 +03:00
committed by GitHub
parent 83bc531186
commit ce7fcff360
5 changed files with 40 additions and 13 deletions

View File

@@ -91,10 +91,6 @@ function CoverMenu:updateItems(select_number, no_recalculate_dimen)
self.page_info:resetLayout()
self.return_button:resetLayout()
self.content_group:resetLayout()
-- default to select the first item
if not select_number then
select_number = 1
end
-- Reset the list of items not found in db that will need to
-- be updated by a scheduled action
@@ -131,8 +127,7 @@ function CoverMenu:updateItems(select_number, no_recalculate_dimen)
-- Specific UI building implementation (defined in some other module)
self._has_cover_images = false
self:_updateItemsBuildUI()
select_number = self:_updateItemsBuildUI() or select_number
-- Set the local variables with the things we know
-- These are used only by extractBooksInDirectory(), which should
-- use the cover_specs set for FileBrowser, and not those from History.

View File

@@ -981,11 +981,15 @@ function ListMenu:_updateItemsBuildUI()
}
table.insert(self.item_group, line_widget)
local idx_offset = (self.page - 1) * self.perpage
local select_number
for idx = 1, self.perpage do
local index = idx_offset + idx
local entry = self.item_table[index]
if entry == nil then break end
entry.idx = index
if index == self.itemnumber then -- focused item
select_number = idx
end
-- Keyboard shortcuts, as done in Menu
local item_shortcut, shortcut_style
if self.is_enable_shortcut then
@@ -1020,6 +1024,7 @@ function ListMenu:_updateItemsBuildUI()
end
end
return select_number
end
return ListMenu

View File

@@ -959,11 +959,15 @@ function MosaicMenu:_updateItemsBuildUI()
local cur_row = nil
local idx_offset = (self.page - 1) * self.perpage
local line_layout = {}
local select_number
for idx = 1, self.perpage do
local index = idx_offset + idx
local entry = self.item_table[index]
if entry == nil then break end
entry.idx = index
if index == self.itemnumber then -- focused item
select_number = idx
end
-- Keyboard shortcuts, as done in Menu
local item_shortcut, shortcut_style
if self.is_enable_shortcut then
@@ -1017,6 +1021,7 @@ function MosaicMenu:_updateItemsBuildUI()
end
table.insert(self.layout, line_layout)
table.insert(self.item_group, VerticalSpan:new{ width = self.item_margin }) -- bottom padding
return select_number
end
return MosaicMenu