[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-data-impl.h
index 568af24..e54c3ae 100644 (file)
@@ -53,10 +53,10 @@ struct Base::Impl
 
   enum Flags
   {
-    IS_ON_SCENE                     = 1,
-    IS_ATLASING_APPLIED             = 1 << 1,
-    IS_PREMULTIPLIED_ALPHA          = 1 << 2,
-    IS_SYNCHRONOUS_RESOURCE_LOADING = 1 << 3
+    IS_ON_SCENE                        = 1,
+    IS_ATLASING_APPLIED                = 1 << 1,
+    IS_PREMULTIPLIED_ALPHA             = 1 << 2,
+    IS_SYNCHRONOUS_RESOURCE_LOADING    = 1 << 3,
   };
 
   struct CustomShader
@@ -114,6 +114,133 @@ struct Base::Impl
     Toolkit::Align::Type mAnchorPoint;
   };
 
+  struct DecorationData
+  {
+    // Default constructor
+    DecorationData()
+    : mBorderlineColor(Color::BLACK),
+      mCornerRadius(Vector4::ZERO),
+      mBorderlineWidth(0.0f),
+      mBorderlineOffset(0.0f),
+      mCornerRadiusPolicy(static_cast<int>(Toolkit::Visual::Transform::Policy::ABSOLUTE))
+    {
+    }
+    Vector4 mBorderlineColor;
+    Vector4 mCornerRadius;
+    float   mBorderlineWidth;
+    float   mBorderlineOffset;
+    int     mCornerRadiusPolicy;
+  };
+
+  DecorationData* EnsureDecorationData()
+  {
+    if(mDecorationData == nullptr)
+    {
+      mDecorationData = new DecorationData();
+    }
+    return mDecorationData;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline width
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  float GetBorderlineWidth()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineWidth : 0.0f;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline width
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineWidth(float value)
+  {
+    EnsureDecorationData()->mBorderlineWidth = value;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline color
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  Vector4 GetBorderlineColor()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineColor : Color::BLACK;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline color
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineColor(Vector4 value)
+  {
+    EnsureDecorationData()->mBorderlineColor = value;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline offset
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  float GetBorderlineOffset()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineOffset : 0.0f;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline offset
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineOffset(float value)
+  {
+    EnsureDecorationData()->mBorderlineOffset = value;
+  }
+
+  /**
+   * @brief Get decoration data value : corner radius
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  Vector4 GetCornerRadius()
+  {
+    return mDecorationData ? mDecorationData->mCornerRadius : Vector4::ZERO;
+  }
+
+  /**
+   * @brief Set decoration data value : corner radius
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetCornerRadius(Vector4 value)
+  {
+    EnsureDecorationData()->mCornerRadius = value;
+  }
+
+  /**
+   * @brief Get decoration data value : corner radius policy
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  int GetCornerRadiusPolicy()
+  {
+    return mDecorationData ? mDecorationData->mCornerRadiusPolicy : static_cast<int>(Toolkit::Visual::Transform::Policy::ABSOLUTE);
+  }
+
+  /**
+   * @brief Set decoration data value : corner radius policy
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetCornerRadiusPolicy(int value)
+  {
+    EnsureDecorationData()->mCornerRadiusPolicy = value;
+  }
+
   VisualRenderer                  mRenderer;
   CustomShader*                   mCustomShader;
   EventObserver*                  mEventObserver; ///< Allows controls to observe when the visual has events to notify
@@ -121,18 +248,14 @@ struct Base::Impl
   Transform                       mTransform;
   Vector4                         mMixColor;
   Size                            mControlSize;
-  float                           mBorderlineWidth;
-  Vector4                         mBorderlineColor;
-  float                           mBorderlineOffset;
-  Vector4                         mCornerRadius;
-  float                           mCornerRadiusPolicy;
+  DecorationData*                 mDecorationData;
   int                             mDepthIndex;
   FittingMode                     mFittingMode; ///< How the contents should fit the view
   int                             mFlags;
   Toolkit::Visual::ResourceStatus mResourceStatus;
   const Toolkit::Visual::Type     mType;
-  bool                            mAlwaysUsingBorderline : 1;   ///< Whether we need the borderline in shader always.
-  bool                            mAlwaysUsingCornerRadius : 1; ///< Whether we need the corner radius in shader always.
+  bool                            mAlwaysUsingBorderline : 1;     ///< Whether we need the borderline in shader always.
+  bool                            mAlwaysUsingCornerRadius : 1;   ///< Whether we need the corner radius in shader always.
 };
 
 } // namespace Visual