Added animation and constraint support for UNSIGNED_INTEGER property type
[platform/core/uifw/dali-core.git] / dali / internal / update / common / animatable-property.h
index 8429b93..7e8fbf0 100644 (file)
@@ -292,11 +292,12 @@ private:
 
 };
 
+
 /**
- * An float animatable property of a scene-graph object.
+ * An integer animatable property of a scene-graph object.
  */
 template <>
-class AnimatableProperty<float> : public AnimatablePropertyBase
+class AnimatableProperty<int> : public AnimatablePropertyBase
 {
 public:
 
@@ -304,7 +305,7 @@ public:
    * Create an animatable property.
    * @param [in] initialValue The initial value of the property.
    */
-  AnimatableProperty( float initialValue )
+  AnimatableProperty( int initialValue )
   : mValue( initialValue ),
     mBaseValue( initialValue )
   {
@@ -322,7 +323,7 @@ public:
    */
   virtual Dali::Property::Type GetType() const
   {
-    return Dali::PropertyTypes::Get<float>();
+    return Dali::PropertyTypes::Get<int>();
   }
 
   /**
@@ -339,9 +340,9 @@ public:
   }
 
   /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
+   * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
    */
-  virtual const float& GetFloat( BufferIndex bufferIndex ) const
+  virtual const int& GetInteger( BufferIndex bufferIndex ) const
   {
     return mValue[ bufferIndex ];
   }
@@ -352,7 +353,7 @@ public:
    * @param[in] bufferIndex The buffer to write.
    * @param[in] value The new property value.
    */
-  void Set(BufferIndex bufferIndex, float value)
+  void Set(BufferIndex bufferIndex, int value)
   {
     mValue[bufferIndex] = value;
 
@@ -364,7 +365,7 @@ public:
    * @param[in] bufferIndex The buffer to write.
    * @param[in] delta The property will change by this amount.
    */
-  void SetRelative(BufferIndex bufferIndex, float delta)
+  void SetRelative(BufferIndex bufferIndex, int delta)
   {
     mValue[bufferIndex] = mValue[bufferIndex] + delta;
 
@@ -374,7 +375,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
    */
-  float& Get(size_t bufferIndex)
+  int& Get(size_t bufferIndex)
   {
     return mValue[bufferIndex];
   }
@@ -382,7 +383,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
    */
-  const float& Get(size_t bufferIndex) const
+  const int& Get(size_t bufferIndex) const
   {
     return mValue[bufferIndex];
   }
@@ -392,7 +393,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  float& operator[](size_t bufferIndex)
+  int& operator[](size_t bufferIndex)
   {
     return mValue[bufferIndex];
   }
@@ -402,7 +403,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const float& operator[](size_t bufferIndex) const
+  const int& operator[](size_t bufferIndex) const
   {
     return mValue[bufferIndex];
   }
@@ -412,7 +413,7 @@ public:
    * @param[in] bufferIndex The buffer to write for the property value.
    * @param[in] value The new property value.
    */
-  void Bake(BufferIndex bufferIndex, float value)
+  void Bake(BufferIndex bufferIndex, int value)
   {
     mValue[bufferIndex] = value;
     mBaseValue = mValue[bufferIndex];
@@ -425,7 +426,7 @@ public:
    * @param[in] bufferIndex The buffer to write for the local property value.
    * @param[in] delta The property will change by this amount.
    */
-  void BakeRelative(BufferIndex bufferIndex, float delta)
+  void BakeRelative(BufferIndex bufferIndex, int delta)
   {
     mValue[bufferIndex] = mValue[bufferIndex] + delta;
     mBaseValue = mValue[bufferIndex];
@@ -438,7 +439,7 @@ public:
    * This should only be used when the owning object has not been connected to the scene-graph.
    * @param[in] value The new property value.
    */
-  void SetInitial(const float& value)
+  void SetInitial(const int& value)
   {
     mValue[0]  = value;
     mValue[1]  = mValue[0];
@@ -450,7 +451,7 @@ public:
    * This should only be used when the owning object has not been connected to the scene-graph.
    * @param[in] delta The property will change by this amount.
    */
-  void SetInitialRelative(const float& delta)
+  void SetInitialRelative(const int& delta)
   {
     mValue[0] = mValue[0] + delta;
     mValue[1] = mValue[0];
@@ -467,16 +468,16 @@ private:
 
 private:
 
-  DoubleBuffered<float> mValue; ///< The double-buffered property value
-  float mBaseValue;             ///< Reset to this base value at the beginning of each frame
+  DoubleBuffered<int> mValue; ///< The double-buffered property value
+  int mBaseValue;             ///< Reset to this base value at the beginning of each frame
 
 };
 
 /**
- * An integer animatable property of a scene-graph object.
+ * An unsigned integer animatable property of a scene-graph object.
  */
 template <>
-class AnimatableProperty<int> : public AnimatablePropertyBase
+class AnimatableProperty<unsigned int> : public AnimatablePropertyBase
 {
 public:
 
@@ -484,7 +485,7 @@ public:
    * Create an animatable property.
    * @param [in] initialValue The initial value of the property.
    */
-  AnimatableProperty( int initialValue )
+  AnimatableProperty( unsigned int initialValue )
   : mValue( initialValue ),
     mBaseValue( initialValue )
   {
@@ -502,7 +503,7 @@ public:
    */
   virtual Dali::Property::Type GetType() const
   {
-    return Dali::PropertyTypes::Get<int>();
+    return Dali::PropertyTypes::Get<unsigned int>();
   }
 
   /**
@@ -519,9 +520,9 @@ public:
   }
 
   /**
-   * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
+   * @copydoc Dali::Internal::PropertyInputImpl::GetUnsignedInteger()
    */
-  virtual const int& GetInteger( BufferIndex bufferIndex ) const
+  virtual const unsigned int& GetUnsignedInteger( BufferIndex bufferIndex ) const
   {
     return mValue[ bufferIndex ];
   }
@@ -532,7 +533,7 @@ public:
    * @param[in] bufferIndex The buffer to write.
    * @param[in] value The new property value.
    */
-  void Set(BufferIndex bufferIndex, int value)
+  void Set(BufferIndex bufferIndex, unsigned int value)
   {
     mValue[bufferIndex] = value;
 
@@ -544,7 +545,7 @@ public:
    * @param[in] bufferIndex The buffer to write.
    * @param[in] delta The property will change by this amount.
    */
-  void SetRelative(BufferIndex bufferIndex, int delta)
+  void SetRelative(BufferIndex bufferIndex, unsigned int delta)
   {
     mValue[bufferIndex] = mValue[bufferIndex] + delta;
 
@@ -554,7 +555,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
    */
-  int& Get(size_t bufferIndex)
+  unsigned int& Get(size_t bufferIndex)
   {
     return mValue[bufferIndex];
   }
@@ -562,7 +563,7 @@ public:
   /**
    * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
    */
-  const int& Get(size_t bufferIndex) const
+  const unsigned int& Get(size_t bufferIndex) const
   {
     return mValue[bufferIndex];
   }
@@ -572,7 +573,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  int& operator[](size_t bufferIndex)
+  unsigned int& operator[](size_t bufferIndex)
   {
     return mValue[bufferIndex];
   }
@@ -582,7 +583,7 @@ public:
    * @param[in] bufferIndex The buffer to read.
    * @return The property value.
    */
-  const int& operator[](size_t bufferIndex) const
+  const unsigned int& operator[](size_t bufferIndex) const
   {
     return mValue[bufferIndex];
   }
@@ -592,7 +593,7 @@ public:
    * @param[in] bufferIndex The buffer to write for the property value.
    * @param[in] value The new property value.
    */
-  void Bake(BufferIndex bufferIndex, int value)
+  void Bake(BufferIndex bufferIndex, unsigned int value)
   {
     mValue[bufferIndex] = value;
     mBaseValue = mValue[bufferIndex];
@@ -605,7 +606,7 @@ public:
    * @param[in] bufferIndex The buffer to write for the local property value.
    * @param[in] delta The property will change by this amount.
    */
-  void BakeRelative(BufferIndex bufferIndex, int delta)
+  void BakeRelative(BufferIndex bufferIndex, unsigned int delta)
   {
     mValue[bufferIndex] = mValue[bufferIndex] + delta;
     mBaseValue = mValue[bufferIndex];
@@ -618,7 +619,7 @@ public:
    * This should only be used when the owning object has not been connected to the scene-graph.
    * @param[in] value The new property value.
    */
-  void SetInitial(const int& value)
+  void SetInitial(const unsigned int& value)
   {
     mValue[0]  = value;
     mValue[1]  = mValue[0];
@@ -630,7 +631,7 @@ public:
    * This should only be used when the owning object has not been connected to the scene-graph.
    * @param[in] delta The property will change by this amount.
    */
-  void SetInitialRelative(const int& delta)
+  void SetInitialRelative(const unsigned int& delta)
   {
     mValue[0] = mValue[0] + delta;
     mValue[1] = mValue[0];
@@ -646,10 +647,188 @@ private:
   AnimatableProperty& operator=(const AnimatableProperty& rhs);
 
 private:
+  DoubleBuffered<unsigned int> mValue; ///< The double-buffered property value
+  unsigned int mBaseValue;             ///< Reset to this base value at the beginning of each frame
+};
 
-  DoubleBuffered<int> mValue; ///< The double-buffered property value
-  int mBaseValue;             ///< Reset to this base value at the beginning of each frame
 
+/**
+ * An float animatable property of a scene-graph object.
+ */
+template <>
+class AnimatableProperty<float> : public AnimatablePropertyBase
+{
+public:
+
+  /**
+   * Create an animatable property.
+   * @param [in] initialValue The initial value of the property.
+   */
+  AnimatableProperty( float initialValue )
+  : mValue( initialValue ),
+    mBaseValue( initialValue )
+  {
+  }
+
+  /**
+   * Virtual destructor.
+   */
+  virtual ~AnimatableProperty()
+  {
+  }
+
+  /**
+   * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
+   */
+  virtual Dali::Property::Type GetType() const
+  {
+    return Dali::PropertyTypes::Get<float>();
+  }
+
+  /**
+   * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
+   */
+  virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
+  {
+    if (CLEAN_FLAG != mDirtyFlags)
+    {
+      mValue[updateBufferIndex] = mBaseValue;
+
+      mDirtyFlags = ( mDirtyFlags >> 1 );
+    }
+  }
+
+  /**
+   * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
+   */
+  virtual const float& GetFloat( BufferIndex bufferIndex ) const
+  {
+    return mValue[ bufferIndex ];
+  }
+
+  /**
+   * Set the property value. This will only persist for the current frame; the property
+   * will be reset with the base value, at the beginning of the next frame.
+   * @param[in] bufferIndex The buffer to write.
+   * @param[in] value The new property value.
+   */
+  void Set(BufferIndex bufferIndex, float value)
+  {
+    mValue[bufferIndex] = value;
+
+    OnSet();
+  }
+
+  /**
+   * Change the property value by a relative amount.
+   * @param[in] bufferIndex The buffer to write.
+   * @param[in] delta The property will change by this amount.
+   */
+  void SetRelative(BufferIndex bufferIndex, float delta)
+  {
+    mValue[bufferIndex] = mValue[bufferIndex] + delta;
+
+    OnSet();
+  }
+
+  /**
+   * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
+   */
+  float& Get(size_t bufferIndex)
+  {
+    return mValue[bufferIndex];
+  }
+
+  /**
+   * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
+   */
+  const float& Get(size_t bufferIndex) const
+  {
+    return mValue[bufferIndex];
+  }
+
+  /**
+   * Retrieve the property value.
+   * @param[in] bufferIndex The buffer to read.
+   * @return The property value.
+   */
+  float& operator[](size_t bufferIndex)
+  {
+    return mValue[bufferIndex];
+  }
+
+  /**
+   * Retrieve the property value.
+   * @param[in] bufferIndex The buffer to read.
+   * @return The property value.
+   */
+  const float& operator[](size_t bufferIndex) const
+  {
+    return mValue[bufferIndex];
+  }
+
+  /**
+   * Set both the property value & base value.
+   * @param[in] bufferIndex The buffer to write for the property value.
+   * @param[in] value The new property value.
+   */
+  void Bake(BufferIndex bufferIndex, float value)
+  {
+    mValue[bufferIndex] = value;
+    mBaseValue = mValue[bufferIndex];
+
+    OnBake();
+  }
+
+  /**
+   * Change the property value & base value by a relative amount.
+   * @param[in] bufferIndex The buffer to write for the local property value.
+   * @param[in] delta The property will change by this amount.
+   */
+  void BakeRelative(BufferIndex bufferIndex, float delta)
+  {
+    mValue[bufferIndex] = mValue[bufferIndex] + delta;
+    mBaseValue = mValue[bufferIndex];
+
+    OnBake();
+  }
+
+  /**
+   * Sets both double-buffered values & the base value.
+   * This should only be used when the owning object has not been connected to the scene-graph.
+   * @param[in] value The new property value.
+   */
+  void SetInitial(const float& value)
+  {
+    mValue[0]  = value;
+    mValue[1]  = mValue[0];
+    mBaseValue = mValue[0];
+  }
+
+  /**
+   * Change both double-buffered values & the base value by a relative amount.
+   * This should only be used when the owning object has not been connected to the scene-graph.
+   * @param[in] delta The property will change by this amount.
+   */
+  void SetInitialRelative(const float& delta)
+  {
+    mValue[0] = mValue[0] + delta;
+    mValue[1] = mValue[0];
+    mBaseValue = mValue[0];
+  }
+
+private:
+
+  // Undefined
+  AnimatableProperty(const AnimatableProperty& property);
+
+  // Undefined
+  AnimatableProperty& operator=(const AnimatableProperty& rhs);
+
+private:
+
+  DoubleBuffered<float> mValue; ///< The double-buffered property value
+  float mBaseValue;             ///< Reset to this base value at the beginning of each frame
 };
 
 /**