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