1 #ifndef __DALI_INTERNAL_LAYER_H__
2 #define __DALI_INTERNAL_LAYER_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
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>
39 typedef Dali::ClippingBox ClippingBox;
41 class Layer : public Actor
46 * @copydoc Dali::Layer::ZValue(const Vector3&, float)
48 static float ZValue(const Vector3& position, float sortModifier)
50 // inlined so we avoid a function call when sorting renderers
51 return position.z + sortModifier;
56 * @return A smart-pointer to the newly allocated Layer.
58 static LayerPtr New();
61 * Create a new root layer; this is typically owned by the stage.
62 * @param[in] stage The owning 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( Stage& stage, 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 * Helper function to get the scene object.
163 * This should only be called by Stage
164 * @return the scene object for the layer.
166 const SceneGraph::Layer& GetSceneLayerOnStage() const;
169 * @copydoc Dali::Internal::Actor::DoAction()
171 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
173 public: // Default property extensions from ProxyObject
175 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
177 virtual unsigned int GetDefaultPropertyCount() const;
180 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
182 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
185 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
187 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
190 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
192 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
195 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
197 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
200 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
202 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
205 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
207 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
210 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
212 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
215 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
217 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
220 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
222 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
227 * Construct a new layer.
228 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
230 Layer( Actor::DerivedType type );
233 * A reference counted object may only be deleted by calling Unreference()
237 private: // From Actor
240 * From Actor; create a node to represent the layer in the scene-graph.
241 * @return A newly allocated layer node.
243 virtual SceneGraph::Node* CreateNode() const;
248 virtual void OnStageConnectionInternal();
253 virtual void OnStageDisconnectionInternal();
257 LayerList* mLayerList; ///< Only valid when layer is on-stage
259 // These properties not animatable; the actor side has the most up-to-date values
260 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
261 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
263 bool mIsClipping:1; ///< True when clipping is enabled
264 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
266 static bool mFirstInstance;
267 static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
270 } // namespace Internal
272 // Helpers for public-api forwarding methods
274 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
276 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
278 BaseObject& handle = layer.GetBaseObject();
280 return static_cast<Internal::Layer&>(handle);
283 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
285 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
287 const BaseObject& handle = layer.GetBaseObject();
289 return static_cast<const Internal::Layer&>(handle);
295 #endif //__DALI_INTERNAL_LAYER_H__