[NUI] Support View BackgroundBlurEffect
authorjmm <j0064423.lee@samsung.com>
Tue, 25 Jun 2024 04:03:50 +0000 (13:03 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 31 Jul 2024 01:55:57 +0000 (10:55 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs [new file with mode: 0644]
src/Tizen.NUI/src/internal/Interop/Interop.View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs
src/Tizen.NUI/src/public/Utility/RenderEffect.cs [new file with mode: 0644]

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs b/src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs
new file mode 100644 (file)
index 0000000..6165073
--- /dev/null
@@ -0,0 +1,17 @@
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class BackgroundBlurEffect
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_BackgroundBlurEffect_New__SWIG_0")]
+            public static extern global::System.IntPtr New();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_BackgroundBlurEffect_New__SWIG_1")]
+            public static extern global::System.IntPtr New(uint pixelRadius);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_BackgroundBlurEffect")]
+            public static extern void Delete(global::System.Runtime.InteropServices.HandleRef self);
+        }
+    }
+}
index 42d6200..3783345 100755 (executable)
@@ -51,6 +51,12 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_ClearBackground")]
             public static extern void ClearBackground(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_SetRenderEffect")]
+            public static extern void SetRenderEffect(global::System.Runtime.InteropServices.HandleRef self, global::System.Runtime.InteropServices.HandleRef effectRef);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_ClearRenderEffect")]
+            public static extern void ClearRenderEffect(global::System.Runtime.InteropServices.HandleRef self);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_View__SWIG_2")]
             public static extern global::System.IntPtr NewViewInternal(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index 5da4b3b..954bb1a 100755 (executable)
@@ -312,6 +312,28 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Sets render effect to the view. The effect is applied to at most one view.
+        /// </summary>
+        /// <param name="effect">A render effect to set.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetRenderEffect(RenderEffect effect)
+        {
+            Interop.View.SetRenderEffect(SwigCPtr, RenderEffect.getCPtr(effect));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Clears render effect.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void ClearRenderEffect()
+        {
+            Interop.View.ClearRenderEffect(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+        }
+
+        /// <summary>
         /// Shows the view.
         /// </summary>
         /// <remarks>
diff --git a/src/Tizen.NUI/src/public/Utility/RenderEffect.cs b/src/Tizen.NUI/src/public/Utility/RenderEffect.cs
new file mode 100644 (file)
index 0000000..9ff734f
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright(c) 2024 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.
+ *
+ */
+using System.ComponentModel;
+using System;
+
+namespace Tizen.NUI
+{
+    /// <summary>
+    /// View's optional render effect.
+    /// Applications can apply RenderEffect as the example below :
+    /// <code>
+    /// 
+    /// RenderEffect effect = RenderEffect.CreateBackgroundBlurEffect(20.0f);
+    ///
+    /// view.SetRenderEffect(effect);
+    /// view.ClearRenderEffect();
+    ///
+    /// </code>
+    /// Note that a view owns at most one render effect.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RenderEffect : BaseHandle
+    {
+        internal RenderEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        /// <summary>
+        /// Create a background blur effect
+        /// </summary>
+        /// <remarks>
+        /// Created RenderEffect is immutable.
+        /// </remarks>
+        /// <param name="blurRadius">The blur radius value. The unit is pixel for standard cases.</param>
+        /// <returns>Background blur effect with given blur radius.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static RenderEffect CreateBackgroundBlurEffect(float blurRadius)
+        {
+            return new BackgroundBlurEffect((uint)Math.Round(blurRadius, 0));
+        }
+    }
+
+
+    /// <summary>
+    /// Applications can create BackgroundBlurEffect as :
+    /// <code>
+    /// RenderEffect.CreateBackgroundBlurEffect(blurRadius);
+    /// </code>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    sealed class BackgroundBlurEffect : RenderEffect
+    {
+        /// <summary>
+        /// Create a BackgroundBlurEffect.
+        /// The default values are:
+        ///     uint  blurRadius = 5;
+        /// </summary>
+        internal BackgroundBlurEffect() : this(Interop.BackgroundBlurEffect.New(), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Create a BackgroundBlurEffect.
+        /// </summary>
+        /// <param name="blurRadius">Size of gaussian kernel, determines blur intensity.</param>
+        internal BackgroundBlurEffect(uint blurRadius) : this(Interop.BackgroundBlurEffect.New(blurRadius), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        internal BackgroundBlurEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.BackgroundBlurEffect.Delete(swigCPtr);
+        }
+    }
+}