Added a Max Core Property Index so that a range can be defined in toolkit
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pan-gesture-detector-impl.cpp
index f1ab255..c819a82 100644 (file)
@@ -18,6 +18,9 @@
 // CLASS HEADER
 #include <dali/internal/event/events/pan-gesture-detector-impl.h>
 
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+
 // INTERNAL INCLUDES
 #include <dali/public-api/events/pan-gesture.h>
 #include <dali/public-api/object/type-registry.h>
@@ -43,18 +46,18 @@ namespace
 
 //              Name                  Type   writable animatable constraint-input  enum for index-checking
 DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "screen-position",     VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::ScreenPosition     )
-DALI_PROPERTY( "screen-displacement", VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::ScreenDisplacement )
-DALI_PROPERTY( "screen-velocity",     VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::ScreenVelocity     )
-DALI_PROPERTY( "local-position",      VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LocalPosition      )
-DALI_PROPERTY( "local-displacement",  VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LocalDisplacement  )
-DALI_PROPERTY( "local-velocity",      VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LocalVelocity      )
-DALI_PROPERTY( "panning",             BOOLEAN, false, false, true,   Dali::PanGestureDetector::Property::Panning            )
+DALI_PROPERTY( "screenPosition",      VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::SCREEN_POSITION     )
+DALI_PROPERTY( "screenDisplacement",  VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT )
+DALI_PROPERTY( "screenVelocity",      VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::SCREEN_VELOCITY     )
+DALI_PROPERTY( "localPosition",       VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LOCAL_POSITION      )
+DALI_PROPERTY( "localDisplacement",   VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT  )
+DALI_PROPERTY( "localVelocity",       VECTOR2, false, false, true,   Dali::PanGestureDetector::Property::LOCAL_VELOCITY      )
+DALI_PROPERTY( "panning",             BOOLEAN, false, false, true,   Dali::PanGestureDetector::Property::PANNING             )
 DALI_PROPERTY_TABLE_END( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX )
 
 // Signals
 
-const char* const SIGNAL_PAN_DETECTED = "pan-detected";
+const char* const SIGNAL_PAN_DETECTED = "panDetected";
 
 BaseHandle Create()
 {
@@ -67,15 +70,6 @@ SignalConnectorType signalConnector1( mType, SIGNAL_PAN_DETECTED, &PanGestureDet
 
 #if defined(DEBUG_ENABLED)
 Integration::Log::Filter* gLogFilter  = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_PAN_GESTURE_DETECTOR");
-
-/**
- * When debugging, helper for converting radians to degrees.
- */
-inline float RadiansToDegrees( float radian )
-{
-  return radian * 180.0f / Math::PI;
-}
-
 #endif
 
 /**
@@ -177,7 +171,7 @@ void PanGestureDetector::AddAngle( Radian angle, Radian threshold )
 
   angle = WrapInDomain( angle, -Math::PI, Math::PI );
 
-  DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", RadiansToDegrees(angle), RadiansToDegrees(threshold) );
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", Degree(angle), Degree(threshold) );
 
   AngleThresholdPair pair( angle, threshold );
   mAngleContainer.push_back( pair );
@@ -193,11 +187,24 @@ void PanGestureDetector::AddDirection( Radian direction, Radian threshold )
   AddAngle( direction, threshold );
 }
 
-const PanGestureDetector::AngleContainer& PanGestureDetector::GetAngles() const
+size_t PanGestureDetector::GetAngleCount() const
 {
-  return mAngleContainer;
+  return mAngleContainer.size();
 }
 
+PanGestureDetector::AngleThresholdPair PanGestureDetector::GetAngle(size_t index) const
+{
+  PanGestureDetector::AngleThresholdPair ret( Radian(0),Radian(0) );
+
+  if( index < mAngleContainer.size() )
+  {
+    ret = mAngleContainer[index];
+  }
+
+  return ret;
+}
+
+
 void PanGestureDetector::ClearAngles()
 {
   mAngleContainer.clear();
@@ -249,7 +256,7 @@ bool PanGestureDetector::CheckAngleAllowed( Radian angle ) const
 
       DALI_LOG_INFO( gLogFilter, Debug::General,
                      "AngleToCheck: %.2f, CompareWith: %.2f, Threshold: %.2f\n",
-                     RadiansToDegrees(angle), RadiansToDegrees(angleAllowed), RadiansToDegrees(threshold) );
+                     Degree(angle), Degree(angleAllowed), Degree(threshold) );
 
       float relativeAngle( fabsf( WrapInDomain( angle - angleAllowed, -Math::PI, Math::PI ) ) );
       if ( relativeAngle <= threshold )
@@ -326,12 +333,12 @@ unsigned int PanGestureDetector::GetDefaultPropertyCount() const
 
 void PanGestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
 {
-  indices.reserve( DEFAULT_PROPERTY_COUNT );
+  indices.Reserve( DEFAULT_PROPERTY_COUNT );
 
   int index = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX;
   for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
   {
-    indices.push_back( index );
+    indices.PushBack( index );
   }
 }
 
@@ -356,7 +363,7 @@ Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& n
     const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
     if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
     {
-      index = i;
+      index = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX + i;
       break;
     }
   }
@@ -406,7 +413,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
 
   switch ( index )
   {
-    case Dali::PanGestureDetector::Property::ScreenPosition:
+    case Dali::PanGestureDetector::Property::SCREEN_POSITION:
     {
       if(mSceneObject)
       {
@@ -419,7 +426,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::ScreenDisplacement:
+    case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
     {
       if(mSceneObject)
       {
@@ -432,7 +439,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::ScreenVelocity:
+    case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
     {
       if(mSceneObject)
       {
@@ -445,7 +452,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::LocalPosition:
+    case Dali::PanGestureDetector::Property::LOCAL_POSITION:
     {
       if(mSceneObject)
       {
@@ -458,7 +465,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::LocalDisplacement:
+    case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
     {
       if(mSceneObject)
       {
@@ -471,7 +478,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::LocalVelocity:
+    case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
     {
       if(mSceneObject)
       {
@@ -484,7 +491,7 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co
       break;
     }
 
-    case Dali::PanGestureDetector::Property::Panning:
+    case Dali::PanGestureDetector::Property::PANNING:
     {
       if(mSceneObject)
       {
@@ -531,9 +538,10 @@ const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Proper
     return property;
   }
 
-  if ( index >= DEFAULT_PROPERTY_MAX_COUNT )
+  if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && // Child properties are also stored as custom properties
+       ( index <= PROPERTY_CUSTOM_MAX_INDEX ) )
   {
-    CustomProperty* custom = FindCustomProperty( index );
+    CustomPropertyMetadata* custom = FindCustomProperty( index );
     DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
     property = custom->GetSceneGraphProperty();
   }
@@ -541,43 +549,43 @@ const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Proper
   {
     switch ( index )
     {
-      case Dali::PanGestureDetector::Property::ScreenPosition:
+      case Dali::PanGestureDetector::Property::SCREEN_POSITION:
       {
         property = &mSceneObject->GetScreenPositionProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::ScreenDisplacement:
+      case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
       {
         property = &mSceneObject->GetScreenDisplacementProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::ScreenVelocity:
+      case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
       {
         property = &mSceneObject->GetScreenVelocityProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::LocalPosition:
+      case Dali::PanGestureDetector::Property::LOCAL_POSITION:
       {
         property = &mSceneObject->GetLocalPositionProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::LocalDisplacement:
+      case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
       {
         property = &mSceneObject->GetLocalDisplacementProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::LocalVelocity:
+      case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
       {
         property = &mSceneObject->GetLocalVelocityProperty();
         break;
       }
 
-      case Dali::PanGestureDetector::Property::Panning:
+      case Dali::PanGestureDetector::Property::PANNING:
       {
         property = &mSceneObject->GetPanningProperty();
         break;