move adjustGesCoordinate from Screen to GestureDetector

also adjust swipe direction according to screen view mode
pull/2/merge
Qingping Hou 11 years ago
parent ab956a10c5
commit a655219eba

@ -326,4 +326,29 @@ function GestureDetector:holdState(tev)
end
end
--[[
@brief change gesture's x and y coordinates according to screen view mode
@param ges gesture that you want to adjust
@return adjusted gesture.
--]]
function GestureDetector:adjustGesCoordinate(ges)
if Screen.cur_rotation_mode == 1 then
-- in landscape mode
ges.pos.x, ges.pos.y = (Screen.width - ges.pos.y), (ges.pos.x)
if ges.ges == "swipe" then
if ges.direction == "down" then
ges.direction = "left"
elseif ges.direction == "up" then
ges.direction = "right"
elseif ges.direction == "right" then
ges.direction = "down"
elseif ges.direction == "left" then
ges.direction = "up"
end
end
end
return ges
end

@ -407,7 +407,7 @@ function Input:handleTouchEv(ev)
--self.cur_ev = {}
if touch_ges then
return Event:new("Gesture",
Screen:adjustGesCoordinate(touch_ges)
GestureDetector:adjustGesCoordinate(touch_ges)
)
end
end
@ -448,7 +448,7 @@ function Input:waitEvent(timeout_us, timeout_s)
-- decided a gesture? FIXME
Input.timer_callbacks = {}
return Event:new("Gesture",
Screen:adjustGesCoordinate(touch_ges)
GestureDetector:adjustGesCoordinate(touch_ges)
)
end -- EOF if touch_ges
end -- EOF if deadline reached

@ -148,21 +148,6 @@ function Screen:setScreenMode(mode)
end
end
--[[
@brief change gesture's x and y coordinates according to screen view mode
@param ges gesture that you want to adjust
@return adjusted gesture.
--]]
function Screen:adjustGesCoordinate(ges)
if self.cur_rotation_mode == 1 then
--@TODO fix wipe direction 03.02 2013 (houqp)
ges.pos.x, ges.pos.y = (self.width - ges.pos.y), (ges.pos.x)
end
return ges
end
function Screen:saveCurrentBB()
local width, height = self:getWidth(), self:getHeight()

Loading…
Cancel
Save