Updated all header files to new format
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / animation-definition.h
1 #ifndef DALI_SCENE_LOADER_ANIMATION_DEFINITION_H
2 #define DALI_SCENE_LOADER_ANIMATION_DEFINITION_H
3 /*
4  * Copyright (c) 2021 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-scene-loader/public-api/animated-property.h"
21 #include "dali-scene-loader/public-api/api.h"
22 #include "dali/public-api/common/vector-wrapper.h"
23
24 namespace Dali
25 {
26 namespace SceneLoader
27 {
28 /**
29  * @brief Animation handle + name + definition of properties.
30  */
31 class DALI_SCENE_LOADER_API AnimationDefinition
32 {
33 public: // STATIC
34   // For Animations created in the SDK.
35   static const float DEFAULT_DURATION_SECONDS;
36
37   // For parsing Animations from dli, when duration was not defined.
38   static const float MIN_DURATION_SECONDS;
39
40   /**
41    * @brief Saves the original end action of @a anim, sets the end action to
42    *  Discard, then stops the animation and returns the end action.
43    */
44   static Animation::EndAction StopForModification(Animation& anim);
45
46 public: // METHODS
47   AnimationDefinition();
48
49   AnimationDefinition(AnimationDefinition&& other);
50
51   /**
52    * @brief Registers the properties against the given @a animation. @a getActor
53    *  will be used to obtain the Actors for each AnimatedProperty.
54    */
55   void Animate(Animation& animation, AnimatedProperty::GetActor getActor);
56
57   /**
58    * @brief Creates a new Animation and Animates() its properties. @a getActor
59    *  will be used to obtain the Actors for each AnimatedProperty.
60    */
61   Animation ReAnimate(AnimatedProperty::GetActor getActor);
62
63   AnimationDefinition& operator=(AnimationDefinition&& other);
64
65 public: // DATA
66   std::string mName;
67
68   float                mDuration         = DEFAULT_DURATION_SECONDS;
69   int                  mLoopCount        = 1;
70   Animation::EndAction mDisconnectAction = Animation::BAKE_FINAL;
71   Animation::EndAction mEndAction        = Animation::BAKE;
72   float                mSpeedFactor      = 1.f;
73   Vector2              mPlayRange        = Vector2{0.f, 1.f};
74
75   std::vector<AnimatedProperty> mProperties;
76 };
77
78 struct AnimationGroupDefinition
79 {
80   std::string              mName;
81   std::vector<std::string> mAnimations;
82 };
83
84 } // namespace SceneLoader
85 } // namespace Dali
86
87 #endif //DALI_SCENE_LOADER_ANIMATION_DEFINITION_H