1 #ifndef DALI_INTERNAL_LAYER_H
2 #define DALI_INTERNAL_LAYER_H
5 * Copyright (c) 2017 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 * This is the default sorting function.
50 * It is useful for 2D user interfaces, and it's used to sort translucent renderers.
52 * Only the Z signed distance from the camera is considererd, lower values will be drawn on top.
54 * @param[in] position position of actor in view space
57 static float ZValue(const Vector3& position)
59 // inlined so we avoid a function call when sorting renderers
65 * @return A smart-pointer to the newly allocated Layer.
67 static LayerPtr New();
70 * Create a new root layer; this is typically owned by the stage.
71 * @param[in] layerList The layer will be added to this ordered list.
72 * @param[in] manager The update manager to install a root node with.
73 * @return A smart-pointer to the newly allocated Actor.
75 static LayerPtr NewRoot( LayerList& layerList, SceneGraph::UpdateManager& manager );
78 * @copydoc Dali::Internal::Actor::OnInitialize
83 * Query the current depth of the layer
85 unsigned int GetDepth() const;
88 * @copydoc Dali::Layer::Raise
93 * @copydoc Dali::Layer::Lower
98 * @copydoc Dali::Layer::RaiseAbove
100 void RaiseAbove( const Internal::Layer& target );
103 * @copydoc Dali::Layer::LowerBelow
105 void LowerBelow( const Internal::Layer& target );
108 * @copydoc Dali::Layer::RaiseToTop
113 * @copydoc Dali::Layer::LowerToBottom
115 void LowerToBottom();
118 * @copydoc Dali::Layer::MoveAbove
120 void MoveAbove( const Internal::Layer& target );
123 * @copydoc Dali::Layer::MoveAbove
125 void MoveBelow( const Internal::Layer& target );
128 * @copydoc Dali::Layer::SetClipping()
130 void SetClipping(bool enabled);
133 * @copydoc Dali::Layer::IsClipping()
135 bool IsClipping() const
137 return mIsClipping; // Actor-side has most up-to-date value
141 * @copydoc Dali::Layer::SetClippingBox()
143 void SetClippingBox(int x, int y, int width, int height);
146 * @copydoc Dali::Layer::GetClippingBox()
148 const Dali::ClippingBox& GetClippingBox() const
150 return mClippingBox; // Actor-side has most up-to-date value
154 * @copydoc Dali::Layer::SetBehavior()
156 void SetBehavior( Dali::Layer::Behavior behavior );
159 * @copydoc Dali::Layer::GetBehavior()
161 Dali::Layer::Behavior GetBehavior() const
167 * @copydoc Dali::Layer::SetDepthTestDisabled()
169 void SetDepthTestDisabled( bool disable );
172 * @copydoc Dali::Layer::IsDepthTestDisabled()
174 bool IsDepthTestDisabled() const;
177 * @copydoc Dali::Layer::SetSortFunction()
179 void SetSortFunction(Dali::Layer::SortFunctionType function);
182 * @copydoc Dali::Layer::SetTouchConsumed()
184 void SetTouchConsumed( bool consume );
187 * @copydoc Dali::Layer::IsTouchConsumed()
189 bool IsTouchConsumed() const;
192 * @copydoc Dali::Layer::SetHoverConsumed()
194 void SetHoverConsumed( bool consume );
197 * @copydoc Dali::Layer::IsHoverConsumed()
199 bool IsHoverConsumed() const;
202 * Helper function to get the scene object.
203 * This should only be called by Stage
204 * @return the scene object for the layer.
206 const SceneGraph::Layer& GetSceneLayerOnStage() const;
209 * @copydoc Dali::Internal::Actor::DoAction()
211 static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
213 public: // Default property extensions from Object
215 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
217 virtual unsigned int GetDefaultPropertyCount() const;
220 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
222 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
225 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
227 virtual const char* GetDefaultPropertyName(Property::Index index) const;
230 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
232 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
235 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
237 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
240 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
242 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
245 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
247 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
250 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
252 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
255 * @copydoc Dali::Internal::Object::SetDefaultProperty()
257 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
260 * @copydoc Dali::Internal::Object::GetDefaultProperty()
262 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
265 * @copydoc Dali::Internal::Object::GetDefaultProperty()
267 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
272 * Construct a new layer.
273 * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
275 Layer( Actor::DerivedType type );
278 * A reference counted object may only be deleted by calling Unreference()
282 private: // From Actor
285 * From Actor; create a node to represent the layer in the scene-graph.
286 * @return A newly allocated layer node.
288 virtual SceneGraph::Node* CreateNode() const;
293 virtual void OnStageConnectionInternal();
298 virtual void OnStageDisconnectionInternal();
302 LayerList* mLayerList; ///< Only valid when layer is on-stage
304 // These properties not animatable; the actor side has the most up-to-date values
305 ClippingBox mClippingBox; ///< The clipping box, in window coordinates
306 Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
308 Dali::Layer::Behavior mBehavior; ///< Behavior of the layer
310 bool mIsClipping:1; ///< True when clipping is enabled
311 bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
312 bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
313 bool mHoverConsumed:1; ///< Whether we should consume hover.
317 } // namespace Internal
319 // Helpers for public-api forwarding methods
321 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
323 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
325 BaseObject& handle = layer.GetBaseObject();
327 return static_cast<Internal::Layer&>(handle);
330 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
332 DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
334 const BaseObject& handle = layer.GetBaseObject();
336 return static_cast<const Internal::Layer&>(handle);
342 #endif // DALI_INTERNAL_LAYER_H