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&)
49 static float ZValue(const Vector3& position)
51 // inlined so we avoid a function call when sorting renderers
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] layerList The layer will be added to this ordered list.
64 * @param[in] manager The update manager to install a root node with.
65 * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
66 * @return A smart-pointer to the newly allocated Actor.
68 static LayerPtr NewRoot( LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
71 * @copydoc Dali::Internal::Actor::OnInitialize
76 * Query the current depth of the layer
78 unsigned int GetDepth() const;
81 * @copydoc Dali::Layer::Raise
86 * @copydoc Dali::Layer::Lower
91 * @copydoc Dali::Layer::RaiseAbove
93 void RaiseAbove( const Internal::Layer& target );
96 * @copydoc Dali::Layer::LowerBelow
98 void LowerBelow( const Internal::Layer& target );
101 * @copydoc Dali::Layer::RaiseToTop
106 * @copydoc Dali::Layer::LowerToBottom
108 void LowerToBottom();
111 * @copydoc Dali::Layer::MoveAbove
113 void MoveAbove( const Internal::Layer& target );
116 * @copydoc Dali::Layer::MoveAbove
118 void MoveBelow( const Internal::Layer& target );
121 * @copydoc Dali::Layer::SetClipping()
123 void SetClipping(bool enabled);
126 * @copydoc Dali::Layer::IsClipping()
128 bool IsClipping() const
130 return mIsClipping; // Actor-side has most up-to-date value
134 * @copydoc Dali::Layer::SetClippingBox()
136 void SetClippingBox(int x, int y, int width, int height);
139 * @copydoc Dali::Layer::GetClippingBox()
141 const Dali::ClippingBox& GetClippingBox() const
143 return mClippingBox; // Actor-side has most up-to-date value
147 * @copydoc Dali::Layer::SetDepthTestDisabled()
149 void SetDepthTestDisabled( bool disable );
152 * @copydoc Dali::Layer::IsDepthTestDisabled()
154 bool IsDepthTestDisabled() const;
157 * @copydoc Dali::Layer::SetSortFunction()
159 void SetSortFunction(Dali::Layer::SortFunctionType function);
162 * @copydoc Dali::Layer::SetTouchConsumed()
164 void SetTouchConsumed( bool consume );
167 * @copydoc Dali::Layer::IsTouchConsumed()
169 bool IsTouchConsumed() const;
172 * @copydoc Dali::Layer::SetHoverConsumed()
174 void SetHoverConsumed( bool consume );
177 * @copydoc Dali::Layer::IsHoverConsumed()
179 bool IsHoverConsumed() const;
182 * Helper function to get the scene object.
183 * This should only be called by Stage
184 * @return the scene object for the layer.
186 const SceneGraph::Layer& GetSceneLayerOnStage() const;
189 * @copydoc Dali::Internal::Actor::DoAction()
191 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
193 public: // Default property extensions from Object
195 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
197 virtual unsigned int GetDefaultPropertyCount() const;
200 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
202 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
205 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
207 virtual const char* GetDefaultPropertyName(Property::Index index) const;
210 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
212 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
215 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
217 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
220 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
222 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
225 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
227 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
230 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
232 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
235 * @copydoc Dali::Internal::Object::SetDefaultProperty()
237 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
240 * @copydoc Dali::Internal::Object::GetDefaultProperty()
242 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
247 * Construct a new layer.
248 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
250 Layer( Actor::DerivedType type );
253 * A reference counted object may only be deleted by calling Unreference()
257 private: // From Actor
260 * From Actor; create a node to represent the layer in the scene-graph.
261 * @return A newly allocated layer node.
263 virtual SceneGraph::Node* CreateNode() const;
268 virtual void OnStageConnectionInternal();
273 virtual void OnStageDisconnectionInternal();
277 LayerList* mLayerList; ///< Only valid when layer is on-stage
279 // These properties not animatable; the actor side has the most up-to-date values
280 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
281 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
283 bool mIsClipping:1; ///< True when clipping is enabled
284 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
285 bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
286 bool mHoverConsumed:1; ///< Whether we should consume hover.
290 } // namespace Internal
292 // Helpers for public-api forwarding methods
294 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
296 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
298 BaseObject& handle = layer.GetBaseObject();
300 return static_cast<Internal::Layer&>(handle);
303 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
305 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
307 const BaseObject& handle = layer.GetBaseObject();
309 return static_cast<const Internal::Layer&>(handle);
315 #endif //__DALI_INTERNAL_LAYER_H__