Previously, the minimum pinch distance is determined by dividing the screen height by 85,
which is proportional to the screen height.
The problem is that, on the big size screen (or law dpi) devices,
the user have to make a long distance between their fingers to make a pinch gesture,
it makes the user misunderstand that the pinch gesture is not workoring properly.
This patch fixes the problem by calculating minimum pinch distance using screen dpi.
Change-Id: Iaab2d37f43421d53f9aa14060bd55465df4f9343
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
if (createRecognizer)
{
Size size = scene.GetSize();
if (createRecognizer)
{
Size size = scene.GetSize();
- mGestureRecognizer = new PinchGestureRecognizer( *this, Vector2(size.width, size.height), mMinimumPinchDistance);
+ mGestureRecognizer = new PinchGestureRecognizer( *this, Vector2(size.width, size.height), scene.GetDpi(), mMinimumPinchDistance );
const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
-const float MINIMUM_DISTANCE_DELTA_DIVISOR = 85.0f;
+const float MINIMUM_DISTANCE_IN_MILLIINCH = 45.0f; // This value is used for measuring minimum pinch distance in pixel.
+const float MINIMUM_DISTANCE_IN_PIXEL = 10.0f; // This value is for devices that do not provide a valid dpi value. (assumes 220dpi)
inline float GetDistance(const Integration::Point& point1, const Integration::Point& point2)
{
inline float GetDistance(const Integration::Point& point1, const Integration::Point& point2)
{
return Vector2(point1.GetScreenPosition() + point2.GetScreenPosition()) * 0.5f;
}
return Vector2(point1.GetScreenPosition() + point2.GetScreenPosition()) * 0.5f;
}
+inline bool IsValidDpi( const Vector2& dpi )
+{
+ return dpi.x > 0.f && dpi.y > 0.f;
+}
+
+inline float GetDefaultMinimumPinchDistance( const Vector2& dpi )
+{
+ return IsValidDpi( dpi ) ? ( ( MINIMUM_DISTANCE_IN_MILLIINCH * std::min( dpi.x, dpi.y ) ) / 1000.f ) : MINIMUM_DISTANCE_IN_PIXEL;
+}
+
-PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, float minimumPinchDistance )
+PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance )
: GestureRecognizer( screenSize, Gesture::Pinch ),
mObserver( observer ),
mState( Clear ),
mTouchEvents(),
: GestureRecognizer( screenSize, Gesture::Pinch ),
mObserver( observer ),
mState( Clear ),
mTouchEvents(),
+ mDefaultMinimumDistanceDelta( GetDefaultMinimumPinchDistance( screenDpi ) ),
mStartingDistance( 0.0f )
{
SetMinimumPinchDistance( minimumPinchDistance );
mStartingDistance( 0.0f )
{
SetMinimumPinchDistance( minimumPinchDistance );
void PinchGestureRecognizer::SetMinimumPinchDistance(float value)
{
void PinchGestureRecognizer::SetMinimumPinchDistance(float value)
{
- mMinimumDistanceDelta = value >= 0.0f ? value : (mScreenSize.height / MINIMUM_DISTANCE_DELTA_DIVISOR);
+ mMinimumDistanceDelta = value >= 0.0f ? value : mDefaultMinimumDistanceDelta;
}
void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
}
void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
/**
* Constructor
* @param[in] screenSize The size of the screen.
/**
* Constructor
* @param[in] screenSize The size of the screen.
+ * @param[in] screenDpi The dpi value of the screen
* @param[in] minimumPinchDistance in pixels
*/
* @param[in] minimumPinchDistance in pixels
*/
- PinchGestureRecognizer(Observer& observer, Vector2 screenSize, float minimumPinchDistance);
+ PinchGestureRecognizer(Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance);
/**
* Virtual destructor.
/**
* Virtual destructor.
State mState; ///< The current state of the detector.
std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
State mState; ///< The current state of the detector.
std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
+ float mDefaultMinimumDistanceDelta; ///< The default value of the mMinimumDistanceDelta.
+
float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.