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>
24 #include <dali/internal/event/images/frame-buffer-image-impl.h>
40 typedef Dali::ClippingBox ClippingBox;
42 class Layer : public Actor
48 * @return A smart-pointer to the newly allocated Layer.
50 static LayerPtr New();
53 * Create a new root layer; this is typically owned by the stage.
54 * @param[in] stage The owning stage.
55 * @param[in] layerList The layer will be added to this ordered list.
56 * @param[in] manager The update manager to install a root node with.
57 * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
58 * @return A smart-pointer to the newly allocated Actor.
60 static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
63 * @copydoc Dali::Internal::Actor::OnInitialize
68 * Query the current depth of the layer
70 unsigned int GetDepth() const;
73 * @copydoc Dali::Layer::Raise
78 * @copydoc Dali::Layer::Lower
83 * @copydoc Dali::Layer::RaiseAbove
85 void RaiseAbove( const Internal::Layer& target );
88 * @copydoc Dali::Layer::LowerBelow
90 void LowerBelow( const Internal::Layer& target );
93 * @copydoc Dali::Layer::RaiseToTop
98 * @copydoc Dali::Layer::LowerToBottom
100 void LowerToBottom();
103 * @copydoc Dali::Layer::MoveAbove
105 void MoveAbove( const Internal::Layer& target );
108 * @copydoc Dali::Layer::MoveAbove
110 void MoveBelow( const Internal::Layer& target );
113 * @copydoc Dali::Layer::SetClipping()
115 void SetClipping(bool enabled);
118 * @copydoc Dali::Layer::IsClipping()
120 bool IsClipping() const
122 return mIsClipping; // Actor-side has most up-to-date value
126 * @copydoc Dali::Layer::SetClippingBox()
128 void SetClippingBox(int x, int y, int width, int height);
131 * @copydoc Dali::Layer::GetClippingBox()
133 const Dali::ClippingBox& GetClippingBox() const
135 return mClippingBox; // Actor-side has most up-to-date value
139 * @copydoc Dali::Layer::SetDepthTestDisabled()
141 void SetDepthTestDisabled( bool disable );
144 * @copydoc Dali::Layer::IsDepthTestDisabled()
146 bool IsDepthTestDisabled() const;
149 * @copydoc Dali::Layer::SetSortFunction()
151 void SetSortFunction(Dali::Layer::SortFunctionType function);
154 * Helper function to get the scene object.
155 * This should only be called by Stage
156 * @return the scene object for the layer.
158 const SceneGraph::Layer& GetSceneLayerOnStage() const;
161 * @copydoc Dali::Internal::Actor::DoAction()
163 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
165 public: // Default property extensions from ProxyObject
167 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
169 virtual unsigned int GetDefaultPropertyCount() const;
172 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
174 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
177 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
179 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
182 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
184 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
187 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
189 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
192 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
194 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
197 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
199 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
202 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
204 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
207 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
209 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
214 * Construct a new layer.
215 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
217 Layer( Actor::DerivedType type );
220 * A reference counted object may only be deleted by calling Unreference()
224 private: // From Actor
227 * From Actor; create a node to represent the layer in the scene-graph.
228 * @return A newly allocated layer node.
230 virtual SceneGraph::Node* CreateNode() const;
235 virtual void OnStageConnectionInternal();
240 virtual void OnStageDisconnectionInternal();
244 LayerList* mLayerList; ///< Only valid when layer is on-stage
246 // These properties not animatable; the actor side has the most up-to-date values
247 FrameBufferImagePtr mFrameBufferImage; ///< Ticket for offscreen render target
248 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
249 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
251 bool mRenderOffscreen:1; ///< true when rendering to a FBO
252 bool mIsClipping:1; ///< True when clipping is enabled
253 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
255 static bool mFirstInstance ;
256 static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
259 } // namespace Internal
261 // Helpers for public-api forwarding methods
263 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
265 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
267 BaseObject& handle = layer.GetBaseObject();
269 return static_cast<Internal::Layer&>(handle);
272 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
274 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
276 const BaseObject& handle = layer.GetBaseObject();
278 return static_cast<const Internal::Layer&>(handle);
284 #endif //__DALI_INTERNAL_LAYER_H__