-//
-// 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) 2014 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 <dali/internal/event/events/pan-gesture-detector-impl.h>
#include <dali/public-api/math/radian.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/thread-local-storage.h>
#include <dali/internal/event/events/gesture-event-processor.h>
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::LOCAL_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3;
+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
-const std::string DEFAULT_PROPERTY_NAMES[] =
+PropertyDetails DEFAULT_PROPERTIES[] =
{
- "screen-position",
- "screen-displacement",
- "local-position",
- "local-displacement",
-};
-const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string );
-
-const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] =
-{
- Property::VECTOR2, // SCREEN_POSITION
- Property::VECTOR2, // SCREEN_DISPLACEMENT
- Property::VECTOR2, // LOCAL_POSITION
- Property::VECTOR2, // LOCAL_DISPLACEMENT
+ { "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] );
BaseHandle Create()
{
} // unnamed namespace
-PanGestureDetector::DefaultPropertyLookup* PanGestureDetector::mDefaultPropertyLookup = NULL;
-
PanGestureDetectorPtr PanGestureDetector::New()
{
return new PanGestureDetector;
mMaximumTouches(1),
mSceneObject(NULL)
{
- if( !mDefaultPropertyLookup )
- {
- mDefaultPropertyLookup = new DefaultPropertyLookup();
- const int start = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
- for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
- {
- ( *mDefaultPropertyLookup )[ DEFAULT_PROPERTY_NAMES[i] ] = i + start;
- }
- }
}
PanGestureDetector::~PanGestureDetector()
// Do nothing
}
-bool PanGestureDetector::IsSceneObjectRemovable() const
-{
- return false;
-}
-
unsigned int PanGestureDetector::GetDefaultPropertyCount() const
{
return DEFAULT_PROPERTY_COUNT;
}
}
-const std::string& PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const
+const char* PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const
{
index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- return DEFAULT_PROPERTY_NAMES[ index ];
+ return DEFAULT_PROPERTIES[ index ].name;
}
else
{
- // Index out-of-range... return empty string.
- static const std::string INVALID_PROPERTY_NAME;
- return INVALID_PROPERTY_NAME;
+ return NULL;
}
}
{
Property::Index index = Property::INVALID_INDEX;
- DALI_ASSERT_DEBUG( NULL != mDefaultPropertyLookup );
-
// Look for name in default properties
- DefaultPropertyLookup::const_iterator result = mDefaultPropertyLookup->find( name );
- if ( mDefaultPropertyLookup->end() != result )
+ for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
{
- index = result->second;
+ const Internal::PropertyDetails* property = &DEFAULT_PROPERTIES[ i ];
+ if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
+ {
+ index = i;
+ break;
+ }
}
-
return index;
}
index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- return DEFAULT_PROPERTY_TYPES[ index ];
+ return DEFAULT_PROPERTIES[ index ].type;
}
else
{
// None of our properties should be settable from Public API
}
-void PanGestureDetector::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
-{
- // None of our properties should be settable from Public API
-}
-
Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
break;
}
+ case Dali::PanGestureDetector::SCREEN_VELOCITY:
+ {
+ if(mSceneObject)
+ {
+ value = mSceneObject->GetScreenVelocityProperty().Get();
+ }
+ else
+ {
+ value = Vector2();
+ }
+ break;
+ }
+
case Dali::PanGestureDetector::LOCAL_POSITION:
{
if(mSceneObject)
break;
}
+ case Dali::PanGestureDetector::LOCAL_VELOCITY:
+ {
+ if(mSceneObject)
+ {
+ value = mSceneObject->GetLocalVelocityProperty().Get();
+ }
+ else
+ {
+ value = Vector2();
+ }
+ break;
+ }
+
+ case Dali::PanGestureDetector::PANNING:
+ {
+ if(mSceneObject)
+ {
+ value = mSceneObject->GetPanningProperty().Get();
+ }
+ else
+ {
+ value = false;
+ }
+ break;
+ }
+
default:
{
DALI_ASSERT_ALWAYS(false && "PanGestureDetector Property index invalid" ); // should not come here
return value;
}
-void PanGestureDetector::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- // We do not want the user to install custom properties
- DALI_ASSERT_ALWAYS(false && "PanGestureDetector does not allow custom properties" );
-}
-
const SceneGraph::PropertyOwner* PanGestureDetector::GetSceneObject() const
{
// This method should only return an object connected to the scene-graph
if ( index >= DEFAULT_PROPERTY_MAX_COUNT )
{
- CustomPropertyLookup::const_iterator entry = GetCustomPropertyLookup().find( index );
-
- DALI_ASSERT_ALWAYS( GetCustomPropertyLookup().end() != entry && "property index is invalid" );
-
- property = entry->second.GetSceneGraphProperty();
+ CustomProperty* custom = FindCustomProperty( index );
+ DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
+ property = custom->GetSceneGraphProperty();
}
else
{
break;
}
+ case Dali::PanGestureDetector::SCREEN_VELOCITY:
+ {
+ property = &mSceneObject->GetScreenVelocityProperty();
+ break;
+ }
+
case Dali::PanGestureDetector::LOCAL_POSITION:
{
property = &mSceneObject->GetLocalPositionProperty();
break;
}
+ case Dali::PanGestureDetector::LOCAL_VELOCITY:
+ {
+ property = &mSceneObject->GetLocalVelocityProperty();
+ break;
+ }
+
+ case Dali::PanGestureDetector::PANNING:
+ {
+ property = &mSceneObject->GetPanningProperty();
+ break;
+ }
+
default:
break;
}