1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
5 * Copyright (c) 2021 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/devel-api/common/owner-container.h>
22 #include <dali/public-api/animation/alpha-function.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/object/property-key.h>
27 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
36 typedef IntrusivePtr<TransitionData> TransitionDataPtr;
39 * TransitionData is an object that holds animator data.
41 class TransitionData : public BaseObject
44 enum class AnimationType : uint8_t
46 TO, ///< Animating TO the given value
47 BY, ///< Animating BY the given value
48 BETWEEN ///< Animating BETWEEN key-frames
52 * @brief TransitionDataElement Describes one animator of an transition.
57 : propertyKey(Property::INVALID_INDEX),
58 alphaFunction(AlphaFunction::DEFAULT),
59 timePeriodDelay(0.0f),
60 timePeriodDuration(1.0f),
61 animationType(AnimationType::TO),
66 std::string objectName; ///< An identifier of the actor or visual
67 Property::Key propertyKey; ///< A property key of the property owner
68 Property::Value initialValue; ///< The value to set at the start of the transition
69 Property::Value targetValue; ///< The value to set or animate to
70 Dali::AlphaFunction alphaFunction;
71 float timePeriodDelay;
72 float timePeriodDuration;
73 AnimationType animationType;
78 * @brief TransitionData holds the required data required to define an
79 * transition to be performed on a property owner
81 typedef Dali::OwnerContainer<Animator*> AnimatorList;
82 typedef AnimatorList::Iterator Iterator;
86 * @copydoc Dali::Transition::New()
88 static TransitionDataPtr New(const Property::Array& value);
91 * @copydoc Dali::Transition::New()
93 static TransitionDataPtr New(const Property::Map& value);
96 * @brief Iterator to the beginning of the data
98 Iterator Begin() const;
101 * @brief Iterator to the end of the data (one past last element)
103 Iterator End() const;
106 * @copydoc Dali::Transition::Count()
108 size_t Count() const;
111 * @copydoc Dali::Transition::GetAnimatorAt()
113 Property::Map GetAnimatorAt(size_t index);
115 private: // Implementation
117 * Ref counted object - Only allow construction via New().
122 * Second stage initialiazation
124 void Initialize(const Property::Map& value);
127 * Second stage initialiazation
129 void Initialize(const Property::Array& value);
132 * @brief Adds one Animator to the list to describe a transition.
133 * @param[in] animator An animator data structure
135 void Add(Animator* animator);
138 * Convert a Property map into Animator data
140 Animator* ConvertMap(const Property::Map& map);
144 * A ref counted object may only be deleted by calling Unreference
146 ~TransitionData() override;
148 private: // Unimplemented methods
149 TransitionData(const TransitionData&);
150 TransitionData& operator=(const TransitionData&);
152 private: // Data members
153 AnimatorList mAnimators; ///< A vector of individual property transitions from which to generate a Dali::Animation.
156 } // namespace Internal
158 // Helpers for public-api forwarding methods
159 inline Internal::TransitionData& GetImplementation(Dali::Toolkit::TransitionData& handle)
161 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
162 BaseObject& object = handle.GetBaseObject();
163 return static_cast<Internal::TransitionData&>(object);
166 inline const Internal::TransitionData& GetImplementation(const Dali::Toolkit::TransitionData& handle)
168 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
169 const BaseObject& object = handle.GetBaseObject();
170 return static_cast<const Internal::TransitionData&>(object);
173 } // namespace Toolkit
176 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H