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 Vector2 animatable property of a scene-graph object.
479 class AnimatableProperty<Vector2> : public AnimatablePropertyBase
484 * Create an animatable property.
485 * @param [in] initialValue The initial value of the property.
487 AnimatableProperty( const Vector2& 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<Vector2>();
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::PropertyInput::GetVector2()
524 virtual const Vector2& GetVector2( 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, const Vector2& 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, const Vector2& delta)
549 mValue[bufferIndex] += delta;
555 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
557 Vector2& Get(size_t bufferIndex)
559 return mValue[bufferIndex];
563 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
565 const Vector2& 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 Vector2& 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 Vector2& 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, const Vector2& value)
597 mValue[bufferIndex] = value;
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, const Vector2& delta)
610 mValue[bufferIndex] += delta;
611 mBaseValue = mValue[bufferIndex];
619 AnimatableProperty(const AnimatableProperty& property);
622 AnimatableProperty& operator=(const AnimatableProperty& rhs);
626 DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
627 Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame
632 * A Vector3 animatable property of a scene-graph object.
635 class AnimatableProperty<Vector3> : public AnimatablePropertyBase
640 * Create an animatable property.
641 * @param [in] initialValue The initial value of the property.
643 AnimatableProperty( const Vector3& initialValue )
644 : mValue( initialValue ),
645 mBaseValue( initialValue )
650 * Virtual destructor.
652 virtual ~AnimatableProperty()
657 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
659 virtual Dali::Property::Type GetType() const
661 return Dali::PropertyTypes::Get<Vector3>();
665 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
667 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
669 if (CLEAN_FLAG != mDirtyFlags)
671 mValue[updateBufferIndex] = mBaseValue;
673 mDirtyFlags = ( mDirtyFlags >> 1 );
678 * @copydoc Dali::PropertyInput::GetVector3()
680 virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
682 return mValue[ bufferIndex ];
686 * Set the property value. This will only persist for the current frame; the property
687 * will be reset with the base value, at the beginning of the next frame.
688 * @param[in] bufferIndex The buffer to write.
689 * @param[in] value The new property value.
691 void Set(BufferIndex bufferIndex, const Vector3& value)
693 mValue[bufferIndex] = value;
699 * Set the property value. This will only persist for the current frame; the property
700 * will be reset with the base value, at the beginning of the next frame.
701 * @param[in] bufferIndex The buffer to write.
702 * @param[in] value The new X value.
704 void SetX(BufferIndex bufferIndex, float value)
706 mValue[bufferIndex].x = value;
712 * Set the property value. This will only persist for the current frame; the property
713 * will be reset with the base value, at the beginning of the next frame.
714 * @param[in] bufferIndex The buffer to write.
715 * @param[in] value The new Y value.
717 void SetY(BufferIndex bufferIndex, float value)
719 mValue[bufferIndex].y = value;
725 * Set the property value. This will only persist for the current frame; the property
726 * will be reset with the base value, at the beginning of the next frame.
727 * @param[in] bufferIndex The buffer to write.
728 * @param[in] value The new Z value.
730 void SetZ(BufferIndex bufferIndex, float value)
732 mValue[bufferIndex].z = value;
738 * Change the property value by a relative amount.
739 * @param[in] bufferIndex The buffer to write.
740 * @param[in] delta The property will change by this amount.
742 void SetRelative(BufferIndex bufferIndex, const Vector3& delta)
744 mValue[bufferIndex] += delta;
750 * Change the X value by a relative amount.
751 * @param[in] bufferIndex The buffer to write.
752 * @param[in] delta The X value will change by this amount.
754 void SetXRelative(BufferIndex bufferIndex, float delta)
756 mValue[bufferIndex].x += delta;
762 * Change the Y value by a relative amount.
763 * @param[in] bufferIndex The buffer to write.
764 * @param[in] delta The Y value will change by this amount.
766 void SetYRelative(BufferIndex bufferIndex, float delta)
768 mValue[bufferIndex].y += delta;
774 * Change the Z value by a relative amount.
775 * @param[in] bufferIndex The buffer to write.
776 * @param[in] delta The Z value will change by this amount.
778 void SetZRelative(BufferIndex bufferIndex, float delta)
780 mValue[bufferIndex].z += delta;
786 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
788 Vector3& Get(size_t bufferIndex)
790 return mValue[bufferIndex];
794 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
796 const Vector3& Get(size_t bufferIndex) const
798 return mValue[bufferIndex];
802 * Retrieve the property value.
803 * @param[in] bufferIndex The buffer to read.
804 * @return The property value.
806 Vector3& operator[](size_t bufferIndex)
808 return mValue[bufferIndex];
812 * Retrieve the property value.
813 * @param[in] bufferIndex The buffer to read.
814 * @return The property value.
816 const Vector3& operator[](size_t bufferIndex) const
818 return mValue[bufferIndex];
822 * Set both the property value & base value.
823 * @param[in] bufferIndex The buffer to write for the property value.
824 * @param[in] value The new property value.
826 void Bake(BufferIndex bufferIndex, const Vector3& value)
828 mValue[bufferIndex] = value;
835 * Set both the X value & base X value.
836 * @param[in] bufferIndex The buffer to write for the property value.
837 * @param[in] value The new property value.
839 void BakeX(BufferIndex bufferIndex, float value)
841 mValue[bufferIndex].x = value;
842 mBaseValue.x = value;
848 * Set both the Y value & base Y value.
849 * @param[in] bufferIndex The buffer to write for the property value.
850 * @param[in] value The new property value.
852 void BakeY(BufferIndex bufferIndex, float value)
854 mValue[bufferIndex].y = value;
855 mBaseValue.y = value;
861 * Set both the Z value & base Z value.
862 * @param[in] bufferIndex The buffer to write for the property value.
863 * @param[in] value The new property value.
865 void BakeZ(BufferIndex bufferIndex, float value)
867 mValue[bufferIndex].z = value;
868 mBaseValue.z = value;
874 * Change the property value & base value by a relative amount.
875 * @param[in] bufferIndex The buffer to write for the local property value.
876 * @param[in] delta The property will change by this amount.
878 void BakeRelative(BufferIndex bufferIndex, const Vector3& delta)
880 mValue[bufferIndex] += delta;
881 mBaseValue = mValue[bufferIndex];
887 * Change the property value & base value by a relative amount.
888 * @param[in] bufferIndex The buffer to write for the local property value.
889 * @param[in] delta The property will change by this amount.
891 void BakeRelativeMultiply(BufferIndex bufferIndex, const Vector3& delta)
893 mValue[bufferIndex] *= delta;
894 mBaseValue = mValue[bufferIndex];
900 * Change the X value & base X value by a relative amount.
901 * @param[in] bufferIndex The buffer to write for the local property value.
902 * @param[in] delta The X value will change by this amount.
904 void BakeXRelative(BufferIndex bufferIndex, float delta)
906 mValue[bufferIndex].x += delta;
907 mBaseValue.x = mValue[bufferIndex].x;
913 * Change the Y value & base Y value by a relative amount.
914 * @param[in] bufferIndex The buffer to write for the local property value.
915 * @param[in] delta The Y value will change by this amount.
917 void BakeYRelative(BufferIndex bufferIndex, float delta)
919 mValue[bufferIndex].y += delta;
920 mBaseValue.y = mValue[bufferIndex].y;
926 * Change the Z value & base Z value by a relative amount.
927 * @param[in] bufferIndex The buffer to write for the local property value.
928 * @param[in] delta The Z value will change by this amount.
930 void BakeZRelative(BufferIndex bufferIndex, float delta)
932 mValue[bufferIndex].z += delta;
933 mBaseValue.z = mValue[bufferIndex].z;
941 AnimatableProperty(const AnimatableProperty& property);
944 AnimatableProperty& operator=(const AnimatableProperty& rhs);
948 DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
949 Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame
954 * A Vector4 animatable property of a scene-graph object.
957 class AnimatableProperty<Vector4> : public AnimatablePropertyBase
962 * Create an animatable property.
963 * @param [in] initialValue The initial value of the property.
965 AnimatableProperty( const Vector4& initialValue )
966 : mValue( initialValue ),
967 mBaseValue( initialValue )
972 * Virtual destructor.
974 virtual ~AnimatableProperty()
979 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
981 virtual Dali::Property::Type GetType() const
983 return Dali::PropertyTypes::Get<Vector4>();
987 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
989 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
991 if (CLEAN_FLAG != mDirtyFlags)
993 mValue[updateBufferIndex] = mBaseValue;
995 mDirtyFlags = ( mDirtyFlags >> 1 );
1000 * @copydoc Dali::PropertyInput::GetVector4()
1002 virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
1004 return mValue[ bufferIndex ];
1008 * Set the property value. This will only persist for the current frame; the property
1009 * will be reset with the base value, at the beginning of the next frame.
1010 * @param[in] bufferIndex The buffer to write.
1011 * @param[in] value The new property value.
1013 void Set(BufferIndex bufferIndex, const Vector4& value)
1015 mValue[bufferIndex] = value;
1021 * Set the X value. This will only persist for the current frame; the property
1022 * will be reset with the base value, at the beginning of the next frame.
1023 * @param[in] bufferIndex The buffer to write.
1024 * @param[in] value The new X value.
1026 void SetX(BufferIndex bufferIndex, float value)
1028 mValue[bufferIndex].x = value;
1034 * Set the Y value. This will only persist for the current frame; the property
1035 * will be reset with the base value, at the beginning of the next frame.
1036 * @param[in] bufferIndex The buffer to write.
1037 * @param[in] value The new Y value.
1039 void SetY(BufferIndex bufferIndex, float value)
1041 mValue[bufferIndex].y = value;
1047 * Set the Z value. This will only persist for the current frame; the property
1048 * will be reset with the base value, at the beginning of the next frame.
1049 * @param[in] bufferIndex The buffer to write.
1050 * @param[in] value The new Z value.
1052 void SetZ(BufferIndex bufferIndex, float value)
1054 mValue[bufferIndex].z = value;
1060 * Set the W value. This will only persist for the current frame; the property
1061 * will be reset with the base value, at the beginning of the next frame.
1062 * @param[in] bufferIndex The buffer to write.
1063 * @param[in] value The new W value.
1065 void SetW(BufferIndex bufferIndex, float value)
1067 mValue[bufferIndex].w = value;
1073 * Change the property value by a relative amount.
1074 * @param[in] bufferIndex The buffer to write.
1075 * @param[in] delta The property will change by this amount.
1077 void SetRelative(BufferIndex bufferIndex, const Vector4& delta)
1079 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1085 * Change the X value by a relative amount.
1086 * @param[in] bufferIndex The buffer to write.
1087 * @param[in] delta The X value will change by this amount.
1089 void SetXRelative(BufferIndex bufferIndex, float delta)
1091 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1097 * Change the Y value by a relative amount.
1098 * @param[in] bufferIndex The buffer to write.
1099 * @param[in] delta The Y value will change by this amount.
1101 void SetYRelative(BufferIndex bufferIndex, float delta)
1103 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1109 * Change the Z value by a relative amount.
1110 * @param[in] bufferIndex The buffer to write.
1111 * @param[in] delta The Z value will change by this amount.
1113 void SetZRelative(BufferIndex bufferIndex, float delta)
1115 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1121 * Change the W value by a relative amount.
1122 * @param[in] bufferIndex The buffer to write.
1123 * @param[in] delta The W value will change by this amount.
1125 void SetWRelative(BufferIndex bufferIndex, float delta)
1127 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1133 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1135 Vector4& Get(size_t bufferIndex)
1137 return mValue[bufferIndex];
1141 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1143 const Vector4& Get(size_t bufferIndex) const
1145 return mValue[bufferIndex];
1149 * Retrieve the property value.
1150 * @param[in] bufferIndex The buffer to read.
1151 * @return The property value.
1153 Vector4& operator[](size_t bufferIndex)
1155 return mValue[bufferIndex];
1159 * Retrieve the property value.
1160 * @param[in] bufferIndex The buffer to read.
1161 * @return The property value.
1163 const Vector4& operator[](size_t bufferIndex) const
1165 return mValue[bufferIndex];
1169 * Set both the property value & base value.
1170 * @param[in] bufferIndex The buffer to write for the property value.
1171 * @param[in] value The new property value.
1173 void Bake(BufferIndex bufferIndex, const Vector4& value)
1175 mValue[bufferIndex] = value;
1176 mBaseValue = mValue[bufferIndex];
1182 * Set both the X value & base X value.
1183 * @param[in] bufferIndex The buffer to write for the property value.
1184 * @param[in] value The new property value.
1186 void BakeX(BufferIndex bufferIndex, float value)
1188 mValue[bufferIndex].x = value;
1189 mBaseValue.x = mValue[bufferIndex].x;
1195 * Set both the Y value & base Y value.
1196 * @param[in] bufferIndex The buffer to write for the property value.
1197 * @param[in] value The new property value.
1199 void BakeY(BufferIndex bufferIndex, float value)
1201 mValue[bufferIndex].y = value;
1202 mBaseValue.y = mValue[bufferIndex].y;
1208 * Set both the Z value & base Z value.
1209 * @param[in] bufferIndex The buffer to write for the property value.
1210 * @param[in] value The new property value.
1212 void BakeZ(BufferIndex bufferIndex, float value)
1214 mValue[bufferIndex].z = value;
1215 mBaseValue.z = mValue[bufferIndex].z;
1221 * Set both the W value & base W value.
1222 * @param[in] bufferIndex The buffer to write for the property value.
1223 * @param[in] value The new property value.
1225 void BakeW(BufferIndex bufferIndex, float value)
1227 mValue[bufferIndex].w = value;
1228 mBaseValue.w = mValue[bufferIndex].w;
1234 * Change the property value & base value by a relative amount.
1235 * @param[in] bufferIndex The buffer to write for the local property value.
1236 * @param[in] delta The property will change by this amount.
1238 void BakeRelative(BufferIndex bufferIndex, const Vector4& delta)
1240 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1241 mBaseValue = mValue[bufferIndex];
1247 * Change the X value & base X value by a relative amount.
1248 * @param[in] bufferIndex The buffer to write for the local property value.
1249 * @param[in] delta The X value will change by this amount.
1251 void BakeXRelative(BufferIndex bufferIndex, float delta)
1253 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1254 mBaseValue.x = mValue[bufferIndex].x;
1260 * Change the Y value & base Y value by a relative amount.
1261 * @param[in] bufferIndex The buffer to write for the local property value.
1262 * @param[in] delta The Y value will change by this amount.
1264 void BakeYRelative(BufferIndex bufferIndex, float delta)
1266 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1267 mBaseValue.y = mValue[bufferIndex].y;
1273 * Change the Z value & base Z value by a relative amount.
1274 * @param[in] bufferIndex The buffer to write for the local property value.
1275 * @param[in] delta The Z value will change by this amount.
1277 void BakeZRelative(BufferIndex bufferIndex, float delta)
1279 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1280 mBaseValue.z = mValue[bufferIndex].z;
1286 * Change the W value & base W value by a relative amount.
1287 * @param[in] bufferIndex The buffer to write for the local property value.
1288 * @param[in] delta The W value will change by this amount.
1290 void BakeWRelative(BufferIndex bufferIndex, float delta)
1292 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1293 mBaseValue.w = mValue[bufferIndex].w;
1299 * Sets both double-buffered W values & the base W value.
1300 * This should only be used when the owning object has not been connected to the scene-graph.
1301 * @param[in] value The new W value.
1303 void SetWInitial(float value)
1305 mValue[0].w = value;
1306 mValue[1].w = mValue[0].w;
1307 mBaseValue.w = mValue[0].w;
1313 AnimatableProperty(const AnimatableProperty& property);
1316 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1320 DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
1321 Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame
1325 * An Quaternion animatable property of a scene-graph object.
1328 class AnimatableProperty<Quaternion> : public AnimatablePropertyBase
1333 * Create an animatable property.
1334 * @param [in] initialValue The initial value of the property.
1336 AnimatableProperty( const Quaternion& initialValue )
1337 : mValue( initialValue ),
1338 mBaseValue( initialValue )
1343 * Virtual destructor.
1345 virtual ~AnimatableProperty()
1350 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1352 virtual Dali::Property::Type GetType() const
1354 return Dali::PropertyTypes::Get<Quaternion>();
1358 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1360 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1362 if (CLEAN_FLAG != mDirtyFlags)
1364 mValue[updateBufferIndex] = mBaseValue;
1366 mDirtyFlags = ( mDirtyFlags >> 1 );
1371 * @copydoc Dali::PropertyInput::GetQuaternion()
1373 virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
1375 return mValue[ bufferIndex ];
1379 * Set the property value. This will only persist for the current frame; the property
1380 * will be reset with the base value, at the beginning of the next frame.
1381 * @param[in] bufferIndex The buffer to write.
1382 * @param[in] value The new property value.
1384 void Set(BufferIndex bufferIndex, const Quaternion& value)
1386 mValue[bufferIndex] = value;
1392 * Change the property value by a relative amount.
1393 * @param[in] bufferIndex The buffer to write.
1394 * @param[in] delta The property will change by this amount.
1396 void SetRelative(BufferIndex bufferIndex, const Quaternion& delta)
1398 mValue[bufferIndex] *= delta;
1404 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1406 Quaternion& Get(size_t bufferIndex)
1408 return mValue[bufferIndex];
1412 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1414 const Quaternion& Get(size_t bufferIndex) const
1416 return mValue[bufferIndex];
1420 * Retrieve the property value.
1421 * @param[in] bufferIndex The buffer to read.
1422 * @return The property value.
1424 Quaternion& operator[](size_t bufferIndex)
1426 return mValue[bufferIndex];
1430 * Retrieve the property value.
1431 * @param[in] bufferIndex The buffer to read.
1432 * @return The property value.
1434 const Quaternion& operator[](size_t bufferIndex) const
1436 return mValue[bufferIndex];
1440 * Set both the property value & base value.
1441 * @param[in] bufferIndex The buffer to write for the property value.
1442 * @param[in] value The new property value.
1444 void Bake(BufferIndex bufferIndex, const Quaternion& value)
1446 mValue[bufferIndex] = value;
1453 * Change the property value & base value by a relative amount.
1454 * @param[in] bufferIndex The buffer to write for the local property value.
1455 * @param[in] delta The property will change by this amount.
1457 void BakeRelative(BufferIndex bufferIndex, const Quaternion& delta)
1459 mValue[bufferIndex] *= delta;
1460 mBaseValue = mValue[bufferIndex];
1468 AnimatableProperty(const AnimatableProperty& property);
1471 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1475 DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
1476 Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame
1481 * A Matrix animatable property of a scene-graph object.
1484 class AnimatableProperty<Matrix> : public AnimatablePropertyBase
1489 * Create an animatable property.
1490 * @param [in] initialValue The initial value of the property.
1492 AnimatableProperty( const Matrix& initialValue )
1493 : mValue( initialValue ),
1494 mBaseValue( initialValue )
1499 * Virtual destructor.
1501 virtual ~AnimatableProperty()
1506 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1508 virtual Dali::Property::Type GetType() const
1510 return Dali::PropertyTypes::Get<Matrix>();
1514 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1516 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1518 if (CLEAN_FLAG != mDirtyFlags)
1520 mValue[updateBufferIndex] = mBaseValue;
1522 mDirtyFlags = ( mDirtyFlags >> 1 );
1527 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
1529 virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
1531 return mValue[ bufferIndex ];
1535 * Set the property value. This will only persist for the current frame; the property
1536 * will be reset with the base value, at the beginning of the next frame.
1537 * @param[in] bufferIndex The buffer to write.
1538 * @param[in] value The new property value.
1540 void Set(BufferIndex bufferIndex, const Matrix& value)
1542 mValue[bufferIndex] = value;
1548 * Change the property value by a relative amount.
1549 * @param[in] bufferIndex The buffer to write.
1550 * @param[in] delta The property will change by this amount.
1552 void SetRelative(BufferIndex bufferIndex, const Matrix& delta)
1555 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1556 mValue[bufferIndex] = temp;
1562 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1564 Matrix& Get(size_t bufferIndex)
1566 return mValue[bufferIndex];
1570 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1572 const Matrix& Get(size_t bufferIndex) const
1574 return mValue[bufferIndex];
1578 * Retrieve the property value.
1579 * @param[in] bufferIndex The buffer to read.
1580 * @return The property value.
1582 Matrix& operator[](size_t bufferIndex)
1584 return mValue[bufferIndex];
1588 * Retrieve the property value.
1589 * @param[in] bufferIndex The buffer to read.
1590 * @return The property value.
1592 const Matrix& operator[](size_t bufferIndex) const
1594 return mValue[bufferIndex];
1598 * Set both the property value & base value.
1599 * @param[in] bufferIndex The buffer to write for the property value.
1600 * @param[in] value The new property value.
1602 void Bake(BufferIndex bufferIndex, const Matrix& value)
1604 mValue[bufferIndex] = value;
1605 mBaseValue = mValue[bufferIndex];
1611 * Change the property value & base value by a relative amount.
1612 * @param[in] bufferIndex The buffer to write for the local property value.
1613 * @param[in] delta The property will change by this amount.
1615 void BakeRelative(BufferIndex bufferIndex, const Matrix& delta)
1618 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1619 mValue[bufferIndex] = temp;
1628 AnimatableProperty(const AnimatableProperty& property);
1631 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1635 DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
1636 Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame
1641 * A Matrix3 animatable property of a scene-graph object.
1644 class AnimatableProperty<Matrix3> : public AnimatablePropertyBase
1649 * Create an animatable property.
1650 * @param [in] initialValue The initial value of the property.
1652 AnimatableProperty( const Matrix3& initialValue )
1653 : mValue( initialValue ),
1654 mBaseValue( initialValue )
1659 * Virtual destructor.
1661 virtual ~AnimatableProperty()
1666 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1668 virtual Dali::Property::Type GetType() const
1670 return Dali::PropertyTypes::Get<Matrix3>();
1674 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1676 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1678 if (CLEAN_FLAG != mDirtyFlags)
1680 mValue[updateBufferIndex] = mBaseValue;
1682 mDirtyFlags = ( mDirtyFlags >> 1 );
1687 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3()
1689 virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
1691 return mValue[ bufferIndex ];
1695 * Set the property value. This will only persist for the current frame; the property
1696 * will be reset with the base value, at the beginning of the next frame.
1697 * @param[in] bufferIndex The buffer to write.
1698 * @param[in] value The new property value.
1700 void Set(BufferIndex bufferIndex, const Matrix3& value)
1702 mValue[bufferIndex] = value;
1707 * Change the property value by a relative amount.
1708 * @param[in] bufferIndex The buffer to write.
1709 * @param[in] delta The property will change by this amount.
1711 void SetRelative(BufferIndex bufferIndex, const Matrix3& delta)
1714 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1715 mValue[bufferIndex] = temp;
1720 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1722 Matrix3& Get(size_t bufferIndex)
1724 return mValue[bufferIndex];
1728 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1730 const Matrix3& Get(size_t bufferIndex) const
1732 return mValue[bufferIndex];
1736 * Retrieve the property value.
1737 * @param[in] bufferIndex The buffer to read.
1738 * @return The property value.
1740 Matrix3& operator[](size_t bufferIndex)
1742 return mValue[bufferIndex];
1746 * Retrieve the property value.
1747 * @param[in] bufferIndex The buffer to read.
1748 * @return The property value.
1750 const Matrix3& operator[](size_t bufferIndex) const
1752 return mValue[bufferIndex];
1756 * Set both the property value & base value.
1757 * @param[in] bufferIndex The buffer to write for the property value.
1758 * @param[in] value The new property value.
1760 void Bake(BufferIndex bufferIndex, const Matrix3& value)
1762 mValue[bufferIndex] = value;
1763 mBaseValue = mValue[bufferIndex];
1769 * Change the property value & base value by a relative amount.
1770 * @param[in] bufferIndex The buffer to write for the local property value.
1771 * @param[in] delta The property will change by this amount.
1773 void BakeRelative(BufferIndex bufferIndex, const Matrix3& delta)
1776 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1777 mValue[bufferIndex] = temp;
1786 AnimatableProperty(const AnimatableProperty& property);
1789 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1793 DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
1794 Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame
1798 } // namespace SceneGraph
1800 // Messages for AnimatableProperty<T>
1803 void BakeMessage( EventToUpdate& eventToUpdate,
1804 const SceneGraph::AnimatableProperty<T>& property,
1805 typename ParameterType< T >::PassingType newValue )
1807 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, T > LocalType;
1809 // Reserve some memory inside the message queue
1810 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1812 // Construct message in the message queue memory; note that delete should not be called on the return value
1813 new (slot) LocalType( &property,
1814 &SceneGraph::AnimatableProperty<T>::Bake,
1819 void BakeRelativeMessage( EventToUpdate& eventToUpdate,
1820 const SceneGraph::AnimatableProperty<T>& property,
1823 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, const T& > LocalType;
1825 // Reserve some memory inside the message queue
1826 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1828 // Construct message in the message queue memory; note that delete should not be called on the return value
1829 new (slot) LocalType( &property,
1830 &SceneGraph::AnimatableProperty<T>::BakeRelative,
1835 void SetXComponentMessage( EventToUpdate& eventToUpdate,
1836 const SceneGraph::AnimatableProperty<T>& property,
1837 typename ParameterType< float >::PassingType newValue )
1839 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1841 // Reserve some memory inside the message queue
1842 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1844 // Construct message in the message queue memory; note that delete should not be called on the return value
1845 new (slot) LocalType( &property,
1846 &SceneGraph::AnimatableProperty<T>::BakeX,
1851 void SetYComponentMessage( EventToUpdate& eventToUpdate,
1852 const SceneGraph::AnimatableProperty<T>& property,
1853 typename ParameterType< float >::PassingType newValue )
1855 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1857 // Reserve some memory inside the message queue
1858 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1860 // Construct message in the message queue memory; note that delete should not be called on the return value
1861 new (slot) LocalType( &property,
1862 &SceneGraph::AnimatableProperty<T>::BakeY,
1867 void SetZComponentMessage( EventToUpdate& eventToUpdate,
1868 const SceneGraph::AnimatableProperty<T>& property,
1869 typename ParameterType< float >::PassingType newValue )
1871 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1873 // Reserve some memory inside the message queue
1874 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1876 // Construct message in the message queue memory; note that delete should not be called on the return value
1877 new (slot) LocalType( &property,
1878 &SceneGraph::AnimatableProperty<T>::BakeZ,
1883 void SetWComponentMessage( EventToUpdate& eventToUpdate,
1884 const SceneGraph::AnimatableProperty<T>& property,
1885 typename ParameterType< float >::PassingType newValue )
1887 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1889 // Reserve some memory inside the message queue
1890 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1892 // Construct message in the message queue memory; note that delete should not be called on the return value
1893 new (slot) LocalType( &property,
1894 &SceneGraph::AnimatableProperty<T>::BakeW,
1898 } // namespace Internal
1902 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__