Remove Constraints from Cluster,ToolBar,View & ImageView 49/34949/3
authorXiangyin Ma <x1.ma@samsung.com>
Wed, 4 Feb 2015 18:37:06 +0000 (18:37 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Thu, 5 Feb 2015 16:23:46 +0000 (08:23 -0800)
Change-Id: I1225da0795796717dc750a5ff5a91f96225e3a72

12 files changed:
optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp
optional/dali-toolkit/internal/controls/cluster/cluster-impl.h
optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.cpp
optional/dali-toolkit/internal/controls/cluster/cluster-style-impl.h
optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp
optional/dali-toolkit/internal/controls/image-view/image-view-impl.h
optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp
optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h
optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp
optional/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.h
optional/dali-toolkit/internal/controls/view/view-impl.cpp
optional/dali-toolkit/internal/controls/view/view-impl.h

index fa9ee42..d94a94b 100644 (file)
@@ -26,6 +26,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
+#include <dali-toolkit/internal/controls/cluster/cluster-style-impl.h>
 
 using namespace Dali;
 
 
 using namespace Dali;
 
@@ -92,6 +93,27 @@ void Cluster::OnInitialize()
 {
 }
 
 {
 }
 
+void Cluster::OnControlSizeSet( const Vector3& targetSize )
+{
+  mClusterSize = targetSize;
+  GetImpl(mClusterStyle).SetClusterSize(targetSize);
+
+  for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter)
+  {
+
+    if((*iter).mActor)
+    {
+      mClusterStyle.ApplyStyle( (*iter).mActor,
+                                (*iter).mPositionIndex,
+                                AlphaFunctions::EaseOut,
+                                0.f );
+    }
+  }
+
+  UpdateBackground(0.f);
+  UpdateTitle(0.f);
+}
+
 Cluster::~Cluster()
 {
 }
 Cluster::~Cluster()
 {
 }
@@ -389,6 +411,7 @@ void Cluster::SetStyle(Toolkit::ClusterStyle style)
 {
   unsigned int previousChildrenNum = mChildren.size();
   mClusterStyle = style;
 {
   unsigned int previousChildrenNum = mChildren.size();
   mClusterStyle = style;
+  GetImpl(mClusterStyle).SetClusterSize(mClusterSize);
   unsigned int newChildrenNum = mClusterStyle.GetMaximumNumberOfChildren();
 
   // New style supports less children (remove those that no longer belong)
   unsigned int newChildrenNum = mClusterStyle.GetMaximumNumberOfChildren();
 
   // New style supports less children (remove those that no longer belong)
@@ -406,14 +429,12 @@ void Cluster::SetStyle(Toolkit::ClusterStyle style)
     mChildren.erase( removeStart, mChildren.end() );
   }
 
     mChildren.erase( removeStart, mChildren.end() );
   }
 
-  // Remove constraints from previous style, and apply new style's constraints.
   for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter)
   {
 
     if((*iter).mActor)
     {
   for(ChildInfoIter iter = mChildren.begin(); iter != mChildren.end(); ++iter)
   {
 
     if((*iter).mActor)
     {
-      (*iter).mActor.RemoveConstraints();
-      style.ApplyStyle( (*iter).mActor,
+      mClusterStyle.ApplyStyle( (*iter).mActor,
                         (*iter).mPositionIndex,
                         AlphaFunctions::EaseOut,
                         CLUSTER_STYLE_CONSTRAINT_DURATION );
                         (*iter).mPositionIndex,
                         AlphaFunctions::EaseOut,
                         CLUSTER_STYLE_CONSTRAINT_DURATION );
@@ -443,7 +464,6 @@ void Cluster::UpdateBackground(float duration)
 {
   if (mBackgroundImage)
   {
 {
   if (mBackgroundImage)
   {
-    mBackgroundImage.RemoveConstraints();
     mClusterStyle.ApplyStyleToBackground(mBackgroundImage, AlphaFunctions::EaseOut, duration);
   }
 }
     mClusterStyle.ApplyStyleToBackground(mBackgroundImage, AlphaFunctions::EaseOut, duration);
   }
 }
@@ -452,7 +472,6 @@ void Cluster::UpdateTitle(float duration)
 {
   if (mTitle)
   {
 {
   if (mTitle)
   {
-    mTitle.RemoveConstraints();
     mClusterStyle.ApplyStyleToTitle(mTitle, AlphaFunctions::EaseOut, duration);
   }
 }
     mClusterStyle.ApplyStyleToTitle(mTitle, AlphaFunctions::EaseOut, duration);
   }
 }
index 398b6a2..a7a30e0 100644 (file)
@@ -256,6 +256,12 @@ private: // From Control
    */
   virtual void OnInitialize();
 
    */
   virtual void OnInitialize();
 
+  /**
+   *
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   */
+  virtual void OnControlSizeSet( const Vector3& targetSize );
+
 protected:
 
   /**
 protected:
 
   /**
@@ -281,6 +287,7 @@ private:
 
   Toolkit::ClusterStyle mClusterStyle;
   ChildInfoContainer mChildren;
 
   Toolkit::ClusterStyle mClusterStyle;
   ChildInfoContainer mChildren;
+  Vector3 mClusterSize;
 
   Actor mBackgroundImage;           ///< Stores the background image.
   Actor mTitle;                     ///< Stores the text title.
 
   Actor mBackgroundImage;           ///< Stores the background image.
   Actor mTitle;                     ///< Stores the text title.
index 3440be7..e53b378 100644 (file)
@@ -19,7 +19,7 @@
 #include <dali-toolkit/internal/controls/cluster/cluster-style-impl.h>
 
 // EXTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/cluster/cluster-style-impl.h>
 
 // EXTERNAL INCLUDES
-
+#include <dali/public-api/animation/animation.h>
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/cluster/cluster.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/cluster/cluster.h>
 
@@ -175,110 +175,10 @@ const unsigned int CLUSTER_RANDOM_SEED(0x17eac9f3);         ///< Random seed for
 
 const int STYLE_RANDOM_CHILDREN_NUMBER = 16;
 
 
 const int STYLE_RANDOM_CHILDREN_NUMBER = 16;
 
-// Constraints
-
-/**
- * First order equation of the form y = Mx + C
- * current' = current * relative + offset
- */
-struct FirstOrderEquationConstraint
-{
-  /**
-   * @param relative The relative multiplier of the source property
-   * @param offset The offset to add onto the result.
-   */
-  FirstOrderEquationConstraint(Vector3 relative, Vector3 offset = Vector3::ZERO)
-  : mRelative(relative),
-    mOffset(offset)
-  {
-  }
-
-  Vector3 operator()(const Vector3&    current,
-                     const PropertyInput& sourceProperty)
-  {
-    const Vector3 source = sourceProperty.GetVector3();
-
-    return source * mRelative + mOffset;
-  }
-
-public:
-
-  Vector3 mRelative;
-  Vector3 mOffset;
-};
-
-/**
- * Depth Constraint.
- * current' = current.xy | + Vector3::ONE.z
- */
-struct DepthConstraint
+Vector3 FirstOrderEquation( const Vector3& source, const Vector3& relative, const Vector3& offset = Vector3::ZERO  )
 {
 {
-  /**
-   * constructor
-   */
-  DepthConstraint()
-  {
-  }
-
-  Vector3 operator()(const Vector3&    current,
-                     const PropertyInput& depthProperty)
-  {
-    Vector3 position(current);
-    position.z = depthProperty.GetFloat();
-    return position;
-  }
-};
-
-
-/**
- * Position Constraint.
- * current' = current * relative + offset
- */
-struct PositionConstraint
-{
-  /**
-   * @param relative The relative multiplier of the source property
-   * @param offset The offset to add onto the result.
-   */
-  PositionConstraint(Vector3 relative, Vector3 offset = Vector3::ZERO)
-  : mRelative(relative),
-    mOffset(offset)
-  {
-  }
-
-  Vector3 operator()(const Vector3&    current,
-                     const PropertyInput& sourceProperty,
-                     const PropertyInput& depthProperty)
-  {
-    const Vector3 source = sourceProperty.GetVector3();
-
-    Vector3 position(source * mRelative + mOffset);
-    position.z += depthProperty.GetFloat();
-    return position;
-  }
-
-public:
-
-  Vector3 mRelative;
-  Vector3 mOffset;
-};
-
-template <class T>
-struct SetConstraint
-{
-  SetConstraint(T value)
-  : mValue(value)
-  {
-
-  }
-
-  T operator()(const T&    current)
-  {
-    return mValue;
-  }
-
-  T mValue;
-};
+  return source * relative + offset;
+}
 
 // random data generator //////////////////////////////////////////////////////
 
 
 // random data generator //////////////////////////////////////////////////////
 
@@ -318,7 +218,8 @@ ClusterStyle::ClusterStyle()
   mTitleSize(Vector3::ONE),
   mBackgroundPositionRelative(Vector3::ONE),
   mBackgroundPositionOffset(Vector3::ZERO),
   mTitleSize(Vector3::ONE),
   mBackgroundPositionRelative(Vector3::ONE),
   mBackgroundPositionOffset(Vector3::ZERO),
-  mBackgroundSize(Vector3::ONE)
+  mBackgroundSize(Vector3::ONE),
+  mClusterSize( Vector3::ZERO )
 {
 }
 
 {
 }
 
@@ -337,6 +238,24 @@ unsigned int ClusterStyle::GetMaximumNumberOfChildren() const
   return mMaxChildren;
 }
 
   return mMaxChildren;
 }
 
+void ClusterStyle::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds)
+{
+  Apply( background,
+         FirstOrderEquation( GetClusterSize(), mBackgroundPositionRelative, mBackgroundPositionOffset ),
+         FirstOrderEquation( GetClusterSize(), mBackgroundSize ),
+         alpha,
+         durationSeconds);
+}
+
+void ClusterStyle::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds)
+{
+  Apply( title,
+         FirstOrderEquation( GetClusterSize(), mTitlePositionRelative, mTitlePositionOffset ),
+         FirstOrderEquation( GetClusterSize(), mTitleSize ),
+         alpha,
+         durationSeconds);
+}
+
 void ClusterStyle::SetTitleProperties(const Vector3& relativePosition,
                                       const Vector3& offsetPosition,
                                       const Vector3& size)
 void ClusterStyle::SetTitleProperties(const Vector3& relativePosition,
                                       const Vector3& offsetPosition,
                                       const Vector3& size)
@@ -355,6 +274,64 @@ void ClusterStyle::SetBackgroundProperties(const Vector3& relativePosition,
   mBackgroundSize = size;
 }
 
   mBackgroundSize = size;
 }
 
+void ClusterStyle::SetClusterSize( const Vector3& clusterSize )
+{
+  mClusterSize = clusterSize;
+}
+
+Vector3 ClusterStyle::GetClusterSize() const
+{
+  return mClusterSize;
+}
+
+void ClusterStyle::Apply( Actor actor,
+                          const Vector3& position,
+                          const Vector3& size,
+                          AlphaFunction alpha,
+                          const TimePeriod& durationSeconds)
+{
+  float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
+  if( animationDuration > 0.f )
+  {
+    Animation animation = Animation::New(animationDuration);
+    animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.Play();
+  }
+  else
+  {
+    actor.SetPosition( position );
+    actor.SetSize( size );
+  }
+}
+
+void ClusterStyle::Apply( Actor actor,
+                          const Vector3& position,
+                          const Vector3& size,
+                          const Quaternion& rotation,
+                          const Vector3& scale,
+                          AlphaFunction alpha,
+                          const TimePeriod& durationSeconds)
+{
+  float animationDuration = durationSeconds.delaySeconds + durationSeconds.durationSeconds;
+  if( animationDuration > 0.f )
+  {
+    Animation animation = Animation::New(animationDuration);
+    animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.RotateTo( actor, rotation, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.ScaleTo( actor, scale, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+    animation.Play();
+  }
+  else
+  {
+    actor.SetPosition( position );
+    actor.SetSize( size );
+    actor.SetRotation( rotation );
+    actor.SetScale( scale );
+  }
+}
+
 // ClusterStyleStandard ///////////////////////////////////////////////////////
 
 ClusterStylePtr ClusterStyleStandard::New(StyleType style)
 // ClusterStyleStandard ///////////////////////////////////////////////////////
 
 ClusterStylePtr ClusterStyleStandard::New(StyleType style)
@@ -449,78 +426,16 @@ void ClusterStyleStandard::ApplyStyle(Actor child, unsigned int index, AlphaFunc
     // counter top-left parent origin and top-left anchor point.
     const Vector3 position = mPositions[index] - Vector3(0.5f, 0.5f, 0.0f) + Vector3(size, size, 0.0f) * 0.5f;
 
     // counter top-left parent origin and top-left anchor point.
     const Vector3 position = mPositions[index] - Vector3(0.5f, 0.5f, 0.0f) + Vector3(size, size, 0.0f) * 0.5f;
 
-    Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                      ParentSource( Actor::SIZE ),
-                                                      FirstOrderEquationConstraint(Vector3(position.x, position.y, 0.0f),
-                                                                                   Vector3(0.0f, 0.0f, position.z)) );
-
-    constraint.SetApplyTime(durationSeconds);
-    constraint.SetAlphaFunction(alpha);
-    constraint.SetRemoveAction(Constraint::Bake);
-    child.ApplyConstraint(constraint);
-
-    constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                           ParentSource( Actor::SIZE ),
-                                           FirstOrderEquationConstraint(Vector3::ONE * size) );
-    constraint.SetApplyTime(durationSeconds);
-    constraint.SetAlphaFunction(alpha);
-    constraint.SetRemoveAction(Constraint::Bake);
-    child.ApplyConstraint(constraint);
-
-    constraint = Constraint::New<Quaternion>( Actor::ROTATION,
-                                              SetConstraint<Quaternion>(Quaternion()) );
-    constraint.SetApplyTime(durationSeconds);
-    constraint.SetAlphaFunction(alpha);
-    constraint.SetRemoveAction(Constraint::Bake);
-    child.ApplyConstraint(constraint);
-
-    constraint = Constraint::New<Vector3>( Actor::SCALE,
-                                           SetConstraint<Vector3>(Vector3::ONE) );
-    constraint.SetApplyTime(durationSeconds);
-    constraint.SetAlphaFunction(alpha);
-    constraint.SetRemoveAction(Constraint::Bake);
-    child.ApplyConstraint(constraint);
+    Apply( child,
+           FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, position.z) ),
+           FirstOrderEquation( GetClusterSize(), Vector3::ONE * size ),
+           Quaternion(),
+           Vector3::ONE,
+           alpha,
+           durationSeconds);
   }
 }
 
   }
 }
 
-void ClusterStyleStandard::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds)
-{
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mBackgroundPositionRelative, mBackgroundPositionOffset) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  background.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mBackgroundSize) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  background.ApplyConstraint(constraint);
-}
-
-void ClusterStyleStandard::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds)
-{
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mTitlePositionRelative, mTitlePositionOffset) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  title.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mTitleSize) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  title.ApplyConstraint(constraint);
-}
-
 // ClusterStyleRandom /////////////////////////////////////////////////////////
 
 ClusterStylePtr ClusterStyleRandom::New()
 // ClusterStyleRandom /////////////////////////////////////////////////////////
 
 ClusterStylePtr ClusterStyleRandom::New()
@@ -552,85 +467,16 @@ void ClusterStyleRandom::ApplyStyle(Actor child, unsigned int index, AlphaFuncti
                          0.0f);
 
   Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH);
                          0.0f);
 
   Property::Index depthProperty = child.GetPropertyIndex(Toolkit::Cluster::CLUSTER_ACTOR_DEPTH);
+  float depthPropertyValue = child.GetProperty<float>( depthProperty );
 
 
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                    ParentSource( Actor::SIZE ),
-                                                    FirstOrderEquationConstraint( Vector3(position.x, position.y, 0.0f),
-                                                                                  Vector3(0.0f, 0.0f, position.z) ) );
-
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  child.ApplyConstraint(constraint);
-
-  // this constraint overrides the Z position. setting it to cluster-actor-depth
-  constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         LocalSource( depthProperty ),
-                                         DepthConstraint() );
-
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  child.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(Vector3::ONE * size) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  child.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Quaternion>( Actor::ROTATION,
-                                            SetConstraint<Quaternion>(Quaternion(rotation, Vector3::ZAXIS)) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  child.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SCALE,
-                                         SetConstraint<Vector3>(Vector3::ONE) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  child.ApplyConstraint(constraint);
-}
 
 
-void ClusterStyleRandom::ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds)
-{
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mBackgroundPositionRelative, mBackgroundPositionOffset) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  background.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mBackgroundSize) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  background.ApplyConstraint(constraint);
-}
-
-void ClusterStyleRandom::ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds)
-{
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mTitlePositionRelative, mTitlePositionOffset) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  title.ApplyConstraint(constraint);
-
-  constraint = Constraint::New<Vector3>( Actor::SIZE,
-                                         ParentSource( Actor::SIZE ),
-                                         FirstOrderEquationConstraint(mTitleSize) );
-  constraint.SetApplyTime(durationSeconds);
-  constraint.SetAlphaFunction(alpha);
-  constraint.SetRemoveAction(Constraint::Bake);
-  title.ApplyConstraint(constraint);
+  Apply( child,
+         FirstOrderEquation( GetClusterSize(), Vector3(position.x, position.y, 0.0f), Vector3(0.0f, 0.0f, depthPropertyValue) ),
+         FirstOrderEquation( GetClusterSize(), Vector3::ONE * size),
+         Quaternion(rotation, Vector3::ZAXIS),
+         Vector3::ONE,
+         alpha,
+         durationSeconds);
 }
 
 } // namespace Internal
 }
 
 } // namespace Internal
index df08a47..a7f3468 100644 (file)
@@ -55,12 +55,17 @@ public:
   /**
    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
    */
   /**
    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
    */
-  virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
+  virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
 
   /**
    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
    */
 
   /**
    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
    */
-  virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
+  virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
+
+  /**
+    * Set the size of cluster
+    */
+  void SetClusterSize( const Vector3& clusterSize );
 
 protected:
 
 
 protected:
 
@@ -90,6 +95,43 @@ protected:
                                const Vector3& offsetPosition,
                                const Vector3& size);
 
                                const Vector3& offsetPosition,
                                const Vector3& size);
 
+  /**
+   * Get the size of cluster.
+   * @return the cluster size
+   */
+   Vector3 GetClusterSize() const;
+
+   /**
+    * Apply the given position & size to the actor
+    * @param[in] position The target position
+    * @param[in] size The target size
+    * @param[in] size The size to resize to
+    * @param[in] alpha The alpha function to use.
+    * @param[in] durationSeconds The time period to apply this style.
+    */
+   void Apply( Actor actor,
+               const Vector3& position,
+               const Vector3& size,
+               AlphaFunction alpha,
+               const TimePeriod& durationSeconds);
+   /**
+    * Apply the given position & size to the actor
+    * @param[in] actor The actor to apply the changes
+    * @param[in] position The target position
+    * @param[in] size The target size
+    * @param[in] rotation The target Quaternion value
+    * @param[in] scale The target scale
+    * @param[in] alpha The alpha function to use.
+    * @param[in] durationSeconds The time period to apply this style.
+    */
+   void Apply( Actor actor,
+               const Vector3& position,
+               const Vector3& size,
+               const Quaternion& rotation,
+               const Vector3& scale,
+               AlphaFunction alpha,
+               const TimePeriod& durationSeconds);
+
 protected:
 
   /**
 protected:
 
   /**
@@ -111,7 +153,7 @@ protected:
   Vector3 mBackgroundPositionRelative;            ///< Background's position relative to size of cluster
   Vector3 mBackgroundPositionOffset;              ///< Background's position offset
   Vector3 mBackgroundSize;                        ///< Background's size relative to size of cluster
   Vector3 mBackgroundPositionRelative;            ///< Background's position relative to size of cluster
   Vector3 mBackgroundPositionOffset;              ///< Background's position offset
   Vector3 mBackgroundSize;                        ///< Background's size relative to size of cluster
-
+  Vector3 mClusterSize;                           ///< The size of cluster
 };
 
 /**
 };
 
 /**
@@ -139,16 +181,6 @@ public:
    */
   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
 
    */
   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
 
-  /**
-   * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
-   */
-  void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
-
-  /**
-   * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
-   */
-  void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
-
 private:
 
   /**
 private:
 
   /**
@@ -197,16 +229,6 @@ public:
    */
   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
 
    */
   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
 
-  /**
-   * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
-   */
-  void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
-
-  /**
-   * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
-   */
-  void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
-
 protected:
 
   /**
 protected:
 
   /**
index 45ab799..7cb6cb4 100644 (file)
@@ -109,7 +109,6 @@ void ImageView::Initialize()
   Image emptyImage;
   mImageActor = ImageActor::New( emptyImage );
   self.Add( mImageActor );
   Image emptyImage;
   mImageActor = ImageActor::New( emptyImage );
   self.Add( mImageActor );
-  mImageActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
   mImageActor.SetParentOrigin( ParentOrigin::CENTER );
 }
 
   mImageActor.SetParentOrigin( ParentOrigin::CENTER );
 }
 
@@ -118,6 +117,11 @@ ImageView::~ImageView()
 
 }
 
 
 }
 
+void ImageView::OnControlSizeSet( const Vector3& targetSize )
+{
+  mImageActor.SetSize( targetSize );
+}
+
 void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
 {
   switch(type)
 void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
 {
   switch(type)
index 69b2f1b..e1f837f 100644 (file)
@@ -138,6 +138,12 @@ protected:
    */
   virtual ~ImageView();
 
    */
   virtual ~ImageView();
 
+  /**
+   *
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   */
+  virtual void OnControlSizeSet( const Vector3& targetSize );
+
 private:
 
   /**
 private:
 
   /**
index ed9d27b..fad0ade 100644 (file)
@@ -534,7 +534,6 @@ void MaskedImageView::Initialize( unsigned int targetWidth,
   // Create actor to display result of off-screen rendering
   mDestinationImageActor = ImageActor::New( mDestinationImage );
   self.Add( mDestinationImageActor );
   // Create actor to display result of off-screen rendering
   mDestinationImageActor = ImageActor::New( mDestinationImage );
   self.Add( mDestinationImageActor );
-  mDestinationImageActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
   mDestinationImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
 
   // Start the masking operation
   mDestinationImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
 
   // Start the masking operation
@@ -633,6 +632,11 @@ MaskedImageView::~MaskedImageView()
   }
 }
 
   }
 }
 
+void MaskedImageView::OnControlSizeSet( const Vector3& targetSize )
+{
+  mDestinationImageActor.SetSize(targetSize);
+}
+
 void MaskedImageView::OnRenderTaskFinished( Dali::RenderTask& renderTask )
 {
   Toolkit::MaskedImageView handle( GetOwner() );
 void MaskedImageView::OnRenderTaskFinished( Dali::RenderTask& renderTask )
 {
   Toolkit::MaskedImageView handle( GetOwner() );
index f9af407..a1c8285 100644 (file)
@@ -185,6 +185,12 @@ protected:
    */
   virtual ~MaskedImageView();
 
    */
   virtual ~MaskedImageView();
 
+  /**
+   *
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   */
+  virtual void OnControlSizeSet( const Vector3& targetSize );
+
 private:
 
   // Undefined
 private:
 
   // Undefined
index ae0c35e..d49c718 100644 (file)
@@ -73,7 +73,7 @@ void ToolBar::SetBackground( Actor background )
   // ToolBar image
   background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
   background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
   // ToolBar image
   background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
   background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
-  background.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  background.SetSize( mToolBarSize );
 
   RenderableActor renderableActor = RenderableActor::DownCast( background );
   if ( renderableActor )
 
   RenderableActor renderableActor = RenderableActor::DownCast( background );
   if ( renderableActor )
@@ -82,6 +82,7 @@ void ToolBar::SetBackground( Actor background )
   }
 
   Self().Add( background );
   }
 
   Self().Add( background );
+  mBackground = background;
 }
 
 void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding )
 }
 
 void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding )
@@ -356,6 +357,12 @@ void ToolBar::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
   Relayout( mLayout, size, container );
 }
 
   Relayout( mLayout, size, container );
 }
 
+void ToolBar::OnControlSizeSet( const Vector3& targetSize )
+{
+  mToolBarSize = targetSize;
+  mBackground.SetSize( mToolBarSize );
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
 } // namespace Internal
 
 } // namespace Toolkit
index f12bf5a..2b2fa6d 100644 (file)
@@ -88,6 +88,12 @@ private: // From Control
    */
   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
 
    */
   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
 
+  /**
+   *
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   */
+  virtual void OnControlSizeSet( const Vector3& targetSize );
+
 private:
   /**
    */
 private:
   /**
    */
@@ -136,6 +142,8 @@ private:
   float              mRightRelativeSpace;       ///< Relative space between center and right groups of controls.
   float              mAccumulatedRelativeSpace; ///< Stores the total percentage space used by controls.
   bool               mInitializing;             ///< Allows the use of Actor's API to add controls.
   float              mRightRelativeSpace;       ///< Relative space between center and right groups of controls.
   float              mAccumulatedRelativeSpace; ///< Stores the total percentage space used by controls.
   bool               mInitializing;             ///< Allows the use of Actor's API to add controls.
+  Vector3            mToolBarSize;              ///< The size of tool bar
+  Actor              mBackground;               ///< The background of the tool bar
 
   std::map<Actor/*control*/,Toolkit::Alignment> mControls; ///< Stores a relationship between controls and their alignments used to place them inside the table view.
 };
 
   std::map<Actor/*control*/,Toolkit::Alignment> mControls; ///< Stores a relationship between controls and their alignments used to place them inside the table view.
 };
index 82b91b7..6c374c0 100644 (file)
@@ -136,7 +136,7 @@ void View::SetBackground( ImageActor backgroundImage )
     mBackgroundLayer = Layer::New();
 
     mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
     mBackgroundLayer = Layer::New();
 
     mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-    mBackgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+    mBackgroundLayer.SetSize( mViewSize );
 
     // Add background layer to custom actor.
     Self().Add( mBackgroundLayer );
 
     // Add background layer to custom actor.
     Self().Add( mBackgroundLayer );
@@ -156,12 +156,7 @@ void View::SetBackground( ImageActor backgroundImage )
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  Constraint constraint = Constraint::New<Vector3>(
-      Actor::SCALE,
-      LocalSource( Actor::SIZE ),
-      ParentSource( Actor::SIZE ),
-      ScaleToFillXYKeepAspectRatioConstraint() );
-  backgroundImage.ApplyConstraint( constraint );
+  backgroundImage.SetScale( FillXYKeepAspectRatio( mViewSize, backgroundImage.GetSize() ) );
   mBackgroundLayer.Add( backgroundImage );
 }
 
   mBackgroundLayer.Add( backgroundImage );
 }
 
@@ -299,6 +294,20 @@ void View::OnInitialize()
   }
 }
 
   }
 }
 
+void View::OnControlSizeSet( const Vector3& targetSize )
+{
+  mViewSize = targetSize;
+  if( mBackgroundLayer )
+  {
+    mBackgroundLayer.SetSize( mViewSize );
+    if( mBackgroundLayer.GetChildCount() > 0 )
+    {
+      Actor background = mBackgroundLayer.GetChildAt(0);
+      background.SetScale( FillXYKeepAspectRatio( mViewSize, background.GetSize() ) );
+    }
+  }
+}
+
 View::Orientation View::DegreeToViewOrientation( Degree degree )
 {
   View::Orientation orientation = PORTRAIT;
 View::Orientation View::DegreeToViewOrientation( Degree degree )
 {
   View::Orientation orientation = PORTRAIT;
index b956eae..5352afe 100644 (file)
@@ -137,6 +137,12 @@ private: // From Control
    */
   virtual void OnInitialize();
 
    */
   virtual void OnInitialize();
 
+  /**
+   *
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   */
+  virtual void OnControlSizeSet( const Vector3& targetSize );
+
 private:
 
 
 private:
 
 
@@ -174,6 +180,7 @@ private:
   Animation      mRotateAnimation;        ///< The animation which rotates the view (and all layers added to it)
   float          mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
   bool           mAutoRotateEnabled;      ///< Whether the view rotates if the OrientationChanged method is called.
   Animation      mRotateAnimation;        ///< The animation which rotates the view (and all layers added to it)
   float          mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
   bool           mAutoRotateEnabled;      ///< Whether the view rotates if the OrientationChanged method is called.
+  Vector3        mViewSize;               ///< The Control Size
 
   Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal;
 };
 
   Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal;
 };