Font menu: open on page with currently selected font

Generic feature added to TouchMenu: an optional callback
'open_on_menu_item_id_func()' set on an items table can
tell which menu item should be shown when opening a menu.
TouchMenu: allows jumping to first or last page with
long-press on the chevrons.
This commit is contained in:
poire-z
2021-04-02 18:12:06 +02:00
parent 8fb6ae715b
commit 247085ad3e
2 changed files with 32 additions and 2 deletions

View File

@@ -96,9 +96,13 @@ function ReaderFont:init()
end,
checked_func = function()
return v == self.font_face
end
end,
menu_item_id = v,
})
end
self.face_table.open_on_menu_item_id_func = function()
return self.font_face
end
self.ui.menu:registerToMainMenu(self)
end
@@ -332,7 +336,9 @@ function ReaderFont:addToMainMenu(menu_items)
self.face_table.max_per_page = 5
-- insert table to main reader menu
menu_items.change_font = {
text = self.font_menu_title,
text_func = function()
return T(_("Font: %1"), BD.wrap(self.font_face))
end,
sub_item_table = self.face_table,
}
end