register ReaderZooming's zoommode menu in ReaderMenu

pull/2/merge
Qingping Hou 12 years ago
parent 9a439f5dc4
commit 5b6558383d

@ -27,12 +27,6 @@ function ReaderMenu:init()
end
end
function ReaderMenu:genSetZoomModeCallBack(mode)
return function()
self.ui:handleEvent(Event:new("SetZoomMode", mode))
end
end
function ReaderMenu:setUpdateItemTable()
table.insert(self.item_table, {
text = "Screen rotate",
@ -56,38 +50,6 @@ function ReaderMenu:setUpdateItemTable()
}
})
if self.ui.document.info.has_pages then
table.insert(self.item_table, {
text = "Switch zoom mode",
sub_item_table = {
{
text = "Zoom to fit content width",
callback = self:genSetZoomModeCallBack("contentwidth")
},
{
text = "Zoom to fit content height",
callback = self:genSetZoomModeCallBack("contentheight")
},
{
text = "Zoom to fit page width",
callback = self:genSetZoomModeCallBack("pagewidth")
},
{
text = "Zoom to fit page height",
callback = self:genSetZoomModeCallBack("pageheight")
},
{
text = "Zoom to fit content",
callback = self:genSetZoomModeCallBack("content")
},
{
text = "Zoom to fit page",
callback = self:genSetZoomModeCallBack("page")
},
}
})
end
for _, widget in pairs(self.registered_widgets) do
widget:addToMainMenu(self.item_table)
end

@ -147,4 +147,42 @@ function ReaderZooming:setZoom()
self.view:onZoomUpdate(self.zoom)
end
function ReaderZooming:genSetZoomModeCallBack(mode)
return function()
self.ui:handleEvent(Event:new("SetZoomMode", mode))
end
end
function ReaderZooming:addToMainMenu(item_table)
if self.ui.document.info.has_pages then
table.insert(item_table, {
text = "Switch zoom mode",
sub_item_table = {
{
text = "Zoom to fit content width",
callback = self:genSetZoomModeCallBack("contentwidth")
},
{
text = "Zoom to fit content height",
callback = self:genSetZoomModeCallBack("contentheight")
},
{
text = "Zoom to fit page width",
callback = self:genSetZoomModeCallBack("pagewidth")
},
{
text = "Zoom to fit page height",
callback = self:genSetZoomModeCallBack("pageheight")
},
{
text = "Zoom to fit content",
callback = self:genSetZoomModeCallBack("content")
},
{
text = "Zoom to fit page",
callback = self:genSetZoomModeCallBack("page")
},
}
})
end
end

Loading…
Cancel
Save