mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #807 from houqp/new_ui_code
bug fix and touch enhancement to old menu widget
This commit is contained in:
@@ -2,7 +2,6 @@ require "ui/widget/menu"
|
||||
require "ui/widget/touchmenu"
|
||||
|
||||
ReaderMenu = InputContainer:new{
|
||||
_name = "ReaderMenu",
|
||||
tab_item_table = nil,
|
||||
registered_widgets = {},
|
||||
}
|
||||
@@ -66,7 +65,6 @@ function ReaderMenu:onShowMenu()
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
name = "haha",
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
@@ -77,21 +77,25 @@ function ReaderToc:onShowToc()
|
||||
end
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
local toc_menu = Menu:new{
|
||||
title = "Table of Contents",
|
||||
item_table = self.toc,
|
||||
ui = self.ui,
|
||||
width = Screen:getWidth()-20,
|
||||
height = Screen:getHeight(),
|
||||
show_parent = menu_container,
|
||||
}
|
||||
|
||||
table.insert(menu_container, toc_menu)
|
||||
|
||||
function toc_menu:onMenuChoice(item)
|
||||
self.ui:handleEvent(Event:new("PageUpdate", item.page))
|
||||
end
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
dimen = Screen:getSize(),
|
||||
toc_menu,
|
||||
}
|
||||
toc_menu.close_callback = function()
|
||||
UIManager:close(menu_container)
|
||||
end
|
||||
|
||||
@@ -91,6 +91,7 @@ Widget that displays an item for menu
|
||||
--]]
|
||||
MenuItem = InputContainer:new{
|
||||
text = nil,
|
||||
show_parent = nil,
|
||||
detail = nil,
|
||||
face = Font:getFace("cfont", 22),
|
||||
dimen = nil,
|
||||
@@ -188,7 +189,13 @@ function MenuItem:onShowItemDetail()
|
||||
end
|
||||
|
||||
function MenuItem:onTapSelect()
|
||||
self.menu:onMenuSelect(self.table)
|
||||
self[1].invert = true
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self[1].invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
self.menu:onMenuSelect(self.table)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -197,6 +204,7 @@ end
|
||||
Widget that displays menu
|
||||
--]]
|
||||
Menu = FocusManager:new{
|
||||
show_parent = nil,
|
||||
-- face for displaying item contents
|
||||
cface = Font:getFace("cfont", 22),
|
||||
-- face for menu title
|
||||
@@ -218,7 +226,7 @@ Menu = FocusManager:new{
|
||||
"A", "S", "D", "F", "G", "H", "J", "K", "L", "Del",
|
||||
"Z", "X", "C", "V", "B", "N", "M", ".", "Sym", "Enter",
|
||||
},
|
||||
item_table_stack = {},
|
||||
item_table_stack = nil,
|
||||
is_enable_shortcut = true,
|
||||
|
||||
item_dimen = nil,
|
||||
@@ -256,6 +264,8 @@ function Menu:_recalculateDimen()
|
||||
end
|
||||
|
||||
function Menu:init()
|
||||
self.show_parent = self.show_parent or self
|
||||
self.item_table_stack = {}
|
||||
self:_recalculateDimen()
|
||||
self.page = 1
|
||||
|
||||
@@ -388,6 +398,7 @@ function Menu:updateItems(select_number)
|
||||
end
|
||||
end
|
||||
local item_tmp = MenuItem:new{
|
||||
show_parent = self.show_parent,
|
||||
text = self.item_table[i].text,
|
||||
face = self.cface,
|
||||
dimen = self.item_dimen:new(),
|
||||
|
||||
24
reader.lua
24
reader.lua
@@ -81,17 +81,20 @@ function HomeMenu:onTapShowMenu()
|
||||
self.item_table = {}
|
||||
self:setUpdateItemTable()
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
}
|
||||
|
||||
local home_menu = Menu:new{
|
||||
show_parent = menu_container,
|
||||
title = "Home menu",
|
||||
item_table = self.item_table,
|
||||
width = Screen:getWidth() - 100,
|
||||
}
|
||||
|
||||
local menu_container = CenterContainer:new{
|
||||
ignore = "height",
|
||||
dimen = Screen:getSize(),
|
||||
home_menu,
|
||||
}
|
||||
menu_container[1] = home_menu
|
||||
|
||||
home_menu.close_callback = function ()
|
||||
UIManager:close(menu_container)
|
||||
end
|
||||
@@ -121,7 +124,12 @@ end
|
||||
|
||||
function showHomePage(path)
|
||||
local exclude_dirs = {"%.sdr$"}
|
||||
|
||||
local HomePage = InputContainer:new{
|
||||
}
|
||||
|
||||
local FileManager = FileChooser:new{
|
||||
show_parent = HomePage,
|
||||
title = "FileManager",
|
||||
path = path,
|
||||
width = Screen:getWidth(),
|
||||
@@ -141,10 +149,8 @@ function showHomePage(path)
|
||||
end
|
||||
}
|
||||
|
||||
local HomePage = InputContainer:new{
|
||||
FileManager,
|
||||
HomeMenu,
|
||||
}
|
||||
table.insert(HomePage, FileManager)
|
||||
table.insert(HomePage, HomeMenu)
|
||||
|
||||
function FileManager:onFileSelect(file)
|
||||
showReader(file)
|
||||
|
||||
Reference in New Issue
Block a user