Supports window background blur.
This new APIs is to request window blur to window manager.
Next time, behind blur will be added.
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_RelativeMotionUnGrab")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool RelativeMotionUnGrab(global::System.Runtime.InteropServices.HandleRef window);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SetBlur")]
+ public static extern void SetBlur(global::System.Runtime.InteropServices.HandleRef window, global::System.IntPtr blurInfo);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetBlur")]
+ public static extern global::System.IntPtr GetBlur(global::System.Runtime.InteropServices.HandleRef window);
}
}
}
--- /dev/null
+/*
+ * 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.Runtime.InteropServices;
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class WindowBlurInfo
+ {
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WindowBlurInfo")]
+ public static extern global::System.IntPtr New();
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WindowBlurInfo_SWIG_0")]
+ public static extern global::System.IntPtr New(int nuiBlurType, int nuiBlurRadius, int nuiCornerRadius);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WindowBlurInfo_SWIG_1")]
+ public static extern global::System.IntPtr New(int nuiBlurType, int nuiBlurRadius);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WindowBlurInfo")]
+ public static extern void DeleteWindowBlurInfo(global::System.IntPtr nuiWindowBlurInfo);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_EqualTo")]
+ [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+ public static extern bool EqualTo(global::System.IntPtr nuiWindowBlurInfo1, global::System.IntPtr nuiWindowBlurInfo2);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_SetBlurType")]
+ public static extern void SetBlurType(global::System.IntPtr nuiWindowBlurInfo, int nuiWindowBlurType);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_GetBlurType")]
+ public static extern int GetBlurType(global::System.IntPtr nuiWindowBlurInfo);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_SetBlurRadius")]
+ public static extern void SetBlurRadius(global::System.IntPtr nuiWindowBlurInfo, int nuiWindowBlurRadius);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_GetBlurRadius")]
+ public static extern int GetBlurRadius(global::System.IntPtr nuiWindowBlurInfo);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_SetBackgroundCornerRadius")]
+ public static extern void SetBackgroundCornerRadius(global::System.IntPtr nuiWindowBlurInfo, int nuiCornerRadius);
+
+ [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowBlurInfo_GetBackgroundCornerRadius")]
+ public static extern int GetBackgroundCornerRadius(global::System.IntPtr nuiWindowBlurInfo);
+ }
+ }
+}
/// This is a desktop type. No other windows can be placed below this type of window.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- Desktop
+ Desktop
}
/// <summary>
}
}
}
+
+ /// <summary>
+ /// Enumeration of window blur type.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum WindowBlurType
+ {
+ /// <summary>
+ /// None type.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None = 0,
+ /// <summary>
+ /// background blur for the window.
+ /// It has a blur effect ot th background area of the window, making it appear blurred.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Background = 1,
+ }
}
return ret;
}
+ /// <summary>
+ /// Sets or gets the window blur using window blur information.
+ ///
+ /// It is designed to apply a blur effect to a window based on specified parameters.
+ /// This supports different types of blurring effects, including blurring the window's background only.
+ /// Or blurring the area surrounding the window while keeping the window itself clear.
+ /// The more information is written WindowBlurInfo struct.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public WindowBlurInfo BlurInfo
+ {
+ get
+ {
+ IntPtr internalBlurInfo = Interop.Window.GetBlur(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ WindowBlurInfo blurInfo = new WindowBlurInfo();
+ blurInfo.BlurType = (WindowBlurType)Interop.WindowBlurInfo.GetBlurType(internalBlurInfo);
+ blurInfo.BlurRadius = Interop.WindowBlurInfo.GetBlurRadius(internalBlurInfo);
+ blurInfo.BackgroundCornerRadius = Interop.WindowBlurInfo.GetBackgroundCornerRadius(internalBlurInfo);
+
+ Interop.WindowBlurInfo.DeleteWindowBlurInfo(internalBlurInfo);
+
+ return blurInfo;
+ }
+ set
+ {
+ IntPtr internalBlurInfo = Interop.WindowBlurInfo.New((int)value.BlurType, value.BlurRadius, value.BackgroundCornerRadius);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ try {
+ Interop.Window.SetBlur(SwigCPtr, internalBlurInfo);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ finally {
+ Interop.WindowBlurInfo.DeleteWindowBlurInfo(internalBlurInfo);
+ }
+ }
+ }
+
IntPtr IWindowProvider.WindowHandle => GetNativeWindowHandler();
float IWindowProvider.X => WindowPosition.X;
float IWindowProvider.Y => WindowPosition.Y;
--- /dev/null
+/*
+ * Copyright (c) 2023 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;
+using System.ComponentModel;
+using Tizen.NUI.Binding;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// WindowBlurInfo is a struct designed to encapsulate the information required to apply a blur effect to a window.
+ /// It contains three properties that define how the blur effect is applied to the window,
+ /// including the type of blur, its intensity, and the corner rounding for the background blur.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public struct WindowBlurInfo
+ {
+ /// <summary>
+ /// The construct with blur type, radius and corner radius for background type.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public WindowBlurInfo(WindowBlurType blurType, int blurRadius, int cornerRadius)
+ {
+ BlurType = blurType;
+ BlurRadius = blurRadius;
+ BackgroundCornerRadius = cornerRadius;
+ }
+
+ /// <summary>
+ /// The construct with blur type and radius.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public WindowBlurInfo(WindowBlurType blurType, int blurRadius)
+ {
+ BlurType = blurType;
+ BlurRadius = blurRadius;
+ BackgroundCornerRadius = 0;
+ }
+
+ /// <summary>
+ /// Gets or sets the blur type of the window.
+ /// </summary>
+ /// <value>The window blur type of the window.</value>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public WindowBlurType BlurType {get; set;}
+
+ /// <summary>
+ /// Gets or sets the blur radius of the window.
+ /// </summary>
+ /// <value>The blur radius of the window.</value>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int BlurRadius {get; set;}
+
+ /// <summary>
+ /// Gets or sets the corner radius of the window.
+ /// It is only useful when window blur type is background.
+ ///
+ /// When applying the background corner radius, ensure that the window's own corner radius is applied first.
+ /// The blur effect will respect the window's pre-defined corner radius settings
+ /// before applying the specified background corner radius.
+ /// </summary>
+ /// <value>The corner radius of the window.</value>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int BackgroundCornerRadius {get; set;}
+ }
+}
mainWin.TouchEvent += WinTouchEvent;
mainWin.BackgroundColor = Color.Cyan;
+ Rectangle rec = new Rectangle(20, 10, 400, 300);
+ mainWin.WindowPositionSize = rec;
+
Information.TryGetValue<int>("http://tizen.org/feature/screen.width", out screenWidth);
Information.TryGetValue<int>("http://tizen.org/feature/screen.height", out screenHeight);
log.Fatal(tag, $"Initialize= screenWidth {screenWidth}, screenHeight {screenHeight} ");
return false;
};
+ subWindow.SetTransparency(true);
+ subWindow.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+
var root = new View()
{
Layout = new LinearLayout()
},
WidthResizePolicy = ResizePolicyType.FillToParent,
HeightResizePolicy = ResizePolicyType.FillToParent,
- BackgroundColor = Color.Brown,
};
var image = new ImageView()
subWindow.KeyEvent += OnSubWindowKeyEvent;
subWindow.MoveCompleted += OnSubWindowMoveCompleted;
subWindow.ResizeCompleted += OnSubWindowResizeCompleted;
+
+ subWindow.BlurInfo = new WindowBlurInfo(WindowBlurType.Background, 10, 50);
}
else
{
break;
case KEY_NUM_8:
+ WindowBlurInfo blurInfo = subWindow.BlurInfo;
+ log.Fatal(tag, $"blur type={blurInfo.BlurType}");
+ log.Fatal(tag, $"blur radius={blurInfo.BlurRadius}");
+ log.Fatal(tag, $"background Corner Radius={blurInfo.BackgroundCornerRadius}");
+ blurInfo.BlurType = WindowBlurType.Background;
+ blurInfo.BlurRadius += 10;
+ blurInfo.BackgroundCornerRadius += 10;
+ subWindow.BlurInfo = blurInfo;
break;
case KEY_NUM_9: