implement full pageturn by viewport for all modes

* add notIntersectWith method for Geom
* add math.roundAwayFromZero in geometry.lua
* Readerview:recalculate now signals ViewRecalculate event.
  For now, this event is only usefull for ReaderPaging
This commit is contained in:
Qingping Hou
2012-12-03 13:48:41 +08:00
parent 7b707ab367
commit ae1c489a0f
4 changed files with 108 additions and 15 deletions

View File

@@ -2,35 +2,43 @@ ReaderZooming = InputContainer:new{
key_events = {
ZoomIn = {
{ "Shift", Input.group.PgFwd },
doc = "zoom in", event = "Zoom", args = "in"
doc = "zoom in",
event = "Zoom", args = "in"
},
ZoomOut = {
{ "Shift", Input.group.PgBack },
doc = "zoom out", event = "Zoom", args = "out"
doc = "zoom out",
event = "Zoom", args = "out"
},
ZoomToFitPage = {
{ "A" },
doc = "zoom to fit page", event = "SetZoomMode", args = "page"
doc = "zoom to fit page",
event = "SetZoomMode", args = "page"
},
ZoomToFitContent = {
{ "Shift", "A" },
doc = "zoom to fit content", event = "SetZoomMode", args = "content"
doc = "zoom to fit content",
event = "SetZoomMode", args = "content"
},
ZoomToFitPageWidth = {
{ "S" },
doc = "zoom to fit page width", event = "SetZoomMode", args = "pagewidth"
doc = "zoom to fit page width",
event = "SetZoomMode", args = "pagewidth"
},
ZoomToFitContentWidth = {
{ "Shift", "S" },
doc = "zoom to fit content width", event = "SetZoomMode", args = "contentwidth"
doc = "zoom to fit content width",
event = "SetZoomMode", args = "contentwidth"
},
ZoomToFitPageHeight = {
{ "D" },
doc = "zoom to fit page height", event = "SetZoomMode", args = "pageheight"
doc = "zoom to fit page height",
event = "SetZoomMode", args = "pageheight"
},
ZoomToFitContentHeight = {
{ "Shift", "D" },
doc = "zoom to fit content height", event = "SetZoomMode", args = "contentheight"
doc = "zoom to fit content height",
event = "SetZoomMode", args = "contentheight"
},
},
zoom = 1.0,
@@ -103,11 +111,12 @@ function ReaderZooming:onZoom(direction)
return true
end
function ReaderZooming:onSetZoomMode(what)
if self.zoom_mode ~= what then
DEBUG("setting zoom mode to", what)
self.zoom_mode = what
function ReaderZooming:onSetZoomMode(new_mode)
if self.zoom_mode ~= new_mode then
DEBUG("setting zoom mode to", new_mode)
self.zoom_mode = new_mode
self:setZoom()
self.ui:handleEvent(Event:new("ZoomModeUpdate", new_mode))
end
return true
end