X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fgesture-event-processor.cpp;h=118c783f64397a96ac1cb9170de5117079e5c32e;hb=0ed4ee4571aacaf595db0f5b4332fa14113f3d51;hp=b307e6e20acabecb50c6ce8cc0e1d4fc62d85564;hpb=2ada356619fc41af1f590e9d471352d8ce475a83;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 b307e6e..118c783 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) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -23,91 +23,76 @@ #endif // INTERNAL INCLUDES +#include #include #include -#include +#include +#include #include -#include -#include - namespace Dali { - namespace Internal { -GestureEventProcessor::GestureEventProcessor( SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController ) +GestureEventProcessor::GestureEventProcessor(SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController) : mLongPressGestureProcessor(), - mPanGestureProcessor( updateManager ), + mPanGestureProcessor(updateManager), mPinchGestureProcessor(), mTapGestureProcessor(), - mRenderController( renderController ), - mLongPressDetectorCount(0), - mPanDetectorCount(0), - mPinchDetectorCount(0), - mTapDetectorCount(0), + mRotationGestureProcessor(), + mRenderController(renderController), envOptionMinimumPanDistance(-1), envOptionMinimumPanEvents(-1) { } -GestureEventProcessor::~GestureEventProcessor() -{ -} +GestureEventProcessor::~GestureEventProcessor() = default; -void GestureEventProcessor::ProcessTouchEvent( Scene& scene, const Integration::TouchEvent& event) +void GestureEventProcessor::ProcessTouchEvent(Scene& scene, const Integration::TouchEvent& event) { - if( mLongPressDetectorCount > 0 ) - { - mLongPressGestureProcessor.ProcessTouch(scene, event); - } - if( mPanDetectorCount > 0 ) - { - mPanGestureProcessor.ProcessTouch(scene, event); - } - if( mPinchDetectorCount > 0 ) - { - mPinchGestureProcessor.ProcessTouch(scene, event); - } - if( mTapDetectorCount > 0 ) - { - mTapGestureProcessor.ProcessTouch(scene, event); - } + 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, Scene& scene) { - switch (gestureDetector->GetType()) + switch(gestureDetector->GetType()) { - case Gesture::LongPress: + case GestureType::LONG_PRESS: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.AddGestureDetector(longPress, scene); - mLongPressDetectorCount++; break; } - case Gesture::Pan: + case GestureType::PAN: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.AddGestureDetector(pan, scene, envOptionMinimumPanDistance, envOptionMinimumPanEvents); - mPanDetectorCount++; break; } - case Gesture::Pinch: + case GestureType::PINCH: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.AddGestureDetector(pinch, scene); - mPinchDetectorCount++; break; } - case Gesture::Tap: + case GestureType::TAP: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.AddGestureDetector(tap, scene); - mTapDetectorCount++; + break; + } + + case GestureType::ROTATION: + { + RotationGestureDetector* rotation = static_cast(gestureDetector); + mRotationGestureProcessor.AddGestureDetector(rotation, scene); break; } } @@ -115,37 +100,40 @@ void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector, void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetector) { - switch (gestureDetector->GetType()) + switch(gestureDetector->GetType()) { - case Gesture::LongPress: + case GestureType::LONG_PRESS: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.RemoveGestureDetector(longPress); - mLongPressDetectorCount--; break; } - case Gesture::Pan: + case GestureType::PAN: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.RemoveGestureDetector(pan); - mPanDetectorCount--; break; } - case Gesture::Pinch: + case GestureType::PINCH: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.RemoveGestureDetector(pinch); - mPinchDetectorCount--; break; } - case Gesture::Tap: + case GestureType::TAP: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.RemoveGestureDetector(tap); - mTapDetectorCount--; + break; + } + + case GestureType::ROTATION: + { + RotationGestureDetector* rotation = static_cast(gestureDetector); + mRotationGestureProcessor.RemoveGestureDetector(rotation); break; } } @@ -153,64 +141,53 @@ void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetect void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetector) { - switch (gestureDetector->GetType()) + switch(gestureDetector->GetType()) { - case Gesture::LongPress: + case GestureType::LONG_PRESS: { LongPressGestureDetector* longPress = static_cast(gestureDetector); mLongPressGestureProcessor.GestureDetectorUpdated(longPress); break; } - case Gesture::Pan: + case GestureType::PAN: { PanGestureDetector* pan = static_cast(gestureDetector); mPanGestureProcessor.GestureDetectorUpdated(pan); break; } - case Gesture::Pinch: + case GestureType::PINCH: { PinchGestureDetector* pinch = static_cast(gestureDetector); mPinchGestureProcessor.GestureDetectorUpdated(pinch); break; } - case Gesture::Tap: + case GestureType::TAP: { TapGestureDetector* tap = static_cast(gestureDetector); mTapGestureProcessor.GestureDetectorUpdated(tap); break; } - } -} -void GestureEventProcessor::SetGestureProperties( const Gesture& gesture ) -{ - bool requestUpdate = false; - - switch ( gesture.type ) - { - case Gesture::Pan: + case GestureType::ROTATION: { - const PanGesture& pan = static_cast< const PanGesture& >( gesture ); - requestUpdate = mPanGestureProcessor.SetPanGestureProperties( pan ); - break; - } - - case Gesture::LongPress: - case Gesture::Pinch: - case Gesture::Tap: - { - DALI_ASSERT_DEBUG( false && "Gesture type does not have scene object\n" ); + // Nothing to do break; } } +} - if( requestUpdate ) +void GestureEventProcessor::SetGestureProperties(const Dali::Gesture& gesture) +{ + DALI_ASSERT_DEBUG(gesture.GetType() == GestureType::PAN && "Only PanGesture has a scene object\n"); + + const Dali::PanGesture& pan = static_cast(gesture); + if(mPanGestureProcessor.SetPanGestureProperties(pan)) { // We may not be updating so we need to ask the render controller for an update. - mRenderController.RequestUpdate( false ); + mRenderController.RequestUpdate(false); } } @@ -222,6 +199,7 @@ bool GestureEventProcessor::NeedsUpdate() updateRequired |= mPanGestureProcessor.NeedsUpdate(); updateRequired |= mPinchGestureProcessor.NeedsUpdate(); updateRequired |= mTapGestureProcessor.NeedsUpdate(); + updateRequired |= mRotationGestureProcessor.NeedsUpdate(); return updateRequired; } @@ -236,89 +214,119 @@ void GestureEventProcessor::SetPanGesturePredictionMode(int mode) mPanGestureProcessor.SetPredictionMode(mode); } -void GestureEventProcessor::SetPanGesturePredictionAmount( uint32_t amount ) +void GestureEventProcessor::SetPanGesturePredictionAmount(uint32_t amount) { mPanGestureProcessor.SetPredictionAmount(amount); } -void GestureEventProcessor::SetPanGestureMaximumPredictionAmount( uint32_t amount ) +void GestureEventProcessor::SetPanGestureMaximumPredictionAmount(uint32_t amount) { mPanGestureProcessor.SetMaximumPredictionAmount(amount); } -void GestureEventProcessor::SetPanGestureMinimumPredictionAmount( uint32_t amount ) +void GestureEventProcessor::SetPanGestureMinimumPredictionAmount(uint32_t amount) { mPanGestureProcessor.SetMinimumPredictionAmount(amount); } -void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment( uint32_t amount ) +void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment(uint32_t amount) { mPanGestureProcessor.SetPredictionAmountAdjustment(amount); } -void GestureEventProcessor::SetPanGestureSmoothingMode( int32_t mode ) +void GestureEventProcessor::SetPanGestureSmoothingMode(int32_t mode) { mPanGestureProcessor.SetSmoothingMode(mode); } -void GestureEventProcessor::SetPanGestureSmoothingAmount( float amount ) +void GestureEventProcessor::SetPanGestureSmoothingAmount(float amount) { mPanGestureProcessor.SetSmoothingAmount(amount); } -void GestureEventProcessor::SetPanGestureUseActualTimes( bool value ) +void GestureEventProcessor::SetPanGestureUseActualTimes(bool value) { - mPanGestureProcessor.SetUseActualTimes( value ); + mPanGestureProcessor.SetUseActualTimes(value); } -void GestureEventProcessor::SetPanGestureInterpolationTimeRange( int32_t value ) +void GestureEventProcessor::SetPanGestureInterpolationTimeRange(int32_t value) { - mPanGestureProcessor.SetInterpolationTimeRange( value ); + mPanGestureProcessor.SetInterpolationTimeRange(value); } -void GestureEventProcessor::SetPanGestureScalarOnlyPredictionEnabled( bool value ) +void GestureEventProcessor::SetPanGestureScalarOnlyPredictionEnabled(bool value) { - mPanGestureProcessor.SetScalarOnlyPredictionEnabled( value ); + mPanGestureProcessor.SetScalarOnlyPredictionEnabled(value); } -void GestureEventProcessor::SetPanGestureTwoPointPredictionEnabled( bool value ) +void GestureEventProcessor::SetPanGestureTwoPointPredictionEnabled(bool value) { - mPanGestureProcessor.SetTwoPointPredictionEnabled( value ); + mPanGestureProcessor.SetTwoPointPredictionEnabled(value); } -void GestureEventProcessor::SetPanGestureTwoPointInterpolatePastTime( int value ) +void GestureEventProcessor::SetPanGestureTwoPointInterpolatePastTime(int value) { - mPanGestureProcessor.SetTwoPointInterpolatePastTime( value ); + mPanGestureProcessor.SetTwoPointInterpolatePastTime(value); } -void GestureEventProcessor::SetPanGestureTwoPointVelocityBias( float value ) +void GestureEventProcessor::SetPanGestureTwoPointVelocityBias(float value) { - mPanGestureProcessor.SetTwoPointVelocityBias( value ); + mPanGestureProcessor.SetTwoPointVelocityBias(value); } -void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias( float value ) +void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias(float value) { - mPanGestureProcessor.SetTwoPointAccelerationBias( value ); + mPanGestureProcessor.SetTwoPointAccelerationBias(value); } -void GestureEventProcessor::SetPanGestureMultitapSmoothingRange( int32_t value ) +void GestureEventProcessor::SetPanGestureMultitapSmoothingRange(int32_t value) { - mPanGestureProcessor.SetMultitapSmoothingRange( value ); + mPanGestureProcessor.SetMultitapSmoothingRange(value); } -void GestureEventProcessor::SetPanGestureMinimumDistance( int32_t value ) +void GestureEventProcessor::SetPanGestureMinimumDistance(int32_t value) { - envOptionMinimumPanDistance = value; + envOptionMinimumPanDistance = value; } -void GestureEventProcessor::SetPanGestureMinimumPanEvents( int32_t value ) +void GestureEventProcessor::SetPanGestureMinimumPanEvents(int32_t value) { envOptionMinimumPanEvents = value; } -void GestureEventProcessor::SetPinchGestureMinimumDistance( float value) +void GestureEventProcessor::SetPinchGestureMinimumDistance(float value) +{ + mPinchGestureProcessor.SetMinimumPinchDistance(value); +} + +void GestureEventProcessor::SetPinchGestureMinimumTouchEvents(uint32_t value) { - mPinchGestureProcessor.SetMinimumPinchDistance( value ); + mPinchGestureProcessor.SetMinimumTouchEvents(value); +} + +void GestureEventProcessor::SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value) +{ + mPinchGestureProcessor.SetMinimumTouchEventsAfterStart(value); +} + +void GestureEventProcessor::SetRotationGestureMinimumTouchEvents(uint32_t value) +{ + mRotationGestureProcessor.SetMinimumTouchEvents(value); +} + +void GestureEventProcessor::SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value) +{ + mRotationGestureProcessor.SetMinimumTouchEventsAfterStart(value); +} + +void GestureEventProcessor::SetLongPressMinimumHoldingTime(uint32_t value) +{ + mLongPressGestureProcessor.SetMinimumHoldingTime(value); +} + +uint32_t GestureEventProcessor::GetLongPressMinimumHoldingTime() const +{ + return mLongPressGestureProcessor.GetMinimumHoldingTime(); } const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor() @@ -326,6 +334,11 @@ const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor() return mPanGestureProcessor; } +void GestureEventProcessor::SetTapMaximumAllowedTime(uint32_t time) +{ + mTapGestureProcessor.SetMaximumAllowedTime(time); +} + } // namespace Internal } // namespace Dali