Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NUI] Geometry Touch / Gesture Event #6452

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Tizen.NUI/src/internal/Interop/Interop.Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ internal static partial class Application

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetScreenSize")]
public static extern global::System.IntPtr GetScreenSize();

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_SetGeometryHittestEnabled")]
public static extern void SetGeometryHittestEnabled(bool enable);

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_IsGeometryHittestEnabled")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool IsGeometryHittestEnabled();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ internal static partial class GestureDetector

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GestureDetector_GetAttachedActor")]
public static extern global::System.IntPtr GetAttachedActor(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GestureDetector_HandleEvent")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool HandleEvent(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);

[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GestureDetector_CancelAllOtherGestureDetectors")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool CancelAllOtherGestureDetectors(global::System.Runtime.InteropServices.HandleRef jarg1);
}
}
}
26 changes: 25 additions & 1 deletion src/Tizen.NUI/src/public/Application/NUIApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Tizen.NUI
public class NUIApplication : CoreApplication
{
/// <summary>
/// Set to true if XAML is used.
/// Set to true if XAML is used.
/// This must be called before or immediately after the NUIApplication constructor is called.
/// The default value is true.
/// </summary>
Expand Down Expand Up @@ -592,6 +592,30 @@ static public Size GetScreenSize()
return ret;
}

/// <summary>
/// Sets the geometry hit-testing enabled or disabled for the application.
/// </summary>
/// <param name="enable">True to enable geometry hit-testing, false otherwise.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
static public void SetGeometryHittestEnabled(bool enable)
{
Interop.Application.SetGeometryHittestEnabled(enable);
NDalicPINVOKE.ThrowExceptionIfExists();
}

/// <summary>
/// Checks whether geometry hit-testing is enabled for the application.
/// </summary>
/// <returns>True if geometry hit-testing is enabled, false otherwise.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
static public bool IsGeometryHittestEnabled()
{
bool ret = Interop.Application.IsGeometryHittestEnabled();
NDalicPINVOKE.ThrowExceptionIfExists();
return ret;
}


/// <summary>
/// The OnLocaleChanged method is called when the system locale settings have changed.
/// Overrides this method if you want to handle behavior.
Expand Down
28 changes: 26 additions & 2 deletions src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,19 @@ private bool OnInterceptTouch(IntPtr view, IntPtr touchData)

if (interceptTouchDataEventHandler != null)
{
consumed = interceptTouchDataEventHandler(this, e);
if(NUIApplication.IsGeometryHittestEnabled())
{
Delegate[] delegateList = interceptTouchDataEventHandler.GetInvocationList();
// Oring the result of each callback.
foreach (EventHandlerWithReturnType<object, TouchEventArgs, bool> del in delegateList)
{
consumed |= del(this, e);
}
}
else
{
consumed = interceptTouchDataEventHandler(this, e);
}
}

return consumed;
Expand Down Expand Up @@ -926,7 +938,19 @@ private bool OnTouch(IntPtr view, IntPtr touchData)

if (touchDataEventHandler != null)
{
consumed = touchDataEventHandler(this, e);
if(NUIApplication.IsGeometryHittestEnabled())
{
Delegate[] delegateList = touchDataEventHandler.GetInvocationList();
// Oring the result of each callback.
foreach (EventHandlerWithReturnType<object, TouchEventArgs, bool> del in delegateList)
{
consumed |= del(this, e);
}
}
else
{
consumed = touchDataEventHandler(this, e);
}
}

if (enableControlState && !consumed)
Expand Down
26 changes: 26 additions & 0 deletions src/Tizen.NUI/src/public/Events/GestureDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ public View GetAttachedView(uint index)
return ret;
}

/// <summary>
/// Handles the event for a given view and touch input.
/// This method should only be called when SetGeometryHittestEnabled is set to true.
/// It processes the touch input and attempts to recognize gestures based on the provided view and touch data.
/// </summary>
/// <param name="view">The view associated with the gesture detector.</param>
/// <param name="touch">The touch input data to analyze for gestures.</param>
/// <returns>True if the event was handled successfully, otherwise false.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool HandleEvent(View view, Touch touch)
{
bool ret = Interop.GestureDetector.HandleEvent(SwigCPtr, View.getCPtr(view), Touch.getCPtr(touch));
NDalicPINVOKE.ThrowExceptionIfExists();
return ret;
}

/// <summary>
/// Cancels all other gesture detectors that are currently recognizing gestures by HandleEvent(View view, Touch touch) api
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void CancelAllOtherGestureDetectors()
{
Interop.GestureDetector.CancelAllOtherGestureDetectors(SwigCPtr);
NDalicPINVOKE.ThrowExceptionIfExists();
}

internal GestureDetector Assign(GestureDetector rhs)
{
GestureDetector ret = new GestureDetector(Interop.GestureDetector.Assign(SwigCPtr, GestureDetector.getCPtr(rhs)), false);
Expand Down
Loading
Loading