END_TEST;
}
+int UtcDaliActorGetCurrentSizeImmediate(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 vector(100.0f, 100.0f, 20.0f);
+
+ DALI_TEST_CHECK(vector != actor.GetSize());
+ DALI_TEST_CHECK(vector != actor.GetCurrentSize());
+
+ actor.SetSize(vector);
+
+ DALI_TEST_CHECK(vector == actor.GetSize());
+ DALI_TEST_CHECK(vector != actor.GetCurrentSize());
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(vector == actor.GetSize());
+ DALI_TEST_CHECK(vector == actor.GetCurrentSize());
+
+ // Animation
+ // Build the animation
+ const float durationSeconds = 2.0f;
+ Animation animation = Animation::New( durationSeconds );
+ const Vector3 targetValue( 10.0f, 20.0f, 30.0f );
+ animation.AnimateTo( Property( actor, Actor::SIZE ), targetValue );
+
+ DALI_TEST_CHECK( actor.GetSize() == targetValue );
+
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( static_cast<unsigned int>( durationSeconds * 1000.0f ) );
+
+ DALI_TEST_CHECK( actor.GetSize() == targetValue );
+
+ END_TEST;
+}
+
// SetPosition(float x, float y)
int UtcDaliActorSetPosition01(void)
{
ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint );
activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 );
+ // Check event-side size
+ DALI_TEST_EQUALS( child1.GetSize(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( child2.GetSize(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( child3.GetSize(), Vector3::ZERO, TEST_LOCATION );
+
DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
+
DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20%
DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10%
DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0%
{
if( NULL != mNode )
{
+ mSize = size;
+
// mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, &mNode->mSize, &AnimatableProperty<Vector3>::Bake, size );
+ SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, &mNode->mSize, &AnimatableProperty<Vector3>::Bake, mSize );
// Notification for derived classes
- OnSizeSet(size);
+ OnSizeSet( mSize );
// Emit signal for application developer
if( !mSetSizeSignalV2.Empty() )
{
Dali::Actor handle( this );
- mSetSizeSignalV2.Emit( handle, size );
+ mSetSizeSignalV2.Emit( handle, mSize );
}
}
}
+void Actor::NotifySizeAnimation(Animation& animation, const Vector3& targetSize)
+{
+ mSize = targetSize;
+
+ // Notify deriving classes
+ OnSizeAnimation( animation, targetSize );
+}
+
void Actor::SetWidth( float width )
{
if( NULL != mNode )
}
}
+const Vector3& Actor::GetSize() const
+{
+ return mSize;
+}
+
const Vector3& Actor::GetCurrentSize() const
{
if( NULL != mNode )
#endif
mGestureData( NULL ),
mAttachment(),
+ mSize( 0.0f, 0.0f, 0.0f ),
mName(),
mId( ++mActorCounter ), // actor ID is initialised to start from 1, and 0 is reserved
mIsRoot( ROOT_LAYER == derivedType ),
void SetDepth( float depth );
/**
- * Retrieve the Actor's size.
+ * Retrieve the Actor's size from event side.
+ * This size will be the size set or if animating then the target size.
+ * @return The Actor's size.
+ */
+ const Vector3& GetSize() const;
+
+ /**
+ * Retrieve the Actor's size from update side.
+ * This size will be the size set or animating but will be a frame behind.
* @return The Actor's size.
*/
const Vector3& GetCurrentSize() const;
public: // For Animation
/**
+ * This should only be called by Animation, when the actor is resized using Animation::Resize().
+ *
+ * @param[in] animation The animation that resized the actor
+ * @param[in] targetSize The new target size of the actor
+ */
+ void NotifySizeAnimation(Animation& animation, const Vector3& targetSize);
+
+ /**
* For use in derived classes.
* This should only be called by Animation, when the actor is resized using Animation::Resize().
*/
Dali::Actor::OnStageSignalV2 mOnStageSignalV2;
Dali::Actor::OffStageSignalV2 mOffStageSignalV2;
+ Vector3 mSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
+
std::string mName; ///< Name of the actor
unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
if ( maybeActor )
{
// Notify the actor that its size is being animated
- maybeActor->OnSizeAnimation( *this, destinationValue.Get<Vector3>() );
+ maybeActor->NotifySizeAnimation( *this, destinationValue.Get<Vector3>() );
}
}
ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
- // notify the actor impl that its size is being animated
- actor.OnSizeAnimation( *this, targetSize );
+ // Notify the actor impl that its size is being animated
+ actor.NotifySizeAnimation( *this, targetSize );
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SIZE,
{
ExtendDuration( TimePeriod(delaySeconds, durationSeconds) );
- // notify the actor impl that its size is being animated
- actor.OnSizeAnimation( *this, size );
+ // Notify the actor impl that its size is being animated
+ actor.NotifySizeAnimation( *this, size );
AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
Dali::Actor::SIZE,
GetImplementation(*this).SetSize(size);
}
+Vector3 Actor::GetSize() const
+{
+ return GetImplementation(*this).GetSize();
+}
+
Vector3 Actor::GetCurrentSize() const
{
return GetImplementation(*this).GetCurrentSize();
* @brief Retrieve the actor's size.
*
* @pre The actor has been initialized.
+ * @note This return is the value that was set using SetSize or the target size of an animation
+ * @return The actor's current size.
+ */
+ Vector3 GetSize() const;
+
+ /**
+ * @brief Retrieve the actor's size.
+ *
+ * @pre The actor has been initialized.
* @note This property can be animated; the return value may not match the value written with SetSize().
* @return The actor's current size.
*/