[problem] Need more than one motion event to determine the direction.
[cause] N/A
[solution] Wait at least one more pan.
Add configurability via environment variables:
Minimum distance before pan: DALI_PAN_MINIMUM_DISTANCE
Minimum motion events before pan (include down): DALI_PAN_MINIMUM_EVENTS
Change-Id: I3dbe34dc56d6c84518aec3807911054280998ca5
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
mPanGestureLoggingLevel(0),
mPanGesturePredictionMode(-1),
mPanGesturePredictionAmount(-1.0f), ///< only sets value in pan gesture if greater than 0
+ mPanMinimumDistance(-1),
+ mPanMinimumEvents(-1),
mLogFunction( NULL )
{
}
return mPanGesturePredictionAmount;
}
+int EnvironmentOptions::GetMinimumPanDistance() const
+{
+ return mPanMinimumDistance;
+}
+
+int EnvironmentOptions::GetMinimumPanEvents() const
+{
+ return mPanMinimumEvents;
+}
+
void EnvironmentOptions::SetPanGesturePredictionMode(unsigned int mode)
{
mPanGesturePredictionMode = mode;
mPanGesturePredictionAmount = amount;
}
+void EnvironmentOptions::SetMinimumPanDistance( int distance )
+{
+ mPanMinimumDistance = distance;
+}
+
+void EnvironmentOptions::SetMinimumPanEvents( int events )
+{
+ mPanMinimumEvents = events;
+}
+
} // Adaptor
} // Internal
float GetPanGesturePredictionAmount() const;
/**
+ * @return The minimum distance before a pan can be started (-1 means it's not set)
+ */
+ int GetMinimumPanDistance() const;
+
+ /**
+ * @return The minimum events before a pan can be started (-1 means it's not set)
+ */
+ int GetMinimumPanEvents() const;
+
+ /**
* @brief Sets the mode used to smooth pan gesture movement properties calculated on the Update thread
*
* @param[in] mode The smoothing mode to use
*/
void SetPanGesturePredictionAmount(unsigned int amount);
+ /**
+ * @brief Sets the minimum distance required before a pan starts
+ *
+ * @param[in] distance The minimum distance before a pan starts
+ */
+ void SetMinimumPanDistance( int distance );
+
+ /**
+ * @brief Sets the minimum number of events required before a pan starts
+ *
+ * @param[in] events The minimum events before a pan starts
+ */
+ void SetMinimumPanEvents( int events );
+
private:
unsigned int mFpsFrequency; ///< how often fps is logged out in seconds
unsigned int mPanGestureLoggingLevel; ///< pan-gesture log level
int mPanGesturePredictionMode; ///< prediction mode for pan gestures
float mPanGesturePredictionAmount; ///< prediction amount for pan gestures
+ int mPanMinimumDistance; ///< minimum distance required before pan starts
+ int mPanMinimumEvents; ///< minimum events required before pan starts
Dali::Integration::Log::LogFunction mLogFunction;
#define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT"
+#define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE"
+
+#define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS"
+
} // namespace Adaptor
} // namespace Internal
{
AccessibilityGestureDetector::AccessibilityGestureDetector()
-: PanGestureDetectorBase(Vector2::ZERO, Integration::PanGestureRequest()),
+: PanGestureDetectorBase(Vector2::ZERO, Integration::PanGestureRequest(), NULL),
mGestureHandler(NULL),
mPanning(false)
{
mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
}
+ int minimumDistance(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
+ {
+ mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
+ }
+
+ int minimumEvents(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
+ {
+ mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
+ }
+
mEnvironmentOptions.InstallLogFunction();
}
PositionSize size = mSurface->GetPositionSize();
- mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager);
+ mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
mGLES = new GlImplementation;
const float MINIMUM_DISTANCE_DELTA_DIVISOR = 85.0f;
} // unnamed namespace
-GestureManager::GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize,CallbackManager* callbackManager)
+GestureManager::GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize,CallbackManager* callbackManager, EnvironmentOptions& environmentOptions)
: mCoreEventInterface( coreEventInterface ),
mScreenSize( screenSize ),
mCallbackManager( callbackManager ),
+ mEnvironmentOptions( environmentOptions ),
mMinimumDistanceDelta(-1.0f),
mRunning( true ) // This allows gestures to be created before Adaptor::Start() is called e.g. by Indicator
{
case Gesture::Pan:
{
- GestureDetectorPtr gesture = new PanGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::PanGestureRequest&>(request));
+ GestureDetectorPtr gesture = new PanGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::PanGestureRequest&>(request), mEnvironmentOptions);
mGestureDetectors.push_back(gesture);
break;
}
class CallbackManager;
class CoreEventInterface;
+class EnvironmentOptions;
/**
* Implementation of the Integration::GestureManager.
* @param[in] coreEventInterface Used to send events to Core.
* @param[in] screenSize The size of the screen.
* @param[in] callbackManager used to install callbacks
+ * @param[in] environmentOptions Environment Options
*/
- GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize, CallbackManager* callbackManager);
+ GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize, CallbackManager* callbackManager, EnvironmentOptions& environmentOptions);
/**
* The destructor
GestureDetectorContainer mGestureDetectors;
Vector2 mScreenSize;
CallbackManager* mCallbackManager;
+ EnvironmentOptions& mEnvironmentOptions;
float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable. (-1.0f means pinch detector uses default value)
bool mRunning; ///< States whether the GestureManager is running or not.
};
#include <dali/integration-api/events/touch-event-integ.h>
// INTERNAL INCLUDES
+#include <base/environment-options.h>
namespace Dali
{
// TODO: Used DPD Value.
const float MINIMUM_MOTION_BEFORE_PAN_SQUARED( 15.0f * 15.0f );
const unsigned long MAXIMUM_TIME_DIFF_ALLOWED( 500 );
+const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2);
} // unnamed namespace
-PanGestureDetectorBase::PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request)
+PanGestureDetectorBase::PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions)
: GestureDetector(screenSize, Gesture::Pan),
mState(Clear),
mPrimaryTouchDownTime(0),
mMinimumTouchesRequired(request.minTouches),
- mMaximumTouchesRequired(request.maxTouches)
+ mMaximumTouchesRequired(request.maxTouches),
+ mMinimumDistanceSquared( MINIMUM_MOTION_BEFORE_PAN_SQUARED ),
+ mMinimumMotionEvents( MINIMUM_MOTION_EVENTS_BEFORE_PAN ),
+ mMotionEvents(0)
{
+ if ( environmentOptions )
+ {
+ int minimumDistance = environmentOptions->GetMinimumPanDistance();
+ if ( minimumDistance >= 0 )
+ {
+ mMinimumDistanceSquared = minimumDistance * minimumDistance;
+ }
+
+ int minimumEvents = environmentOptions->GetMinimumPanEvents();
+ if ( minimumEvents >= 1 )
+ {
+ mMinimumMotionEvents = minimumEvents - 1; // Down is the first event
+ }
+ }
}
PanGestureDetectorBase::~PanGestureDetectorBase()
{
mPrimaryTouchDownLocation = event.points[0].screen;
mPrimaryTouchDownTime = event.time;
+ mMotionEvents = 0;
if (event.GetPointCount() == mMinimumTouchesRequired)
{
// We have satisfied the minimum touches required for a pan, tell core that a gesture may be possible and change our state accordingly.
if (primaryPointState == TouchPoint::Motion)
{
mTouchEvents.push_back(event);
+ mMotionEvents++;
Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
- if (delta.LengthSquared() >= MINIMUM_MOTION_BEFORE_PAN_SQUARED)
+ if ( ( mMotionEvents >= mMinimumMotionEvents ) &&
+ ( delta.LengthSquared() >= mMinimumDistanceSquared ) )
{
// If the touch point(s) have moved enough distance to be considered a pan, then tell Core that the pan gesture has started and change our state accordingly.
mState = Started;
else if (primaryPointState == TouchPoint::Up)
{
Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
- if(delta.LengthSquared() >= MINIMUM_MOTION_BEFORE_PAN_SQUARED)
+ if(delta.LengthSquared() >= mMinimumDistanceSquared)
{
SendPan(Gesture::Started, event);
mTouchEvents.push_back(event);
namespace Adaptor
{
+class EnvironmentOptions;
+
/**
* When given a set of touch events, this detector attempts to determine if a pan gesture has taken place.
*/
* @param[in] screenSize The size of the screen.
* @param[in] request The details of the request.
*/
- PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request);
+ PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions);
private:
unsigned long mPrimaryTouchDownTime; ///< The initial touch down time.
unsigned int mMinimumTouchesRequired; ///< The minimum touches required before a pan should be emitted.
unsigned int mMaximumTouchesRequired; ///< The maximum touches after which a pan should not be emitted.
+
+ unsigned int mMinimumDistanceSquared; ///< The minimum distance squared before pan should start.
+ unsigned int mMinimumMotionEvents; ///< The minimum motion events before pan should start.
+ unsigned int mMotionEvents; ///< The motion events received so far (before pan is emitted).
};
} // namespace Adaptor
namespace Adaptor
{
-PanGestureDetector::PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request)
-: PanGestureDetectorBase(screenSize, request),
+PanGestureDetector::PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions)
+: PanGestureDetectorBase(screenSize, request, &environmentOptions),
mCoreEventInterface(coreEventInterface)
{
}
* @param[in] coreEventInterface Used to send events to Core.
* @param[in] screenSize The size of the screen.
* @param[in] request The details of the request.
+ * @param[in] environmentOptions The environmentOptions.
*/
- PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request);
+ PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions);
/**
* Virtual destructor.