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 Flora License, Version 1.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://floralicense.org/license/
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.
24 #include <dali/public-api/common/dali-common.h>
25 #include <dali/public-api/object/property.h>
26 #include <dali/public-api/object/property-input.h>
27 #include <dali/public-api/object/property-types.h>
28 #include <dali/internal/common/message.h>
29 #include <dali/internal/common/event-to-update.h>
30 #include <dali/internal/event/common/property-input-impl.h>
31 #include <dali/internal/update/common/double-buffered.h>
32 #include <dali/internal/update/common/property-base.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
45 * Dirty flags record whether an animatable property has changed.
46 * In the frame following a change, the property is reset to a base value.
48 * If the property was "Baked", then the base value matches the (double-buffered) value from the previous frame.
49 * Therefore when reset, the property is flagged as "clean".
51 * However if the property was only "Set" (and not "Baked"), then typically the base value and previous value will not match.
52 * In this case the reset operation is equivalent to a "Bake", and the value is considered "dirty" for an additional frame.
54 static const unsigned int CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame
55 static const unsigned int BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
56 static const unsigned int SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame
59 class AnimatableProperty;
62 * Base class to reduce code size from the templates.
64 class AnimatablePropertyBase : public PropertyBase
69 * Constructor, initialize the dirty flag
71 AnimatablePropertyBase()
73 mDirtyFlags( BAKED_FLAG )
79 virtual ~AnimatablePropertyBase()
82 protected: // for derived classes
85 * Flag that the property has been Set during the current frame.
89 mDirtyFlags = SET_FLAG;
93 * Flag that the property has been Baked during the current frame.
97 mDirtyFlags = BAKED_FLAG;
100 public: // From PropertyBase
103 * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
105 virtual bool IsClean() const
107 return ( CLEAN_FLAG == mDirtyFlags );
111 * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
113 virtual bool InputInitialized() const
115 return true; // Animatable properties are always valid
118 protected: // so that ResetToBaseValue can set it directly
120 unsigned int mDirtyFlags; ///< Flag whether value changed during previous 2 frames
126 * An boolean animatable property of a scene-graph object.
129 class AnimatableProperty<bool> : public AnimatablePropertyBase
134 * Create an animatable property.
135 * @param [in] initialValue The initial value of the property.
137 AnimatableProperty( bool initialValue )
138 : mValue( initialValue ),
139 mBaseValue( initialValue )
144 * Virtual destructor.
146 virtual ~AnimatableProperty()
151 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
153 virtual Dali::Property::Type GetType() const
155 return Dali::PropertyTypes::Get<bool>();
159 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
161 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
163 if (CLEAN_FLAG != mDirtyFlags)
165 mValue[updateBufferIndex] = mBaseValue;
167 mDirtyFlags = ( mDirtyFlags >> 1 );
172 * @copydoc Dali::Internal::PropertyInputImpl::GetBoolean()
174 virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
176 return mValue[ bufferIndex ];
180 * Set the property value. This will only persist for the current frame; the property
181 * will be reset with the base value, at the beginning of the next frame.
182 * @param[in] bufferIndex The buffer to write.
183 * @param[in] value The new property value.
185 void Set(BufferIndex bufferIndex, bool value)
187 // check if the value actually changed to avoid dirtying nodes unnecessarily
188 if( mValue[bufferIndex] != value )
190 mValue[bufferIndex] = value;
197 * Change the property value by a relative amount.
198 * @param[in] bufferIndex The buffer to write.
199 * @param[in] delta The property will change by this amount.
201 void SetRelative(BufferIndex bufferIndex, bool delta)
203 // check if the value actually changed to avoid dirtying nodes unnecessarily
204 // false + false does not change value, true + false does not either
205 if( delta && !mValue[bufferIndex] )
207 mValue[bufferIndex] += delta;
214 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
216 bool& Get(size_t bufferIndex)
218 return mValue[bufferIndex];
222 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
224 const bool& Get(size_t bufferIndex) const
226 return mValue[bufferIndex];
230 * Retrieve the property value.
231 * @param[in] bufferIndex The buffer to read.
232 * @return The property value.
234 bool& operator[](size_t bufferIndex)
236 return mValue[bufferIndex];
240 * Retrieve the property value.
241 * @param[in] bufferIndex The buffer to read.
242 * @return The property value.
244 const bool& operator[](size_t bufferIndex) const
246 return mValue[bufferIndex];
250 * Set both the property value & base value.
251 * @param[in] bufferIndex The buffer to write for the property value.
252 * @param[in] value The new property value.
254 void Bake(BufferIndex bufferIndex, bool value)
256 // check if the value actually changed to avoid dirtying nodes unnecessarily
257 if( mValue[bufferIndex] != value )
259 mValue[bufferIndex] = value;
267 * Change the property value & base value by a relative amount.
268 * @param[in] bufferIndex The buffer to write for the local property value.
269 * @param[in] delta The property will change by this amount.
271 void BakeRelative(BufferIndex bufferIndex, bool delta)
273 mValue[bufferIndex] += delta;
274 mBaseValue = mValue[bufferIndex];
282 AnimatableProperty(const AnimatableProperty& property);
285 AnimatableProperty& operator=(const AnimatableProperty& rhs);
289 DoubleBuffered<bool> mValue; ///< The double-buffered property value
290 bool mBaseValue; ///< Reset to this base value at the beginning of each frame
295 * An float animatable property of a scene-graph object.
298 class AnimatableProperty<float> : public AnimatablePropertyBase
303 * Create an animatable property.
304 * @param [in] initialValue The initial value of the property.
306 AnimatableProperty( float initialValue )
307 : mValue( initialValue ),
308 mBaseValue( initialValue )
313 * Virtual destructor.
315 virtual ~AnimatableProperty()
320 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
322 virtual Dali::Property::Type GetType() const
324 return Dali::PropertyTypes::Get<float>();
328 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
330 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
332 if (CLEAN_FLAG != mDirtyFlags)
334 mValue[updateBufferIndex] = mBaseValue;
336 mDirtyFlags = ( mDirtyFlags >> 1 );
341 * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
343 virtual const float& GetFloat( BufferIndex bufferIndex ) const
345 return mValue[ bufferIndex ];
349 * Set the property value. This will only persist for the current frame; the property
350 * will be reset with the base value, at the beginning of the next frame.
351 * @param[in] bufferIndex The buffer to write.
352 * @param[in] value The new property value.
354 void Set(BufferIndex bufferIndex, float value)
356 mValue[bufferIndex] = value;
362 * Change the property value by a relative amount.
363 * @param[in] bufferIndex The buffer to write.
364 * @param[in] delta The property will change by this amount.
366 void SetRelative(BufferIndex bufferIndex, float delta)
368 mValue[bufferIndex] = mValue[bufferIndex] + delta;
374 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
376 float& Get(size_t bufferIndex)
378 return mValue[bufferIndex];
382 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
384 const float& Get(size_t bufferIndex) const
386 return mValue[bufferIndex];
390 * Retrieve the property value.
391 * @param[in] bufferIndex The buffer to read.
392 * @return The property value.
394 float& operator[](size_t bufferIndex)
396 return mValue[bufferIndex];
400 * Retrieve the property value.
401 * @param[in] bufferIndex The buffer to read.
402 * @return The property value.
404 const float& operator[](size_t bufferIndex) const
406 return mValue[bufferIndex];
410 * Set both the property value & base value.
411 * @param[in] bufferIndex The buffer to write for the property value.
412 * @param[in] value The new property value.
414 void Bake(BufferIndex bufferIndex, float value)
416 mValue[bufferIndex] = value;
417 mBaseValue = mValue[bufferIndex];
423 * Change the property value & base value by a relative amount.
424 * @param[in] bufferIndex The buffer to write for the local property value.
425 * @param[in] delta The property will change by this amount.
427 void BakeRelative(BufferIndex bufferIndex, float delta)
429 mValue[bufferIndex] = mValue[bufferIndex] + delta;
430 mBaseValue = mValue[bufferIndex];
436 * Sets both double-buffered values & the base value.
437 * This should only be used when the owning object has not been connected to the scene-graph.
438 * @param[in] value The new property value.
440 void SetInitial(const float& value)
443 mValue[1] = mValue[0];
444 mBaseValue = mValue[0];
448 * Change both double-buffered values & the base value by a relative amount.
449 * This should only be used when the owning object has not been connected to the scene-graph.
450 * @param[in] delta The property will change by this amount.
452 void SetInitialRelative(const float& delta)
454 mValue[0] = mValue[0] + delta;
455 mValue[1] = mValue[0];
456 mBaseValue = mValue[0];
462 AnimatableProperty(const AnimatableProperty& property);
465 AnimatableProperty& operator=(const AnimatableProperty& rhs);
469 DoubleBuffered<float> mValue; ///< The double-buffered property value
470 float mBaseValue; ///< Reset to this base value at the beginning of each frame
475 * An Vector2 animatable property of a scene-graph object.
478 class AnimatableProperty<Vector2> : public AnimatablePropertyBase
483 * Create an animatable property.
484 * @param [in] initialValue The initial value of the property.
486 AnimatableProperty( const Vector2& initialValue )
487 : mValue( initialValue ),
488 mBaseValue( initialValue )
493 * Virtual destructor.
495 virtual ~AnimatableProperty()
500 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
502 virtual Dali::Property::Type GetType() const
504 return Dali::PropertyTypes::Get<Vector2>();
508 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
510 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
512 if (CLEAN_FLAG != mDirtyFlags)
514 mValue[updateBufferIndex] = mBaseValue;
516 mDirtyFlags = ( mDirtyFlags >> 1 );
521 * @copydoc Dali::PropertyInput::GetVector2()
523 virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
525 return mValue[ bufferIndex ];
529 * Set the property value. This will only persist for the current frame; the property
530 * will be reset with the base value, at the beginning of the next frame.
531 * @param[in] bufferIndex The buffer to write.
532 * @param[in] value The new property value.
534 void Set(BufferIndex bufferIndex, const Vector2& value)
536 mValue[bufferIndex] = value;
542 * Change the property value by a relative amount.
543 * @param[in] bufferIndex The buffer to write.
544 * @param[in] delta The property will change by this amount.
546 void SetRelative(BufferIndex bufferIndex, const Vector2& delta)
548 mValue[bufferIndex] += delta;
554 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
556 Vector2& Get(size_t bufferIndex)
558 return mValue[bufferIndex];
562 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
564 const Vector2& Get(size_t bufferIndex) const
566 return mValue[bufferIndex];
570 * Retrieve the property value.
571 * @param[in] bufferIndex The buffer to read.
572 * @return The property value.
574 Vector2& operator[](size_t bufferIndex)
576 return mValue[bufferIndex];
580 * Retrieve the property value.
581 * @param[in] bufferIndex The buffer to read.
582 * @return The property value.
584 const Vector2& operator[](size_t bufferIndex) const
586 return mValue[bufferIndex];
590 * Set both the property value & base value.
591 * @param[in] bufferIndex The buffer to write for the property value.
592 * @param[in] value The new property value.
594 void Bake(BufferIndex bufferIndex, const Vector2& value)
596 mValue[bufferIndex] = value;
603 * Change the property value & base value by a relative amount.
604 * @param[in] bufferIndex The buffer to write for the local property value.
605 * @param[in] delta The property will change by this amount.
607 void BakeRelative(BufferIndex bufferIndex, const Vector2& delta)
609 mValue[bufferIndex] += delta;
610 mBaseValue = mValue[bufferIndex];
618 AnimatableProperty(const AnimatableProperty& property);
621 AnimatableProperty& operator=(const AnimatableProperty& rhs);
625 DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
626 Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame
631 * A Vector3 animatable property of a scene-graph object.
634 class AnimatableProperty<Vector3> : public AnimatablePropertyBase
639 * Create an animatable property.
640 * @param [in] initialValue The initial value of the property.
642 AnimatableProperty( const Vector3& initialValue )
643 : mValue( initialValue ),
644 mBaseValue( initialValue )
649 * Virtual destructor.
651 virtual ~AnimatableProperty()
656 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
658 virtual Dali::Property::Type GetType() const
660 return Dali::PropertyTypes::Get<Vector3>();
664 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
666 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
668 if (CLEAN_FLAG != mDirtyFlags)
670 mValue[updateBufferIndex] = mBaseValue;
672 mDirtyFlags = ( mDirtyFlags >> 1 );
677 * @copydoc Dali::PropertyInput::GetVector3()
679 virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
681 return mValue[ bufferIndex ];
685 * Set the property value. This will only persist for the current frame; the property
686 * will be reset with the base value, at the beginning of the next frame.
687 * @param[in] bufferIndex The buffer to write.
688 * @param[in] value The new property value.
690 void Set(BufferIndex bufferIndex, const Vector3& value)
692 mValue[bufferIndex] = value;
698 * Set the property value. This will only persist for the current frame; the property
699 * will be reset with the base value, at the beginning of the next frame.
700 * @param[in] bufferIndex The buffer to write.
701 * @param[in] value The new X value.
703 void SetX(BufferIndex bufferIndex, float value)
705 mValue[bufferIndex].x = value;
711 * Set the property value. This will only persist for the current frame; the property
712 * will be reset with the base value, at the beginning of the next frame.
713 * @param[in] bufferIndex The buffer to write.
714 * @param[in] value The new Y value.
716 void SetY(BufferIndex bufferIndex, float value)
718 mValue[bufferIndex].y = value;
724 * Set the property value. This will only persist for the current frame; the property
725 * will be reset with the base value, at the beginning of the next frame.
726 * @param[in] bufferIndex The buffer to write.
727 * @param[in] value The new Z value.
729 void SetZ(BufferIndex bufferIndex, float value)
731 mValue[bufferIndex].z = value;
737 * Change the property value by a relative amount.
738 * @param[in] bufferIndex The buffer to write.
739 * @param[in] delta The property will change by this amount.
741 void SetRelative(BufferIndex bufferIndex, const Vector3& delta)
743 mValue[bufferIndex] += delta;
749 * Change the X value by a relative amount.
750 * @param[in] bufferIndex The buffer to write.
751 * @param[in] delta The X value will change by this amount.
753 void SetXRelative(BufferIndex bufferIndex, float delta)
755 mValue[bufferIndex].x += delta;
761 * Change the Y value by a relative amount.
762 * @param[in] bufferIndex The buffer to write.
763 * @param[in] delta The Y value will change by this amount.
765 void SetYRelative(BufferIndex bufferIndex, float delta)
767 mValue[bufferIndex].y += delta;
773 * Change the Z value by a relative amount.
774 * @param[in] bufferIndex The buffer to write.
775 * @param[in] delta The Z value will change by this amount.
777 void SetZRelative(BufferIndex bufferIndex, float delta)
779 mValue[bufferIndex].z += delta;
785 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
787 Vector3& Get(size_t bufferIndex)
789 return mValue[bufferIndex];
793 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
795 const Vector3& Get(size_t bufferIndex) const
797 return mValue[bufferIndex];
801 * Retrieve the property value.
802 * @param[in] bufferIndex The buffer to read.
803 * @return The property value.
805 Vector3& operator[](size_t bufferIndex)
807 return mValue[bufferIndex];
811 * Retrieve the property value.
812 * @param[in] bufferIndex The buffer to read.
813 * @return The property value.
815 const Vector3& operator[](size_t bufferIndex) const
817 return mValue[bufferIndex];
821 * Set both the property value & base value.
822 * @param[in] bufferIndex The buffer to write for the property value.
823 * @param[in] value The new property value.
825 void Bake(BufferIndex bufferIndex, const Vector3& value)
827 mValue[bufferIndex] = value;
834 * Set both the X value & base X value.
835 * @param[in] bufferIndex The buffer to write for the property value.
836 * @param[in] value The new property value.
838 void BakeX(BufferIndex bufferIndex, float value)
840 mValue[bufferIndex].x = value;
841 mBaseValue.x = value;
847 * Set both the Y value & base Y value.
848 * @param[in] bufferIndex The buffer to write for the property value.
849 * @param[in] value The new property value.
851 void BakeY(BufferIndex bufferIndex, float value)
853 mValue[bufferIndex].y = value;
854 mBaseValue.y = value;
860 * Set both the Z value & base Z value.
861 * @param[in] bufferIndex The buffer to write for the property value.
862 * @param[in] value The new property value.
864 void BakeZ(BufferIndex bufferIndex, float value)
866 mValue[bufferIndex].z = value;
867 mBaseValue.z = value;
873 * Change the property value & base value by a relative amount.
874 * @param[in] bufferIndex The buffer to write for the local property value.
875 * @param[in] delta The property will change by this amount.
877 void BakeRelative(BufferIndex bufferIndex, const Vector3& delta)
879 mValue[bufferIndex] += delta;
880 mBaseValue = mValue[bufferIndex];
886 * Change the property value & base value by a relative amount.
887 * @param[in] bufferIndex The buffer to write for the local property value.
888 * @param[in] delta The property will change by this amount.
890 void BakeRelativeMultiply(BufferIndex bufferIndex, const Vector3& delta)
892 mValue[bufferIndex] *= delta;
893 mBaseValue = mValue[bufferIndex];
899 * Change the X value & base X value by a relative amount.
900 * @param[in] bufferIndex The buffer to write for the local property value.
901 * @param[in] delta The X value will change by this amount.
903 void BakeXRelative(BufferIndex bufferIndex, float delta)
905 mValue[bufferIndex].x += delta;
906 mBaseValue.x = mValue[bufferIndex].x;
912 * Change the Y value & base Y value by a relative amount.
913 * @param[in] bufferIndex The buffer to write for the local property value.
914 * @param[in] delta The Y value will change by this amount.
916 void BakeYRelative(BufferIndex bufferIndex, float delta)
918 mValue[bufferIndex].y += delta;
919 mBaseValue.y = mValue[bufferIndex].y;
925 * Change the Z value & base Z value by a relative amount.
926 * @param[in] bufferIndex The buffer to write for the local property value.
927 * @param[in] delta The Z value will change by this amount.
929 void BakeZRelative(BufferIndex bufferIndex, float delta)
931 mValue[bufferIndex].z += delta;
932 mBaseValue.z = mValue[bufferIndex].z;
940 AnimatableProperty(const AnimatableProperty& property);
943 AnimatableProperty& operator=(const AnimatableProperty& rhs);
947 DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
948 Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame
953 * A Vector4 animatable property of a scene-graph object.
956 class AnimatableProperty<Vector4> : public AnimatablePropertyBase
961 * Create an animatable property.
962 * @param [in] initialValue The initial value of the property.
964 AnimatableProperty( const Vector4& initialValue )
965 : mValue( initialValue ),
966 mBaseValue( initialValue )
971 * Virtual destructor.
973 virtual ~AnimatableProperty()
978 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
980 virtual Dali::Property::Type GetType() const
982 return Dali::PropertyTypes::Get<Vector4>();
986 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
988 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
990 if (CLEAN_FLAG != mDirtyFlags)
992 mValue[updateBufferIndex] = mBaseValue;
994 mDirtyFlags = ( mDirtyFlags >> 1 );
999 * @copydoc Dali::PropertyInput::GetVector4()
1001 virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
1003 return mValue[ bufferIndex ];
1007 * Set the property value. This will only persist for the current frame; the property
1008 * will be reset with the base value, at the beginning of the next frame.
1009 * @param[in] bufferIndex The buffer to write.
1010 * @param[in] value The new property value.
1012 void Set(BufferIndex bufferIndex, const Vector4& value)
1014 mValue[bufferIndex] = value;
1020 * Set the X value. This will only persist for the current frame; the property
1021 * will be reset with the base value, at the beginning of the next frame.
1022 * @param[in] bufferIndex The buffer to write.
1023 * @param[in] value The new X value.
1025 void SetX(BufferIndex bufferIndex, float value)
1027 mValue[bufferIndex].x = value;
1033 * Set the Y value. This will only persist for the current frame; the property
1034 * will be reset with the base value, at the beginning of the next frame.
1035 * @param[in] bufferIndex The buffer to write.
1036 * @param[in] value The new Y value.
1038 void SetY(BufferIndex bufferIndex, float value)
1040 mValue[bufferIndex].y = value;
1046 * Set the Z value. This will only persist for the current frame; the property
1047 * will be reset with the base value, at the beginning of the next frame.
1048 * @param[in] bufferIndex The buffer to write.
1049 * @param[in] value The new Z value.
1051 void SetZ(BufferIndex bufferIndex, float value)
1053 mValue[bufferIndex].z = value;
1059 * Set the W value. This will only persist for the current frame; the property
1060 * will be reset with the base value, at the beginning of the next frame.
1061 * @param[in] bufferIndex The buffer to write.
1062 * @param[in] value The new W value.
1064 void SetW(BufferIndex bufferIndex, float value)
1066 mValue[bufferIndex].w = value;
1072 * Change the property value by a relative amount.
1073 * @param[in] bufferIndex The buffer to write.
1074 * @param[in] delta The property will change by this amount.
1076 void SetRelative(BufferIndex bufferIndex, const Vector4& delta)
1078 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1084 * Change the X value by a relative amount.
1085 * @param[in] bufferIndex The buffer to write.
1086 * @param[in] delta The X value will change by this amount.
1088 void SetXRelative(BufferIndex bufferIndex, float delta)
1090 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1096 * Change the Y value by a relative amount.
1097 * @param[in] bufferIndex The buffer to write.
1098 * @param[in] delta The Y value will change by this amount.
1100 void SetYRelative(BufferIndex bufferIndex, float delta)
1102 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1108 * Change the Z value by a relative amount.
1109 * @param[in] bufferIndex The buffer to write.
1110 * @param[in] delta The Z value will change by this amount.
1112 void SetZRelative(BufferIndex bufferIndex, float delta)
1114 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1120 * Change the W value by a relative amount.
1121 * @param[in] bufferIndex The buffer to write.
1122 * @param[in] delta The W value will change by this amount.
1124 void SetWRelative(BufferIndex bufferIndex, float delta)
1126 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1132 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1134 Vector4& Get(size_t bufferIndex)
1136 return mValue[bufferIndex];
1140 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1142 const Vector4& Get(size_t bufferIndex) const
1144 return mValue[bufferIndex];
1148 * Retrieve the property value.
1149 * @param[in] bufferIndex The buffer to read.
1150 * @return The property value.
1152 Vector4& operator[](size_t bufferIndex)
1154 return mValue[bufferIndex];
1158 * Retrieve the property value.
1159 * @param[in] bufferIndex The buffer to read.
1160 * @return The property value.
1162 const Vector4& operator[](size_t bufferIndex) const
1164 return mValue[bufferIndex];
1168 * Set both the property value & base value.
1169 * @param[in] bufferIndex The buffer to write for the property value.
1170 * @param[in] value The new property value.
1172 void Bake(BufferIndex bufferIndex, const Vector4& value)
1174 mValue[bufferIndex] = value;
1175 mBaseValue = mValue[bufferIndex];
1181 * Set both the X value & base X value.
1182 * @param[in] bufferIndex The buffer to write for the property value.
1183 * @param[in] value The new property value.
1185 void BakeX(BufferIndex bufferIndex, float value)
1187 mValue[bufferIndex].x = value;
1188 mBaseValue.x = mValue[bufferIndex].x;
1194 * Set both the Y value & base Y value.
1195 * @param[in] bufferIndex The buffer to write for the property value.
1196 * @param[in] value The new property value.
1198 void BakeY(BufferIndex bufferIndex, float value)
1200 mValue[bufferIndex].y = value;
1201 mBaseValue.y = mValue[bufferIndex].y;
1207 * Set both the Z value & base Z value.
1208 * @param[in] bufferIndex The buffer to write for the property value.
1209 * @param[in] value The new property value.
1211 void BakeZ(BufferIndex bufferIndex, float value)
1213 mValue[bufferIndex].z = value;
1214 mBaseValue.z = mValue[bufferIndex].z;
1220 * Set both the W value & base W value.
1221 * @param[in] bufferIndex The buffer to write for the property value.
1222 * @param[in] value The new property value.
1224 void BakeW(BufferIndex bufferIndex, float value)
1226 mValue[bufferIndex].w = value;
1227 mBaseValue.w = mValue[bufferIndex].w;
1233 * Change the property value & base value by a relative amount.
1234 * @param[in] bufferIndex The buffer to write for the local property value.
1235 * @param[in] delta The property will change by this amount.
1237 void BakeRelative(BufferIndex bufferIndex, const Vector4& delta)
1239 mValue[bufferIndex] = mValue[bufferIndex] + delta;
1240 mBaseValue = mValue[bufferIndex];
1246 * Change the X value & base X value by a relative amount.
1247 * @param[in] bufferIndex The buffer to write for the local property value.
1248 * @param[in] delta The X value will change by this amount.
1250 void BakeXRelative(BufferIndex bufferIndex, float delta)
1252 mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
1253 mBaseValue.x = mValue[bufferIndex].x;
1259 * Change the Y value & base Y value by a relative amount.
1260 * @param[in] bufferIndex The buffer to write for the local property value.
1261 * @param[in] delta The Y value will change by this amount.
1263 void BakeYRelative(BufferIndex bufferIndex, float delta)
1265 mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
1266 mBaseValue.y = mValue[bufferIndex].y;
1272 * Change the Z value & base Z value by a relative amount.
1273 * @param[in] bufferIndex The buffer to write for the local property value.
1274 * @param[in] delta The Z value will change by this amount.
1276 void BakeZRelative(BufferIndex bufferIndex, float delta)
1278 mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
1279 mBaseValue.z = mValue[bufferIndex].z;
1285 * Change the W value & base W value by a relative amount.
1286 * @param[in] bufferIndex The buffer to write for the local property value.
1287 * @param[in] delta The W value will change by this amount.
1289 void BakeWRelative(BufferIndex bufferIndex, float delta)
1291 mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
1292 mBaseValue.w = mValue[bufferIndex].w;
1298 * Sets both double-buffered W values & the base W value.
1299 * This should only be used when the owning object has not been connected to the scene-graph.
1300 * @param[in] value The new W value.
1302 void SetWInitial(float value)
1304 mValue[0].w = value;
1305 mValue[1].w = mValue[0].w;
1306 mBaseValue.w = mValue[0].w;
1312 AnimatableProperty(const AnimatableProperty& property);
1315 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1319 DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
1320 Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame
1324 * An Quaternion animatable property of a scene-graph object.
1327 class AnimatableProperty<Quaternion> : public AnimatablePropertyBase
1332 * Create an animatable property.
1333 * @param [in] initialValue The initial value of the property.
1335 AnimatableProperty( const Quaternion& initialValue )
1336 : mValue( initialValue ),
1337 mBaseValue( initialValue )
1342 * Virtual destructor.
1344 virtual ~AnimatableProperty()
1349 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1351 virtual Dali::Property::Type GetType() const
1353 return Dali::PropertyTypes::Get<Quaternion>();
1357 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1359 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1361 if (CLEAN_FLAG != mDirtyFlags)
1363 mValue[updateBufferIndex] = mBaseValue;
1365 mDirtyFlags = ( mDirtyFlags >> 1 );
1370 * @copydoc Dali::PropertyInput::GetQuaternion()
1372 virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
1374 return mValue[ bufferIndex ];
1378 * Set the property value. This will only persist for the current frame; the property
1379 * will be reset with the base value, at the beginning of the next frame.
1380 * @param[in] bufferIndex The buffer to write.
1381 * @param[in] value The new property value.
1383 void Set(BufferIndex bufferIndex, const Quaternion& value)
1385 mValue[bufferIndex] = value;
1391 * Change the property value by a relative amount.
1392 * @param[in] bufferIndex The buffer to write.
1393 * @param[in] delta The property will change by this amount.
1395 void SetRelative(BufferIndex bufferIndex, const Quaternion& delta)
1397 mValue[bufferIndex] *= delta;
1403 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1405 Quaternion& Get(size_t bufferIndex)
1407 return mValue[bufferIndex];
1411 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1413 const Quaternion& Get(size_t bufferIndex) const
1415 return mValue[bufferIndex];
1419 * Retrieve the property value.
1420 * @param[in] bufferIndex The buffer to read.
1421 * @return The property value.
1423 Quaternion& operator[](size_t bufferIndex)
1425 return mValue[bufferIndex];
1429 * Retrieve the property value.
1430 * @param[in] bufferIndex The buffer to read.
1431 * @return The property value.
1433 const Quaternion& operator[](size_t bufferIndex) const
1435 return mValue[bufferIndex];
1439 * Set both the property value & base value.
1440 * @param[in] bufferIndex The buffer to write for the property value.
1441 * @param[in] value The new property value.
1443 void Bake(BufferIndex bufferIndex, const Quaternion& value)
1445 mValue[bufferIndex] = value;
1452 * Change the property value & base value by a relative amount.
1453 * @param[in] bufferIndex The buffer to write for the local property value.
1454 * @param[in] delta The property will change by this amount.
1456 void BakeRelative(BufferIndex bufferIndex, const Quaternion& delta)
1458 mValue[bufferIndex] *= delta;
1459 mBaseValue = mValue[bufferIndex];
1467 AnimatableProperty(const AnimatableProperty& property);
1470 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1474 DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
1475 Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame
1480 * A Matrix animatable property of a scene-graph object.
1483 class AnimatableProperty<Matrix> : public AnimatablePropertyBase
1488 * Create an animatable property.
1489 * @param [in] initialValue The initial value of the property.
1491 AnimatableProperty( const Matrix& initialValue )
1492 : mValue( initialValue ),
1493 mBaseValue( initialValue )
1498 * Virtual destructor.
1500 virtual ~AnimatableProperty()
1505 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1507 virtual Dali::Property::Type GetType() const
1509 return Dali::PropertyTypes::Get<Matrix>();
1513 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1515 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1517 if (CLEAN_FLAG != mDirtyFlags)
1519 mValue[updateBufferIndex] = mBaseValue;
1521 mDirtyFlags = ( mDirtyFlags >> 1 );
1526 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
1528 virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
1530 return mValue[ bufferIndex ];
1534 * Set the property value. This will only persist for the current frame; the property
1535 * will be reset with the base value, at the beginning of the next frame.
1536 * @param[in] bufferIndex The buffer to write.
1537 * @param[in] value The new property value.
1539 void Set(BufferIndex bufferIndex, const Matrix& value)
1541 mValue[bufferIndex] = value;
1547 * Change the property value by a relative amount.
1548 * @param[in] bufferIndex The buffer to write.
1549 * @param[in] delta The property will change by this amount.
1551 void SetRelative(BufferIndex bufferIndex, const Matrix& delta)
1554 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1555 mValue[bufferIndex] = temp;
1561 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1563 Matrix& Get(size_t bufferIndex)
1565 return mValue[bufferIndex];
1569 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1571 const Matrix& Get(size_t bufferIndex) const
1573 return mValue[bufferIndex];
1577 * Retrieve the property value.
1578 * @param[in] bufferIndex The buffer to read.
1579 * @return The property value.
1581 Matrix& operator[](size_t bufferIndex)
1583 return mValue[bufferIndex];
1587 * Retrieve the property value.
1588 * @param[in] bufferIndex The buffer to read.
1589 * @return The property value.
1591 const Matrix& operator[](size_t bufferIndex) const
1593 return mValue[bufferIndex];
1597 * Set both the property value & base value.
1598 * @param[in] bufferIndex The buffer to write for the property value.
1599 * @param[in] value The new property value.
1601 void Bake(BufferIndex bufferIndex, const Matrix& value)
1603 mValue[bufferIndex] = value;
1604 mBaseValue = mValue[bufferIndex];
1610 * Change the property value & base value by a relative amount.
1611 * @param[in] bufferIndex The buffer to write for the local property value.
1612 * @param[in] delta The property will change by this amount.
1614 void BakeRelative(BufferIndex bufferIndex, const Matrix& delta)
1617 Matrix::Multiply(temp, mValue[bufferIndex], delta);
1618 mValue[bufferIndex] = temp;
1627 AnimatableProperty(const AnimatableProperty& property);
1630 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1634 DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
1635 Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame
1640 * A Matrix3 animatable property of a scene-graph object.
1643 class AnimatableProperty<Matrix3> : public AnimatablePropertyBase
1648 * Create an animatable property.
1649 * @param [in] initialValue The initial value of the property.
1651 AnimatableProperty( const Matrix3& initialValue )
1652 : mValue( initialValue ),
1653 mBaseValue( initialValue )
1658 * Virtual destructor.
1660 virtual ~AnimatableProperty()
1665 * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1667 virtual Dali::Property::Type GetType() const
1669 return Dali::PropertyTypes::Get<Matrix3>();
1673 * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
1675 virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
1677 if (CLEAN_FLAG != mDirtyFlags)
1679 mValue[updateBufferIndex] = mBaseValue;
1681 mDirtyFlags = ( mDirtyFlags >> 1 );
1686 * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3()
1688 virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
1690 return mValue[ bufferIndex ];
1694 * Set the property value. This will only persist for the current frame; the property
1695 * will be reset with the base value, at the beginning of the next frame.
1696 * @param[in] bufferIndex The buffer to write.
1697 * @param[in] value The new property value.
1699 void Set(BufferIndex bufferIndex, const Matrix3& value)
1701 mValue[bufferIndex] = value;
1706 * Change the property value by a relative amount.
1707 * @param[in] bufferIndex The buffer to write.
1708 * @param[in] delta The property will change by this amount.
1710 void SetRelative(BufferIndex bufferIndex, const Matrix3& delta)
1713 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1714 mValue[bufferIndex] = temp;
1719 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1721 Matrix3& Get(size_t bufferIndex)
1723 return mValue[bufferIndex];
1727 * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
1729 const Matrix3& Get(size_t bufferIndex) const
1731 return mValue[bufferIndex];
1735 * Retrieve the property value.
1736 * @param[in] bufferIndex The buffer to read.
1737 * @return The property value.
1739 Matrix3& operator[](size_t bufferIndex)
1741 return mValue[bufferIndex];
1745 * Retrieve the property value.
1746 * @param[in] bufferIndex The buffer to read.
1747 * @return The property value.
1749 const Matrix3& operator[](size_t bufferIndex) const
1751 return mValue[bufferIndex];
1755 * Set both the property value & base value.
1756 * @param[in] bufferIndex The buffer to write for the property value.
1757 * @param[in] value The new property value.
1759 void Bake(BufferIndex bufferIndex, const Matrix3& value)
1761 mValue[bufferIndex] = value;
1762 mBaseValue = mValue[bufferIndex];
1768 * Change the property value & base value by a relative amount.
1769 * @param[in] bufferIndex The buffer to write for the local property value.
1770 * @param[in] delta The property will change by this amount.
1772 void BakeRelative(BufferIndex bufferIndex, const Matrix3& delta)
1775 Matrix3::Multiply(temp, mValue[bufferIndex], delta);
1776 mValue[bufferIndex] = temp;
1785 AnimatableProperty(const AnimatableProperty& property);
1788 AnimatableProperty& operator=(const AnimatableProperty& rhs);
1792 DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
1793 Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame
1797 } // namespace SceneGraph
1799 // Messages for AnimatableProperty<T>
1802 void BakeMessage( EventToUpdate& eventToUpdate,
1803 const SceneGraph::AnimatableProperty<T>& property,
1804 typename ParameterType< T >::PassingType newValue )
1806 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, T > LocalType;
1808 // Reserve some memory inside the message queue
1809 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1811 // Construct message in the message queue memory; note that delete should not be called on the return value
1812 new (slot) LocalType( &property,
1813 &SceneGraph::AnimatableProperty<T>::Bake,
1818 void BakeRelativeMessage( EventToUpdate& eventToUpdate,
1819 const SceneGraph::AnimatableProperty<T>& property,
1822 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, const T& > LocalType;
1824 // Reserve some memory inside the message queue
1825 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1827 // Construct message in the message queue memory; note that delete should not be called on the return value
1828 new (slot) LocalType( &property,
1829 &SceneGraph::AnimatableProperty<T>::BakeRelative,
1834 void SetXComponentMessage( EventToUpdate& eventToUpdate,
1835 const SceneGraph::AnimatableProperty<T>& property,
1836 typename ParameterType< float >::PassingType newValue )
1838 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1840 // Reserve some memory inside the message queue
1841 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1843 // Construct message in the message queue memory; note that delete should not be called on the return value
1844 new (slot) LocalType( &property,
1845 &SceneGraph::AnimatableProperty<T>::BakeX,
1850 void SetYComponentMessage( EventToUpdate& eventToUpdate,
1851 const SceneGraph::AnimatableProperty<T>& property,
1852 typename ParameterType< float >::PassingType newValue )
1854 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1856 // Reserve some memory inside the message queue
1857 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1859 // Construct message in the message queue memory; note that delete should not be called on the return value
1860 new (slot) LocalType( &property,
1861 &SceneGraph::AnimatableProperty<T>::BakeY,
1866 void SetZComponentMessage( EventToUpdate& eventToUpdate,
1867 const SceneGraph::AnimatableProperty<T>& property,
1868 typename ParameterType< float >::PassingType newValue )
1870 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1872 // Reserve some memory inside the message queue
1873 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1875 // Construct message in the message queue memory; note that delete should not be called on the return value
1876 new (slot) LocalType( &property,
1877 &SceneGraph::AnimatableProperty<T>::BakeZ,
1882 void SetWComponentMessage( EventToUpdate& eventToUpdate,
1883 const SceneGraph::AnimatableProperty<T>& property,
1884 typename ParameterType< float >::PassingType newValue )
1886 typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
1888 // Reserve some memory inside the message queue
1889 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1891 // Construct message in the message queue memory; note that delete should not be called on the return value
1892 new (slot) LocalType( &property,
1893 &SceneGraph::AnimatableProperty<T>::BakeW,
1897 } // namespace Internal
1901 #endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__