X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fgesture-event-processor.cpp;h=04863ffa3b23f77688a02fbe79c80ad62ceffc20;hb=a4eb68faf1e75d213c951a7d4d1b67727247917a;hp=456cbc97d33e51f00603bf0206ad2091412aaf8c;hpb=c114bfe4714e8f02c54b25e381a41d80bdcb2d93;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/gesture-event-processor.cpp b/dali/internal/event/events/gesture-event-processor.cpp index 456cbc9..04863ff 100644 --- a/dali/internal/event/events/gesture-event-processor.cpp +++ b/dali/internal/event/events/gesture-event-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -18,34 +18,33 @@ // CLASS HEADER #include +#if defined(DEBUG_ENABLED) +#include +#endif + // INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include #include #include -#include +#include #include #include +#include + 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(), + mRotationGestureProcessor(), mRenderController( renderController ), - mUpdateRequired( false ) + envOptionMinimumPanDistance(-1), + envOptionMinimumPanEvents(-1) { } @@ -53,62 +52,51 @@ GestureEventProcessor::~GestureEventProcessor() { } -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(event)); - break; - - case Gesture::Pan: - mPanGestureProcessor.Process(static_cast(event)); - break; - - case Gesture::Pinch: - mPinchGestureProcessor.Process(static_cast(event)); - break; - - case Gesture::Tap: - mTapGestureProcessor.Process(static_cast(event)); - break; - } + mLongPressGestureProcessor.ProcessTouch(scene, event); + mPanGestureProcessor.ProcessTouch(scene, event); + mPinchGestureProcessor.ProcessTouch(scene, event); + mTapGestureProcessor.ProcessTouch(scene, event); + mRotationGestureProcessor.ProcessTouch(scene, event); } -void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector) +void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector, Scene& scene) { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case DevelGesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); - mLongPressGestureProcessor.AddGestureDetector(longPress); + mLongPressGestureProcessor.AddGestureDetector(longPress, scene); break; } - case Gesture::Pan: + case DevelGesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); - mPanGestureProcessor.AddGestureDetector(pan); + mPanGestureProcessor.AddGestureDetector(pan, scene, envOptionMinimumPanDistance, envOptionMinimumPanEvents); break; } - case Gesture::Pinch: + case DevelGesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); - mPinchGestureProcessor.AddGestureDetector(pinch); + mPinchGestureProcessor.AddGestureDetector(pinch, scene); break; } - case Gesture::Tap: + case DevelGesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); - mTapGestureProcessor.AddGestureDetector(tap); + mTapGestureProcessor.AddGestureDetector(tap, scene); + break; + } + + case DevelGesture::Rotation: + { + RotationGestureDetector* rotation = static_cast(gestureDetector); + mRotationGestureProcessor.AddGestureDetector(rotation, scene); break; } } @@ -118,33 +106,40 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case DevelGesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.RemoveGestureDetector(longPress); break; } - case Gesture::Pan: + case DevelGesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.RemoveGestureDetector(pan); break; } - case Gesture::Pinch: + case DevelGesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.RemoveGestureDetector(pinch); break; } - case Gesture::Tap: + case DevelGesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.RemoveGestureDetector(tap); break; } + + case DevelGesture::Rotation: + { + RotationGestureDetector* rotation = static_cast(gestureDetector); + mRotationGestureProcessor.RemoveGestureDetector(rotation); + break; + } } } @@ -152,75 +147,81 @@ void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetec { switch (gestureDetector->GetType()) { - case Gesture::LongPress: + case DevelGesture::LongPress: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.GestureDetectorUpdated(longPress); break; } - case Gesture::Pan: + case DevelGesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.GestureDetectorUpdated(pan); break; } - case Gesture::Pinch: + case DevelGesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.GestureDetectorUpdated(pinch); break; } - case Gesture::Tap: + case DevelGesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.GestureDetectorUpdated(tap); break; } - } -} -void GestureEventProcessor::SetUpdateRequired() -{ - mUpdateRequired = true; + case DevelGesture::Rotation: + { + // Nothing to do + break; + } + } } 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( false ); - } + bool requestUpdate = false; - switch ( gesture.type ) + switch ( static_cast< DevelGesture::Type >( gesture.type ) ) { - case Gesture::Pan: + case DevelGesture::Pan: { const PanGesture& pan = static_cast< const PanGesture& >( gesture ); - mPanGestureProcessor.SetPanGestureProperties( pan ); + requestUpdate = mPanGestureProcessor.SetPanGestureProperties( pan ); break; } - case Gesture::LongPress: - case Gesture::Pinch: - case Gesture::Tap: + case DevelGesture::LongPress: + case DevelGesture::Pinch: + case DevelGesture::Tap: + case DevelGesture::Rotation: { DALI_ASSERT_DEBUG( false && "Gesture type does not have scene object\n" ); 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(); + updateRequired |= mRotationGestureProcessor.NeedsUpdate(); return updateRequired; } @@ -235,27 +236,27 @@ void GestureEventProcessor::SetPanGesturePredictionMode(int mode) 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); } @@ -270,7 +271,7 @@ void GestureEventProcessor::SetPanGestureUseActualTimes( bool value ) mPanGestureProcessor.SetUseActualTimes( value ); } -void GestureEventProcessor::SetPanGestureInterpolationTimeRange( int value ) +void GestureEventProcessor::SetPanGestureInterpolationTimeRange( int32_t value ) { mPanGestureProcessor.SetInterpolationTimeRange( value ); } @@ -300,11 +301,36 @@ void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias( float value ) mPanGestureProcessor.SetTwoPointAccelerationBias( value ); } -void GestureEventProcessor::SetPanGestureMultitapSmoothingRange( int 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 ); +} + +void GestureEventProcessor::SetLongPressMinimumHoldingTime( uint32_t value ) +{ + mLongPressGestureProcessor.SetMinimumHoldingTime( value ); +} + +uint32_t GestureEventProcessor::GetLongPressMinimumHoldingTime() const +{ + return mLongPressGestureProcessor.GetMinimumHoldingTime(); +} + const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor() { return mPanGestureProcessor;