/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// CLASS HEADER
#include <dali/internal/event/events/gesture-event-processor.h>
+#if defined(DEBUG_ENABLED)
+#include <sstream>
+#endif
+
// INTERNAL INCLUDES
-#include <dali/integration-api/events/gesture-event.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
-#include <dali/integration-api/gesture-manager.h>
#include <dali/integration-api/render-controller.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/events/pinch-gesture-detector-impl.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/public-api/events/pan-gesture.h>
+#include <dali/integration-api/debug.h>
+
namespace Dali
{
namespace Internal
{
-
-GestureEventProcessor::GestureEventProcessor( Stage& stage, SceneGraph::UpdateManager& updateManager, Integration::GestureManager& gestureManager, Integration::RenderController& renderController )
-: mStage( stage ),
- mGestureManager( gestureManager ),
- mLongPressGestureProcessor( stage, gestureManager ),
- mPanGestureProcessor( stage, gestureManager, updateManager ),
- mPinchGestureProcessor( stage, gestureManager ),
- mTapGestureProcessor( stage, gestureManager ),
+GestureEventProcessor::GestureEventProcessor( SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController )
+: mLongPressGestureProcessor(),
+ mPanGestureProcessor( updateManager ),
+ mPinchGestureProcessor(),
+ mTapGestureProcessor(),
mRenderController( renderController ),
- mUpdateRequired( false )
+ envOptionMinimumPanDistance(-1),
+ envOptionMinimumPanEvents(-1)
{
}
{
}
-void GestureEventProcessor::ProcessGestureEvent(const Integration::GestureEvent& event)
+void GestureEventProcessor::ProcessTouchEvent( Scene& scene, const Integration::TouchEvent& event)
{
- if( Gesture::Started == event.state || Gesture::Continuing == event.state )
- {
- SetUpdateRequired();
- }
-
- switch(event.gestureType)
- {
- case Gesture::LongPress:
- mLongPressGestureProcessor.Process(static_cast<const Integration::LongPressGestureEvent&>(event));
- break;
-
- case Gesture::Pan:
- mPanGestureProcessor.Process(static_cast<const Integration::PanGestureEvent&>(event));
- break;
-
- case Gesture::Pinch:
- mPinchGestureProcessor.Process(static_cast<const Integration::PinchGestureEvent&>(event));
- break;
-
- case Gesture::Tap:
- mTapGestureProcessor.Process(static_cast<const Integration::TapGestureEvent&>(event));
- break;
- }
+ mLongPressGestureProcessor.ProcessTouch(scene, event);
+ mPanGestureProcessor.ProcessTouch(scene, event);
+ mPinchGestureProcessor.ProcessTouch(scene, event);
+ mTapGestureProcessor.ProcessTouch(scene, event);
}
-void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector)
+void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector, Scene& scene)
{
switch (gestureDetector->GetType())
{
case Gesture::LongPress:
{
LongPressGestureDetector* longPress = static_cast<LongPressGestureDetector*>(gestureDetector);
- mLongPressGestureProcessor.AddGestureDetector(longPress);
+ mLongPressGestureProcessor.AddGestureDetector(longPress, scene);
break;
}
case Gesture::Pan:
{
PanGestureDetector* pan = static_cast<PanGestureDetector*>(gestureDetector);
- mPanGestureProcessor.AddGestureDetector(pan);
+ mPanGestureProcessor.AddGestureDetector(pan, scene, envOptionMinimumPanDistance, envOptionMinimumPanEvents);
break;
}
case Gesture::Pinch:
{
PinchGestureDetector* pinch = static_cast<PinchGestureDetector*>(gestureDetector);
- mPinchGestureProcessor.AddGestureDetector(pinch);
+ mPinchGestureProcessor.AddGestureDetector(pinch, scene);
break;
}
case Gesture::Tap:
{
TapGestureDetector* tap = static_cast<TapGestureDetector*>(gestureDetector);
- mTapGestureProcessor.AddGestureDetector(tap);
+ mTapGestureProcessor.AddGestureDetector(tap, scene);
break;
}
}
}
}
-void GestureEventProcessor::SetUpdateRequired()
-{
- mUpdateRequired = true;
-}
-
void GestureEventProcessor::SetGestureProperties( const Gesture& gesture )
{
- if( Gesture::Started == gesture.state || Gesture::Continuing == gesture.state )
- {
- SetUpdateRequired();
-
- // We may not be updating so we need to ask the render controller for an update.
- mRenderController.RequestUpdate();
- }
+ bool requestUpdate = false;
switch ( gesture.type )
{
case Gesture::Pan:
{
const PanGesture& pan = static_cast< const PanGesture& >( gesture );
- mPanGestureProcessor.SetPanGestureProperties( pan );
+ requestUpdate = mPanGestureProcessor.SetPanGestureProperties( pan );
break;
}
break;
}
}
+
+ if( requestUpdate )
+ {
+ // We may not be updating so we need to ask the render controller for an update.
+ mRenderController.RequestUpdate( false );
+ }
}
bool GestureEventProcessor::NeedsUpdate()
{
- bool updateRequired( mUpdateRequired );
+ bool updateRequired = false;
- mUpdateRequired = false;
+ updateRequired |= mLongPressGestureProcessor.NeedsUpdate();
+ updateRequired |= mPanGestureProcessor.NeedsUpdate();
+ updateRequired |= mPinchGestureProcessor.NeedsUpdate();
+ updateRequired |= mTapGestureProcessor.NeedsUpdate();
return updateRequired;
}
mPanGestureProcessor.SetPredictionMode(mode);
}
-void GestureEventProcessor::SetPanGesturePredictionAmount( unsigned int amount )
+void GestureEventProcessor::SetPanGesturePredictionAmount( uint32_t amount )
{
mPanGestureProcessor.SetPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGestureMaximumPredictionAmount( unsigned int amount )
+void GestureEventProcessor::SetPanGestureMaximumPredictionAmount( uint32_t amount )
{
mPanGestureProcessor.SetMaximumPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGestureMinimumPredictionAmount( unsigned int amount )
+void GestureEventProcessor::SetPanGestureMinimumPredictionAmount( uint32_t amount )
{
mPanGestureProcessor.SetMinimumPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment( unsigned int amount )
+void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment( uint32_t amount )
{
mPanGestureProcessor.SetPredictionAmountAdjustment(amount);
}
-void GestureEventProcessor::SetPanGestureSmoothingMode(int mode)
+void GestureEventProcessor::SetPanGestureSmoothingMode( int32_t mode )
{
mPanGestureProcessor.SetSmoothingMode(mode);
}
mPanGestureProcessor.SetSmoothingAmount(amount);
}
+void GestureEventProcessor::SetPanGestureUseActualTimes( bool value )
+{
+ mPanGestureProcessor.SetUseActualTimes( value );
+}
+
+void GestureEventProcessor::SetPanGestureInterpolationTimeRange( int32_t value )
+{
+ mPanGestureProcessor.SetInterpolationTimeRange( value );
+}
+
+void GestureEventProcessor::SetPanGestureScalarOnlyPredictionEnabled( bool value )
+{
+ mPanGestureProcessor.SetScalarOnlyPredictionEnabled( value );
+}
+
+void GestureEventProcessor::SetPanGestureTwoPointPredictionEnabled( bool value )
+{
+ mPanGestureProcessor.SetTwoPointPredictionEnabled( value );
+}
+
+void GestureEventProcessor::SetPanGestureTwoPointInterpolatePastTime( int value )
+{
+ mPanGestureProcessor.SetTwoPointInterpolatePastTime( value );
+}
+
+void GestureEventProcessor::SetPanGestureTwoPointVelocityBias( float value )
+{
+ mPanGestureProcessor.SetTwoPointVelocityBias( value );
+}
+
+void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias( float value )
+{
+ mPanGestureProcessor.SetTwoPointAccelerationBias( value );
+}
+
+void GestureEventProcessor::SetPanGestureMultitapSmoothingRange( int32_t value )
+{
+ mPanGestureProcessor.SetMultitapSmoothingRange( value );
+}
+
+void GestureEventProcessor::SetPanGestureMinimumDistance( int32_t value )
+{
+ envOptionMinimumPanDistance = value;
+}
+
+void GestureEventProcessor::SetPanGestureMinimumPanEvents( int32_t value )
+{
+ envOptionMinimumPanEvents = value;
+}
+
+void GestureEventProcessor::SetPinchGestureMinimumDistance( float value)
+{
+ mPinchGestureProcessor.SetMinimumPinchDistance( value );
+}
+
+const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor()
+{
+ return mPanGestureProcessor;
+}
+
} // namespace Internal
} // namespace Dali