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 static float ZValue(const Vector3& position, float sortModifier)
51 // inlined so we avoid a function call when sorting renderers
52 return position.z + sortModifier;
57 * @return A smart-pointer to the newly allocated Layer.
59 static LayerPtr New();
62 * Create a new root layer; this is typically owned by the stage.
63 * @param[in] stage The owning stage.
64 * @param[in] layerList The layer will be added to this ordered list.
65 * @param[in] manager The update manager to install a root node with.
66 * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
67 * @return A smart-pointer to the newly allocated Actor.
69 static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
72 * @copydoc Dali::Internal::Actor::OnInitialize
77 * Query the current depth of the layer
79 unsigned int GetDepth() const;
82 * @copydoc Dali::Layer::Raise
87 * @copydoc Dali::Layer::Lower
92 * @copydoc Dali::Layer::RaiseAbove
94 void RaiseAbove( const Internal::Layer& target );
97 * @copydoc Dali::Layer::LowerBelow
99 void LowerBelow( const Internal::Layer& target );
102 * @copydoc Dali::Layer::RaiseToTop
107 * @copydoc Dali::Layer::LowerToBottom
109 void LowerToBottom();
112 * @copydoc Dali::Layer::MoveAbove
114 void MoveAbove( const Internal::Layer& target );
117 * @copydoc Dali::Layer::MoveAbove
119 void MoveBelow( const Internal::Layer& target );
122 * @copydoc Dali::Layer::SetClipping()
124 void SetClipping(bool enabled);
127 * @copydoc Dali::Layer::IsClipping()
129 bool IsClipping() const
131 return mIsClipping; // Actor-side has most up-to-date value
135 * @copydoc Dali::Layer::SetClippingBox()
137 void SetClippingBox(int x, int y, int width, int height);
140 * @copydoc Dali::Layer::GetClippingBox()
142 const Dali::ClippingBox& GetClippingBox() const
144 return mClippingBox; // Actor-side has most up-to-date value
148 * @copydoc Dali::Layer::SetDepthTestDisabled()
150 void SetDepthTestDisabled( bool disable );
153 * @copydoc Dali::Layer::IsDepthTestDisabled()
155 bool IsDepthTestDisabled() const;
158 * @copydoc Dali::Layer::SetSortFunction()
160 void SetSortFunction(Dali::Layer::SortFunctionType function);
163 * @copydoc Dali::Layer::SetTouchConsumed()
165 void SetTouchConsumed( bool consume );
168 * @copydoc Dali::Layer::IsTouchConsumed()
170 bool IsTouchConsumed() const;
173 * @copydoc Dali::Layer::SetHoverConsumed()
175 void SetHoverConsumed( bool consume );
178 * @copydoc Dali::Layer::IsHoverConsumed()
180 bool IsHoverConsumed() const;
183 * Helper function to get the scene object.
184 * This should only be called by Stage
185 * @return the scene object for the layer.
187 const SceneGraph::Layer& GetSceneLayerOnStage() const;
190 * @copydoc Dali::Internal::Actor::DoAction()
192 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
194 public: // Default property extensions from ProxyObject
196 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
198 virtual unsigned int GetDefaultPropertyCount() const;
201 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
203 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
206 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
208 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
211 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
213 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
216 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
218 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
221 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
223 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
226 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
228 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
231 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
233 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
236 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
238 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
241 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
243 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
248 * Construct a new layer.
249 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
251 Layer( Actor::DerivedType type );
254 * A reference counted object may only be deleted by calling Unreference()
258 private: // From Actor
261 * From Actor; create a node to represent the layer in the scene-graph.
262 * @return A newly allocated layer node.
264 virtual SceneGraph::Node* CreateNode() const;
269 virtual void OnStageConnectionInternal();
274 virtual void OnStageDisconnectionInternal();
278 LayerList* mLayerList; ///< Only valid when layer is on-stage
280 // These properties not animatable; the actor side has the most up-to-date values
281 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
282 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
284 bool mIsClipping:1; ///< True when clipping is enabled
285 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
286 bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
287 bool mHoverConsumed:1; ///< Whether we should consume hover.
289 static bool mFirstInstance;
290 static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
293 } // namespace Internal
295 // Helpers for public-api forwarding methods
297 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
299 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
301 BaseObject& handle = layer.GetBaseObject();
303 return static_cast<Internal::Layer&>(handle);
306 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
308 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
310 const BaseObject& handle = layer.GetBaseObject();
312 return static_cast<const Internal::Layer&>(handle);
318 #endif //__DALI_INTERNAL_LAYER_H__