extern int UtcDaliActorApplyConstraintAppliedCallback(void);
extern int UtcDaliActorRemoveConstraints(void);
extern int UtcDaliActorRemoveConstraint(void);
+extern int UtcDaliActorRemoveConstraintTag(void);
extern int UtcDaliActorTouchedSignal(void);
extern int UtcDaliActorSetSizeSignal(void);
extern int UtcDaliActorOnOffStageSignal(void);
{"UtcDaliActorApplyConstraintAppliedCallback", UtcDaliActorApplyConstraintAppliedCallback, utc_dali_actor_startup, utc_dali_actor_cleanup},
{"UtcDaliActorRemoveConstraints", UtcDaliActorRemoveConstraints, utc_dali_actor_startup, utc_dali_actor_cleanup},
{"UtcDaliActorRemoveConstraint", UtcDaliActorRemoveConstraint, utc_dali_actor_startup, utc_dali_actor_cleanup},
+ {"UtcDaliActorRemoveConstraintTag", UtcDaliActorRemoveConstraintTag, utc_dali_actor_startup, utc_dali_actor_cleanup},
{"UtcDaliActorTouchedSignal", UtcDaliActorTouchedSignal, utc_dali_actor_startup, utc_dali_actor_cleanup},
{"UtcDaliActorSetSizeSignal", UtcDaliActorSetSizeSignal, utc_dali_actor_startup, utc_dali_actor_cleanup},
{"UtcDaliActorOnOffStageSignal", UtcDaliActorOnOffStageSignal, utc_dali_actor_startup, utc_dali_actor_cleanup},
END_TEST;
}
+int UtcDaliActorRemoveConstraintTag(void)
+{
+ tet_infoline(" UtcDaliActorRemoveConstraintTag");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // 1. Apply Constraint1 and Constraint2, and test...
+ unsigned int result1 = 0u;
+ unsigned int result2 = 0u;
+
+ unsigned constraint1Tag = 1u;
+ Constraint constraint1 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result1, 1) );
+ constraint1.SetTag( constraint1Tag );
+ actor.ApplyConstraint( constraint1 );
+
+ unsigned constraint2Tag = 2u;
+ Constraint constraint2 = Constraint::New<Vector4>( Actor::COLOR, TestConstraintRef<Vector4>(result2, 2) );
+ constraint2.SetTag( constraint2Tag );
+ actor.ApplyConstraint( constraint2 );
+
+ Stage::GetCurrent().Add( actor );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
+
+ // 2. Remove Constraint1 and test...
+ result1 = 0;
+ result2 = 0;
+ actor.RemoveConstraints(constraint1Tag);
+ // make color property dirty, which will trigger constraints to be reapplied.
+ actor.SetColor( Color::WHITE );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
+ DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
+
+ // 3. Re-Apply Constraint1 and test...
+ result1 = 0;
+ result2 = 0;
+ actor.ApplyConstraint( constraint1 );
+ // make color property dirty, which will trigger constraints to be reapplied.
+ actor.SetColor( Color::WHITE );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION );
+
+ // 2. Remove Constraint2 and test...
+ result1 = 0;
+ result2 = 0;
+ actor.RemoveConstraints(constraint2Tag);
+ // make color property dirty, which will trigger constraints to be reapplied.
+ actor.SetColor( Color::WHITE );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
+
+ // 2. Remove Constraint1 as well and test...
+ result1 = 0;
+ result2 = 0;
+ actor.RemoveConstraints(constraint1Tag);
+ // make color property dirty, which will trigger constraints to be reapplied.
+ actor.SetColor( Color::WHITE );
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now.
+ DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now.
+ END_TEST;
+}
int UtcDaliActorTouchedSignal(void)
{
*/
RemoveAction GetRemoveAction() const;
+ /**
+ * @brief Set a tag for the constraint so it can be identified later
+ *
+ * @param[in] tag An integer to identify the constraint
+ */
+ void SetTag( const unsigned int tag );
+
+ /**
+ * @brief Get the tag
+ *
+ * @return The tag
+ */
+ unsigned int GetTag() const;
+
public: // Not intended for use by Application developers
/**
*/
void RemoveConstraints();
+ /**
+ * @brief Remove all the constraint from the Object with a matching tag.
+ *
+ * @pre The Object has been intialized.
+ * @param[in] tag The tag of the constraints which will be removed
+ */
+ void RemoveConstraints( unsigned int tag );
+
public:
mRemoveTime( 0.0f ),
mAlphaFunction( Dali::Constraint::DEFAULT_ALPHA_FUNCTION ),
mRemoveAction( Dali::Constraint::DEFAULT_REMOVE_ACTION ),
+ mTag(0),
mApplyAnimation(),
mRemoveAnimation()
{
return mRemoveAction;
}
+void ActiveConstraintBase::SetTag(const unsigned int tag)
+{
+ mTag = tag;
+}
+
+unsigned int ActiveConstraintBase::GetTag() const
+{
+ return mTag;
+}
+
+
bool ActiveConstraintBase::IsSceneObjectRemovable() const
{
return true; // The constraint removed when target SceneGraph::PropertyOwner is destroyed
RemoveAction GetRemoveAction() const;
/**
+ * @copydoc Dali::Constraint::SetTag()
+ */
+ void SetTag(const unsigned int tag);
+
+ /**
+ * @copydoc Dali::Constraint::GetTag()
+ */
+ unsigned int GetTag() const;
+
+
+
+ /**
* Connects a callback function with the object's signals.
* @param[in] object The object providing the signal.
* @param[in] tracker Used to disconnect the signal.
AlphaFunction mAlphaFunction;
RemoveAction mRemoveAction;
+ unsigned int mTag;
private:
Dali::Animation mApplyAnimation; ///< Used to automatically animate weight from 0.0f -> 1.0f
Dali::Animation mRemoveAnimation; ///< Used to automatically animate weight back to 0.0f
+
+
};
} // namespace Internal
clone->SetRemoveTime(mRemoveTime);
clone->SetAlphaFunction(mAlphaFunction);
clone->SetRemoveAction(mRemoveAction);
+ clone->SetTag( mTag );
return clone;
}
clone->SetRemoveTime(mRemoveTime);
clone->SetAlphaFunction(mAlphaFunction);
clone->SetRemoveAction(mRemoveAction);
+ clone->SetTag( mTag );
return clone;
}
return GetImplementation( mActiveConstraintTemplate ).GetRemoveAction();
}
+
+void Constraint::SetTag(unsigned int tag)
+{
+ GetImplementation( mActiveConstraintTemplate ).SetTag(tag);
+}
+
+unsigned int Constraint::GetTag() const
+{
+ return GetImplementation( mActiveConstraintTemplate ).GetTag();
+}
+
+
+
Constraint::~Constraint()
{
}
Dali::Constraint::RemoveAction GetRemoveAction() const;
/**
+ * @copydoc Dali::Constraint::SetTag()
+ */
+ void SetTag( const unsigned int tag);
+
+ /**
+ * @copydoc Dali::Constraint::GetTag()
+ */
+ unsigned int GetTag() const;
+
+
+
+
+ /**
* Create an active constraint.
* An active constraint is created each time the constraint is applied to an object.
* @return A newly allocated active-constraint.
return mTypeInfo;
}
-void ProxyObject::RemoveConstraint( Dali::ActiveConstraint activeConstraint )
+void ProxyObject::RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph )
{
- if( mConstraints )
+ if( isInScenegraph )
{
- // If we have nothing in the scene-graph, just remove the activeConstraint from container
- const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject();
- if ( NULL == propertyOwner )
+ ActiveConstraintBase& baseConstraint = GetImplementation( constraint );
+ baseConstraint.BeginRemove();
+ if ( baseConstraint.IsRemoving() )
{
- ActiveConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), activeConstraint ) );
- if( it != mConstraints->end() )
+ if( !mRemovedConstraints )
{
- mConstraints->erase( it );
+ mRemovedConstraints = new ActiveConstraintContainer;
}
- delete mRemovedConstraints;
- mRemovedConstraints = NULL;
- return;
+ // Wait for remove animation before destroying active-constraints
+ mRemovedConstraints->push_back( constraint );
}
+ }
+ else if( mRemovedConstraints )
+ {
+ delete mRemovedConstraints;
+ mRemovedConstraints = NULL;
+ }
+}
- // Discard constraints which are fully removed
- DeleteRemovedConstraints();
- ActiveConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), activeConstraint ) );
- if( it != mConstraints->end() )
+void ProxyObject::RemoveConstraint( Dali::ActiveConstraint activeConstraint )
+{
+ if( mConstraints )
+ {
+ bool isInSceneGraph( NULL != GetSceneObject() );
+ if( isInSceneGraph )
{
- ActiveConstraintBase& constraint = GetImplementation( *it );
+ DeleteRemovedConstraints();
+ }
- constraint.BeginRemove();
+ ActiveConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), activeConstraint ) );
+ if( it != mConstraints->end() )
+ {
+ RemoveConstraint( *it, isInSceneGraph );
mConstraints->erase( it );
+ }
+ }
+
+}
+
- if ( constraint.IsRemoving() )
+
+void ProxyObject::RemoveConstraints( unsigned int tag )
+{
+ if( mConstraints )
+ {
+ bool isInSceneGraph( NULL != GetSceneObject() );
+ if( isInSceneGraph )
+ {
+ DeleteRemovedConstraints();
+ }
+
+ ActiveConstraintIter iter( mConstraints->begin() );
+ while(iter != mConstraints->end() )
+ {
+ ActiveConstraintBase& constraint = GetImplementation( *iter );
+ if( constraint.GetTag() == tag )
{
- if( !mRemovedConstraints )
- {
- mRemovedConstraints = new ActiveConstraintContainer;
- }
- // Wait for remove animation before destroying active-constraints
- mRemovedConstraints->push_back( *it );
+ RemoveConstraint( *iter, isInSceneGraph );
+ iter = mConstraints->erase( iter );
+ }
+ else
+ {
+ ++iter;
}
}
}
const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject();
if ( NULL == propertyOwner )
{
- delete mConstraints;
- mConstraints = NULL;
delete mRemovedConstraints;
mRemovedConstraints = NULL;
- return;
}
-
- // Discard constraints which are fully removed
- DeleteRemovedConstraints();
-
- const ActiveConstraintConstIter endIter = mConstraints->end();
- for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
+ else
{
- ActiveConstraintBase& constraint = GetImplementation( *iter );
+ // Discard constraints which are fully removed
+ DeleteRemovedConstraints();
- constraint.BeginRemove();
-
- if ( constraint.IsRemoving() )
+ const ActiveConstraintConstIter endIter = mConstraints->end();
+ for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
{
- if( !mRemovedConstraints )
- {
- mRemovedConstraints = new ActiveConstraintContainer;
- }
- // Wait for remove animation before destroying active-constraints
- mRemovedConstraints->push_back( *iter );
+ RemoveConstraint( *iter, true );
}
}
}
}
+
+
ProxyObject::~ProxyObject()
{
// Notification for observers
*/
void RemoveConstraints();
+ /**
+ * Remove all constraints from a ProxyObject with a matching tag
+ */
+ void RemoveConstraints( unsigned int tag );
+
protected:
/**
*/
void DeleteRemovedConstraints();
+ /**
+ * Helper to remove active constraints
+ */
+ void RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph );
+
+
private: // Default property extensions for derived classes
/**
return GetImplementation(*this).GetRemoveAction();
}
+void Constraint::SetTag( const unsigned int tag )
+{
+ GetImplementation(*this).SetTag( tag );
+}
+
+unsigned int Constraint::GetTag() const
+{
+ return GetImplementation(*this).GetTag();
+}
+
+
+
+
+
Constraint Constraint::New( Property::Index target,
Property::Type targetType,
AnyFunction func,
GetImplementation(*this).RemoveConstraints();
}
+void Constrainable::RemoveConstraints( unsigned int tag )
+{
+ GetImplementation(*this).RemoveConstraints( tag );
+}
+
+
+
} // Dali