From: joogab.yun Date: Fri, 8 Sep 2023 05:11:44 +0000 (+0900) Subject: [NUI] Binding PointerConstraintsEvent X-Git-Tag: submit/tizen/20230911.073618~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c54615cd69c75cf48554fb2431bad98e3bf8e291;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Binding PointerConstraintsEvent --- diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.PointerConstraints.cs b/src/Tizen.NUI/src/internal/Interop/Interop.PointerConstraints.cs new file mode 100755 index 000000000..6766cd537 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.PointerConstraints.cs @@ -0,0 +1,45 @@ +/* + * 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 PointerConstraints + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_PointerConstraintsEvent__SWIG_0")] + public static extern global::System.IntPtr NewPointerConstraints(int x, int y, bool locked, bool confined); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_PointerConstraintsEvent")] + public static extern void DeletePointerConstraints(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PointerConstraintsEvent_x_get")] + public static extern int XGet(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PointerConstraintsEvent_y_get")] + public static extern int YGet(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PointerConstraintsEvent_locked_get")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool LockedGet(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PointerConstraintsEvent_confined_get")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool ConfinedGet(global::System.Runtime.InteropServices.HandleRef jarg1); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowPointerConstraintsSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowPointerConstraintsSignal.cs new file mode 100755 index 000000000..063301a73 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.WindowPointerConstraintsSignal.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 WindowPointerConstraintsSignal + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowPointerConstraintsEventSignal")] + public static extern global::System.IntPtr GetSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowPointerConstraintsEventSignal_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_WindowPointerConstraintsEventSignal_GetConnectionCount")] + public static extern uint GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_WindowPointerConstraintsEventSignal_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_WindowPointerConstraintsEventSignal_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_WindowPointerConstraintsEventSignal_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_WindowPointerConstraintsEventSignal")] + public static extern global::System.IntPtr NewWindowPointerConstraintsSignal(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_WindowPointerConstraintsEventSignal")] + public static extern void DeleteWindowPointerConstraintsSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Window/WindowPointerConstraintsSignal.cs b/src/Tizen.NUI/src/internal/Window/WindowPointerConstraintsSignal.cs new file mode 100755 index 000000000..8165e4679 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Window/WindowPointerConstraintsSignal.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 WindowPointerConstraintsSignal : Disposable + { + internal WindowPointerConstraintsSignal(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Dispose + /// + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.WindowPointerConstraintsSignal.DeleteWindowPointerConstraintsSignal(swigCPtr); + } + + /// + /// Queries whether there are any connected slots. + /// + /// True if there are any slots connected to the signal + public bool Empty() + { + bool ret = Interop.WindowPointerConstraintsSignal.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.WindowPointerConstraintsSignal.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.WindowPointerConstraintsSignal.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.WindowPointerConstraintsSignal.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, PointerConstraints pointerConstraints) + { + Interop.WindowPointerConstraintsSignal.Emit(SwigCPtr, Window.getCPtr(window), PointerConstraints.getCPtr(pointerConstraints)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// The constructor. + /// + public WindowPointerConstraintsSignal(Window window) : this(Interop.WindowPointerConstraintsSignal.GetSignal(Window.getCPtr(window)), false) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } +} diff --git a/src/Tizen.NUI/src/public/Window/PointerConstraints.cs b/src/Tizen.NUI/src/public/Window/PointerConstraints.cs new file mode 100755 index 000000000..c3b623af5 --- /dev/null +++ b/src/Tizen.NUI/src/public/Window/PointerConstraints.cs @@ -0,0 +1,135 @@ +/* + * 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 +{ + /// + /// PointerConstraints is used when pointer is locked/unlocked + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PointerConstraints : Disposable + { + + /// + /// The default constructor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PointerConstraints() : this(Interop.PointerConstraints.NewPointerConstraints(0, 0, false, false), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// The constructor. + /// + /// The x coordinate relative to window where event happened. + /// The y coordinate relative to window where event happened. + /// The status whether pointer is locked/unlocked. + /// The status whether pointer is confined/unconfined. + [EditorBrowsable(EditorBrowsableState.Never)] + public PointerConstraints(int x, int y, bool locked, bool confined): this(Interop.PointerConstraints.NewPointerConstraints(x, y, locked, confined), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal PointerConstraints(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Gets the x, y position, + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Position2D Position + { + get + { + return position; + } + } + + /// + /// Gets the status whether pointer is locked/unlocked. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Locked + { + get + { + return locked; + } + } + + /// + /// Gets the status whether pointer is confined/unconfined. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Confined + { + get + { + return confined; + } + } + + private Position2D position + { + get + { + Position2D ret = new Position2D(Interop.PointerConstraints.XGet(SwigCPtr), Interop.PointerConstraints.YGet(SwigCPtr)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + private bool locked + { + get + { + bool ret = Interop.PointerConstraints.LockedGet(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + private bool confined + { + get + { + bool ret = Interop.PointerConstraints.ConfinedGet(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + internal static PointerConstraints GetPointerConstraintsFromPtr(global::System.IntPtr cPtr) + { + PointerConstraints ret = new PointerConstraints(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.PointerConstraints.DeletePointerConstraints(swigCPtr); + } + } +} diff --git a/src/Tizen.NUI/src/public/Window/WindowEvent.cs b/src/Tizen.NUI/src/public/Window/WindowEvent.cs index 5fe725e3e..b278409e3 100755 --- a/src/Tizen.NUI/src/public/Window/WindowEvent.cs +++ b/src/Tizen.NUI/src/public/Window/WindowEvent.cs @@ -56,6 +56,7 @@ namespace Tizen.NUI private MoveCompletedEventCallbackType moveCompletedEventCallback; private ResizeCompletedEventCallbackType resizeCompletedEventCallback; private InsetsChangedEventCallbackType insetsChangedEventCallback; + private WindowPointerConstraintsEventCallback windowPointerConstraintsEventCallback; [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -88,6 +89,8 @@ namespace Tizen.NUI private delegate void ResizeCompletedEventCallbackType(IntPtr window, IntPtr size); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void InsetsChangedEventCallbackType(int partType, int partState, IntPtr extents); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void WindowPointerConstraintsEventCallback(IntPtr window, IntPtr constraintsEvent); /// @@ -605,6 +608,34 @@ namespace Tizen.NUI } } + /// + /// Emits the event when pointer is locked/unlocked
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler PointerConstraintsEvent + { + add + { + if (windowPointerConstraintsEventHandler == null) + { + windowPointerConstraintsEventCallback = OnWindowPointerConstraintsEvent; + using WindowPointerConstraintsSignal signal = new WindowPointerConstraintsSignal(Interop.WindowPointerConstraintsSignal.GetSignal(SwigCPtr), false); + signal?.Connect(windowPointerConstraintsEventCallback); + } + windowPointerConstraintsEventHandler += value; + } + remove + { + windowPointerConstraintsEventHandler -= value; + if (windowPointerConstraintsEventHandler == null && windowPointerConstraintsEventCallback != null) + { + using WindowPointerConstraintsSignal signal = new WindowPointerConstraintsSignal(Interop.WindowPointerConstraintsSignal.GetSignal(SwigCPtr), false); + signal?.Disconnect(windowMouseRelativeEventCallback); + windowPointerConstraintsEventCallback = null; + } + } + } + private event EventHandler windowFocusChangedEventHandler; private event EventHandler rootLayerTouchDataEventHandler; private ReturnTypeEventHandler rootLayerInterceptTouchDataEventHandler; @@ -625,6 +656,7 @@ namespace Tizen.NUI private event EventHandler moveCompletedHandler; private event EventHandler resizeCompletedHandler; private event EventHandler insetsChangedEventHandler; + private event EventHandler windowPointerConstraintsEventHandler; internal event EventHandler EventProcessingFinished @@ -916,6 +948,13 @@ namespace Tizen.NUI signal?.Disconnect(insetsChangedEventCallback); insetsChangedEventCallback = null; } + + if (windowPointerConstraintsEventCallback != null) + { + using WindowPointerConstraintsSignal signal = new WindowPointerConstraintsSignal(Interop.WindowPointerConstraintsSignal.GetSignal(GetBaseHandleCPtrHandleRef), false); + signal?.Disconnect(windowPointerConstraintsEventCallback); + windowPointerConstraintsEventCallback = null; + } } private void OnWindowFocusedChanged(IntPtr window, bool focusGained) @@ -1210,6 +1249,22 @@ namespace Tizen.NUI } } + private void OnWindowPointerConstraintsEvent(IntPtr view, IntPtr constraintsEvent) + { + if (constraintsEvent == global::System.IntPtr.Zero) + { + NUILog.Error("constraintsEvent should not be null!"); + return; + } + + if (windowPointerConstraintsEventHandler != null) + { + PointerConstraintsEventArgs e = new PointerConstraintsEventArgs(); + e.PointerConstraints = Tizen.NUI.PointerConstraints.GetPointerConstraintsFromPtr(constraintsEvent); + windowPointerConstraintsEventHandler(this, e); + } + } + /// /// The focus changed event argument. /// @@ -1378,6 +1433,32 @@ namespace Tizen.NUI } } + + /// + /// PointerConstraints evnet arguments. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PointerConstraintsEventArgs : EventArgs + { + private PointerConstraints constraintsEvent; + + /// + /// PointerConstraints event. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PointerConstraints PointerConstraints + { + get + { + return constraintsEvent; + } + set + { + constraintsEvent = value; + } + } + } + /// /// Do not use this, that will be deprecated. ///