[dali_1.4.8] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / layer-list.h
1 #ifndef __DALI_INTERNAL_LAYER_LIST_H__
2 #define __DALI_INTERNAL_LAYER_LIST_H__
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <cstdint> // uint32_t
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/vector-wrapper.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace SceneGraph
34 {
35 class UpdateManager;
36 }
37
38 class Layer;
39
40 /**
41  * An ordered list of layers.
42  * Layers are not owned by the LayerList; each layer is responsible for registering & unregistering.
43  * This is used by the Stage, to keep track of layer depths.
44  */
45 class LayerList
46 {
47 public:
48
49   /**
50    * Create a new list of layers.
51    * @param[in] updateManager A reference to the update manager.
52    */
53   static LayerList* New( SceneGraph::UpdateManager& updateManager );
54
55   /**
56    * Non-virtual destructor; not suitable as a base class.
57    */
58   ~LayerList();
59
60   /**
61    * Query the number of layers.
62    * @return The number of layers.
63    */
64   uint32_t GetLayerCount() const;
65
66   /**
67    * Retrieve the layer at a specified depth.
68    * @pre depth is less than layer count; see GetLayerCount().
69    * @param[in] depth The depth.
70    * @return The layer found at the given depth.
71    */
72   Layer* GetLayer( uint32_t depth ) const;
73
74   /**
75    * Gets the depth of a given layer
76    * @param layer which depth to check
77    */
78   uint32_t GetDepth( const Layer* layer ) const;
79
80   /**
81    * Register a layer with the stage.
82    * The stage determines the relative depth of each layer.
83    */
84   void RegisterLayer( Layer& layer );
85
86   /**
87    * Unregister a layer from the stage
88    */
89   void UnregisterLayer(Layer& layer);
90
91   /**
92    * Increment the depth of the layer inside the stage
93    * @pre layer is on stage
94    */
95   void RaiseLayer(Layer& layer);
96
97   /**
98    * Decrement the depth of the layer inside the stage
99    * @pre layer is on stage
100    */
101   void LowerLayer(Layer& layer);
102
103   /**
104    * Raises the layer to the top of the stage
105    * @pre layer is on stage
106    * @param layer to move
107    */
108   void RaiseLayerToTop( const Layer& layer );
109
110   /**
111    * Lowers the layer to the bottom of the stage
112    * @pre layer is on stage
113    * @param layer to move
114    */
115   void LowerLayerToBottom( const Layer& layer );
116
117   /**
118    * Moves the layer above the target layer on the stage
119    * @pre layer is on stage
120    * @pre target is on stage
121    * @param layer to move
122    * @param target to move above of
123    */
124   void MoveLayerAbove( const Layer& layer, const Layer& target );
125
126   /**
127    * Moves the layer below the target layer on the stage
128    * @pre layer is on stage
129    * @pre target is on stage
130    * @param layer to move
131    * @param target to move below of
132    */
133   void MoveLayerBelow( const Layer& layer, const Layer& target );
134
135   /**
136    * Sets the root layer that this layer list belongs to
137    * @pre the root layer is created
138    * @param rootLayer The root layer
139    */
140   void SetRootLayer(Layer* rootLayer);
141
142 private:
143
144   /**
145    * Protected constructor; see also LayerList::New().
146    * @param[in] updateManager to send messages.
147    */
148   LayerList( SceneGraph::UpdateManager& updateManager );
149
150   /**
151    * A private helper method to set the depth for each layer.
152    * Layers have depth which is the same as their ordinal number in the stage container
153    * This method propagates any changes in the layer depths onto the scene graph side
154    */
155   void SetLayerDepths();
156
157 private:
158
159   SceneGraph::UpdateManager& mUpdateManager;
160
161   Layer* mRoot;        ///< The root layer that this ordered list of layers belong to
162
163   typedef std::vector<Layer*> LayerContainer;
164
165   // Layers are not owned by the LayerList.
166   // Each layer is responsible for registering & unregistering before the end of its life-time.
167   LayerContainer mLayers;
168 };
169
170 } // namespace Internal
171
172 } // namespace Dali
173
174 #endif // __DALI_INTERNAL_LAYER_LIST_H__