Merge "Add log for font load validation" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / animated-property.h
1 #ifndef DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H
2 #define DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_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 // INTERNAL INCLUDES
21 #include "dali-scene3d/public-api/api.h"
22
23 // EXTERNAL INCLUDES
24 #include <functional>
25 #include <memory>
26 #include "dali/public-api/actors/actor.h"
27 #include "dali/public-api/animation/animation.h"
28 #include "dali/public-api/object/property.h"
29
30 namespace Dali
31 {
32 namespace Scene3D
33 {
34 namespace Loader
35 {
36 /**
37  * @brief Intermediate representation for a property that's given to
38  *  a Animation to animate. Since there is no getting an
39  *  animated property back from the Animation (i.e. past AnimateBetween/By/To()),
40  *  changing properties (e.g. from the SDK) requires the whole Animation
41  *  object to be recreated with all of its properties (incl. modifications).
42  */
43 struct DALI_SCENE3D_API AnimatedProperty
44 {
45 public: // METHODS
46   /**
47    * @brief Function to obtain an Actor based on its name. Its processing will
48    *  ignore empty handles returned by it.
49    */
50   using GetActor = std::function<Actor(const std::string&)>;
51
52   /**
53    * @return The Property object (of the given @a actor) whose value is being animated.
54    */
55   Property GetProperty(Actor& actor)
56   {
57     auto idx = actor.GetPropertyIndex(mPropertyName);
58     return Property(actor, idx);
59   }
60
61   /**
62    * @brief The type of the Property (of the given @a actor) that is being animated.
63    */
64   Property::Type GetPropertyType(Actor& actor)
65   {
66     auto idx = actor.GetPropertyIndex(mPropertyName);
67     return actor.GetPropertyType(idx);
68   }
69
70   /**
71    * @brief Registers the animation of this property against the given @a anim.
72    *  @a getActor will be used to obtain the Actor named by this property.
73    *  Failing to find the actor purely means that this property will not be
74    *  animated.
75    */
76   void Animate(Animation& anim, GetActor getActor);
77
78 public: // DATA
79   struct Value
80   {
81     Property::Value mValue;
82     bool            mIsRelative;
83   };
84
85   std::string mNodeName;
86   std::string mPropertyName;
87
88   KeyFrames              mKeyFrames;
89   std::unique_ptr<Value> mValue;
90
91   AlphaFunction mAlphaFunction = AlphaFunction::DEFAULT;
92   TimePeriod    mTimePeriod    = TimePeriod(0.f);
93 };
94
95 } // namespace Loader
96 } // namespace Scene3D
97 } // namespace Dali
98
99 #endif //DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H