Change dali-scene-loader to dali-scene3d
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / animation-definition.h
1 #ifndef DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H
2 #define DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H
3 /*
4  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "dali-scene3d/public-api/api.h"
21 #include "dali-scene3d/public-api/loader/animated-property.h"
22 #include "dali/public-api/common/vector-wrapper.h"
23
24 namespace Dali
25 {
26 namespace Scene3D
27 {
28 namespace Loader
29 {
30 /**
31  * @brief Animation handle + name + definition of properties.
32  */
33 class DALI_SCENE3D_API AnimationDefinition
34 {
35 public: // STATIC
36   // For Animations created in the SDK.
37   static const float DEFAULT_DURATION_SECONDS;
38
39   // For parsing Animations from dli, when duration was not defined.
40   static const float MIN_DURATION_SECONDS;
41
42   /**
43    * @brief Saves the original end action of @a anim, sets the end action to
44    *  Discard, then stops the animation and returns the end action.
45    */
46   static Animation::EndAction StopForModification(Animation& anim);
47
48 public: // METHODS
49   AnimationDefinition();
50
51   AnimationDefinition(AnimationDefinition&& other);
52
53   /**
54    * @brief Registers the properties against the given @a animation. @a getActor
55    *  will be used to obtain the Actors for each AnimatedProperty.
56    */
57   void Animate(Animation& animation, AnimatedProperty::GetActor getActor);
58
59   /**
60    * @brief Creates a new Animation and Animates() its properties. @a getActor
61    *  will be used to obtain the Actors for each AnimatedProperty.
62    */
63   Animation ReAnimate(AnimatedProperty::GetActor getActor);
64
65   AnimationDefinition& operator=(AnimationDefinition&& other);
66
67 public: // DATA
68   std::string mName;
69
70   float                mDuration         = DEFAULT_DURATION_SECONDS;
71   int                  mLoopCount        = 1;
72   Animation::EndAction mDisconnectAction = Animation::BAKE_FINAL;
73   Animation::EndAction mEndAction        = Animation::BAKE;
74   float                mSpeedFactor      = 1.f;
75   Vector2              mPlayRange        = Vector2{0.f, 1.f};
76
77   std::vector<AnimatedProperty> mProperties;
78 };
79
80 struct AnimationGroupDefinition
81 {
82   std::string              mName;
83   std::vector<std::string> mAnimations;
84 };
85
86 } // namespace Loader
87 } // namespace Scene3D
88 } // namespace Dali
89
90 #endif //DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H