Remove std::vector from public api
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / layer-impl.h
1 #ifndef __DALI_INTERNAL_LAYER_H__
2 #define __DALI_INTERNAL_LAYER_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/actors/layer.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/internal/event/actors/actor-declarations.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class LayerList;
33
34 namespace SceneGraph
35 {
36 class UpdateManager;
37 class Layer;
38 }
39
40 typedef Dali::ClippingBox ClippingBox;
41
42 class Layer : public Actor
43 {
44 public:
45
46   /**
47    * @brief This sort function sorts translucent actors according to the Z-value in view space.
48    *
49    * This is useful for 2D user interfaces.
50    *
51    * This is the default sorting function.
52    *
53    * We return a negative z value as in our translation, a low z means that it should
54    * be sorted further away and a high z means that it should be closer.
55    * @param[in] position     position of actor in view space
56    * @param[in] sortModifier additional sort modifer
57    * @return depth
58    */
59   static float ZValue(const Vector3& position, float sortModifier)
60   {
61     // inlined so we avoid a function call when sorting renderers
62     return position.z + sortModifier;
63   }
64
65   /**
66    * Create a new Layer.
67    * @return A smart-pointer to the newly allocated Layer.
68    */
69   static LayerPtr New();
70
71   /**
72    * Create a new root layer; this is typically owned by the stage.
73    * @param[in] layerList The layer will be added to this ordered list.
74    * @param[in] manager The update manager to install a root node with.
75    * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
76    * @return A smart-pointer to the newly allocated Actor.
77    */
78   static LayerPtr NewRoot( LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
79
80   /**
81    * @copydoc Dali::Internal::Actor::OnInitialize
82    */
83   void OnInitialize();
84
85   /**
86    * Query the current depth of the layer
87    */
88   unsigned int GetDepth() const;
89
90   /**
91    * @copydoc Dali::Layer::Raise
92    */
93   void Raise();
94
95   /**
96    * @copydoc Dali::Layer::Lower
97    */
98   void Lower();
99
100   /**
101    * @copydoc Dali::Layer::RaiseAbove
102    */
103   void RaiseAbove( const Internal::Layer& target );
104
105   /**
106    * @copydoc Dali::Layer::LowerBelow
107    */
108   void LowerBelow( const Internal::Layer& target );
109
110   /**
111    * @copydoc Dali::Layer::RaiseToTop
112    */
113   void RaiseToTop();
114
115   /**
116    * @copydoc Dali::Layer::LowerToBottom
117    */
118   void LowerToBottom();
119
120   /**
121    * @copydoc Dali::Layer::MoveAbove
122    */
123   void MoveAbove( const Internal::Layer& target );
124
125   /**
126    * @copydoc Dali::Layer::MoveAbove
127    */
128   void MoveBelow( const Internal::Layer& target );
129
130   /**
131    * @copydoc Dali::Layer::SetClipping()
132    */
133   void SetClipping(bool enabled);
134
135   /**
136    * @copydoc Dali::Layer::IsClipping()
137    */
138   bool IsClipping() const
139   {
140     return mIsClipping; // Actor-side has most up-to-date value
141   }
142
143   /**
144    * @copydoc Dali::Layer::SetClippingBox()
145    */
146   void SetClippingBox(int x, int y, int width, int height);
147
148   /**
149    * @copydoc Dali::Layer::GetClippingBox()
150    */
151   const Dali::ClippingBox& GetClippingBox() const
152   {
153     return mClippingBox; // Actor-side has most up-to-date value
154   }
155
156   /**
157    * @copydoc Dali::Layer::SetDepthTestDisabled()
158    */
159   void SetDepthTestDisabled( bool disable );
160
161   /**
162    * @copydoc Dali::Layer::IsDepthTestDisabled()
163    */
164   bool IsDepthTestDisabled() const;
165
166   /**
167    * @copydoc Dali::Layer::SetSortFunction()
168    */
169   void SetSortFunction(Dali::Layer::SortFunctionType function);
170
171   /**
172    * @copydoc Dali::Layer::SetTouchConsumed()
173    */
174   void SetTouchConsumed( bool consume );
175
176   /**
177    * @copydoc Dali::Layer::IsTouchConsumed()
178    */
179   bool IsTouchConsumed() const;
180
181   /**
182    * @copydoc Dali::Layer::SetHoverConsumed()
183    */
184   void SetHoverConsumed( bool consume );
185
186   /**
187    * @copydoc Dali::Layer::IsHoverConsumed()
188    */
189   bool IsHoverConsumed() const;
190
191   /**
192    * Helper function to get the scene object.
193    * This should only be called by Stage
194    * @return the scene object for the layer.
195    */
196   const SceneGraph::Layer& GetSceneLayerOnStage() const;
197
198   /**
199    * @copydoc Dali::Internal::Actor::DoAction()
200    */
201   static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
202
203 public: // Default property extensions from Object
204   /**
205    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
206    */
207   virtual unsigned int GetDefaultPropertyCount() const;
208
209   /**
210    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
211    */
212   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
213
214   /**
215    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
216    */
217   virtual const char* GetDefaultPropertyName(Property::Index index) const;
218
219   /**
220    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
221    */
222   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
223
224   /**
225    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
226    */
227   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
228
229   /**
230    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
231    */
232   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
233
234   /**
235    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
236    */
237   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
238
239   /**
240    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
241    */
242   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
243
244   /**
245    * @copydoc Dali::Internal::Object::SetDefaultProperty()
246    */
247   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
248
249   /**
250    * @copydoc Dali::Internal::Object::GetDefaultProperty()
251    */
252   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
253
254 protected:
255
256   /**
257    * Construct a new layer.
258    * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
259    */
260   Layer( Actor::DerivedType type );
261
262   /**
263    * A reference counted object may only be deleted by calling Unreference()
264    */
265   virtual ~Layer();
266
267 private: // From Actor
268
269   /**
270    * From Actor; create a node to represent the layer in the scene-graph.
271    * @return A newly allocated layer node.
272    */
273   virtual SceneGraph::Node* CreateNode() const;
274
275   /**
276    * From Actor.
277    */
278   virtual void OnStageConnectionInternal();
279
280   /**
281    * From Actor.
282    */
283   virtual void OnStageDisconnectionInternal();
284
285 private:
286
287   LayerList* mLayerList; ///< Only valid when layer is on-stage
288
289   // These properties not animatable; the actor side has the most up-to-date values
290   ClippingBox mClippingBox;                     ///< The clipping box, in window coordinates
291   Dali::Layer::SortFunctionType mSortFunction;  ///< Used to sort semi-transparent geometry
292
293   bool mIsClipping:1;                           ///< True when clipping is enabled
294   bool mDepthTestDisabled:1;                    ///< Whether depth test is disabled.
295   bool mTouchConsumed:1;                        ///< Whether we should consume touch (including gesture).
296   bool mHoverConsumed:1;                        ///< Whether we should consume hover.
297
298 };
299
300 } // namespace Internal
301
302 // Helpers for public-api forwarding methods
303
304 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
305 {
306   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
307
308   BaseObject& handle = layer.GetBaseObject();
309
310   return static_cast<Internal::Layer&>(handle);
311 }
312
313 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
314 {
315   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
316
317   const BaseObject& handle = layer.GetBaseObject();
318
319   return static_cast<const Internal::Layer&>(handle);
320 }
321
322 } // namespace Dali
323
324
325 #endif //__DALI_INTERNAL_LAYER_H__