Emscripten workarounds and llvm syntax fixes
[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 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/actors/layer.h>
22 #include <dali/internal/event/actors/actor-impl.h>
23 #include <dali/internal/event/actors/actor-declarations.h>
24 #include <dali/internal/event/images/frame-buffer-image-impl.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    * Create a new Layer.
48    * @return A smart-pointer to the newly allocated Layer.
49    */
50   static LayerPtr New();
51
52   /**
53    * Create a new root layer; this is typically owned by the stage.
54    * @param[in] stage The owning stage.
55    * @param[in] layerList The layer will be added to this ordered list.
56    * @param[in] manager The update manager to install a root node with.
57    * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
58    * @return A smart-pointer to the newly allocated Actor.
59    */
60   static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
61
62   /**
63    * @copydoc Dali::Internal::Actor::OnInitialize
64    */
65   void OnInitialize();
66
67    /**
68    * Query the current depth of the layer
69    */
70   unsigned int GetDepth() const;
71
72   /**
73    * @copydoc Dali::Layer::Raise
74    */
75   void Raise();
76
77   /**
78    * @copydoc Dali::Layer::Lower
79    */
80   void Lower();
81
82   /**
83    * @copydoc Dali::Layer::RaiseAbove
84    */
85   void RaiseAbove( const Internal::Layer& target );
86
87   /**
88    * @copydoc Dali::Layer::LowerBelow
89    */
90   void LowerBelow( const Internal::Layer& target );
91
92   /**
93    * @copydoc Dali::Layer::RaiseToTop
94    */
95   void RaiseToTop();
96
97   /**
98    * @copydoc Dali::Layer::LowerToBottom
99    */
100   void LowerToBottom();
101
102   /**
103    * @copydoc Dali::Layer::MoveAbove
104    */
105   void MoveAbove( const Internal::Layer& target );
106
107   /**
108    * @copydoc Dali::Layer::MoveAbove
109    */
110   void MoveBelow( const Internal::Layer& target );
111
112   /**
113    * @copydoc Dali::Layer::SetClipping()
114    */
115   void SetClipping(bool enabled);
116
117   /**
118    * @copydoc Dali::Layer::IsClipping()
119    */
120   bool IsClipping() const
121   {
122     return mIsClipping; // Actor-side has most up-to-date value
123   }
124
125   /**
126    * @copydoc Dali::Layer::SetClippingBox()
127    */
128   void SetClippingBox(int x, int y, int width, int height);
129
130   /**
131    * @copydoc Dali::Layer::GetClippingBox()
132    */
133   const Dali::ClippingBox& GetClippingBox() const
134   {
135     return mClippingBox; // Actor-side has most up-to-date value
136   }
137
138   /**
139    * @copydoc Dali::Layer::SetDepthTestDisabled()
140    */
141   void SetDepthTestDisabled( bool disable );
142
143   /**
144    * @copydoc Dali::Layer::IsDepthTestDisabled()
145    */
146   bool IsDepthTestDisabled() const;
147
148   /**
149    * @copydoc Dali::Layer::SetSortFunction()
150    */
151   void SetSortFunction(Dali::Layer::SortFunctionType function);
152
153   /**
154    * Helper function to get the scene object.
155    * This should only be called by Stage
156    * @return the scene object for the layer.
157    */
158   const SceneGraph::Layer& GetSceneLayerOnStage() const;
159
160   /**
161    * @copydoc Dali::Internal::Actor::DoAction()
162    */
163   static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
164
165 public: // Default property extensions from ProxyObject
166   /**
167    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
168    */
169   virtual unsigned int GetDefaultPropertyCount() const;
170
171   /**
172    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
173    */
174   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
175
176   /**
177    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
178    */
179   virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
180
181   /**
182    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
183    */
184   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
185
186   /**
187    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
188    */
189   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
190
191   /**
192    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
193    */
194   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
195
196   /**
197    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
198    */
199   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
200
201   /**
202    * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
203    */
204   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
205
206   /**
207    * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
208    */
209   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
210
211 protected:
212
213   /**
214    * Construct a new layer.
215    * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
216    */
217   Layer( Actor::DerivedType type );
218
219   /**
220    * A reference counted object may only be deleted by calling Unreference()
221    */
222   virtual ~Layer();
223
224 private: // From Actor
225
226   /**
227    * From Actor; create a node to represent the layer in the scene-graph.
228    * @return A newly allocated layer node.
229    */
230   virtual SceneGraph::Node* CreateNode() const;
231
232   /**
233    * From Actor.
234    */
235   virtual void OnStageConnectionInternal();
236
237   /**
238    * From Actor.
239    */
240   virtual void OnStageDisconnectionInternal();
241
242 private:
243
244   LayerList* mLayerList; ///< Only valid when layer is on-stage
245
246   // These properties not animatable; the actor side has the most up-to-date values
247   FrameBufferImagePtr mFrameBufferImage;        ///< Ticket for offscreen render target
248   ClippingBox mClippingBox;                     ///< The clipping box, in window coordinates
249   Dali::Layer::SortFunctionType mSortFunction;  ///< Used to sort semi-transparent geometry
250
251   bool mIsClipping:1;                           ///< True when clipping is enabled
252   bool mDepthTestDisabled:1;                    ///< Whether depth test is disabled.
253
254   static bool mFirstInstance;
255   static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
256 };
257
258 } // namespace Internal
259
260 // Helpers for public-api forwarding methods
261
262 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
263 {
264   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
265
266   BaseObject& handle = layer.GetBaseObject();
267
268   return static_cast<Internal::Layer&>(handle);
269 }
270
271 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
272 {
273   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
274
275   const BaseObject& handle = layer.GetBaseObject();
276
277   return static_cast<const Internal::Layer&>(handle);
278 }
279
280 } // namespace Dali
281
282
283 #endif //__DALI_INTERNAL_LAYER_H__