add math.lua, move all math related helpers in to it

This commit is contained in:
Qingping Hou
2013-02-19 11:57:14 +08:00
parent 79b3ee91c7
commit f3452234ea
5 changed files with 33 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
require "math"
--[[
BBoxWidget shows a bbox for page cropping
]]
@@ -89,14 +91,6 @@ function BBoxWidget:screen_to_page()
return bbox
end
function BBoxWidget:oddEven(number)
if number % 2 == 1 then
return "odd"
else
return "even"
end
end
function BBoxWidget:onAdjustCrop(arg, ges)
DEBUG("adjusting crop bbox with pos", ges.pos)
local bbox = self.screen_bbox
@@ -136,7 +130,7 @@ function BBoxWidget:onConfirmCrop()
UIManager:close(self)
self.ui:handleEvent(Event:new("BBoxUpdate"), self.page_bbox)
self.document.bbox[self.pageno] = self.page_bbox
self.document.bbox[self:oddEven(self.pageno)] = self.page_bbox
self.document.bbox[math.oddEven(self.pageno)] = self.page_bbox
self.ui:handleEvent(Event:new("ExitPageCrop"))
end