1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
5 * Copyright (c) 2016 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.
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/animation/alpha-function.h>
23 #include <dali/public-api/object/property-key.h>
24 #include <dali/devel-api/common/owner-container.h>
27 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
37 typedef IntrusivePtr<TransitionData> TransitionDataPtr;
40 * TransitionData is an object that holds animator data.
42 class TransitionData : public BaseObject
47 * @brief TransitionDataElement Describes one animator of an transition.
52 : propertyKey( Property::INVALID_INDEX ),
53 alphaFunction( AlphaFunction::DEFAULT ),
54 timePeriodDelay( 0.0f ),
55 timePeriodDuration( 1.0f ),
60 std::string objectName; ///< An identifier of the actor or visual
61 Property::Key propertyKey; ///< A property key of the property owner
62 Property::Value initialValue; ///< The value to set at the start of the transition
63 Property::Value targetValue; ///< The value to set or animate to
64 Dali::AlphaFunction alphaFunction;
65 float timePeriodDelay;
66 float timePeriodDuration;
71 * @brief TransitionData holds the required data required to define an
72 * transition to be performed on a property owner
74 typedef Dali::OwnerContainer< Animator* > AnimatorList;
75 typedef AnimatorList::Iterator Iterator;
79 * @copydoc Dali::Transition::New()
81 static TransitionDataPtr New( const Property::Array& value );
84 * @copydoc Dali::Transition::New()
86 static TransitionDataPtr New( const Property::Map& value );
89 * @brief Iterator to the beginning of the data
91 Iterator Begin() const;
94 * @brief Iterator to the end of the data (one past last element)
99 * @copydoc Dali::Transition::Count()
101 size_t Count() const;
104 * @copydoc Dali::Transition::GetAnimatorAt()
106 Property::Map GetAnimatorAt( size_t index );
108 private: // Implementation
110 * Ref counted object - Only allow construction via New().
115 * Second stage initialiazation
117 void Initialize( const Property::Map& value );
120 * Second stage initialiazation
122 void Initialize( const Property::Array& value );
125 * @brief Adds one Animator to the list to describe a transition.
126 * @param[in] animator An animator data structure
128 void Add( Animator* animator );
131 * Convert a Property map into Animator data
133 Animator* ConvertMap( const Property::Map& map );
137 * A ref counted object may only be deleted by calling Unreference
139 ~TransitionData() override;
141 private: // Unimplemented methods
142 TransitionData( const TransitionData& );
143 TransitionData& operator=( const TransitionData& );
145 private: // Data members
146 AnimatorList mAnimators; ///< A vector of individual property transitions from which to generate a Dali::Animation.
149 } // namespace Internal
151 // Helpers for public-api forwarding methods
152 inline Internal::TransitionData& GetImplementation( Dali::Toolkit::TransitionData& handle )
154 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
155 BaseObject& object = handle.GetBaseObject();
156 return static_cast<Internal::TransitionData&>(object);
159 inline const Internal::TransitionData& GetImplementation( const Dali::Toolkit::TransitionData& handle )
161 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
162 const BaseObject& object = handle.GetBaseObject();
163 return static_cast<const Internal::TransitionData&>(object);
166 } // namespace Toolkit
170 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H