#include <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/input-options.h>
#include <dali/integration-api/render-task-list-integ.h>
+#include <dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h>
#include <dali-test-suite-utils.h>
#include <test-touch-utils.h>
END_TEST;
}
+
+int UtcDaliLongPressGestureSetMinimumHoldingTime(void)
+{
+ TestApplication application;
+
+ const uint32_t kMinumumHolding1 = 5000;
+ const uint32_t kMinumumHolding2 = 3000;
+
+ Integration::SetLongPressMinimumHoldingTime( kMinumumHolding1 );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 100.0f, 100.0f );
+ actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( actor );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ SignalData data;
+ GestureReceivedFunctor functor( data );
+
+ LongPressGestureDetector detector = LongPressGestureDetector::New();
+ detector.Attach(actor);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ Internal::LongPressGestureDetector& detectorImpl = Dali::GetImplementation( detector );
+
+ DALI_TEST_EQUALS( detectorImpl.GetMinimumHoldingTime(), kMinumumHolding1, TEST_LOCATION );
+
+ Integration::SetLongPressMinimumHoldingTime( kMinumumHolding2 );
+ DALI_TEST_EQUALS( detectorImpl.GetMinimumHoldingTime(), kMinumumHolding2, TEST_LOCATION );
+
+ END_TEST;
+}
eventProcessor.SetPinchGestureMinimumDistance( value );
}
+void SetLongPressMinimumHoldingTime( unsigned int value )
+{
+ GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+ eventProcessor.SetLongPressMinimumHoldingTime( value );
+}
+
} // namespace Integration
* @param[in] value Distance to move in pixels
*/
DALI_CORE_API void SetPinchGestureMinimumDistance( float value );
+
+/**
+ * @brief Sets the minimum holding time required to be recognized as a long press gesture
+ *
+ * @param[in] value The time value in milliseconds
+ */
+DALI_CORE_API void SetLongPressMinimumHoldingTime( unsigned int value );
+
} // namespace Integration
} // namespace Dali
mPinchGestureProcessor.SetMinimumPinchDistance( value );
}
+void GestureEventProcessor::SetLongPressMinimumHoldingTime( uint32_t value )
+{
+ mLongPressGestureProcessor.SetMinimumHoldingTime( value );
+}
+
+uint32_t GestureEventProcessor::GetLongPressMinimumHoldingTime() const
+{
+ return mLongPressGestureProcessor.GetMinimumHoldingTime();
+}
+
const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor()
{
return mPanGestureProcessor;
*/
void SetPinchGestureMinimumDistance( float value);
+ /**
+ * @brief Sets the minimum holding time required to be recognized as a long press gesture
+ *
+ * @param[in] value The time value in milliseconds
+ */
+ void SetLongPressMinimumHoldingTime( uint32_t value );
+
+ /**
+ * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
+ */
+ uint32_t GetLongPressMinimumHoldingTime() const;
+
public: // needed for PanGesture
/**
// Do nothing
}
+uint32_t LongPressGestureDetector::GetMinimumHoldingTime() const
+{
+ return mGestureEventProcessor.GetLongPressMinimumHoldingTime();
+}
+
} // namespace Internal
} // namespace Dali
*/
unsigned int GetMaximumTouchesRequired() const;
+ /**
+ * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
+ */
+ uint32_t GetMinimumHoldingTime() const;
+
public:
/**
namespace
{
+const unsigned long DEFAULT_MINIMUM_HOLDING_TIME = 500u;
+
/**
* Creates a LongPressGesture and asks the specified detector to emit its detected signal.
* @param[in] actor The actor on which the long press gesture has occurred.
mCurrentRenderTask(),
mMinTouchesRequired( 1 ),
mMaxTouchesRequired( 1 ),
- mCurrentLongPressEvent( NULL )
+ mCurrentLongPressEvent( NULL ),
+ mMinimumHoldingTime( DEFAULT_MINIMUM_HOLDING_TIME )
{
}
Size size = scene.GetSize();
- mGestureRecognizer = new LongPressGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const LongPressGestureRequest&>(request));
+ mGestureRecognizer = new LongPressGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const LongPressGestureRequest&>(request), mMinimumHoldingTime );
}
else
{
UpdateDetection();
}
+void LongPressGestureProcessor::SetMinimumHoldingTime( uint32_t time )
+{
+ if( time > 0u )
+ {
+ mMinimumHoldingTime = time;
+
+ if( mGestureRecognizer )
+ {
+ LongPressGestureRecognizer* longPressRecognizer = dynamic_cast<LongPressGestureRecognizer*>( mGestureRecognizer.Get() );
+ if( longPressRecognizer )
+ {
+ longPressRecognizer->SetMinimumHoldingTime( time );
+ }
+ }
+ }
+}
+
+uint32_t LongPressGestureProcessor::GetMinimumHoldingTime() const
+{
+ return mMinimumHoldingTime;
+}
+
void LongPressGestureProcessor::UpdateDetection()
{
DALI_ASSERT_DEBUG(!mLongPressGestureDetectors.empty());
*/
void GestureDetectorUpdated(LongPressGestureDetector* gestureDetector);
+ /**
+ * @brief This method sets the minimum holding time required to be recognized as a long press gesture
+ *
+ * @param[in] value The time value in milliseconds
+ */
+ void SetMinimumHoldingTime( uint32_t time );
+
+ /**
+ * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
+ */
+ uint32_t GetMinimumHoldingTime() const;
+
private:
// Undefined
uint32_t mMaxTouchesRequired;
const LongPressGestureEvent* mCurrentLongPressEvent; ///< Pointer to current longPressEvent, used when calling ProcessAndEmit()
+
+ uint32_t mMinimumHoldingTime;
};
} // namespace Internal
{
// TODO: Set these according to DPI
const float MAXIMUM_MOTION_ALLOWED = 60.0f;
-// TODO: Set this time according to system setting (vconf)
-const unsigned long LONG_PRESS_TIME = 500u;
+
} // unnamed namespace
-LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request )
+LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime )
: GestureRecognizer( screenSize, Gesture::LongPress ),
mObserver( observer ),
mState( Clear ),
mMinimumTouchesRequired( request.minTouches ),
mMaximumTouchesRequired( request.maxTouches ),
mTouchTime( 0 ),
- mTimerId( 0 )
+ mTimerId( 0 ),
+ mMinimumHoldingTime( minimumHoldingTime )
{
}
mTouchTime = event.time;
- mTimerId = platformAbstraction.StartTimer(GetSystemValue(), MakeCallback( this, &LongPressGestureRecognizer::TimerCallback));
+ mTimerId = platformAbstraction.StartTimer( mMinimumHoldingTime, MakeCallback( this, &LongPressGestureRecognizer::TimerCallback ) );
// A long press gesture may be possible, tell Core about this and change state to Touched.
mState = Touched;
mMaximumTouchesRequired = longPress.maxTouches;
}
+void LongPressGestureRecognizer::SetMinimumHoldingTime( uint32_t time )
+{
+ mMinimumHoldingTime = time;
+}
+
+
bool LongPressGestureRecognizer::TimerCallback()
{
EmitGesture(Gesture::Started);
longPress.time = mTouchTime;
if ( state != Gesture::Possible )
{
- longPress.time += GetSystemValue();
+ longPress.time += mMinimumHoldingTime;
}
if( mScene )
}
}
-int LongPressGestureRecognizer::GetSystemValue()
-{
- return LONG_PRESS_TIME;
-}
-
} // namespace Internal
} // namespace Dali
* @param[in] coreEventInterface Used to send events to Core.
* @param[in] screenSize The size of the screen.
* @param[in] request The long press gesture request.
+ * @param[in] minimumHoldingTime The minimum holding time required in milliseconds.
*/
- LongPressGestureRecognizer( Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request );
+ LongPressGestureRecognizer( Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime );
/**
* Virtual destructor.
*/
virtual void Update(const GestureRequest& request);
+ /**
+ * @brief This method sets the minimum holding time required to be recognized as a long press gesture
+ *
+ * @param[in] value The time value in milliseconds
+ */
+ void SetMinimumHoldingTime( uint32_t time );
+
private:
/**
*/
void EmitGesture(Gesture::State state);
- /**
- * Get current system setting value for tap and hold gesture
- * @return system value for tap and hold gesture [ms]
- */
- int GetSystemValue();
-
private:
// Reference to the gesture processor for this recognizer
uint32_t mTouchTime; ///< The time we first pressed down.
uint32_t mTimerId;
+
+ uint32_t mMinimumHoldingTime;
};
} // namespace Internal