From 9cfc2e26ff4e814f7027472c7acb925110e6e058 Mon Sep 17 00:00:00 2001
From: JoogabYun <40262755+JoogabYun@users.noreply.github.com>
Date: Thu, 4 May 2023 10:56:27 +0900
Subject: [PATCH] [NUI] Add WindowMouseInOutEvent (#5242)
MouseInOutEvent is used when the mouse enters or exits a window
refer :
https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-adaptor/+/292271/
https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-csharp-binder/+/292272/
---
.../src/internal/Interop/Interop.MouseInOut.cs | 49 +++++
.../Interop/Interop.WindowMouseInOutEventSignal.cs | 50 +++++
.../internal/Window/WindowMouseInOutEventSignal.cs | 102 +++++++++
src/Tizen.NUI/src/public/Window/MouseInOut.cs | 227 +++++++++++++++++++++
src/Tizen.NUI/src/public/Window/WindowEvent.cs | 81 ++++++++
5 files changed, 509 insertions(+)
create mode 100755 src/Tizen.NUI/src/internal/Interop/Interop.MouseInOut.cs
create mode 100755 src/Tizen.NUI/src/internal/Interop/Interop.WindowMouseInOutEventSignal.cs
create mode 100755 src/Tizen.NUI/src/internal/Window/WindowMouseInOutEventSignal.cs
create mode 100755 src/Tizen.NUI/src/public/Window/MouseInOut.cs
diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.MouseInOut.cs b/src/Tizen.NUI/src/internal/Interop/Interop.MouseInOut.cs
new file mode 100755
index 0000000..a8dbb80
--- /dev/null
+++ b/src/Tizen.NUI/src/internal/Interop/Interop.MouseInOut.cs
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class MouseInOut
+ {
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_MouseInOutEvent__SWIG_0")]
+ public static extern global::System.IntPtr NewMouseInOut(int jarg1, uint jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, uint jarg4);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_MouseInOutEvent")]
+ public static extern void DeleteMouseInOut(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_type_get")]
+ public static extern int TypeGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_modifiers_get")]
+ public static extern uint ModifiersGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_point_get")]
+ public static extern global::System.IntPtr PointGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_timeStamp_get")]
+ public static extern uint TimeStampGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_GetDeviceClass")]
+ public static extern int DeviceClassGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MouseInOutEvent_GetDeviceSubClass")]
+ public static extern int DeviceSubClassGet(global::System.Runtime.InteropServices.HandleRef jarg1);
+ }
+ }
+}
diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowMouseInOutEventSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowMouseInOutEventSignal.cs
new file mode 100755
index 0000000..1df5ddb
--- /dev/null
+++ b/src/Tizen.NUI/src/internal/Interop/Interop.WindowMouseInOutEventSignal.cs
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class WindowMouseInOutEventSignal
+ {
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal")]
+ public static extern global::System.IntPtr GetSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal_Empty")]
+ [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+ public static extern bool Empty(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal_GetConnectionCount")]
+ public static extern uint GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal_Connect")]
+ public static extern void Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal_Disconnect")]
+ public static extern void Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowMouseInOutEventSignal_Emit")]
+ public static extern void Emit(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef mouseEvent);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_WindowMouseInOutEventSignal")]
+ public static extern global::System.IntPtr NewWindowMouseInOutEventSignal();
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WindowMouseInOutEventSignal")]
+ public static extern void DeleteWindowMouseInOutEventSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+ }
+ }
+}
diff --git a/src/Tizen.NUI/src/internal/Window/WindowMouseInOutEventSignal.cs b/src/Tizen.NUI/src/internal/Window/WindowMouseInOutEventSignal.cs
new file mode 100755
index 0000000..635fcc3
--- /dev/null
+++ b/src/Tizen.NUI/src/internal/Window/WindowMouseInOutEventSignal.cs
@@ -0,0 +1,102 @@
+/*
+ * 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 Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI
+{
+ internal class WindowMouseInOutEventSignal : Disposable
+ {
+ internal WindowMouseInOutEventSignal(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ ///
+ /// Dispose
+ ///
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ Interop.WindowMouseInOutEventSignal.DeleteWindowMouseInOutEventSignal(swigCPtr);
+ }
+
+ ///
+ /// Queries whether there are any connected slots.
+ ///
+ /// True if there are any slots connected to the signal
+ public bool Empty()
+ {
+ bool ret = Interop.WindowMouseInOutEventSignal.Empty(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ ///
+ /// Queries the number of slots.
+ ///
+ /// The number of slots connected to this signal
+ public uint GetConnectionCount()
+ {
+ uint ret = Interop.WindowMouseInOutEventSignal.GetConnectionCount(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ ///
+ /// Connects a function.
+ ///
+ /// The function to connect
+ public void Connect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ Interop.WindowMouseInOutEventSignal.Connect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+
+ ///
+ /// Disconnects a function.
+ ///
+ /// The function to disconnect
+ public void Disconnect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ Interop.WindowMouseInOutEventSignal.Disconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+
+ ///
+ /// Emits the signal.
+ ///
+ /// The first value to pass to callbacks
+ /// The second value to pass to callbacks
+ public void Emit(Window window, MouseInOut mouseInOut)
+ {
+ Interop.WindowMouseInOutEventSignal.Emit(SwigCPtr, Window.getCPtr(window), MouseInOut.getCPtr(mouseInOut));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ ///
+ /// The constructor.
+ ///
+ public WindowMouseInOutEventSignal(Window window) : this(Interop.WindowMouseInOutEventSignal.GetSignal(Window.getCPtr(window)), false)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+}
diff --git a/src/Tizen.NUI/src/public/Window/MouseInOut.cs b/src/Tizen.NUI/src/public/Window/MouseInOut.cs
new file mode 100755
index 0000000..31e5dfe
--- /dev/null
+++ b/src/Tizen.NUI/src/public/Window/MouseInOut.cs
@@ -0,0 +1,227 @@
+/*
+ * 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.ComponentModel;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI
+{
+ ///
+ /// MouseInOut is used when the mouse enters or exits a window.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class MouseInOut : Disposable
+ {
+
+ ///
+ /// The default constructor.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public MouseInOut() : this(Interop.MouseInOut.NewMouseInOut((int)MouseInOut.StateType.None, 0, Vector2.getCPtr(new Vector2(0, 0)), 0), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ ///
+ /// The constructor.
+ ///
+ /// The state of the event.
+ /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
+ /// The coordinates of the cursor relative to the top-left of the screen.
+ /// The time the event is being started.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public MouseInOut(MouseInOut.StateType state, uint modifiers, Vector2 point, uint timeStamp) : this(Interop.MouseInOut.NewMouseInOut((int)state, modifiers, Vector2.getCPtr(point), timeStamp), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal MouseInOut(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ ///
+ /// The state of the mouse event.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum StateType
+ {
+ ///
+ /// Default value
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None,
+
+ ///
+ /// Mouse entered
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ In,
+
+ ///
+ /// Mouse exited
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Out
+ }
+
+ ///
+ /// The state of the mouse event.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public MouseInOut.StateType State
+ {
+ get
+ {
+ return state;
+ }
+ }
+
+ ///
+ /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint Modifiers
+ {
+ get
+ {
+ return modifiers;
+ }
+ }
+
+ ///
+ /// The coordinates of the cursor relative to the top-left of the screen.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Vector2 Point
+ {
+ get
+ {
+ return point;
+ }
+ }
+
+ ///
+ /// The time the mouse evnet is being started
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint TimeStamp
+ {
+ get
+ {
+ return timeStamp;
+ }
+ }
+
+ ///
+ /// Get the device class the mouse event originated from.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public DeviceClassType DeviceClass
+ {
+ get
+ {
+ return deviceClass;
+ }
+ }
+
+ ///
+ /// Get the device subclass the mouse event originated from.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public DeviceSubClassType DeviceSubClass
+ {
+ get
+ {
+ return deviceSubClass;
+ }
+ }
+
+ private MouseInOut.StateType state
+ {
+ get
+ {
+ MouseInOut.StateType ret = (MouseInOut.StateType)Interop.MouseInOut.TypeGet(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ private uint modifiers
+ {
+ get
+ {
+ uint ret = Interop.MouseInOut.ModifiersGet(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ private Vector2 point
+ {
+ get
+ {
+ global::System.IntPtr cPtr = Interop.MouseInOut.PointGet(SwigCPtr);
+ Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ private uint timeStamp
+ {
+ get
+ {
+ uint ret = Interop.MouseInOut.TimeStampGet(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ private DeviceClassType deviceClass
+ {
+ get
+ {
+ int ret = Interop.MouseInOut.DeviceClassGet(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return (DeviceClassType)ret;
+ }
+ }
+
+ private DeviceSubClassType deviceSubClass
+ {
+ get
+ {
+ int ret = Interop.MouseInOut.DeviceSubClassGet(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return (DeviceSubClassType)ret;
+ }
+ }
+
+ internal static MouseInOut GetMouseInOutFromPtr(global::System.IntPtr cPtr)
+ {
+ MouseInOut ret = new MouseInOut(cPtr, false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ /// This will not be public opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ Interop.MouseInOut.DeleteMouseInOut(swigCPtr);
+ }
+ }
+}
diff --git a/src/Tizen.NUI/src/public/Window/WindowEvent.cs b/src/Tizen.NUI/src/public/Window/WindowEvent.cs
index b1f00ed..1578cf8 100755
--- a/src/Tizen.NUI/src/public/Window/WindowEvent.cs
+++ b/src/Tizen.NUI/src/public/Window/WindowEvent.cs
@@ -50,6 +50,7 @@ namespace Tizen.NUI
private OrientationChangedEventCallbackType orientationChangedEventCallback;
private KeyboardRepeatSettingsChangedEventCallbackType keyboardRepeatSettingsChangedEventCallback;
private AuxiliaryMessageEventCallbackType auxiliaryMessageEventCallback;
+ private WindowMouseInOutEventCallbackType windowMouseInOutEventCallback;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -72,6 +73,8 @@ namespace Tizen.NUI
private delegate void AuxiliaryMessageEventCallbackType(IntPtr kData, IntPtr vData, IntPtr optionsArray);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate bool InterceptKeyEventDelegateType(IntPtr arg1);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ private delegate void WindowMouseInOutEventCallbackType(IntPtr window, IntPtr mouseEvent);
///
/// FocusChanged event.
@@ -441,6 +444,34 @@ namespace Tizen.NUI
}
}
+ ///
+ /// MouseInOutEvent event.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler MouseInOutEvent
+ {
+ add
+ {
+ if (windowMouseInOutEventHandler == null)
+ {
+ windowMouseInOutEventCallback = OnWindowMouseInOutEvent;
+ using WindowMouseInOutEventSignal signal = new WindowMouseInOutEventSignal(Interop.WindowMouseInOutEventSignal.GetSignal(SwigCPtr), false);
+ signal.Ensure()?.Connect(windowMouseInOutEventCallback);
+ }
+ windowMouseInOutEventHandler += value;
+ }
+ remove
+ {
+ windowMouseInOutEventHandler -= value;
+ if (windowMouseInOutEventHandler == null && windowMouseInOutEventCallback != null)
+ {
+ using WindowMouseInOutEventSignal signal = new WindowMouseInOutEventSignal(Interop.WindowMouseInOutEventSignal.GetSignal(SwigCPtr), false);
+ signal.Ensure()?.Disconnect(windowMouseInOutEventCallback);
+ windowMouseInOutEventCallback = null;
+ }
+ }
+ }
+
private event EventHandler windowFocusChangedEventHandler;
private event EventHandler rootLayerTouchDataEventHandler;
private ReturnTypeEventHandler