1 #ifndef __DALI_INTERNAL_LAYER_H__
2 #define __DALI_INTERNAL_LAYER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
40 typedef Dali::ClippingBox ClippingBox;
42 class Layer : public Actor
47 * @copydoc Dali::Layer::ZValue(const Vector3&, float)
49 * This is the default sorting function.
50 * It is useful for 2D user interfaces, and it's used to sort translucent renderers.
52 * Only the Z signed distance from the camera is considererd, lower values will be drawn on top.
54 * @param[in] position position of actor in view space
57 static float ZValue(const Vector3& position)
59 // inlined so we avoid a function call when sorting renderers
65 * @return A smart-pointer to the newly allocated Layer.
67 static LayerPtr New();
70 * Create a new root layer; this is typically owned by the stage.
71 * @param[in] layerList The layer will be added to this ordered list.
72 * @param[in] manager The update manager to install a root node with.
73 * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
74 * @return A smart-pointer to the newly allocated Actor.
76 static LayerPtr NewRoot( LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
79 * @copydoc Dali::Internal::Actor::OnInitialize
84 * Query the current depth of the layer
86 unsigned int GetDepth() const;
89 * @copydoc Dali::Layer::Raise
94 * @copydoc Dali::Layer::Lower
99 * @copydoc Dali::Layer::RaiseAbove
101 void RaiseAbove( const Internal::Layer& target );
104 * @copydoc Dali::Layer::LowerBelow
106 void LowerBelow( const Internal::Layer& target );
109 * @copydoc Dali::Layer::RaiseToTop
114 * @copydoc Dali::Layer::LowerToBottom
116 void LowerToBottom();
119 * @copydoc Dali::Layer::MoveAbove
121 void MoveAbove( const Internal::Layer& target );
124 * @copydoc Dali::Layer::MoveAbove
126 void MoveBelow( const Internal::Layer& target );
129 * @copydoc Dali::Layer::SetClipping()
131 void SetClipping(bool enabled);
134 * @copydoc Dali::Layer::IsClipping()
136 bool IsClipping() const
138 return mIsClipping; // Actor-side has most up-to-date value
142 * @copydoc Dali::Layer::SetClippingBox()
144 void SetClippingBox(int x, int y, int width, int height);
147 * @copydoc Dali::Layer::GetClippingBox()
149 const Dali::ClippingBox& GetClippingBox() const
151 return mClippingBox; // Actor-side has most up-to-date value
155 * @copydoc Dali::Layer::SetDepthTestDisabled()
157 void SetDepthTestDisabled( bool disable );
160 * @copydoc Dali::Layer::IsDepthTestDisabled()
162 bool IsDepthTestDisabled() const;
165 * @copydoc Dali::Layer::SetSortFunction()
167 void SetSortFunction(Dali::Layer::SortFunctionType function);
170 * @copydoc Dali::Layer::SetTouchConsumed()
172 void SetTouchConsumed( bool consume );
175 * @copydoc Dali::Layer::IsTouchConsumed()
177 bool IsTouchConsumed() const;
180 * @copydoc Dali::Layer::SetHoverConsumed()
182 void SetHoverConsumed( bool consume );
185 * @copydoc Dali::Layer::IsHoverConsumed()
187 bool IsHoverConsumed() const;
190 * Helper function to get the scene object.
191 * This should only be called by Stage
192 * @return the scene object for the layer.
194 const SceneGraph::Layer& GetSceneLayerOnStage() const;
197 * @copydoc Dali::Internal::Actor::DoAction()
199 static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
201 public: // Default property extensions from Object
203 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
205 virtual unsigned int GetDefaultPropertyCount() const;
208 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
210 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
213 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
215 virtual const char* GetDefaultPropertyName(Property::Index index) const;
218 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
220 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
223 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
225 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
228 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
230 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
233 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
235 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
238 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
240 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
243 * @copydoc Dali::Internal::Object::SetDefaultProperty()
245 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
248 * @copydoc Dali::Internal::Object::GetDefaultProperty()
250 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
255 * Construct a new layer.
256 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
258 Layer( Actor::DerivedType type );
261 * A reference counted object may only be deleted by calling Unreference()
265 private: // From Actor
268 * From Actor; create a node to represent the layer in the scene-graph.
269 * @return A newly allocated layer node.
271 virtual SceneGraph::Node* CreateNode() const;
276 virtual void OnStageConnectionInternal();
281 virtual void OnStageDisconnectionInternal();
285 LayerList* mLayerList; ///< Only valid when layer is on-stage
287 // These properties not animatable; the actor side has the most up-to-date values
288 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
289 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
291 bool mIsClipping:1; ///< True when clipping is enabled
292 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
293 bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
294 bool mHoverConsumed:1; ///< Whether we should consume hover.
298 } // namespace Internal
300 // Helpers for public-api forwarding methods
302 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
304 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
306 BaseObject& handle = layer.GetBaseObject();
308 return static_cast<Internal::Layer&>(handle);
311 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
313 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
315 const BaseObject& handle = layer.GetBaseObject();
317 return static_cast<const Internal::Layer&>(handle);
323 #endif //__DALI_INTERNAL_LAYER_H__