END_TEST;
}
-int UtcDaliActorInsert(void)
-{
- tet_infoline("Testing Actor::Insert");
- TestApplication application;
-
- Actor parent = Actor::New();
- Stage::GetCurrent().Add( parent );
- Actor first = Actor::New();
- Actor second = Actor::New();
- Actor third = Actor::New();
-
- parent.Insert(1, first); // test insert beyond range
- DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION );
- parent.Insert(0, second);
- DALI_TEST_EQUALS( parent.GetChildCount(), 2u, TEST_LOCATION );
- parent.Insert(1, third);
-
- DALI_TEST_EQUALS( parent.GetChildCount(), 3u, TEST_LOCATION );
-
- DALI_TEST_CHECK(parent.GetChildAt(0) == second);
- DALI_TEST_CHECK(parent.GetChildAt(1) == third);
- DALI_TEST_CHECK(parent.GetChildAt(2) == first);
-
- END_TEST;
-}
-
-
int UtcDaliActorRemoveN(void)
{
tet_infoline("Testing Actor::Remove");
}
}
-void Actor::Insert( unsigned int index, Actor& child )
-{
- DALI_ASSERT_ALWAYS( this != &child && "Cannot add actor to itself" );
- DALI_ASSERT_ALWAYS( !child.IsRoot() && "Cannot add root actor" );
-
- if( !mChildren )
- {
- mChildren = new ActorContainer;
- }
-
- Actor* const oldParent( child.mParent );
-
- // since an explicit position has been given, always insert, even if already a child
- if( oldParent )
- {
- oldParent->Remove( child ); // This causes OnChildRemove callback
-
- // Old parent may need to readjust to missing child
- if( oldParent->RelayoutDependentOnChildren() )
- {
- oldParent->RelayoutRequest();
- }
- }
-
- // Guard against Add() during previous OnChildRemove callback
- if( !child.mParent )
- {
- // Do this first, since user callbacks from within SetParent() may need to remove child
- if( index < GetChildCount() )
- {
- ActorIter it = mChildren->begin();
- std::advance( it, index );
- mChildren->insert( it, ActorPtr( &child ) );
- }
- else
- {
- mChildren->push_back( ActorPtr( &child ) );
- }
- // SetParent asserts that child can be added
- child.SetParent( this, index );
-
- // Notification for derived classes
- OnChildAdd( child );
-
- // Only put in a relayout request if there is a suitable dependency
- if( RelayoutDependentOnChildren() )
- {
- RelayoutRequest();
- }
-
- if( child.RelayoutDependentOnParent() )
- {
- child.RelayoutRequest();
- }
- }
-}
-
void Actor::Remove( Actor& child )
{
if( (this == &child) || (!mChildren) )
void Add( Actor& child );
/**
- * Inserts a child Actor to this Actor's child list
- * @pre The child actor is not the same as the parent actor.
- * @pre The child actor does not already have a parent.
- * @param [in] index in childlist to insert child at
- * @param [in] child The child.
- * @post The child will be referenced by its parent.
- */
- void Insert( unsigned int index, Actor& child );
-
- /**
* Removes a child Actor from this Actor.
* @param [in] child The child.
* @post The child will be unreferenced.
GetImplementation(*this).Add(GetImplementation(actor));
}
-void Actor::Insert(unsigned int index, Actor actor)
-{
- GetImplementation(*this).Insert(index, GetImplementation(actor));
-}
-
void Actor::Remove(Actor actor)
{
GetImplementation(*this).Remove(GetImplementation(actor));
void Add(Actor child);
/**
- * @brief Inserts a child Actor to this actor's list of children at the given index
- *
- * NOTE! if the child already has a parent, it will be removed from old parent
- * and reparented to this actor. This may change childs position, color,
- * scale etc as it now inherits them from this actor
- * @pre This Actor (the parent) has been initialized.
- * @pre The child actor has been initialized.
- * @pre The child actor is not the same as the parent actor.
- * @pre The actor is not the Root actor
- * @param [in] index of actor to insert before
- * @param [in] child The child.
- * @post The child will be referenced by its parent. This means that the child will be kept alive,
- * even if the handle passed into this method is reset or destroyed.
- * @post If the index is greater than the current child count, it will be ignored and added at the end.
- */
- void Insert(unsigned int index, Actor child);
-
- /**
* @brief Removes a child Actor from this Actor.
*
* If the actor was not a child of this actor, this is a no-op.