1ad32ede2f2b7e0652446e9e8ebc2ce282a0c18c
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / layout-item.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_H
2 #define DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_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-toolkit/public-api/dali-toolkit-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/devel-api/layouting/child-layout-data.h>
28 #include <dali-toolkit/devel-api/layouting/measure-spec.h>
29 #include <dali-toolkit/devel-api/layouting/layout-transition-data.h>
30 #include <dali-toolkit/public-api/dali-toolkit-common.h>
31
32 namespace Dali
33 {
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39 class LayoutItem;
40 }
41
42 using LayoutId = unsigned int;
43
44 /**
45  * Base class for layouts. It is used to layout a control (or visual).
46  * It can be laid out by a LayoutGroup.
47  */
48 class DALI_TOOLKIT_API LayoutItem : public BaseHandle
49 {
50 public:
51
52   enum PropertyRange
53   {
54     CHILD_PROPERTY_START_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX, ///< Start index is used by child properties
55     CHILD_PROPERTY_END_INDEX   = CHILD_PROPERTY_REGISTRATION_START_INDEX+1000 ///< Reserving 1000 property indices
56   };
57
58   struct ChildProperty
59   {
60     enum
61     {
62       WIDTH_SPECIFICATION = ///< Child property to specify desired width (May use MATCH_PARENT/WRAP_CONTENT)
63         CHILD_PROPERTY_START_INDEX,
64       HEIGHT_SPECIFICATION ///< Child property to specify desired height (May use MATCH_PARENT/WRAP_CONTENT)
65     };
66   };
67
68   /**
69    * @brief Default constructor which provides an uninitialized Dali::LayoutItem.
70    */
71   LayoutItem();
72
73   /**
74    * @brief Default destructor
75    */
76   ~LayoutItem()=default;
77
78   /**
79    * @brief Create an initialized LayoutItem
80    *
81    * @param[in] handle A handle to the object that this layout for, e.g. a Control or a Visual::Base
82    * @warning This is an interim function, and will be deleted when all controls have layouts
83    * @todo Ensure that this warning is implemented
84    */
85   static LayoutItem New( Handle& handle );
86
87   /**
88    * @brief Copy constructor
89    * @param[in] copy The LayoutItem to copy.
90    */
91   LayoutItem(const LayoutItem& copy) = default;
92
93   /**
94    * @brief Assignment operator
95    * @param[in] rhs The LayoutItem to copy
96    */
97   LayoutItem& operator=( const LayoutItem& rhs ) = default;
98
99   /**
100    * @brief Get a handle to the control or visual this layout represents.
101    *
102    * @return
103    */
104   Handle GetOwner() const;
105
106   /**
107    * @brief Set whether this layout should be animated or not
108    *
109    * @param[in] animateLayout True if the layout should be animated when applied
110    */
111   void SetAnimateLayout( bool animateLayout );
112
113   /**
114    * @brief Predicate to determine whether this layout should be animated when applied
115    *
116    * @return True if the layout should be animated when applied
117    */
118   bool IsLayoutAnimated() const;
119
120   /**
121    * @brief Set the layout transition data
122    *
123    * @param[in] layoutTransitionType The type of the layout transition
124    * @param[in] layoutTransitionData The layout transition data
125    */
126   void SetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType, LayoutTransitionData layoutTransitionData );
127
128   /**
129    * @brief Get the layout transition data
130    *
131    * @param[in] layoutTransitionType The type of the layout transition
132    *
133    * @return The layout transition data
134    */
135   LayoutTransitionData GetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType ) const;
136
137 public:
138   /// @cond internal
139   /**
140    * @brief This constructor is used by LayoutItem::New() methods.
141    *
142    * @param[in] actor A pointer to a newly allocated Dali resource
143    */
144   explicit LayoutItem( Internal::LayoutItem* LayoutItem );
145   /// @endcond
146 };
147
148
149 }//namespace Toolkit
150 }//namespace Dali
151
152 #endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_H