1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/property.h>
27 #include <dali/public-api/object/property-input.h>
28 #include <dali/public-api/object/property-types.h>
29 #include <dali/internal/common/message.h>
30 #include <dali/internal/common/event-to-update.h>
31 #include <dali/internal/event/common/property-input-impl.h>
32 #include <dali/internal/update/common/double-buffered.h>
33 #include <dali/internal/update/common/property-base.h>
34 #include <dali/internal/update/common/scene-graph-buffers.h>
46 * Dirty flags record whether an animatable property has changed.
47 * In the frame following a change, the property is reset to a base value.
49 * If the property was "Baked", then the base value matches the (double-buffered) value from the previous frame.
50 * Therefore when reset, the property is flagged as "clean".
52 * However if the property was only "Set" (and not "Baked"), then typically the base value and previous value will not match.
53 * In this case the reset operation is equivalent to a "Bake", and the value is considered "dirty" for an additional frame.
55 static const unsigned int CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame
56 static const unsigned int BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
57 static const unsigned int SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame
60 class AnimatableProperty;
63 * Base class to reduce code size from the templates.
65 class AnimatablePropertyBase : public PropertyBase
70 * Constructor, initialize the dirty flag
72 AnimatablePropertyBase()
74 mDirtyFlags( BAKED_FLAG )
80 virtual ~AnimatablePropertyBase()
83 protected: // for derived classes
86 * Flag that the property has been Set during the current frame.
90 mDirtyFlags = SET_FLAG;
94 * Flag that the property has been Baked during the current frame.
98 mDirtyFlags = BAKED_FLAG;
101 public: // From PropertyBase
104 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
106 virtual bool IsClean() const
108 return ( CLEAN_FLAG == mDirtyFlags );
112 * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
114 virtual bool InputInitialized() const
116 return true; // Animatable properties are always valid
119 protected: // so that ResetToBaseValue can set it directly
121 unsigned int mDirtyFlags; ///< Flag whether value changed during previous 2 frames
127 * An boolean animatable property of a scene-graph object.
130 class AnimatableProperty<bool> : public AnimatablePropertyBase
135 * Create an animatable property.
136 * @param [in] initialValue The initial value of the property.
138 AnimatableProperty( bool initialValue )
139 : mValue( initialValue ),
140 mBaseValue( initialValue )
145 * Virtual destructor.
147 virtual ~AnimatableProperty()
152 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
154 virtual Dali::Property::Type GetType() const
156 return Dali::PropertyTypes::Get<bool>();
160 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
162 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
164 if (CLEAN_FLAG != mDirtyFlags)
166 mValue[updateBufferIndex] = mBaseValue;
168 mDirtyFlags = ( mDirtyFlags >> 1 );
173 * @copydoc Dali::Internal::PropertyInputImpl::GetBoolean()
175 virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
177 return mValue[ bufferIndex ];
181 * Set the property value. This will only persist for the current frame; the property
182 * will be reset with the base value, at the beginning of the next frame.
183 * @param[in] bufferIndex The buffer to write.
184 * @param[in] value The new property value.
186 void Set(BufferIndex bufferIndex, bool value)
188 // check if the value actually changed to avoid dirtying nodes unnecessarily
189 if( mValue[bufferIndex] != value )
191 mValue[bufferIndex] = value;
198 * Change the property value by a relative amount.
199 * @param[in] bufferIndex The buffer to write.
200 * @param[in] delta The property will change by this amount.
202 void SetRelative(BufferIndex bufferIndex, bool delta)
204 // check if the value actually changed to avoid dirtying nodes unnecessarily
205 // false + false does not change value, true + false does not either
206 if( delta && !mValue[bufferIndex] )
208 mValue[bufferIndex] += delta;
215 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
217 bool& Get(size_t bufferIndex)
219 return mValue[bufferIndex];
223 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
225 const bool& Get(size_t bufferIndex) const
227 return mValue[bufferIndex];
231 * Retrieve the property value.
232 * @param[in] bufferIndex The buffer to read.
233 * @return The property value.
235 bool& operator[](size_t bufferIndex)
237 return mValue[bufferIndex];
241 * Retrieve the property value.
242 * @param[in] bufferIndex The buffer to read.
243 * @return The property value.
245 const bool& operator[](size_t bufferIndex) const
247 return mValue[bufferIndex];
251 * Set both the property value & base value.
252 * @param[in] bufferIndex The buffer to write for the property value.
253 * @param[in] value The new property value.
255 void Bake(BufferIndex bufferIndex, bool value)
257 // check if the value actually changed to avoid dirtying nodes unnecessarily
258 if( mValue[bufferIndex] != value )
260 mValue[bufferIndex] = value;
268 * Change the property value & base value by a relative amount.
269 * @param[in] bufferIndex The buffer to write for the local property value.
270 * @param[in] delta The property will change by this amount.
272 void BakeRelative(BufferIndex bufferIndex, bool delta)
274 mValue[bufferIndex] += delta;
275 mBaseValue = mValue[bufferIndex];
283 AnimatableProperty(const AnimatableProperty& property);
286 AnimatableProperty& operator=(const AnimatableProperty& rhs);
290 DoubleBuffered<bool> mValue; ///< The double-buffered property value
291 bool mBaseValue; ///< Reset to this base value at the beginning of each frame
296 * An float animatable property of a scene-graph object.
299 class AnimatableProperty<float> : public AnimatablePropertyBase
304 * Create an animatable property.
305 * @param [in] initialValue The initial value of the property.
307 AnimatableProperty( float initialValue )
308 : mValue( initialValue ),
309 mBaseValue( initialValue )
314 * Virtual destructor.
316 virtual ~AnimatableProperty()
321 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
323 virtual Dali::Property::Type GetType() const
325 return Dali::PropertyTypes::Get<float>();
329 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
331 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
333 if (CLEAN_FLAG != mDirtyFlags)
335 mValue[updateBufferIndex] = mBaseValue;
337 mDirtyFlags = ( mDirtyFlags >> 1 );
342 * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
344 virtual const float& GetFloat( BufferIndex bufferIndex ) const
346 return mValue[ bufferIndex ];
350 * Set the property value. This will only persist for the current frame; the property
351 * will be reset with the base value, at the beginning of the next frame.
352 * @param[in] bufferIndex The buffer to write.
353 * @param[in] value The new property value.
355 void Set(BufferIndex bufferIndex, float value)
357 mValue[bufferIndex] = value;
363 * Change the property value by a relative amount.
364 * @param[in] bufferIndex The buffer to write.
365 * @param[in] delta The property will change by this amount.
367 void SetRelative(BufferIndex bufferIndex, float delta)
369 mValue[bufferIndex] = mValue[bufferIndex] + delta;
375 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
377 float& Get(size_t bufferIndex)
379 return mValue[bufferIndex];
383 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
385 const float& Get(size_t bufferIndex) const
387 return mValue[bufferIndex];
391 * Retrieve the property value.
392 * @param[in] bufferIndex The buffer to read.
393 * @return The property value.
395 float& operator[](size_t bufferIndex)
397 return mValue[bufferIndex];
401 * Retrieve the property value.
402 * @param[in] bufferIndex The buffer to read.
403 * @return The property value.
405 const float& operator[](size_t bufferIndex) const
407 return mValue[bufferIndex];
411 * Set both the property value & base value.
412 * @param[in] bufferIndex The buffer to write for the property value.
413 * @param[in] value The new property value.
415 void Bake(BufferIndex bufferIndex, float value)
417 mValue[bufferIndex] = value;
418 mBaseValue = mValue[bufferIndex];
424 * Change the property value & base value by a relative amount.
425 * @param[in] bufferIndex The buffer to write for the local property value.
426 * @param[in] delta The property will change by this amount.
428 void BakeRelative(BufferIndex bufferIndex, float delta)
430 mValue[bufferIndex] = mValue[bufferIndex] + delta;
431 mBaseValue = mValue[bufferIndex];
437 * Sets both double-buffered values & the base value.
438 * This should only be used when the owning object has not been connected to the scene-graph.
439 * @param[in] value The new property value.
441 void SetInitial(const float& value)
444 mValue[1] = mValue[0];
445 mBaseValue = mValue[0];
449 * Change both double-buffered values & the base value by a relative amount.
450 * This should only be used when the owning object has not been connected to the scene-graph.
451 * @param[in] delta The property will change by this amount.
453 void SetInitialRelative(const float& delta)
455 mValue[0] = mValue[0] + delta;
456 mValue[1] = mValue[0];
457 mBaseValue = mValue[0];
463 AnimatableProperty(const AnimatableProperty& property);
466 AnimatableProperty& operator=(const AnimatableProperty& rhs);
470 DoubleBuffered<float> mValue; ///< The double-buffered property value
471 float mBaseValue; ///< Reset to this base value at the beginning of each frame
476 * An integer animatable property of a scene-graph object.
479 class AnimatableProperty<int> : public AnimatablePropertyBase
484 * Create an animatable property.
485 * @param [in] initialValue The initial value of the property.
487 AnimatableProperty( int initialValue )
488 : mValue( initialValue ),
489 mBaseValue( initialValue )
494 * Virtual destructor.
496 virtual ~AnimatableProperty()
501 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
503 virtual Dali::Property::Type GetType() const
505 return Dali::PropertyTypes::Get<int>();
509 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
511 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
513 if (CLEAN_FLAG != mDirtyFlags)
515 mValue[updateBufferIndex] = mBaseValue;
517 mDirtyFlags = ( mDirtyFlags >> 1 );
522 * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
524 virtual const int& GetInteger( BufferIndex bufferIndex ) const
526 return mValue[ bufferIndex ];
530 * Set the property value. This will only persist for the current frame; the property
531 * will be reset with the base value, at the beginning of the next frame.
532 * @param[in] bufferIndex The buffer to write.
533 * @param[in] value The new property value.
535 void Set(BufferIndex bufferIndex, int value)
537 mValue[bufferIndex] = value;
543 * Change the property value by a relative amount.
544 * @param[in] bufferIndex The buffer to write.
545 * @param[in] delta The property will change by this amount.
547 void SetRelative(BufferIndex bufferIndex, int delta)
549 mValue[bufferIndex] = mValue[bufferIndex] + delta;
555 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
557 int& Get(size_t bufferIndex)
559 return mValue[bufferIndex];
563 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
565 const int& Get(size_t bufferIndex) const
567 return mValue[bufferIndex];
571 * Retrieve the property value.
572 * @param[in] bufferIndex The buffer to read.
573 * @return The property value.
575 int& operator[](size_t bufferIndex)
577 return mValue[bufferIndex];
581 * Retrieve the property value.
582 * @param[in] bufferIndex The buffer to read.
583 * @return The property value.
585 const int& operator[](size_t bufferIndex) const
587 return mValue[bufferIndex];
591 * Set both the property value & base value.
592 * @param[in] bufferIndex The buffer to write for the property value.
593 * @param[in] value The new property value.
595 void Bake(BufferIndex bufferIndex, int value)
597 mValue[bufferIndex] = value;
598 mBaseValue = mValue[bufferIndex];
604 * Change the property value & base value by a relative amount.
605 * @param[in] bufferIndex The buffer to write for the local property value.
606 * @param[in] delta The property will change by this amount.
608 void BakeRelative(BufferIndex bufferIndex, int delta)
610 mValue[bufferIndex] = mValue[bufferIndex] + delta;
611 mBaseValue = mValue[bufferIndex];
617 * Sets both double-buffered values & the base value.
618 * This should only be used when the owning object has not been connected to the scene-graph.
619 * @param[in] value The new property value.
621 void SetInitial(const int& value)
624 mValue[1] = mValue[0];
625 mBaseValue = mValue[0];
629 * Change both double-buffered values & the base value by a relative amount.
630 * This should only be used when the owning object has not been connected to the scene-graph.
631 * @param[in] delta The property will change by this amount.
633 void SetInitialRelative(const int& delta)
635 mValue[0] = mValue[0] + delta;
636 mValue[1] = mValue[0];
637 mBaseValue = mValue[0];
643 AnimatableProperty(const AnimatableProperty& property);
646 AnimatableProperty& operator=(const AnimatableProperty& rhs);
650 DoubleBuffered<int> mValue; ///< The double-buffered property value
651 int mBaseValue; ///< Reset to this base value at the beginning of each frame
656 * An Vector2 animatable property of a scene-graph object.
659 class AnimatableProperty<Vector2> : public AnimatablePropertyBase
664 * Create an animatable property.
665 * @param [in] initialValue The initial value of the property.
667 AnimatableProperty( const Vector2& initialValue )
668 : mValue( initialValue ),
669 mBaseValue( initialValue )
674 * Virtual destructor.
676 virtual ~AnimatableProperty()
681 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
683 virtual Dali::Property::Type GetType() const
685 return Dali::PropertyTypes::Get<Vector2>();
689 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
691 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
693 if (CLEAN_FLAG != mDirtyFlags)
695 mValue[updateBufferIndex] = mBaseValue;
697 mDirtyFlags = ( mDirtyFlags >> 1 );
702 * @copydoc Dali::PropertyInput::GetVector2()
704 virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
706 return mValue[ bufferIndex ];
710 * Set the property value. This will only persist for the current frame; the property
711 * will be reset with the base value, at the beginning of the next frame.
712 * @param[in] bufferIndex The buffer to write.
713 * @param[in] value The new property value.
715 void Set(BufferIndex bufferIndex, const Vector2& value)
717 mValue[bufferIndex] = value;
723 * Change the property value by a relative amount.
724 * @param[in] bufferIndex The buffer to write.
725 * @param[in] delta The property will change by this amount.
727 void SetRelative(BufferIndex bufferIndex, const Vector2& delta)
729 mValue[bufferIndex] += delta;
735 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
737 Vector2& Get(size_t bufferIndex)
739 return mValue[bufferIndex];
743 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
745 const Vector2& Get(size_t bufferIndex) const
747 return mValue[bufferIndex];
751 * Retrieve the property value.
752 * @param[in] bufferIndex The buffer to read.
753 * @return The property value.
755 Vector2& operator[](size_t bufferIndex)
757 return mValue[bufferIndex];
761 * Retrieve the property value.
762 * @param[in] bufferIndex The buffer to read.
763 * @return The property value.
765 const Vector2& operator[](size_t bufferIndex) const
767 return mValue[bufferIndex];
771 * Set both the property value & base value.
772 * @param[in] bufferIndex The buffer to write for the property value.
773 * @param[in] value The new property value.
775 void Bake(BufferIndex bufferIndex, const Vector2& value)
777 mValue[bufferIndex] = value;
784 * Change the property value & base value by a relative amount.
785 * @param[in] bufferIndex The buffer to write for the local property value.
786 * @param[in] delta The property will change by this amount.
788 void BakeRelative(BufferIndex bufferIndex, const Vector2& delta)
790 mValue[bufferIndex] += delta;
791 mBaseValue = mValue[bufferIndex];
799 AnimatableProperty(const AnimatableProperty& property);
802 AnimatableProperty& operator=(const AnimatableProperty& rhs);
806 DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
807 Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame
812 * A Vector3 animatable property of a scene-graph object.
815 class AnimatableProperty<Vector3> : public AnimatablePropertyBase
820 * Create an animatable property.
821 * @param [in] initialValue The initial value of the property.
823 AnimatableProperty( const Vector3& initialValue )
824 : mValue( initialValue ),
825 mBaseValue( initialValue )
830 * Virtual destructor.
832 virtual ~AnimatableProperty()
837 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
839 virtual Dali::Property::Type GetType() const
841 return Dali::PropertyTypes::Get<Vector3>();
845 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
847 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
849 if (CLEAN_FLAG != mDirtyFlags)
851 mValue[updateBufferIndex] = mBaseValue;
853 mDirtyFlags = ( mDirtyFlags >> 1 );
858 * @copydoc Dali::PropertyInput::GetVector3()
860 virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
862 return mValue[ bufferIndex ];
866 * Set the property value. This will only persist for the current frame; the property
867 * will be reset with the base value, at the beginning of the next frame.
868 * @param[in] bufferIndex The buffer to write.
869 * @param[in] value The new property value.
871 void Set(BufferIndex bufferIndex, const Vector3& value)
873 mValue[bufferIndex] = value;
879 * Set the property value. This will only persist for the current frame; the property
880 * will be reset with the base value, at the beginning of the next frame.
881 * @param[in] bufferIndex The buffer to write.
882 * @param[in] value The new X value.
884 void SetX(BufferIndex bufferIndex, float value)
886 mValue[bufferIndex].x = value;
892 * Set the property value. This will only persist for the current frame; the property
893 * will be reset with the base value, at the beginning of the next frame.
894 * @param[in] bufferIndex The buffer to write.
895 * @param[in] value The new Y value.
897 void SetY(BufferIndex bufferIndex, float value)
899 mValue[bufferIndex].y = value;
905 * Set the property value. This will only persist for the current frame; the property
906 * will be reset with the base value, at the beginning of the next frame.
907 * @param[in] bufferIndex The buffer to write.
908 * @param[in] value The new Z value.
910 void SetZ(BufferIndex bufferIndex, float value)
912 mValue[bufferIndex].z = value;
918 * Change the property value by a relative amount.
919 * @param[in] bufferIndex The buffer to write.
920 * @param[in] delta The property will change by this amount.
922 void SetRelative(BufferIndex bufferIndex, const Vector3& delta)
924 mValue[bufferIndex] += delta;
930 * Change the X value by a relative amount.
931 * @param[in] bufferIndex The buffer to write.
932 * @param[in] delta The X value will change by this amount.
934 void SetXRelative(BufferIndex bufferIndex, float delta)
936 mValue[bufferIndex].x += delta;
942 * Change the Y value by a relative amount.
943 * @param[in] bufferIndex The buffer to write.
944 * @param[in] delta The Y value will change by this amount.
946 void SetYRelative(BufferIndex bufferIndex, float delta)
948 mValue[bufferIndex].y += delta;
954 * Change the Z value by a relative amount.
955 * @param[in] bufferIndex The buffer to write.
956 * @param[in] delta The Z value will change by this amount.
958 void SetZRelative(BufferIndex bufferIndex, float delta)
960 mValue[bufferIndex].z += delta;
966 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
968 Vector3& Get(size_t bufferIndex)
970 return mValue[bufferIndex];
974 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
976 const Vector3& Get(size_t bufferIndex) const
978 return mValue[bufferIndex];
982 * Retrieve the property value.
983 * @param[in] bufferIndex The buffer to read.
984 * @return The property value.
986 Vector3& operator[](size_t bufferIndex)
988 return mValue[bufferIndex];
992 * Retrieve the property value.
993 * @param[in] bufferIndex The buffer to read.
994 * @return The property value.
996 const Vector3& operator[](size_t bufferIndex) const
998 return mValue[bufferIndex];
1002 * Set both the property value & base value.
1003 * @param[in] bufferIndex The buffer to write for the property value.
1004 * @param[in] value The new property value.
1006 void Bake(BufferIndex bufferIndex, const Vector3& value)
1008 mValue[bufferIndex] = value;
1015 * Set both the X value & base X value.
1016 * @param[in] bufferIndex The buffer to write for the property value.
1017 * @param[in] value The new property value.
1019 void BakeX(BufferIndex bufferIndex, float value)
1021 mValue[bufferIndex].x = value;
1022 mBaseValue.x = value;
1028 * Set both the Y value & base Y value.
1029 * @param[in] bufferIndex The buffer to write for the property value.
1030 * @param[in] value The new property value.
1032 void BakeY(BufferIndex bufferIndex, float value)
1034 mValue[bufferIndex].y = value;
1035 mBaseValue.y = value;
1041 * Set both the Z value & base Z value.
1042 * @param[in] bufferIndex The buffer to write for the property value.
1043 * @param[in] value The new property value.
1045 void BakeZ(BufferIndex bufferIndex, float value)
1047 mValue[bufferIndex].z = value;
1048 mBaseValue.z = value;
1054 * Change the property value & base value by a relative amount.
1055 * @param[in] bufferIndex The buffer to write for the local property value.
1056 * @param[in] delta The property will change by this amount.
1058 void BakeRelative(BufferIndex bufferIndex, const Vector3& delta)
1060 mValue[bufferIndex] += delta;
1061 mBaseValue = mValue[bufferIndex];
1067 * Change the property value & base value by a relative amount.
1068 * @param[in] bufferIndex The buffer to write for the local property value.
1069 * @param[in] delta The property will change by this amount.
1071 void BakeRelativeMultiply(BufferIndex bufferIndex, const Vector3& delta)
1073 mValue[bufferIndex] *= delta;
1074 mBaseValue = mValue[bufferIndex];
1080 * Change the X value & base X value by a relative amount.
1081 * @param[in] bufferIndex The buffer to write for the local property value.
1082 * @param[in] delta The X value will change by this amount.
1084 void BakeXRelative(BufferIndex bufferIndex, float delta)
1086 mValue[bufferIndex].x += delta;
1087 mBaseValue.x = mValue[bufferIndex].x;
1093 * Change the Y value & base Y value by a relative amount.
1094 * @param[in] bufferIndex The buffer to write for the local property value.
1095 * @param[in] delta The Y value will change by this amount.
1097 void BakeYRelative(BufferIndex bufferIndex, float delta)
1099 mValue[bufferIndex].y += delta;
1100 mBaseValue.y = mValue[bufferIndex].y;
1106 * Change the Z value & base Z value by a relative amount.
1107 * @param[in] bufferIndex The buffer to write for the local property value.
1108 * @param[in] delta The Z value will change by this amount.
1110 void BakeZRelative(BufferIndex bufferIndex, float delta)
1112 mValue[bufferIndex].z += delta;
1113 mBaseValue.z = mValue[bufferIndex].z;
1121 AnimatableProperty(const AnimatableProperty& property);
1124 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1128 DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
1129 Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame
1134 * A Vector4 animatable property of a scene-graph object.
1137 class AnimatableProperty<Vector4> : public AnimatablePropertyBase
1142 * Create an animatable property.
1143 * @param [in] initialValue The initial value of the property.
1145 AnimatableProperty( const Vector4& initialValue )
1146 : mValue( initialValue ),
1147 mBaseValue( initialValue )
1152 * Virtual destructor.
1154 virtual ~AnimatableProperty()
1159 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1161 virtual Dali::Property::Type GetType() const
1163 return Dali::PropertyTypes::Get<Vector4>();
1167 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1169 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1171 if (CLEAN_FLAG != mDirtyFlags)
1173 mValue[updateBufferIndex] = mBaseValue;
1175 mDirtyFlags = ( mDirtyFlags >> 1 );
1180 * @copydoc Dali::PropertyInput::GetVector4()
1182 virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
1184 return mValue[ bufferIndex ];
1188 * Set the property value. This will only persist for the current frame; the property
1189 * will be reset with the base value, at the beginning of the next frame.
1190 * @param[in] bufferIndex The buffer to write.
1191 * @param[in] value The new property value.
1193 void Set(BufferIndex bufferIndex, const Vector4& value)
1195 mValue[bufferIndex] = value;
1201 * Set the X value. This will only persist for the current frame; the property
1202 * will be reset with the base value, at the beginning of the next frame.
1203 * @param[in] bufferIndex The buffer to write.
1204 * @param[in] value The new X value.
1206 void SetX(BufferIndex bufferIndex, float value)
1208 mValue[bufferIndex].x = value;
1214 * Set the Y value. This will only persist for the current frame; the property
1215 * will be reset with the base value, at the beginning of the next frame.
1216 * @param[in] bufferIndex The buffer to write.
1217 * @param[in] value The new Y value.
1219 void SetY(BufferIndex bufferIndex, float value)
1221 mValue[bufferIndex].y = value;
1227 * Set the Z value. This will only persist for the current frame; the property
1228 * will be reset with the base value, at the beginning of the next frame.
1229 * @param[in] bufferIndex The buffer to write.
1230 * @param[in] value The new Z value.
1232 void SetZ(BufferIndex bufferIndex, float value)
1234 mValue[bufferIndex].z = value;
1240 * Set the W value. This will only persist for the current frame; the property
1241 * will be reset with the base value, at the beginning of the next frame.
1242 * @param[in] bufferIndex The buffer to write.
1243 * @param[in] value The new W value.
1245 void SetW(BufferIndex bufferIndex, float value)
1247 mValue[bufferIndex].w = value;
1253 * Change the property value by a relative amount.
1254 * @param[in] bufferIndex The buffer to write.
1255 * @param[in] delta The property will change by this amount.
1257 void SetRelative(BufferIndex bufferIndex, const Vector4& delta)
1259 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1265 * Change the X value by a relative amount.
1266 * @param[in] bufferIndex The buffer to write.
1267 * @param[in] delta The X value will change by this amount.
1269 void SetXRelative(BufferIndex bufferIndex, float delta)
1271 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1277 * Change the Y value by a relative amount.
1278 * @param[in] bufferIndex The buffer to write.
1279 * @param[in] delta The Y value will change by this amount.
1281 void SetYRelative(BufferIndex bufferIndex, float delta)
1283 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1289 * Change the Z value by a relative amount.
1290 * @param[in] bufferIndex The buffer to write.
1291 * @param[in] delta The Z value will change by this amount.
1293 void SetZRelative(BufferIndex bufferIndex, float delta)
1295 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1301 * Change the W value by a relative amount.
1302 * @param[in] bufferIndex The buffer to write.
1303 * @param[in] delta The W value will change by this amount.
1305 void SetWRelative(BufferIndex bufferIndex, float delta)
1307 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1313 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1315 Vector4& Get(size_t bufferIndex)
1317 return mValue[bufferIndex];
1321 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1323 const Vector4& Get(size_t bufferIndex) const
1325 return mValue[bufferIndex];
1329 * Retrieve the property value.
1330 * @param[in] bufferIndex The buffer to read.
1331 * @return The property value.
1333 Vector4& operator[](size_t bufferIndex)
1335 return mValue[bufferIndex];
1339 * Retrieve the property value.
1340 * @param[in] bufferIndex The buffer to read.
1341 * @return The property value.
1343 const Vector4& operator[](size_t bufferIndex) const
1345 return mValue[bufferIndex];
1349 * Set both the property value & base value.
1350 * @param[in] bufferIndex The buffer to write for the property value.
1351 * @param[in] value The new property value.
1353 void Bake(BufferIndex bufferIndex, const Vector4& value)
1355 mValue[bufferIndex] = value;
1356 mBaseValue = mValue[bufferIndex];
1362 * Set both the X value & base X value.
1363 * @param[in] bufferIndex The buffer to write for the property value.
1364 * @param[in] value The new property value.
1366 void BakeX(BufferIndex bufferIndex, float value)
1368 mValue[bufferIndex].x = value;
1369 mBaseValue.x = mValue[bufferIndex].x;
1375 * Set both the Y value & base Y value.
1376 * @param[in] bufferIndex The buffer to write for the property value.
1377 * @param[in] value The new property value.
1379 void BakeY(BufferIndex bufferIndex, float value)
1381 mValue[bufferIndex].y = value;
1382 mBaseValue.y = mValue[bufferIndex].y;
1388 * Set both the Z value & base Z value.
1389 * @param[in] bufferIndex The buffer to write for the property value.
1390 * @param[in] value The new property value.
1392 void BakeZ(BufferIndex bufferIndex, float value)
1394 mValue[bufferIndex].z = value;
1395 mBaseValue.z = mValue[bufferIndex].z;
1401 * Set both the W value & base W value.
1402 * @param[in] bufferIndex The buffer to write for the property value.
1403 * @param[in] value The new property value.
1405 void BakeW(BufferIndex bufferIndex, float value)
1407 mValue[bufferIndex].w = value;
1408 mBaseValue.w = mValue[bufferIndex].w;
1414 * Change the property value & base value by a relative amount.
1415 * @param[in] bufferIndex The buffer to write for the local property value.
1416 * @param[in] delta The property will change by this amount.
1418 void BakeRelative(BufferIndex bufferIndex, const Vector4& delta)
1420 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1421 mBaseValue = mValue[bufferIndex];
1427 * Change the X value & base X value by a relative amount.
1428 * @param[in] bufferIndex The buffer to write for the local property value.
1429 * @param[in] delta The X value will change by this amount.
1431 void BakeXRelative(BufferIndex bufferIndex, float delta)
1433 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1434 mBaseValue.x = mValue[bufferIndex].x;
1440 * Change the Y value & base Y value by a relative amount.
1441 * @param[in] bufferIndex The buffer to write for the local property value.
1442 * @param[in] delta The Y value will change by this amount.
1444 void BakeYRelative(BufferIndex bufferIndex, float delta)
1446 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1447 mBaseValue.y = mValue[bufferIndex].y;
1453 * Change the Z value & base Z value by a relative amount.
1454 * @param[in] bufferIndex The buffer to write for the local property value.
1455 * @param[in] delta The Z value will change by this amount.
1457 void BakeZRelative(BufferIndex bufferIndex, float delta)
1459 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1460 mBaseValue.z = mValue[bufferIndex].z;
1466 * Change the W value & base W value by a relative amount.
1467 * @param[in] bufferIndex The buffer to write for the local property value.
1468 * @param[in] delta The W value will change by this amount.
1470 void BakeWRelative(BufferIndex bufferIndex, float delta)
1472 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1473 mBaseValue.w = mValue[bufferIndex].w;
1479 * Sets both double-buffered W values & the base W value.
1480 * This should only be used when the owning object has not been connected to the scene-graph.
1481 * @param[in] value The new W value.
1483 void SetWInitial(float value)
1485 mValue[0].w = value;
1486 mValue[1].w = mValue[0].w;
1487 mBaseValue.w = mValue[0].w;
1493 AnimatableProperty(const AnimatableProperty& property);
1496 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1500 DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
1501 Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame
1505 * An Quaternion animatable property of a scene-graph object.
1508 class AnimatableProperty<Quaternion> : public AnimatablePropertyBase
1513 * Create an animatable property.
1514 * @param [in] initialValue The initial value of the property.
1516 AnimatableProperty( const Quaternion& initialValue )
1517 : mValue( initialValue ),
1518 mBaseValue( initialValue )
1523 * Virtual destructor.
1525 virtual ~AnimatableProperty()
1530 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1532 virtual Dali::Property::Type GetType() const
1534 return Dali::PropertyTypes::Get<Quaternion>();
1538 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1540 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1542 if (CLEAN_FLAG != mDirtyFlags)
1544 mValue[updateBufferIndex] = mBaseValue;
1546 mDirtyFlags = ( mDirtyFlags >> 1 );
1551 * @copydoc Dali::PropertyInput::GetQuaternion()
1553 virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
1555 return mValue[ bufferIndex ];
1559 * Set the property value. This will only persist for the current frame; the property
1560 * will be reset with the base value, at the beginning of the next frame.
1561 * @param[in] bufferIndex The buffer to write.
1562 * @param[in] value The new property value.
1564 void Set(BufferIndex bufferIndex, const Quaternion& value)
1566 mValue[bufferIndex] = value;
1572 * Change the property value by a relative amount.
1573 * @param[in] bufferIndex The buffer to write.
1574 * @param[in] delta The property will change by this amount.
1576 void SetRelative(BufferIndex bufferIndex, const Quaternion& delta)
1578 mValue[bufferIndex] *= delta;
1584 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1586 Quaternion& Get(size_t bufferIndex)
1588 return mValue[bufferIndex];
1592 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1594 const Quaternion& Get(size_t bufferIndex) const
1596 return mValue[bufferIndex];
1600 * Retrieve the property value.
1601 * @param[in] bufferIndex The buffer to read.
1602 * @return The property value.
1604 Quaternion& operator[](size_t bufferIndex)
1606 return mValue[bufferIndex];
1610 * Retrieve the property value.
1611 * @param[in] bufferIndex The buffer to read.
1612 * @return The property value.
1614 const Quaternion& operator[](size_t bufferIndex) const
1616 return mValue[bufferIndex];
1620 * Set both the property value & base value.
1621 * @param[in] bufferIndex The buffer to write for the property value.
1622 * @param[in] value The new property value.
1624 void Bake(BufferIndex bufferIndex, const Quaternion& value)
1626 mValue[bufferIndex] = value;
1633 * Change the property value & base value by a relative amount.
1634 * @param[in] bufferIndex The buffer to write for the local property value.
1635 * @param[in] delta The property will change by this amount.
1637 void BakeRelative(BufferIndex bufferIndex, const Quaternion& delta)
1639 mValue[bufferIndex] *= delta;
1640 mBaseValue = mValue[bufferIndex];
1648 AnimatableProperty(const AnimatableProperty& property);
1651 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1655 DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
1656 Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame
1661 * A Matrix animatable property of a scene-graph object.
1664 class AnimatableProperty<Matrix> : public AnimatablePropertyBase
1669 * Create an animatable property.
1670 * @param [in] initialValue The initial value of the property.
1672 AnimatableProperty( const Matrix& initialValue )
1673 : mValue( initialValue ),
1674 mBaseValue( initialValue )
1679 * Virtual destructor.
1681 virtual ~AnimatableProperty()
1686 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1688 virtual Dali::Property::Type GetType() const
1690 return Dali::PropertyTypes::Get<Matrix>();
1694 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1696 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1698 if (CLEAN_FLAG != mDirtyFlags)
1700 mValue[updateBufferIndex] = mBaseValue;
1702 mDirtyFlags = ( mDirtyFlags >> 1 );
1707 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
1709 virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
1711 return mValue[ bufferIndex ];
1715 * Set the property value. This will only persist for the current frame; the property
1716 * will be reset with the base value, at the beginning of the next frame.
1717 * @param[in] bufferIndex The buffer to write.
1718 * @param[in] value The new property value.
1720 void Set(BufferIndex bufferIndex, const Matrix& value)
1722 mValue[bufferIndex] = value;
1728 * Change the property value by a relative amount.
1729 * @param[in] bufferIndex The buffer to write.
1730 * @param[in] delta The property will change by this amount.
1732 void SetRelative(BufferIndex bufferIndex, const Matrix& delta)
1735 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1736 mValue[bufferIndex] = temp;
1742 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1744 Matrix& Get(size_t bufferIndex)
1746 return mValue[bufferIndex];
1750 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1752 const Matrix& Get(size_t bufferIndex) const
1754 return mValue[bufferIndex];
1758 * Retrieve the property value.
1759 * @param[in] bufferIndex The buffer to read.
1760 * @return The property value.
1762 Matrix& operator[](size_t bufferIndex)
1764 return mValue[bufferIndex];
1768 * Retrieve the property value.
1769 * @param[in] bufferIndex The buffer to read.
1770 * @return The property value.
1772 const Matrix& operator[](size_t bufferIndex) const
1774 return mValue[bufferIndex];
1778 * Set both the property value & base value.
1779 * @param[in] bufferIndex The buffer to write for the property value.
1780 * @param[in] value The new property value.
1782 void Bake(BufferIndex bufferIndex, const Matrix& value)
1784 mValue[bufferIndex] = value;
1785 mBaseValue = mValue[bufferIndex];
1791 * Change the property value & base value by a relative amount.
1792 * @param[in] bufferIndex The buffer to write for the local property value.
1793 * @param[in] delta The property will change by this amount.
1795 void BakeRelative(BufferIndex bufferIndex, const Matrix& delta)
1798 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1799 mValue[bufferIndex] = temp;
1808 AnimatableProperty(const AnimatableProperty& property);
1811 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1815 DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
1816 Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame
1821 * A Matrix3 animatable property of a scene-graph object.
1824 class AnimatableProperty<Matrix3> : public AnimatablePropertyBase
1829 * Create an animatable property.
1830 * @param [in] initialValue The initial value of the property.
1832 AnimatableProperty( const Matrix3& initialValue )
1833 : mValue( initialValue ),
1834 mBaseValue( initialValue )
1839 * Virtual destructor.
1841 virtual ~AnimatableProperty()
1846 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1848 virtual Dali::Property::Type GetType() const
1850 return Dali::PropertyTypes::Get<Matrix3>();
1854 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1856 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1858 if (CLEAN_FLAG != mDirtyFlags)
1860 mValue[updateBufferIndex] = mBaseValue;
1862 mDirtyFlags = ( mDirtyFlags >> 1 );
1867 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3()
1869 virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
1871 return mValue[ bufferIndex ];
1875 * Set the property value. This will only persist for the current frame; the property
1876 * will be reset with the base value, at the beginning of the next frame.
1877 * @param[in] bufferIndex The buffer to write.
1878 * @param[in] value The new property value.
1880 void Set(BufferIndex bufferIndex, const Matrix3& value)
1882 mValue[bufferIndex] = value;
1887 * Change the property value by a relative amount.
1888 * @param[in] bufferIndex The buffer to write.
1889 * @param[in] delta The property will change by this amount.
1891 void SetRelative(BufferIndex bufferIndex, const Matrix3& delta)
1894 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1895 mValue[bufferIndex] = temp;
1900 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1902 Matrix3& Get(size_t bufferIndex)
1904 return mValue[bufferIndex];
1908 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1910 const Matrix3& Get(size_t bufferIndex) const
1912 return mValue[bufferIndex];
1916 * Retrieve the property value.
1917 * @param[in] bufferIndex The buffer to read.
1918 * @return The property value.
1920 Matrix3& operator[](size_t bufferIndex)
1922 return mValue[bufferIndex];
1926 * Retrieve the property value.
1927 * @param[in] bufferIndex The buffer to read.
1928 * @return The property value.
1930 const Matrix3& operator[](size_t bufferIndex) const
1932 return mValue[bufferIndex];
1936 * Set both the property value & base value.
1937 * @param[in] bufferIndex The buffer to write for the property value.
1938 * @param[in] value The new property value.
1940 void Bake(BufferIndex bufferIndex, const Matrix3& value)
1942 mValue[bufferIndex] = value;
1943 mBaseValue = mValue[bufferIndex];
1949 * Change the property value & base value by a relative amount.
1950 * @param[in] bufferIndex The buffer to write for the local property value.
1951 * @param[in] delta The property will change by this amount.
1953 void BakeRelative(BufferIndex bufferIndex, const Matrix3& delta)
1956 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1957 mValue[bufferIndex] = temp;
1966 AnimatableProperty(const AnimatableProperty& property);
1969 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1973 DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
1974 Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame
1978 } // namespace SceneGraph
1980 // Messages for AnimatableProperty<T>
1983 void BakeMessage( EventToUpdate& eventToUpdate,
1984 const SceneGraph::AnimatableProperty<T>& property,
1985 typename ParameterType< T >::PassingType newValue )
1987 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, T > LocalType;
1989 // Reserve some memory inside the message queue
1990 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1992 // Construct message in the message queue memory; note that delete should not be called on the return value
1993 new (slot) LocalType( &property,
1994 &SceneGraph::AnimatableProperty<T>::Bake,
1999 void BakeRelativeMessage( EventToUpdate& eventToUpdate,
2000 const SceneGraph::AnimatableProperty<T>& property,
2003 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, const T& > LocalType;
2005 // Reserve some memory inside the message queue
2006 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
2008 // Construct message in the message queue memory; note that delete should not be called on the return value
2009 new (slot) LocalType( &property,
2010 &SceneGraph::AnimatableProperty<T>::BakeRelative,
2015 void SetXComponentMessage( EventToUpdate& eventToUpdate,
2016 const SceneGraph::AnimatableProperty<T>& property,
2017 typename ParameterType< float >::PassingType newValue )
2019 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
2021 // Reserve some memory inside the message queue
2022 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
2024 // Construct message in the message queue memory; note that delete should not be called on the return value
2025 new (slot) LocalType( &property,
2026 &SceneGraph::AnimatableProperty<T>::BakeX,
2031 void SetYComponentMessage( EventToUpdate& eventToUpdate,
2032 const SceneGraph::AnimatableProperty<T>& property,
2033 typename ParameterType< float >::PassingType newValue )
2035 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
2037 // Reserve some memory inside the message queue
2038 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
2040 // Construct message in the message queue memory; note that delete should not be called on the return value
2041 new (slot) LocalType( &property,
2042 &SceneGraph::AnimatableProperty<T>::BakeY,
2047 void SetZComponentMessage( EventToUpdate& eventToUpdate,
2048 const SceneGraph::AnimatableProperty<T>& property,
2049 typename ParameterType< float >::PassingType newValue )
2051 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
2053 // Reserve some memory inside the message queue
2054 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
2056 // Construct message in the message queue memory; note that delete should not be called on the return value
2057 new (slot) LocalType( &property,
2058 &SceneGraph::AnimatableProperty<T>::BakeZ,
2063 void SetWComponentMessage( EventToUpdate& eventToUpdate,
2064 const SceneGraph::AnimatableProperty<T>& property,
2065 typename ParameterType< float >::PassingType newValue )
2067 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
2069 // Reserve some memory inside the message queue
2070 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
2072 // Construct message in the message queue memory; note that delete should not be called on the return value
2073 new (slot) LocalType( &property,
2074 &SceneGraph::AnimatableProperty<T>::BakeW,
2078 } // namespace Internal
2082 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__