From 8c1c51e23095bb3759ec3876abfe16f21915b16f Mon Sep 17 00:00:00 2001 From: chrox Date: Tue, 5 Feb 2013 21:11:53 +0800 Subject: [PATCH 1/2] use hold event to cancel page crop --- frontend/ui/bbox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/bbox.lua b/frontend/ui/bbox.lua index 1743a614f..152db44f2 100644 --- a/frontend/ui/bbox.lua +++ b/frontend/ui/bbox.lua @@ -85,7 +85,7 @@ function BBoxWidget:init() }, CancelCrop = { GestureRange:new{ - ges = "hold_release", + ges = "hold", range = Geom:new{ x = 0, y = 0, w = Screen:getWidth(), From 72d806fbfce8423615cb099e02053c9f711195a7 Mon Sep 17 00:00:00 2001 From: chrox Date: Tue, 5 Feb 2013 21:35:17 +0800 Subject: [PATCH 2/2] adjust four corners of page bbox --- frontend/ui/bbox.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/ui/bbox.lua b/frontend/ui/bbox.lua index 152db44f2..102ad2d9c 100644 --- a/frontend/ui/bbox.lua +++ b/frontend/ui/bbox.lua @@ -113,13 +113,23 @@ function BBoxWidget:onAdjustCrop(pos) DEBUG("adjusting crop bbox with pos", pos) local bbox = self.screen_bbox local upper_left = Geom:new{ x = bbox.x0, y = bbox.y0} + local upper_right = Geom:new{ x = bbox.x1, y = bbox.y0} + local bottom_left = Geom:new{ x = bbox.x0, y = bbox.y1} local bottom_right = Geom:new{ x = bbox.x1, y = bbox.y1} - if upper_left:distance(pos) < bottom_right:distance(pos) then + local corners = {upper_left, upper_right, bottom_left, bottom_right} + table.sort(corners, function(a,b) return a:distance(pos) < b:distance(pos) end) + if corners[1] == upper_left then upper_left.x = pos.x upper_left.y = pos.y - else + elseif corners[1] == bottom_right then bottom_right.x = pos.x bottom_right.y = pos.y + elseif corners[1] == upper_right then + bottom_right.x = pos.x + upper_left.y = pos.y + elseif corners[1] == bottom_left then + upper_left.x = pos.x + bottom_right.y = pos.y end self.screen_bbox = { x0 = upper_left.x,