X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fgesture-event-processor.cpp;h=b307e6e20acabecb50c6ce8cc0e1d4fc62d85564;hb=e67905c37a8858178193e7569d663c639927cca8;hp=cfe7e586560fd87bbf535989427e95da261dc13f;hpb=ce20e9f082e811130930d13c9e9edc1da4ce1013;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 cfe7e58..b307e6e 100644 --- a/dali/internal/event/events/gesture-event-processor.cpp +++ b/dali/internal/event/events/gesture-event-processor.cpp @@ -1,49 +1,53 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include +#if defined(DEBUG_ENABLED) +#include +#endif + // INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include #include #include #include +#include #include +#include + namespace Dali { namespace Internal { - -GestureEventProcessor::GestureEventProcessor(Stage& stage, Integration::GestureManager& gestureManager, Integration::RenderController& renderController) -: mStage(stage), - mGestureManager(gestureManager), - mLongPressGestureProcessor(stage, gestureManager), - mPanGestureProcessor(stage, gestureManager), - mPinchGestureProcessor(stage, gestureManager), - mTapGestureProcessor(stage, gestureManager), - mRenderController(renderController), - mUpdateRequired( false ) +GestureEventProcessor::GestureEventProcessor( SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController ) +: mLongPressGestureProcessor(), + mPanGestureProcessor( updateManager ), + mPinchGestureProcessor(), + mTapGestureProcessor(), + mRenderController( renderController ), + mLongPressDetectorCount(0), + mPanDetectorCount(0), + mPinchDetectorCount(0), + mTapDetectorCount(0), + envOptionMinimumPanDistance(-1), + envOptionMinimumPanEvents(-1) { } @@ -51,72 +55,61 @@ 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 ) + if( mLongPressDetectorCount > 0 ) { - SetUpdateRequired(); + mLongPressGestureProcessor.ProcessTouch(scene, event); } - - switch(event.gestureType) + if( mPanDetectorCount > 0 ) { - 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; - - default: - DALI_ASSERT_ALWAYS( false && "Invalid gesture type sent from Integration\n" ); - break; + mPanGestureProcessor.ProcessTouch(scene, event); + } + if( mPinchDetectorCount > 0 ) + { + mPinchGestureProcessor.ProcessTouch(scene, event); + } + if( mTapDetectorCount > 0 ) + { + 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(gestureDetector); - mLongPressGestureProcessor.AddGestureDetector(longPress); + mLongPressGestureProcessor.AddGestureDetector(longPress, scene); + mLongPressDetectorCount++; break; } case Gesture::Pan: { PanGestureDetector* pan = static_cast(gestureDetector); - mPanGestureProcessor.AddGestureDetector(pan); + mPanGestureProcessor.AddGestureDetector(pan, scene, envOptionMinimumPanDistance, envOptionMinimumPanEvents); + mPanDetectorCount++; break; } case Gesture::Pinch: { PinchGestureDetector* pinch = static_cast(gestureDetector); - mPinchGestureProcessor.AddGestureDetector(pinch); + mPinchGestureProcessor.AddGestureDetector(pinch, scene); + mPinchDetectorCount++; break; } case Gesture::Tap: { TapGestureDetector* tap = static_cast(gestureDetector); - mTapGestureProcessor.AddGestureDetector(tap); + mTapGestureProcessor.AddGestureDetector(tap, scene); + mTapDetectorCount++; break; } - - default: - DALI_ASSERT_DEBUG( false && "Invalid gesture detector type created\n" ); - break; } } @@ -128,6 +121,7 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.RemoveGestureDetector(longPress); + mLongPressDetectorCount--; break; } @@ -135,6 +129,7 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.RemoveGestureDetector(pan); + mPanDetectorCount--; break; } @@ -142,6 +137,7 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.RemoveGestureDetector(pinch); + mPinchDetectorCount--; break; } @@ -149,12 +145,9 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.RemoveGestureDetector(tap); + mTapDetectorCount--; break; } - - default: - DALI_ASSERT_DEBUG( false && "Invalid gesture detector type removal request\n" ); - break; } } @@ -189,34 +182,19 @@ void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetec mTapGestureProcessor.GestureDetectorUpdated(tap); break; } - - default: - DALI_ASSERT_DEBUG( false && "Invalid gesture type update request\n" ); - 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; } @@ -228,17 +206,126 @@ void GestureEventProcessor::SetGestureProperties( const Gesture& gesture ) 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; } +void GestureEventProcessor::EnablePanGestureProfiling() +{ + mPanGestureProcessor.EnableProfiling(); +} + +void GestureEventProcessor::SetPanGesturePredictionMode(int mode) +{ + mPanGestureProcessor.SetPredictionMode(mode); +} + +void GestureEventProcessor::SetPanGesturePredictionAmount( uint32_t amount ) +{ + mPanGestureProcessor.SetPredictionAmount(amount); +} + +void GestureEventProcessor::SetPanGestureMaximumPredictionAmount( uint32_t amount ) +{ + mPanGestureProcessor.SetMaximumPredictionAmount(amount); +} + +void GestureEventProcessor::SetPanGestureMinimumPredictionAmount( uint32_t amount ) +{ + mPanGestureProcessor.SetMinimumPredictionAmount(amount); +} + +void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment( uint32_t amount ) +{ + mPanGestureProcessor.SetPredictionAmountAdjustment(amount); +} + +void GestureEventProcessor::SetPanGestureSmoothingMode( int32_t mode ) +{ + mPanGestureProcessor.SetSmoothingMode(mode); +} + +void GestureEventProcessor::SetPanGestureSmoothingAmount( float amount ) +{ + 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