#define __DALI_INTERNAL_ACTIVE_CONSTRAINT_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/property-owner-messages.h>
+#include <dali/internal/update/common/property-resetter.h>
#include <dali/internal/update/animation/scene-graph-constraint.h>
#include <dali/internal/update/animation/property-accessor.h>
#include <dali/internal/update/animation/property-component-accessor.h>
+#include <memory>
namespace Dali
{
Constraint& operator=( const Constraint& rhs );
/**
- * Create and connect a constraint for a scene-object.
+ * Create and connect a constraint and property resetter for a scene-graph property
*/
void ConnectConstraint()
{
- // Should not come here if target-object has been destroyed
+ // Should not come here if target object has been destroyed
DALI_ASSERT_DEBUG( NULL != mTargetObject );
// Guard against double connections
if ( func )
{
- // Create the SceneGraphConstraint, and connect to the scene-graph
+ // Create the SceneGraphConstraint and PropertyResetter, and connect them to the scene-graph
const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetIndex );
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
// The targetProperty should exist, when targetObject exists
DALI_ASSERT_ALWAYS( NULL != targetProperty && "Constraint target property does not exist" );
if( targetProperty->IsTransformManagerProperty() ) //It is a property managed by the transform manager
{
// Connect the constraint
- mSceneGraphConstraint = SceneGraph::Constraint<PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
+ mSceneGraphConstraint =
+ SceneGraph::Constraint<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction );
+ // Don't create a resetter for transform manager property, it's less efficient
}
else //SceneGraph property
{
propertyOwners,
func,
mRemoveAction );
+ // Connect the resetter
+ resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+
}
OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
+
+ if( resetter != nullptr )
+ {
+ AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+ }
}
}
// Create the SceneGraphConstraint, and connect to the scene-graph
const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetIndex );
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
// The targetProperty should exist, when targetObject exists
DALI_ASSERT_ALWAYS( NULL != targetProperty && "Constraint target property does not exist" );
typedef SceneGraph::Constraint< float, PropertyAccessor<float> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
}
else
{
typedef SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector2> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
}
+ if( mSceneGraphConstraint )
+ {
+ resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ }
}
else if ( PropertyTypes::Get< Vector3 >() == targetProperty->GetType() )
{
typedef SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,2> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
}
+ // Do not create a resetter for transform manager property
}
else
{
typedef SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector3> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
}
+ if( mSceneGraphConstraint )
+ {
+ resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ }
}
}
else if ( PropertyTypes::Get< Vector4 >() == targetProperty->GetType() )
typedef SceneGraph::Constraint< float, PropertyComponentAccessorW<Vector4> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
}
+
+ if( mSceneGraphConstraint )
+ {
+ resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ }
}
}
OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
}
+ if( resetter != nullptr )
+ {
+ AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+ }
}
}