[dali_1.4.16] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / layout-transition-data.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H
2 #define DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H
3 /*
4  * Copyright (c) 2018 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 #include <memory>
20 #include <cstdint>
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/object/property-index-ranges.h>
26 #include <dali/public-api/object/property-map.h>
27 #include <dali-toolkit/public-api/dali-toolkit-common.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36 class LayoutTransitionData;
37 }
38
39 /**
40  * @brief The LayoutTransitionData class to collect the actors properties animators for layout transitions.
41  */
42 class DALI_TOOLKIT_API LayoutTransitionData final : public BaseHandle
43 {
44 public:
45
46   /**
47    * @brief Enumeration for property animator keys belonging to the LayoutTransitionData class.
48    */
49   struct AnimatorKey
50   {
51     enum Type
52     {
53       CONDITION,            ///< A condition triggering the transition animation (the actor is added/removed/focus gained/focus lost)
54       PROPERTY,             ///< A property to animate
55       INITIAL_VALUE,        ///< Initial value of an animated property
56       TARGET_VALUE,         ///< Target value of an animated property
57       ANIMATOR,             ///< Animator for an animated property
58       TYPE,                 ///< Type of an animator
59       NAME,                 ///< Name of an animator
60       TIME_PERIOD,          ///< Time period of an property animation
61       DURATION,             ///< Duration of an property animation
62       DELAY,                ///< Delay of an property animation
63       ALPHA_FUNCTION,       ///< Alpha function of a property animation
64       AFFECTS_SIBLINGS,     ///< Might change the actor siblings positions etc by updating the actor measured size if the actor size is changed due to the animation. False by default.
65     };
66   };
67
68   struct Animator
69   {
70     enum Type
71     {
72       ANIMATE_TO,           ///< Animate to property target value
73       ANIMATE_BY,           ///< Animate by property target value
74       ANIMATE_BETWEEN,      ///< Animate between property initial and target values
75       ANIMATE_PATH          ///< Animate using the animation path
76     };
77   };
78
79   struct Condition
80   {
81     enum Type
82     {
83       NONE,            ///< Default, no conditions to animate property. The property is animated for all relevant animations related to a control
84       ON_ADD,          ///< A condition to animate property when a control is added to the container
85       ON_REMOVE,       ///< A condition to animate property when a control is removed from the container
86       ON_FOCUS_GAINED, ///< A condition to animate property when a control focus is gained
87       ON_FOCUS_LOST,   ///< A condition to animate property when a control focus is lost
88     };
89   };
90
91   enum Type
92   {
93     // Children related transitions
94     ON_CHILD_ADD,          ///< A transition is triggered when a control is added to the container
95     ON_CHILD_REMOVE,       ///< A transition is triggered when a control is removed from the container
96     ON_CHILD_FOCUS,        ///< A transition is triggered when a control focus is changed in the container
97     // Layout related transitions
98     ON_OWNER_SET,          ///< A transition is triggered when a layout is set to a new container
99     ON_LAYOUT_CHANGE,      ///< A transition is triggered when a layout geometry is changed
100   };
101
102   typedef Signal< void (LayoutTransitionData::Type, LayoutTransitionData&) > LayoutTransitionSignalType; ///< Transition finished signal
103
104   /**
105    * Create an uninitialized handle
106    *
107    * @SINCE_1_2.12
108    */
109   LayoutTransitionData();
110
111   /**
112    * Destructor - non virtual
113    *
114    * @SINCE_1_2.12
115    */
116   ~LayoutTransitionData() = default;
117
118   /**
119    * Create an initialized LayoutTransitionData
120    */
121   static LayoutTransitionData New();
122
123   /**
124    * @brief Downcasts a handle to LayoutTransitionData handle.
125    *
126    * If handle points to an LayoutTransitionData object, the downcast produces valid handle.
127    * If not, the returned handle is left uninitialized.
128    *
129    * @param[in] handle Handle to an object
130    * @return Handle to an LayoutTransitionData object or an uninitialized handle
131    */
132   static LayoutTransitionData DownCast( BaseHandle handle );
133
134   /**
135    * @brief Add a property animator for an actor
136    *
137    * @param[in] actor An owner of the animated property.
138    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
139    * @param[in] map The animated property map including animator map
140    */
141   void AddPropertyAnimator( Actor actor, Property::Map map );
142
143   /**
144    * @brief Add a property animator for an actor
145    *
146    * @param[in] actor An owner of the animated property
147    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
148    * @param[in] map The properties map
149    * @param[in] keyFrames key frames
150    * @param[in] interpolation An interpolation
151    */
152   void AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation );
153
154   /**
155    * @brief Add a property animator for an actor
156    *
157    * @param[in] actor An owner of the animated property
158    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
159    * @param[in] map A properties map
160    * @param[in] path An animation path
161    * @param[in] forward A forward vector for the path
162    */
163   void AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward );
164
165   /**
166     * @brief Connects to this signal to be notified when a transition animation have finished.
167     *
168     * @return A signal object to connect with
169     */
170   LayoutTransitionSignalType& FinishedSignal();
171
172 public:
173   /// @cond internal
174   /**
175    * @brief This constructor is used by LayoutTransitionData::New() method.
176    *
177    * @param[in] layoutTransitonData A pointer to a newly allocated transition data resource
178    */
179   DALI_INTERNAL explicit LayoutTransitionData( Internal::LayoutTransitionData* layoutTransitonData );
180   /// @endcond
181 };
182
183 }//namespace Toolkit
184 }//namespace Dali
185
186 #endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H