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