License conversion from Flora to Apache 2.0
[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) 2014 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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 class Layer;
31 class Stage;
32
33 /**
34  * An ordered list of layers.
35  * Layers are not owned by the LayerList; each layer is responsible for registering & unregistering.
36  * This is used by the Stage, to keep track of layer depths.
37  * A separate LayerList is maintained for actors added via the SystemOverlay::Add().
38  */
39 class LayerList
40 {
41 public:
42
43   /**
44    * Create a new list of layers.
45    * @param[in] stage A reference to the stage.
46    * @param[in] systemLevel True if the layers are added via the SystemOverlay API.
47    */
48   static LayerList* New( Stage& stage, bool systemLevel );
49
50   /**
51    * Non-virtual destructor; not suitable as a base class.
52    */
53   ~LayerList();
54
55   /**
56    * Query the number of layers.
57    * @return The number of layers.
58    */
59   unsigned int GetLayerCount() const;
60
61   /**
62    * Retrieve the layer at a specified depth.
63    * @pre depth is less than layer count; see GetLayerCount().
64    * @param[in] depth The depth.
65    * @return The layer found at the given depth.
66    */
67   Layer* GetLayer( unsigned int depth ) const;
68
69   /**
70    * Gets the depth of a given layer
71    * @param layer which depth to check
72    */
73   unsigned int GetDepth( const Layer* layer ) const;
74
75   /**
76    * Register a layer with the stage.
77    * The stage determines the relative depth of each layer.
78    */
79   void RegisterLayer( Layer& layer );
80
81   /**
82    * Unregister a layer from the stage
83    */
84   void UnregisterLayer(Layer& layer);
85
86   /**
87    * Increment the depth of the layer inside the stage
88    * @pre layer is on stage
89    */
90   void RaiseLayer(Layer& layer);
91
92   /**
93    * Decrement the depth of the layer inside the stage
94    * @pre layer is on stage
95    */
96   void LowerLayer(Layer& layer);
97
98   /**
99    * Raises the layer to the top of the stage
100    * @pre layer is on stage
101    * @param layer to move
102    */
103   void RaiseLayerToTop( const Layer& layer );
104
105   /**
106    * Lowers the layer to the bottom of the stage
107    * @pre layer is on stage
108    * @param layer to move
109    */
110   void LowerLayerToBottom( const Layer& layer );
111
112   /**
113    * Moves the layer above the target layer on the stage
114    * @pre layer is on stage
115    * @pre target is on stage
116    * @param layer to move
117    * @param target to move above of
118    */
119   void MoveLayerAbove( const Layer& layer, const Layer& target );
120
121   /**
122    * Moves the layer below the target layer on the stage
123    * @pre layer is on stage
124    * @pre target is on stage
125    * @param layer to move
126    * @param target to move below of
127    */
128   void MoveLayerBelow( const Layer& layer, const Layer& target );
129
130 private:
131
132   /**
133    * Protected constructor; see also LayerList::New().
134    * @param[in] stage A reference to the stage.
135    * @param[in] systemLevel True if the layers are added via the SystemOverlay API.
136    */
137   LayerList( Stage& stage, bool systemLevel );
138
139   /**
140    * A private helper method to set the depth for each layer.
141    * Layers have depth which is the same as their ordinal number in the stage container
142    * This method propagates any changes in the layer depths onto the scene graph side
143    */
144   void SetLayerDepths();
145
146 private:
147
148   Stage& mStage;
149
150   bool mIsSystemLevel; ///< True if the layers are added via the SystemOverlay API.
151
152   typedef std::vector<Layer*> LayerContainer;
153
154   // Layers are not owned by the LayerList.
155   // Each layer is responsible for registering & unregistering before the end of its life-time.
156   LayerContainer mLayers;
157 };
158
159 } // namespace Internal
160
161 } // namespace Dali
162
163 #endif // __DALI_INTERNAL_LAYER_LIST_H__