1 #ifndef DALI_SCENE3D_MODEL_MOTION_MOTION_VALUE_H
2 #define DALI_SCENE3D_MODEL_MOTION_MOTION_VALUE_H
5 * Copyright (c) 2023 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.
22 #include <dali/public-api/animation/key-frames.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/object/property-value.h>
28 #include <dali-scene3d/public-api/api.h>
34 //Forward declarations.
38 } // namespace Internal
41 * @addtogroup dali_scene3d_model_motion_motion_value
46 * @brief This MotionValue be used for target value of each MotionIndex.
47 * We can get and set MotionValue as 2 types : Property::Value and KeyFrames.
49 * Each types will be cross-converted internally.
50 * For example, when we set Property::Value, we can get KeyFrames with 2 frames, and target value is setted.
52 * @note The type of property should be matched with MotionIndex required.
55 class DALI_SCENE3D_API MotionValue : public Dali::BaseHandle
59 * @brief Determine whether current stored value is PropertyValue, or KeyFrames.
64 INVALID = -1, ///< Value is null, or invalid.
66 PROPERTY_VALUE = 0, ///< Value is PropertyValue.
67 KEY_FRAMES, ///< Value is KeyFrames.
70 public: // Creation & Destruction
72 * @brief Create an initialized MotionValue.
75 * @return A handle to a newly allocated Dali resource
77 static MotionValue New();
80 * @brief Create an initialized MotionValue with Property::Value.
83 * @param[in] propertyValue The static value.
84 * @return A handle to a newly allocated Dali resource
86 static MotionValue New(Property::Value propertyValue);
89 * @brief Create an initialized MotionValue with KeyFrames.
92 * @param[in] keyFrames The keyframes value.
93 * @return A handle to a newly allocated Dali resource
95 static MotionValue New(KeyFrames keyFrames);
98 * @brief Creates an uninitialized MotionValue.
100 * Only derived versions can be instantiated. Calling member
101 * functions with an uninitialized Dali::Object is not allowed.
110 * This is non-virtual since derived Handle types must not contain data or virtual methods.
117 * @brief Copy constructor.
120 * @param[in] motionValue Handle to an object
122 MotionValue(const MotionValue& motionValue);
125 * @brief Move constructor
128 * @param[in] rhs A reference to the moved handle
130 MotionValue(MotionValue&& rhs) noexcept;
133 * @brief Assignment operator.
136 * @param[in] motionValue Handle to an object
137 * @return reference to this
139 MotionValue& operator=(const MotionValue& motionValue);
142 * @brief Move assignment
145 * @param[in] rhs A reference to the moved handle
146 * @return A reference to this
148 MotionValue& operator=(MotionValue&& rhs) noexcept;
151 * @brief Downcasts an Object handle to MotionValue.
153 * If handle points to a MotionValue, the downcast produces valid handle.
154 * If not, the returned handle is left uninitialized.
157 * @param[in] handle Handle to an object
158 * @return Handle to a MotionValue or an uninitialized handle
160 static MotionValue DownCast(BaseHandle handle);
162 public: // Public Method
164 * @brief Get the type of value this MotionValue hold.
165 * The type of value will be changed what we set.
168 * @return Type of value.
170 ValueType GetValueType() const;
173 * @brief Set the value as Property::Value type.
176 * @param[in] propertyValue The static value.
178 void SetValue(Property::Value propertyValue);
181 * @brief Set the value as KeyFrames type.
184 * @param[in] keyFrames The keyframes value.
186 void SetValue(KeyFrames keyFrames);
189 * @brief Make value as Invalid type.
196 * @brief Get the value as Property::Value.
197 * If ValueType is KEY_FRAMES, it will return last value of stored KeyFrames.
200 * @return Property value, or empty if it is invalid.
202 Property::Value GetPropertyValue() const;
205 * @brief Get the value as KeyFrames
206 * If ValueType is PROPERTY_VALUE, it will create new KeyFrames by stored Property::Value.
209 * @return Keyframes handle, or empty if it is invalid.
211 KeyFrames GetKeyFrames() const;
213 public: // Not intended for application developers
216 * @brief Creates a handle using the Scene3D::Internal implementation.
218 * @param[in] implementation The MotionValue implementation
220 DALI_INTERNAL MotionValue(Dali::Scene3D::Internal::MotionValue* implementation);
228 } // namespace Scene3D
232 #endif // DALI_SCENE3D_MODEL_MOTION_MOTION_VALUE_H