Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / layer-impl.h
index 3ac048d..864867e 100644 (file)
@@ -1,27 +1,27 @@
-#ifndef __DALI_INTERNAL_LAYER_H__
-#define __DALI_INTERNAL_LAYER_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_INTERNAL_LAYER_H
+#define DALI_INTERNAL_LAYER_H
+
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/public-api/actors/layer.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/actor-declarations.h>
-#include <dali/internal/event/images/frame-buffer-image-impl.h>
 
 namespace Dali
 {
@@ -37,7 +37,7 @@ class UpdateManager;
 class Layer;
 }
 
-typedef Dali::ClippingBox ClippingBox;
+using ClippingBox = Dali::ClippingBox;
 
 class Layer : public Actor
 {
@@ -45,11 +45,19 @@ public:
 
   /**
    * @copydoc Dali::Layer::ZValue(const Vector3&, float)
-   */
-  static float ZValue(const Vector3& position, float sortModifier)
+   *
+   * This is the default sorting function.
+   * It is useful for 2D user interfaces, and it's used to sort translucent renderers.
+   *
+   * Only the Z signed distance from the camera is considererd, lower values will be drawn on top.
+   *
+   * @param[in] position     position of actor in view space
+   * @return depth
+   */
+  static float ZValue(const Vector3& position)
   {
     // inlined so we avoid a function call when sorting renderers
-    return position.z + sortModifier;
+    return position.z;
   }
 
   /**
@@ -60,20 +68,17 @@ public:
 
   /**
    * Create a new root layer; this is typically owned by the stage.
-   * @param[in] stage The owning stage.
    * @param[in] layerList The layer will be added to this ordered list.
-   * @param[in] manager The update manager to install a root node with.
-   * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
    * @return A smart-pointer to the newly allocated Actor.
    */
-  static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
+  static LayerPtr NewRoot( LayerList& layerList );
 
   /**
    * @copydoc Dali::Internal::Actor::OnInitialize
    */
   void OnInitialize();
 
-   /**
+  /**
    * Query the current depth of the layer
    */
   unsigned int GetDepth() const;
@@ -145,6 +150,19 @@ public:
   }
 
   /**
+   * @copydoc Dali::Layer::SetBehavior()
+   */
+  void SetBehavior( Dali::Layer::Behavior behavior );
+
+  /**
+   * @copydoc Dali::Layer::GetBehavior()
+   */
+  Dali::Layer::Behavior GetBehavior() const
+  {
+    return mBehavior;
+  }
+
+  /**
    * @copydoc Dali::Layer::SetDepthTestDisabled()
    */
   void SetDepthTestDisabled( bool disable );
@@ -160,70 +178,62 @@ public:
   void SetSortFunction(Dali::Layer::SortFunctionType function);
 
   /**
-   * Helper function to get the scene object.
-   * This should only be called by Stage
-   * @return the scene object for the layer.
+   * @copydoc Dali::Layer::SetTouchConsumed()
    */
-  const SceneGraph::Layer& GetSceneLayerOnStage() const;
+  void SetTouchConsumed( bool consume );
 
   /**
-   * @copydoc Dali::Internal::Actor::DoAction()
+   * @copydoc Dali::Layer::IsTouchConsumed()
    */
-  static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
+  bool IsTouchConsumed() const;
 
-public: // Default property extensions from ProxyObject
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
+   * @copydoc Dali::Layer::SetHoverConsumed()
    */
-  virtual unsigned int GetDefaultPropertyCount() const;
+  void SetHoverConsumed( bool consume );
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
+   * @copydoc Dali::Layer::IsHoverConsumed()
    */
-  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+  bool IsHoverConsumed() const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
-   */
-  virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
+   * Helper function to get the scene object.
+   *
+   * @return the scene object for the layer.
    */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
+  const SceneGraph::Layer& GetSceneGraphLayer() const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
+   * @copydoc Dali::Internal::Actor::DoAction()
    */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
+  static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
 
-  /**
-   * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
-   */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
+public: // Default property extensions from Object
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
+   * @copydoc Dali::Internal::Object::SetDefaultProperty()
    */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
+  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
+   * @copydoc Dali::Internal::Object::GetDefaultProperty()
    */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
+  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
+   * @copydoc Dali::Internal::Object::GetDefaultProperty()
    */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+  virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
 
 protected:
 
   /**
    * Construct a new layer.
    * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
+   * @param[in] layer the scene graph layer
    */
-  Layer( Actor::DerivedType type );
+  Layer( Actor::DerivedType type, const SceneGraph::Layer& layer );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -233,35 +243,30 @@ protected:
 private: // From Actor
 
   /**
-   * From Actor; create a node to represent the layer in the scene-graph.
-   * @return A newly allocated layer node.
-   */
-  virtual SceneGraph::Node* CreateNode() const;
-
-  /**
    * From Actor.
    */
-  virtual void OnStageConnectionInternal();
+  virtual void OnSceneConnectionInternal();
 
   /**
    * From Actor.
    */
-  virtual void OnStageDisconnectionInternal();
+  virtual void OnSceneDisconnectionInternal();
 
 private:
 
-  LayerList* mLayerList; ///< Only valid when layer is on-stage
+  LayerList* mLayerList; ///< Only valid when layer is on-scene
 
   // These properties not animatable; the actor side has the most up-to-date values
-  FrameBufferImagePtr mFrameBufferImage;        ///< Ticket for offscreen render target
   ClippingBox mClippingBox;                     ///< The clipping box, in window coordinates
   Dali::Layer::SortFunctionType mSortFunction;  ///< Used to sort semi-transparent geometry
 
+  Dali::Layer::Behavior mBehavior;              ///< Behavior of the layer
+
   bool mIsClipping:1;                           ///< True when clipping is enabled
   bool mDepthTestDisabled:1;                    ///< Whether depth test is disabled.
+  bool mTouchConsumed:1;                        ///< Whether we should consume touch (including gesture).
+  bool mHoverConsumed:1;                        ///< Whether we should consume hover.
 
-  static bool mFirstInstance;
-  static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
 };
 
 } // namespace Internal
@@ -289,4 +294,4 @@ inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
 } // namespace Dali
 
 
-#endif //__DALI_INTERNAL_LAYER_H__
+#endif // DALI_INTERNAL_LAYER_H