// 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>
#include <dali/public-api/math/degree.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/common/property-index-ranges.h>
+#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/events/gesture-event-processor.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
namespace Dali
{
-const Property::Index PanGestureDetector::SCREEN_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
-const Property::Index PanGestureDetector::SCREEN_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index PanGestureDetector::SCREEN_VELOCITY = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index PanGestureDetector::LOCAL_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3;
-const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 4;
-const Property::Index PanGestureDetector::LOCAL_VELOCITY = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 5;
-const Property::Index PanGestureDetector::PANNING = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 6;
-
namespace Internal
{
// Properties
-PropertyDetails DEFAULT_PROPERTIES[] =
-{
- { "screen-position", Property::VECTOR2, false, false, true },
- { "screen-displacement", Property::VECTOR2, false, false, true },
- { "screen-velocity", Property::VECTOR2, false, false, true },
- { "local-position", Property::VECTOR2, false, false, true },
- { "local-displacement", Property::VECTOR2, false, false, true },
- { "local-velocity", Property::VECTOR2, false, false, true },
- { "panning", Property::BOOLEAN, false, false, true },
-};
-const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTIES ) / sizeof( DEFAULT_PROPERTIES[0] );
+// Name Type writable animatable constraint-input enum for index-checking
+DALI_PROPERTY_TABLE_BEGIN
+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()
{
#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
/**
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 );
AddAngle( direction, threshold );
}
-const PanGestureDetector::AngleContainer& PanGestureDetector::GetAngles() const
+size_t PanGestureDetector::GetAngleCount() const
+{
+ return mAngleContainer.size();
+}
+
+PanGestureDetector::AngleThresholdPair PanGestureDetector::GetAngle(size_t index) const
{
- return mAngleContainer;
+ PanGestureDetector::AngleThresholdPair ret( Radian(0),Radian(0) );
+
+ if( index < mAngleContainer.size() )
+ {
+ ret = mAngleContainer[index];
+ }
+
+ return ret;
}
+
void PanGestureDetector::ClearAngles()
{
mAngleContainer.clear();
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 )
void PanGestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
{
- indices.reserve( DEFAULT_PROPERTY_COUNT );
+ indices.Reserve( DEFAULT_PROPERTY_COUNT );
- int index = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_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 );
}
}
const char* PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const
{
- index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
+ index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX;
if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- return DEFAULT_PROPERTIES[ index ].name;
- }
- else
- {
- return NULL;
+ return DEFAULT_PROPERTY_DETAILS[ index ].name;
}
+
+ return NULL;
}
Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& name) const
// Look for name in default properties
for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
{
- const Internal::PropertyDetails* property = &DEFAULT_PROPERTIES[ i ];
+ 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;
}
}
bool PanGestureDetector::IsDefaultPropertyWritable(Property::Index index) const
{
// None of our properties should be writable through the Public API
- return false;
+ return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].writable;
}
bool PanGestureDetector::IsDefaultPropertyAnimatable(Property::Index index) const
{
// None of our properties are animatable
- return false;
+ return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].animatable;
}
bool PanGestureDetector::IsDefaultPropertyAConstraintInput( Property::Index index ) const
{
// All our properties can be used as an input to a constraint.
- return true;
+ return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].constraintInput;
}
Property::Type PanGestureDetector::GetDefaultPropertyType(Property::Index index) const
{
- index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
+ index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX;
if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- return DEFAULT_PROPERTIES[ index ].type;
+ return DEFAULT_PROPERTY_DETAILS[ index ].type;
}
else
{
switch ( index )
{
- case Dali::PanGestureDetector::SCREEN_POSITION:
+ case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::SCREEN_DISPLACEMENT:
+ case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::SCREEN_VELOCITY:
+ case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::LOCAL_POSITION:
+ case Dali::PanGestureDetector::Property::LOCAL_POSITION:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::LOCAL_DISPLACEMENT:
+ case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::LOCAL_VELOCITY:
+ case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
{
if(mSceneObject)
{
break;
}
- case Dali::PanGestureDetector::PANNING:
+ case Dali::PanGestureDetector::Property::PANNING:
{
if(mSceneObject)
{
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();
}
{
switch ( index )
{
- case Dali::PanGestureDetector::SCREEN_POSITION:
+ case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
property = &mSceneObject->GetScreenPositionProperty();
break;
}
- case Dali::PanGestureDetector::SCREEN_DISPLACEMENT:
+ case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
{
property = &mSceneObject->GetScreenDisplacementProperty();
break;
}
- case Dali::PanGestureDetector::SCREEN_VELOCITY:
+ case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
{
property = &mSceneObject->GetScreenVelocityProperty();
break;
}
- case Dali::PanGestureDetector::LOCAL_POSITION:
+ case Dali::PanGestureDetector::Property::LOCAL_POSITION:
{
property = &mSceneObject->GetLocalPositionProperty();
break;
}
- case Dali::PanGestureDetector::LOCAL_DISPLACEMENT:
+ case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
{
property = &mSceneObject->GetLocalDisplacementProperty();
break;
}
- case Dali::PanGestureDetector::LOCAL_VELOCITY:
+ case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
{
property = &mSceneObject->GetLocalVelocityProperty();
break;
}
- case Dali::PanGestureDetector::PANNING:
+ case Dali::PanGestureDetector::Property::PANNING:
{
property = &mSceneObject->GetPanningProperty();
break;