Change RenderTaskList to behave like any other SceneGraph object
[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  * A separate LayerList is maintained for actors added via the SystemOverlay::Add().
45  */
46 class LayerList
47 {
48 public:
49
50   /**
51    * Create a new list of layers.
52    * @param[in] updateManager A reference to the update manager.
53    */
54   static LayerList* New( SceneGraph::UpdateManager& updateManager );
55
56   /**
57    * Non-virtual destructor; not suitable as a base class.
58    */
59   ~LayerList();
60
61   /**
62    * Query the number of layers.
63    * @return The number of layers.
64    */
65   uint32_t GetLayerCount() const;
66
67   /**
68    * Retrieve the layer at a specified depth.
69    * @pre depth is less than layer count; see GetLayerCount().
70    * @param[in] depth The depth.
71    * @return The layer found at the given depth.
72    */
73   Layer* GetLayer( uint32_t depth ) const;
74
75   /**
76    * Gets the depth of a given layer
77    * @param layer which depth to check
78    */
79   uint32_t GetDepth( const Layer* layer ) const;
80
81   /**
82    * Register a layer with the stage.
83    * The stage determines the relative depth of each layer.
84    */
85   void RegisterLayer( Layer& layer );
86
87   /**
88    * Unregister a layer from the stage
89    */
90   void UnregisterLayer(Layer& layer);
91
92   /**
93    * Increment the depth of the layer inside the stage
94    * @pre layer is on stage
95    */
96   void RaiseLayer(Layer& layer);
97
98   /**
99    * Decrement the depth of the layer inside the stage
100    * @pre layer is on stage
101    */
102   void LowerLayer(Layer& layer);
103
104   /**
105    * Raises the layer to the top of the stage
106    * @pre layer is on stage
107    * @param layer to move
108    */
109   void RaiseLayerToTop( const Layer& layer );
110
111   /**
112    * Lowers the layer to the bottom of the stage
113    * @pre layer is on stage
114    * @param layer to move
115    */
116   void LowerLayerToBottom( const Layer& layer );
117
118   /**
119    * Moves the layer above the target layer on the stage
120    * @pre layer is on stage
121    * @pre target is on stage
122    * @param layer to move
123    * @param target to move above of
124    */
125   void MoveLayerAbove( const Layer& layer, const Layer& target );
126
127   /**
128    * Moves the layer below the target layer on the stage
129    * @pre layer is on stage
130    * @pre target is on stage
131    * @param layer to move
132    * @param target to move below of
133    */
134   void MoveLayerBelow( const Layer& layer, const Layer& target );
135
136   /**
137    * Sets the root layer that this layer list belongs to
138    * @pre the root layer is created
139    * @param rootLayer The root layer
140    */
141   void SetRootLayer(Layer* rootLayer);
142
143 private:
144
145   /**
146    * Protected constructor; see also LayerList::New().
147    * @param[in] updateManager to send messages.
148    */
149   LayerList( SceneGraph::UpdateManager& updateManager );
150
151   /**
152    * A private helper method to set the depth for each layer.
153    * Layers have depth which is the same as their ordinal number in the stage container
154    * This method propagates any changes in the layer depths onto the scene graph side
155    */
156   void SetLayerDepths();
157
158 private:
159
160   SceneGraph::UpdateManager& mUpdateManager;
161
162   Layer* mRoot;        ///< The root layer that this ordered list of layers belong to
163
164   typedef std::vector<Layer*> LayerContainer;
165
166   // Layers are not owned by the LayerList.
167   // Each layer is responsible for registering & unregistering before the end of its life-time.
168   LayerContainer mLayers;
169 };
170
171 } // namespace Internal
172
173 } // namespace Dali
174
175 #endif // __DALI_INTERNAL_LAYER_LIST_H__