Merge "Remove connecting Layout Child order with Actor child order" into 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     };
65   };
66
67   struct Condition
68   {
69     enum Type
70     {
71       NONE,            ///< Default, no conditions to animate property. The property is animated for all relevant animations related to a control
72       ON_ADD,          ///< A condition to animate property when a control is added to the container
73       ON_REMOVE,       ///< A condition to animate property when a control is removed from the container
74       ON_FOCUS_GAINED, ///< A condition to animate property when a control focus is gained
75       ON_FOCUS_LOST,   ///< A condition to animate property when a control focus is lost
76     };
77   };
78
79   enum Type
80   {
81     // Children related transitions
82     ON_CHILD_ADD,          ///< A transition is triggered when a control is added to the container
83     ON_CHILD_REMOVE,       ///< A transition is triggered when a control is removed from the container
84     ON_CHILD_FOCUS,        ///< A transition is triggered when a control focus is changed in the container
85     // Layout related transitions
86     ON_OWNER_SET,          ///< A transition is triggered when a layout is set to a new container
87     ON_LAYOUT_CHANGE,      ///< A transition is triggered when a layout geometry is changed
88   };
89
90   typedef Signal< void (LayoutTransitionData::Type, LayoutTransitionData&) > LayoutTransitionSignalType; ///< Transition finished signal
91
92   /**
93    * Create an uninitialized handle
94    *
95    * @SINCE_1_2.12
96    */
97   LayoutTransitionData();
98
99   /**
100    * Destructor - non virtual
101    *
102    * @SINCE_1_2.12
103    */
104   ~LayoutTransitionData() = default;
105
106   /**
107    * Create an initialized LayoutTransitionData
108    */
109   static LayoutTransitionData New();
110
111   /**
112    * @brief Downcasts a handle to LayoutTransitionData handle.
113    *
114    * If handle points to an LayoutTransitionData object, the downcast produces valid handle.
115    * If not, the returned handle is left uninitialized.
116    *
117    * @param[in] handle Handle to an object
118    * @return Handle to an LayoutTransitionData object or an uninitialized handle
119    */
120   static LayoutTransitionData DownCast( BaseHandle handle );
121
122   /**
123    * @brief Add a property animator for an actor
124    *
125    * @param[in] actor An owner of the animated property.
126    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
127    * @param[in] map The animated property map including animator map
128    */
129   void AddPropertyAnimator( Actor actor, Property::Map map );
130
131   /**
132    * @brief Add a property animator for an actor
133    *
134    * @param[in] actor An owner of the animated property
135    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
136    * @param[in] map The properties map
137    * @param[in] keyFrames key frames
138    * @param[in] interpolation An interpolation
139    */
140   void AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation );
141
142   /**
143    * @brief Add a property animator for an actor
144    *
145    * @param[in] actor An owner of the animated property
146    *                  If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met.
147    * @param[in] map A properties map
148    * @param[in] path An animation path
149    * @param[in] forward A forward vector for the path
150    */
151   void AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward );
152
153   /**
154     * @brief Connects to this signal to be notified when a transition animation have finished.
155     *
156     * @return A signal object to connect with
157     */
158   LayoutTransitionSignalType& FinishedSignal();
159
160 public:
161   /// @cond internal
162   /**
163    * @brief This constructor is used by LayoutTransitionData::New() method.
164    *
165    * @param[in] layoutTransitonData A pointer to a newly allocated transition data resource
166    */
167   DALI_INTERNAL explicit LayoutTransitionData( Internal::LayoutTransitionData* layoutTransitonData );
168   /// @endcond
169 };
170
171 }//namespace Toolkit
172 }//namespace Dali
173
174 #endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H