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>
25 #include <dali/internal/event/images/frame-buffer-image-impl.h>
41 typedef Dali::ClippingBox ClippingBox;
43 class Layer : public Actor
48 * @copydoc Dali::Layer::ZValue(const Vector3&, float)
50 static float ZValue(const Vector3& position, float sortModifier)
52 // inlined so we avoid a function call when sorting renderers
53 return position.z + sortModifier;
58 * @return A smart-pointer to the newly allocated Layer.
60 static LayerPtr New();
63 * Create a new root layer; this is typically owned by the stage.
64 * @param[in] stage The owning stage.
65 * @param[in] layerList The layer will be added to this ordered list.
66 * @param[in] manager The update manager to install a root node with.
67 * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
68 * @return A smart-pointer to the newly allocated Actor.
70 static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
73 * @copydoc Dali::Internal::Actor::OnInitialize
78 * Query the current depth of the layer
80 unsigned int GetDepth() const;
83 * @copydoc Dali::Layer::Raise
88 * @copydoc Dali::Layer::Lower
93 * @copydoc Dali::Layer::RaiseAbove
95 void RaiseAbove( const Internal::Layer& target );
98 * @copydoc Dali::Layer::LowerBelow
100 void LowerBelow( const Internal::Layer& target );
103 * @copydoc Dali::Layer::RaiseToTop
108 * @copydoc Dali::Layer::LowerToBottom
110 void LowerToBottom();
113 * @copydoc Dali::Layer::MoveAbove
115 void MoveAbove( const Internal::Layer& target );
118 * @copydoc Dali::Layer::MoveAbove
120 void MoveBelow( const Internal::Layer& target );
123 * @copydoc Dali::Layer::SetClipping()
125 void SetClipping(bool enabled);
128 * @copydoc Dali::Layer::IsClipping()
130 bool IsClipping() const
132 return mIsClipping; // Actor-side has most up-to-date value
136 * @copydoc Dali::Layer::SetClippingBox()
138 void SetClippingBox(int x, int y, int width, int height);
141 * @copydoc Dali::Layer::GetClippingBox()
143 const Dali::ClippingBox& GetClippingBox() const
145 return mClippingBox; // Actor-side has most up-to-date value
149 * @copydoc Dali::Layer::SetDepthTestDisabled()
151 void SetDepthTestDisabled( bool disable );
154 * @copydoc Dali::Layer::IsDepthTestDisabled()
156 bool IsDepthTestDisabled() const;
159 * @copydoc Dali::Layer::SetSortFunction()
161 void SetSortFunction(Dali::Layer::SortFunctionType function);
164 * Helper function to get the scene object.
165 * This should only be called by Stage
166 * @return the scene object for the layer.
168 const SceneGraph::Layer& GetSceneLayerOnStage() const;
171 * @copydoc Dali::Internal::Actor::DoAction()
173 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
175 public: // Default property extensions from ProxyObject
177 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
179 virtual unsigned int GetDefaultPropertyCount() const;
182 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
184 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
187 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
189 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
192 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
194 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
197 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
199 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
202 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
204 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
207 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
209 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
212 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
214 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
217 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
219 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
222 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
224 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
229 * Construct a new layer.
230 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
232 Layer( Actor::DerivedType type );
235 * A reference counted object may only be deleted by calling Unreference()
239 private: // From Actor
242 * From Actor; create a node to represent the layer in the scene-graph.
243 * @return A newly allocated layer node.
245 virtual SceneGraph::Node* CreateNode() const;
250 virtual void OnStageConnectionInternal();
255 virtual void OnStageDisconnectionInternal();
259 LayerList* mLayerList; ///< Only valid when layer is on-stage
261 // These properties not animatable; the actor side has the most up-to-date values
262 FrameBufferImagePtr mFrameBufferImage; ///< Ticket for offscreen render target
263 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
264 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
266 bool mIsClipping:1; ///< True when clipping is enabled
267 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
269 static bool mFirstInstance;
270 static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
273 } // namespace Internal
275 // Helpers for public-api forwarding methods
277 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
279 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
281 BaseObject& handle = layer.GetBaseObject();
283 return static_cast<Internal::Layer&>(handle);
286 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
288 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
290 const BaseObject& handle = layer.GetBaseObject();
292 return static_cast<const Internal::Layer&>(handle);
298 #endif //__DALI_INTERNAL_LAYER_H__