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

@@ -137,6 +137,19 @@ function Geom:intersect(rect_b)
return intersected
end
--[[
return true if self does not share any area with rect_b
]]--
function Geom:notIntersectWith(rect_b)
if (self.x >= (rect_b.x + rect_b.w))
or (self.y >= (rect_b.y + rect_b.h))
or (rect_b.x >= (self.x + self.w))
or (rect_b.y >= (self.y + self.h)) then
return true
end
return false
end
--[[
set size of dimension or rectangle to size of given dimension/rectangle
]]--
@@ -245,3 +258,20 @@ function Geom:offsetWithin(rect_b, dx, dy)
self.y = rect_b.y + rect_b.h - self.h
end
end
--[[
Simple math helper function
]]--
function math.roundAwayFromZero(num)
if num > 0 then
return math.ceil(num)
else
return math.floor(num)
end
end