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