[NUI] Change TouchArea to TouchAreaOffset (#2948)
authorJoogabYun <40262755+JoogabYun@users.noreply.github.com>
Mon, 26 Apr 2021 06:05:53 +0000 (15:05 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 28 Apr 2021 03:36:30 +0000 (12:36 +0900)
    You can expand the touch area.

    for example)
      View view = new View();
      view.Size = new Size(10, 10);
      view.TouchEvent += OnTouch;
      view.TouchAreaOffset = new Offset(-100, 100, 100, -100); // left, right, bottom, top

    then touch area is 210x210.
    this is view.width  -touchAreaOffset.left + touchAreaOffset.right
    and view.height + touchAreaOffset.bottom  -touchAreaOffset.top

src/Tizen.NUI/src/internal/Interop/Interop.ActorInternal.cs
src/Tizen.NUI/src/internal/Interop/Interop.ActorProperty.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEnum.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/Common/NUIConstants.cs

index abd81fe..42fc88c 100755 (executable)
@@ -212,6 +212,12 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_GetMaximumSize")]
             public static extern global::System.IntPtr GetMaximumSize(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_DevelActor_Property_SetTouchAreaOffset")]
+            public static extern void SetTouchAreaOffset(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3, int jarg4, int jarg5);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_DevelActor_Property_GetTouchAreaOffset")]
+            public static extern void GetTouchAreaOffset(global::System.Runtime.InteropServices.HandleRef jarg1, out int jarg2, out int jarg3, out int jarg4, out int jarg5);
         }
     }
 }
index 363066a..a85431d 100755 (executable)
@@ -204,9 +204,6 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Actor_Property_BLEND_EQUATION_get")]
             public static extern int BlendEquationGet();
 
-            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Actor_Property_TOUCH_AREA_get")]
-            public static extern int TouchAreaGet();
-
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_Actor_Property")]
             public static extern global::System.IntPtr NewActorProperty();
 
index 498b896..63520b9 100755 (executable)
@@ -218,7 +218,6 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int AccessibilityHighlightable = Interop.ViewProperty.AccessibilityHighlightableGet();
             internal static readonly int AccessibilityAttributes = Interop.ViewProperty.AccessibilityAttributesGet();
             internal static readonly int AccessibilityAnimated = Interop.ViewProperty.AccessibilityAnimatedGet();
-            internal static readonly int TouchArea = Interop.ActorProperty.TouchAreaGet();
         }
     }
 }
index 861d37b..80f5dd7 100755 (executable)
@@ -1290,22 +1290,48 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// TouchArea can reset the view's touchable area.<br/>
-        /// If you set the TouchArea on an view, when you touch the view, the touch area is used rather than the size of the view.
+        /// TouchArea can expand the view's touchable area.<br/>
+        /// If you set the TouchAreaOffset on an view, when you touch the view, the touch area is used rather than the size of the view.<br/>
+        /// This is based on the top left x, y coordinates.<br/>
+        /// example) <br/>
+        ///  view.Size = new Size(100, 100);<br/>
+        ///  view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top <br/>
+        /// then touch area is 130x170.<br/>
+        /// this is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
+        /// +---------------------+ <br/>
+        /// |         ^           | <br/>
+        /// |         |           | <br/>
+        /// |         | -40       | <br/>
+        /// |         |           | <br/>
+        /// |         |           | <br/>
+        /// |    +----+----+      | <br/>
+        /// |    |         |      | <br/>
+        /// | -10|         | 20   | <br/>
+        /// |<---+         +----->| <br/>
+        /// |    |         |      | <br/>
+        /// |    |         |      | <br/>
+        /// |    +----+----+      | <br/>
+        /// |         |           | <br/>
+        /// |         | 30        | <br/>
+        /// |         |           | <br/>
+        /// |         v           | <br/>
+        /// +---------------------+ <br/>
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Size TouchArea
+        public Offset TouchAreaOffset
         {
             get
             {
-                Size value = new Size(0, 0, 0);
-                GetProperty(View.Property.TouchArea).Get(value);
-                return value;
+                Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
+                if (NDalicPINVOKE.SWIGPendingException.Pending)
+                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                return new Offset(left, right, bottom, top);
             }
             set
             {
-                SetProperty(View.Property.TouchArea, new Tizen.NUI.PropertyValue(value));
-                NotifyPropertyChanged();
+                Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
+                if (NDalicPINVOKE.SWIGPendingException.Pending)
+                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
         }
 
index a5641d7..5847844 100755 (executable)
@@ -1830,6 +1830,54 @@ namespace Tizen.NUI
     }
 
     /// <summary>
+    /// Offset has left, right, bottom, top value.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public struct Offset
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="left">left offset</param>
+        /// <param name="right">right offset</param>
+        /// <param name="bottom">bottom offset</param>
+        /// <param name="top">top offset</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Offset(int left, int right, int bottom, int top)
+        {
+            Left = left;
+            Right = right;
+            Bottom = bottom;
+            Top = top;
+        }
+
+        /// <summary>
+        /// Left
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public int Left {get; set;}
+
+        /// <summary>
+        /// Right
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public int Right {get; set;}
+
+        /// <summary>
+        /// Bottom
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public int Bottom {get; set;}
+
+        /// <summary>
+        /// Top
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public int Top {get; set;}
+
+    }
+
+    /// <summary>
     /// TODO This is to get TizenFX resource path. It needs to be fixed to use application framework API in the future.
     /// Internal use only. Do not open this API.
     /// </summary>