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
45 * @brief TransitionDataElement Describes one animator of an transition.
50 : propertyKey(Property::INVALID_INDEX),
51 alphaFunction(AlphaFunction::DEFAULT),
52 timePeriodDelay(0.0f),
53 timePeriodDuration(1.0f),
58 std::string objectName; ///< An identifier of the actor or visual
59 Property::Key propertyKey; ///< A property key of the property owner
60 Property::Value initialValue; ///< The value to set at the start of the transition
61 Property::Value targetValue; ///< The value to set or animate to
62 Dali::AlphaFunction alphaFunction;
63 float timePeriodDelay;
64 float timePeriodDuration;
69 * @brief TransitionData holds the required data required to define an
70 * transition to be performed on a property owner
72 typedef Dali::OwnerContainer<Animator*> AnimatorList;
73 typedef AnimatorList::Iterator Iterator;
77 * @copydoc Dali::Transition::New()
79 static TransitionDataPtr New(const Property::Array& value);
82 * @copydoc Dali::Transition::New()
84 static TransitionDataPtr New(const Property::Map& value);
87 * @brief Iterator to the beginning of the data
89 Iterator Begin() const;
92 * @brief Iterator to the end of the data (one past last element)
97 * @copydoc Dali::Transition::Count()
102 * @copydoc Dali::Transition::GetAnimatorAt()
104 Property::Map GetAnimatorAt(size_t index);
106 private: // Implementation
108 * Ref counted object - Only allow construction via New().
113 * Second stage initialiazation
115 void Initialize(const Property::Map& value);
118 * Second stage initialiazation
120 void Initialize(const Property::Array& value);
123 * @brief Adds one Animator to the list to describe a transition.
124 * @param[in] animator An animator data structure
126 void Add(Animator* animator);
129 * Convert a Property map into Animator data
131 Animator* ConvertMap(const Property::Map& map);
135 * A ref counted object may only be deleted by calling Unreference
137 ~TransitionData() override;
139 private: // Unimplemented methods
140 TransitionData(const TransitionData&);
141 TransitionData& operator=(const TransitionData&);
143 private: // Data members
144 AnimatorList mAnimators; ///< A vector of individual property transitions from which to generate a Dali::Animation.
147 } // namespace Internal
149 // Helpers for public-api forwarding methods
150 inline Internal::TransitionData& GetImplementation(Dali::Toolkit::TransitionData& handle)
152 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
153 BaseObject& object = handle.GetBaseObject();
154 return static_cast<Internal::TransitionData&>(object);
157 inline const Internal::TransitionData& GetImplementation(const Dali::Toolkit::TransitionData& handle)
159 DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
160 const BaseObject& object = handle.GetBaseObject();
161 return static_cast<const Internal::TransitionData&>(object);
164 } // namespace Toolkit
167 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H