Refactored more code into Actor::Relayouter
[platform/core/uifw/dali-core.git] / dali / public-api / actors / layer.h
index 3db29be..13f5328 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_LAYER_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * 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.
 #include <cstdint> // uint32_t
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/math/vector3.h>
-#include <dali/public-api/images/frame-buffer-image.h>
+#include <dali/public-api/object/ref-object.h>
 
 namespace Dali
 {
@@ -46,14 +45,14 @@ class Layer;
  * @SINCE_1_0.0
  * @see Dali::Layer::SetClippingBox()
  */
-typedef Rect<int32_t> ClippingBox;
+using ClippingBox = Rect<int32_t>;
 
 /**
  * @brief Layers provide a mechanism for overlaying groups of actors on top of each other.
  *
- * When added to the stage, a layer can be ordered relative to other
- * layers. The bottom layer is at depth zero. The stage provides a default
- * layer for it's children (see Stage::GetRootLayer()).
+ * When added to a scene, a layer can be ordered relative to other
+ * layers. The bottom layer is at depth zero. A scene provides a default
+ * layer for its children.
  *
  * Layered actors inherit position etc. as normal, but are drawn in an order
  * determined by the layers. In case of LAYER_3D, the depth buffer is cleared
@@ -86,7 +85,6 @@ typedef Rect<int32_t> ClippingBox;
 class DALI_CORE_API Layer : public Actor
 {
 public:
-
   /**
    * @brief Enumeration for the instance of properties belonging to the Layer class.
    *
@@ -105,7 +103,42 @@ public:
     {
       CLIPPING_ENABLE = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< name "clippingEnable",   type bool @SINCE_1_0.0
       CLIPPING_BOX,                                                 ///< name "clippingBox",      type Rect<int32_t> @SINCE_1_0.0
-      BEHAVIOR,                                                     ///< name "behavior",         type String @SINCE_1_0.0
+      BEHAVIOR,                                                     ///< name "behavior",         type integer or string @SINCE_1_0.0
+
+      /**
+       * @brief The current depth of the layer.
+       * @details Name "depth", type Property::INTEGER. Read-only
+       * @note 0 is the bottom most layer, higher number is on top.
+       * @note Layer should be on the stage. If layer is not added to the stage, the depth is 0.
+       * @SINCE_1_9.16
+       */
+      DEPTH,
+
+      /**
+       * @brief Whether to enable the depth test.
+       * @details Name "depthTest", type Property::BOOLEAN.
+       * @note By default a layer enables depth test if there is more than one opaque actor
+       * or if there is one opaque actor and one, or more, transparent actors in LAYER_3D mode.
+       * However, it's possible to disable the depth test by setting this property to False.
+       * @SINCE_1_9.16
+       */
+      DEPTH_TEST,
+
+      /**
+       * @brief Whether this layer should consume touch (including gestures).
+       * @details Name "consumesTouch", type Property::BOOLEAN.
+       * @note When this is True, any layers behind this layer will not be hit-test.
+       * @SINCE_1_9.16
+       */
+      CONSUMES_TOUCH,
+
+      /**
+       * @brief Whether this layer should consume hover (including gestures).
+       * @details Name "consumesHover", type Property::BOOLEAN.
+       * @note When this is True, any layers behind this layer will not be hit-test.
+       * @SINCE_1_9.16
+       */
+      CONSUMES_HOVER,
     };
   };
 
@@ -179,23 +212,12 @@ public:
   };
 
   /**
-   * @DEPRECATED_1_2.26. Not intended for application use.
-   *
-   * @brief Enumeration for TREE_DEPTH_MULTIPLIER is used by the rendering sorting algorithm to decide which actors to render first.
-   * @SINCE_1_0.0
-   */
-  enum TreeDepthMultiplier
-  {
-    TREE_DEPTH_MULTIPLIER = 10000,
-  };
-
-  /**
    * @brief The sort function type.
    *
    * @SINCE_1_0.0
    * @param[in] position This is the actor translation from camera
    */
-  typedef float (*SortFunctionType)( const Vector3& position );
+  using SortFunctionType = float (*)(const Vector3&);
 
   /**
    * @brief Creates an empty Layer handle.
@@ -222,7 +244,7 @@ public:
    * @param[in] handle Handle to an object
    * @return Handle to a Layer or an uninitialized handle
    */
-  static Layer DownCast( BaseHandle handle );
+  static Layer DownCast(BaseHandle handle);
 
   /**
    * @brief Destructor.
@@ -250,15 +272,21 @@ public:
   Layer& operator=(const Layer& rhs);
 
   /**
-   * @brief Queries the depth of the layer.
+   * @brief Move constructor.
    *
-   * 0 is the bottom most layer, higher number is on top.
-   * @SINCE_1_0.0
-   * @return The current depth of the layer
-   * @pre Layer is on the stage.
-   * If layer is not added to the stage, returns 0.
+   * @SINCE_1_9.22
+   * @param[in] rhs The layer to move
+   */
+  Layer(Layer&& rhs);
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @SINCE_1_9.22
+   * @param[in] rhs The layer to move
+   * @return A reference to this
    */
-  uint32_t GetDepth() const;
+  Layer& operator=(Layer&& rhs);
 
   /**
    * @brief Increments the depth of the layer.
@@ -287,7 +315,7 @@ public:
    * @pre Target layer is on the stage.
    * @note All layers between this layer and target get new depth values.
    */
-  void RaiseAbove( Layer target );
+  void RaiseAbove(Layer target);
 
   /**
    * @brief Ensures the layers depth is less than the target layer.
@@ -300,7 +328,7 @@ public:
    * @pre Target layer is on the stage.
    * @note All layers between this layer and target get new depth values.
    */
-  void LowerBelow( Layer target );
+  void LowerBelow(Layer target);
 
   /**
    * @brief Raises the layer to the top.
@@ -326,7 +354,7 @@ public:
    * @pre Target layer is on the stage.
    * @note All layers between this layer and target get new depth values.
    */
-  void MoveAbove( Layer target );
+  void MoveAbove(Layer target);
 
   /**
    * @brief Moves the layer directly below the given layer.
@@ -338,94 +366,7 @@ public:
    * @pre Target layer is on the stage.
    * @note All layers between this layer and target get new depth values.
    */
-  void MoveBelow( Layer target );
-
-  /**
-   * @brief Sets the behavior of the layer.
-   *
-   * @SINCE_1_0.0
-   * @param[in] behavior The desired behavior
-   */
-  void SetBehavior( Behavior behavior );
-
-  /**
-   * @brief Gets the behavior of the layer.
-   *
-   * @SINCE_1_0.0
-   * @return The behavior of the layer
-   */
-  Behavior GetBehavior() const;
-
-  /**
-   * @brief Sets whether clipping is enabled for a layer.
-   *
-   * Clipping is initially disabled; see also SetClippingBox().
-   * @SINCE_1_0.0
-   * @param[in] enabled True if clipping is enabled
-   *
-   * @note When clipping is enabled, the default clipping box is empty (0,0,0,0), which means everything is clipped.
-   */
-  void SetClipping(bool enabled);
-
-  /**
-   * @brief Queries whether clipping is enabled for a layer.
-   * @SINCE_1_0.0
-   * @return True if clipping is enabled
-   */
-  bool IsClipping() const;
-
-  /**
-   * @brief Sets the clipping box of a layer, in window coordinates.
-   *
-   * The contents of the layer will not be visible outside this box, when clipping is
-   * enabled. The default clipping box is empty (0,0,0,0) which means everything is clipped.
-   * You can only do rectangular clipping using this API in window coordinates.
-   * @SINCE_1_0.0
-   * @param[in] x The X-coordinate of the top-left corner of the box
-   * @param[in] y The Y-coordinate of the top-left corner of the box
-   * @param[in] width The width of the box
-   * @param[in] height The height of the box
-   */
-  void SetClippingBox(int32_t x, int32_t y, int32_t width, int32_t height);
-
-  /**
-   * @brief Sets the clipping box of a layer in window coordinates.
-   *
-   * The contents of the layer will not be visible outside this box when clipping is
-   * enabled. The default clipping box is empty (0,0,0,0).
-   * @SINCE_1_0.0
-   * @param[in] box The clipping box
-   */
-  void SetClippingBox(ClippingBox box);
-
-  /**
-   * @brief Retrieves the clipping box of a layer in window coordinates.
-   *
-   * @SINCE_1_0.0
-   * @return The clipping box
-   */
-  ClippingBox GetClippingBox() const;
-
-  // Depth test
-
-  /**
-   * @brief Whether to disable the depth test.
-   *
-   * By default a layer enables depth test if there is more than one opaque actor or if there is one opaque actor and one, or more, transparent actors in LAYER_3D mode.
-   * However, it's possible to disable the depth test by calling this method.
-   *
-   * @SINCE_1_0.0
-   * @param[in] disable \e True disables depth test. \e false sets the default behavior
-   */
-  void SetDepthTestDisabled( bool disable );
-
-  /**
-   * @brief Retrieves whether depth test is disabled.
-   *
-   * @SINCE_1_0.0
-   * @return \e True if depth test is disabled
-   */
-  bool IsDepthTestDisabled() const;
+  void MoveBelow(Layer target);
 
   // Sorting
 
@@ -449,35 +390,7 @@ public:
    * layer, then the sort function used by the child layer will also be the same.
    *
   */
-  void SetSortFunction( SortFunctionType function );
-
-  /**
-   * @brief This allows the user to specify whether this layer should consume touch (including gestures).
-   *
-   * If set, any layers behind this layer will not be hit-test.
-   *
-   * @SINCE_1_0.0
-   * @param[in] consume Whether the layer should consume touch (including gestures)
-   */
-  void SetTouchConsumed( bool consume );
-
-  /**
-   * @brief Retrieves whether the layer consumes touch (including gestures).
-   *
-   * @SINCE_1_0.0
-   * @return @c True if consuming touch, @c false otherwise
-   */
-  bool IsTouchConsumed() const;
-
-  /**
-   * @brief This allows the user to specify whether this layer should consume hover.
-   *
-   * If set, any layers behind this layer will not be hit-test.
-   *
-   * @SINCE_1_0.0
-   * @param[in] consume Whether the layer should consume hover
-   */
-  void SetHoverConsumed( bool consume );
+  void SetSortFunction(SortFunctionType function);
 
   /**
    * @brief Retrieves whether the layer consumes hover.
@@ -488,7 +401,6 @@ public:
   bool IsHoverConsumed() const;
 
 public: // Not intended for application developers
-
   /// @cond internal
   /**
    * @brief This constructor is used by Layer::New() methods.