Merge remote-tracking branch 'origin/API10' into tizen_7.0
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / View.cs
index a826ca6..db1b8a9 100755 (executable)
@@ -71,7 +71,37 @@ namespace Tizen.NUI.BaseComponents
         private Size2D internalSize2D = null;
         private int layoutCount = 0;
         private ControlState propagatableControlStates = ControlState.All;
+
+        // List of dispatch Event
+        private PanGestureDetector panGestureDetector = null;
+        private LongPressGestureDetector longGestureDetector = null;
+        private PinchGestureDetector pinchGestureDetector = null;
+        private TapGestureDetector tapGestureDetector = null;
+        private RotationGestureDetector rotationGestureDetector = null;
+        private int configGestureCount = 0;
         private bool dispatchTouchEvents = true;
+        private bool dispatchGestureEvents = true;
+        private bool dispatchParentGestureEvents = true;
+
+#if NUI_PROPERTY_CHANGE_1
+        private string internalName = string.Empty;
+#endif
+#if NUI_PROPERTY_CHANGE_3
+        private Position internalCurrentParentOrigin = null;
+        private Position internalCurrentAnchorPoint = null;
+        private Vector3 internalTargetSize = null;
+        private Size2D internalCurrentSize = null;
+        private Vector3 internalNaturalSize = null;
+        private Position internalCurrentPosition = null;
+        private Vector3 internalCurrentWorldPosition = null;
+        private Vector3 internalCurrentScale = null;
+        private Vector3 internalCurrentWorldScale = null;
+        private Vector4 internalCurrentColor = null;
+        private Vector4 internalCurrentWorldColor = null;
+#endif
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+        private Vector2 internalCurrentScreenPosition = null;
+#endif
 
         static View()
         {
@@ -689,6 +719,24 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// The color selector for the borderline of the View.
+        /// Like BackgroundColor, color selector typed BorderlineColor should be used in ViewStyle only.
+        /// So this API is internally used only.
+        /// </summary>
+        internal Selector<Color> BorderlineColorSelector
+        {
+            get
+            {
+                return (Selector<Color>)GetValue(BorderlineColorSelectorProperty);
+            }
+            set
+            {
+                SetValue(BorderlineColorSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
         /// The Relative offset for the borderline of the View.
         /// Recommended range : [-1.0f to 1.0f].
         /// If -1.0f, draw borderline inside of the View.
@@ -1163,7 +1211,7 @@ namespace Tizen.NUI.BaseComponents
         /// <remarks>
         /// The <see cref="Size"/>, <see cref="Position"/>, <see cref="Color"/>, and <see cref="Scale"/> properties are set in the main thread.
         /// Therefore, it is not updated in real time when the value is changed in the render thread (for example, the value is changed during animation).
-        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time, 
+        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time,
         /// and users can get the current actual values through them.
         /// </remarks>
         /// <since_tizen> 3 </since_tizen>
@@ -1225,7 +1273,7 @@ namespace Tizen.NUI.BaseComponents
         /// <remarks>
         /// The <see cref="Size"/>, <see cref="Position"/>, <see cref="Color"/>, and <see cref="Scale"/> properties are set in the main thread.
         /// Therefore, it is not updated in real time when the value is changed in the render thread (for example, the value is changed during animation).
-        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time, 
+        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time,
         /// and users can get the current actual values through them.
         /// </remarks>
         /// <since_tizen> 3 </since_tizen>
@@ -1303,11 +1351,24 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                Vector2 temp = new Vector2(0.0f, 0.0f);
-                var pValue = GetProperty(View.Property.ScreenPosition);
-                pValue.Get(temp);
-                pValue.Dispose();
-                return temp;
+                return GetCurrentScreenPosition();
+            }
+        }
+
+        /// <summary>
+        /// Retrieves the screen position and size of the view.<br />
+        /// </summary>
+        /// <remarks>
+        /// The float type Rectangle class is not ready yet.
+        /// Therefore, it transmits data in Vector4 class.
+        /// This type should later be changed to the appropriate data type.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Vector4 ScreenPositionSize
+        {
+            get
+            {
+                return GetCurrentScreenPositionSize();
             }
         }
 
@@ -1359,17 +1420,25 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return Object.InternalGetPropertyBool(SwigCPtr, View.Property.PositionUsesAnchorPoint);
+#else
                 bool temp = false;
                 var pValue = GetProperty(View.Property.PositionUsesAnchorPoint);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
             set
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                Object.InternalSetPropertyBool(SwigCPtr, View.Property.PositionUsesAnchorPoint, value);
+#else
                 var temp = new Tizen.NUI.PropertyValue(value);
                 SetProperty(View.Property.PositionUsesAnchorPoint, temp);
                 temp.Dispose();
+#endif
                 NotifyPropertyChanged();
             }
         }
@@ -1691,11 +1760,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return GetCurrentWorldPosition();
+#else
                 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
                 var pValue = GetProperty(View.Property.WorldPosition);
                 pValue.Get(temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
         }
 
@@ -1864,11 +1937,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return GetCurrentWorldScale();
+#else
                 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
                 var pValue = GetProperty(View.Property.WorldScale);
                 pValue.Get(temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
         }
 
@@ -1892,11 +1969,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return Object.InternalGetPropertyBool(SwigCPtr, View.Property.VISIBLE);
+#else
                 bool temp = false;
                 var pValue = GetProperty(View.Property.VISIBLE);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
         }
 
@@ -1908,11 +1989,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return GetCurrentWorldColor();
+#else
                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
                 var pValue = GetProperty(View.Property.WorldColor);
                 pValue.Get(temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
         }
 
@@ -2373,6 +2458,9 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return GetCurrentAnchorPoint();
+#else
                 Position temp = new Position(0.0f, 0.0f, 0.0f);
                 var pValue = GetProperty(View.Property.AnchorPoint);
                 pValue.Get(temp);
@@ -2380,12 +2468,17 @@ namespace Tizen.NUI.BaseComponents
                 Position ret = new Position(OnAnchorPointChanged, temp.X, temp.Y, temp.Z);
                 temp.Dispose();
                 return ret;
+#endif
             }
             set
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                SetAnchorPoint(value);
+#else
                 var temp = new Tizen.NUI.PropertyValue(value);
                 SetProperty(View.Property.AnchorPoint, temp);
                 temp.Dispose();
+#endif
                 NotifyPropertyChanged();
             }
         }
@@ -2755,6 +2848,10 @@ namespace Tizen.NUI.BaseComponents
 
         /// <summary>
         /// The Color of View. This is an RGBA value.
+        /// Each RGBA components match as <see cref="ColorRed"/>, <see cref="ColorGreen"/>, <see cref="ColorBlue"/>, and <see cref="Opacity"/>.
+        /// This property will multiply the final color of this view. (BackgroundColor, BorderlineColor, BackgroundImage, etc).
+        /// For example, if view.BackgroundColor = Color.Yellow and view.Color = Color.Purple, this view will shown as Red.
+        /// Inherient of color value depend on <see cref="ColorMode"/>.
         /// </summary>
         /// <remarks>
         /// <para>
@@ -2788,6 +2885,72 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// The Red component of View.Color.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// Animatable - This property can be animated using <c>Animation</c> class.
+        /// </para>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public float ColorRed
+        {
+            get
+            {
+                return (float)GetValue(ColorRedProperty);
+            }
+            set
+            {
+                SetValue(ColorRedProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// The Green component of View.Color.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// Animatable - This property can be animated using <c>Animation</c> class.
+        /// </para>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public float ColorGreen
+        {
+            get
+            {
+                return (float)GetValue(ColorGreenProperty);
+            }
+            set
+            {
+                SetValue(ColorGreenProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// The Blue component of View.Color.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// Animatable - This property can be animated using <c>Animation</c> class.
+        /// </para>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public float ColorBlue
+        {
+            get
+            {
+                return (float)GetValue(ColorBlueProperty);
+            }
+            set
+            {
+                SetValue(ColorBlueProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
         /// Set the layout on this View. Replaces any existing Layout.
         /// </summary>
         /// <remarks>
@@ -2980,12 +3143,16 @@ namespace Tizen.NUI.BaseComponents
             {
                 backgroundImageSynchronousLoading = value;
 
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                if (!string.IsNullOrEmpty(BackgroundImage))
+#else
                 string bgUrl = null;
                 var pValue = Background.Find(ImageVisualProperty.URL);
                 pValue?.Get(out bgUrl);
                 pValue?.Dispose();
 
                 if (!string.IsNullOrEmpty(bgUrl))
+#endif
                 {
                     PropertyMap bgMap = this.Background;
                     var temp = new PropertyValue(backgroundImageSynchronousLoading);
@@ -3114,17 +3281,25 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return Object.InternalGetPropertyBool(SwigCPtr, View.Property.CaptureAllTouchAfterStart);
+#else
                 bool temp = false;
                 var pValue = GetProperty(View.Property.CaptureAllTouchAfterStart);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
             set
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                Object.InternalSetPropertyBool(SwigCPtr, View.Property.CaptureAllTouchAfterStart, value);
+#else
                 var temp = new Tizen.NUI.PropertyValue(value);
                 SetProperty(View.Property.CaptureAllTouchAfterStart, temp);
                 temp.Dispose();
+#endif
                 NotifyPropertyChanged();
             }
         }
@@ -3150,17 +3325,25 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return Object.InternalGetPropertyBool(SwigCPtr, View.Property.AllowOnlyOwnTouch);
+#else
                 bool temp = false;
                 var pValue = GetProperty(View.Property.AllowOnlyOwnTouch);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
             set
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                Object.InternalSetPropertyBool(SwigCPtr, View.Property.AllowOnlyOwnTouch, value);
+#else
                 var temp = new Tizen.NUI.PropertyValue(value);
                 SetProperty(View.Property.AllowOnlyOwnTouch, temp);
                 temp.Dispose();
+#endif
                 NotifyPropertyChanged();
             }
         }
@@ -3187,17 +3370,25 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return (BlendEquationType)Object.InternalGetPropertyInt(SwigCPtr, View.Property.BlendEquation);
+#else
                 int temp = 0;
                 var pValue = GetProperty(View.Property.BlendEquation);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return (BlendEquationType)temp;
+#endif
             }
             set
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                Object.InternalSetPropertyInt(SwigCPtr, View.Property.BlendEquation, (int)value);
+#else
                 var temp = new Tizen.NUI.PropertyValue((int)value);
                 SetProperty(View.Property.BlendEquation, temp);
                 temp.Dispose();
+#endif
                 NotifyPropertyChanged();
             }
         }
@@ -3307,11 +3498,15 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+#if NUI_VISUAL_PROPERTY_CHANGE_1
+                return Object.InternalGetPropertyBool(SwigCPtr, View.Property.Culled);
+#else
                 bool temp = false;
                 var pValue = GetProperty(View.Property.Culled);
                 pValue.Get(out temp);
                 pValue.Dispose();
                 return temp;
+#endif
             }
         }
 
@@ -3347,7 +3542,7 @@ namespace Tizen.NUI.BaseComponents
 
         /// <summary>
         /// Gets or sets the status of whether the view should emit key event signals.
-        /// If a View's DispatchKeyEvents is set to false, then it's children will not emit a key event signal either.
+        /// If a View's DispatchKeyEvents is set to false, then itself and parents will not receive key event signals.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool DispatchKeyEvents
@@ -3401,6 +3596,107 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets the status of whether the view should emit Gesture event signals.
+        /// If a View's DispatchGestureEvents is set to false, then itself and parents will not receive all gesture event signals.
+        /// The itself and parents does not receive tap, pinch, pan, rotation, or longpress gestures.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool DispatchGestureEvents
+        {
+            get
+            {
+                return dispatchGestureEvents;
+            }
+            set
+            {
+                if (dispatchGestureEvents != value)
+                {
+                    dispatchGestureEvents = value;
+                    ConfigGestureDetector(dispatchGestureEvents);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the status of whether the view should emit Gesture event signals.
+        /// If a View's DispatchParentGestureEvents is set to false, then parents will not receive all gesture event signals.
+        /// The parents does not receive tap, pinch, pan, rotation, or longpress gestures.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool DispatchParentGestureEvents
+        {
+            get
+            {
+                return dispatchParentGestureEvents;
+            }
+            set
+            {
+                if (dispatchParentGestureEvents != value)
+                {
+                    dispatchParentGestureEvents = value;
+                    ConfigGestureDetector(dispatchParentGestureEvents);
+                }
+            }
+        }
+
+        private void ConfigGestureDetector(bool dispatch)
+        {
+            if (panGestureDetector == null) panGestureDetector = new PanGestureDetector();
+            if (longGestureDetector == null) longGestureDetector = new LongPressGestureDetector();
+            if (pinchGestureDetector == null) pinchGestureDetector = new PinchGestureDetector();
+            if (tapGestureDetector == null) tapGestureDetector = new TapGestureDetector();
+            if (rotationGestureDetector == null) rotationGestureDetector = new RotationGestureDetector();
+
+            if (dispatch == true)
+            {
+                configGestureCount = configGestureCount > 0 ? configGestureCount-- : 0;
+                if (configGestureCount == 0)
+                {
+                    panGestureDetector.Detach(this);
+                    longGestureDetector.Detach(this);
+                    pinchGestureDetector.Detach(this);
+                    tapGestureDetector.Detach(this);
+                    rotationGestureDetector.Detach(this);
+
+                    panGestureDetector.Detected -= OnGestureDetected;
+                    longGestureDetector.Detected -= OnGestureDetected;
+                    pinchGestureDetector.Detected -= OnGestureDetected;
+                    tapGestureDetector.Detected -= OnGestureDetected;
+                    rotationGestureDetector.Detected -= OnGestureDetected;
+
+                    panGestureDetector = null;
+                    longGestureDetector = null;
+                    pinchGestureDetector = null;
+                    tapGestureDetector = null;
+                    rotationGestureDetector = null;
+                }
+            }
+            else
+            {
+                if (configGestureCount == 0)
+                {
+                    panGestureDetector.Attach(this);
+                    longGestureDetector.Attach(this);
+                    pinchGestureDetector.Attach(this);
+                    tapGestureDetector.Attach(this);
+                    rotationGestureDetector.Attach(this);
+
+                    panGestureDetector.Detected += OnGestureDetected;
+                    longGestureDetector.Detected += OnGestureDetected;
+                    pinchGestureDetector.Detected += OnGestureDetected;
+                    tapGestureDetector.Detected += OnGestureDetected;
+                    rotationGestureDetector.Detected += OnGestureDetected;
+                }
+                configGestureCount++;
+            }
+        }
+
+        private void OnGestureDetected(object source, EventArgs e)
+        {
+            // Does notting. This is to consume the gesture.
+        }
+
+        /// <summary>
         /// Called when the view is hit through TouchEvent or GestureEvent.
         /// If it returns true, it means that it was hit, and the touch/gesture event is called from the view.
         /// If it returns false, it means that it will not be hit, and the hit-test continues to the next view.
@@ -3421,7 +3717,7 @@ namespace Tizen.NUI.BaseComponents
         /// <remarks>
         /// The <see cref="Size"/>, <see cref="Position"/>, <see cref="Color"/>, and <see cref="Scale"/> properties are set in the main thread.
         /// Therefore, it is not updated in real time when the value is changed in the render thread (for example, the value is changed during animation).
-        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time, 
+        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time,
         /// and users can get the current actual values through them.
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -3433,7 +3729,7 @@ namespace Tizen.NUI.BaseComponents
         /// <remarks>
         /// The <see cref="Size"/>, <see cref="Position"/>, <see cref="Color"/>, and <see cref="Scale"/> properties are set in the main thread.
         /// Therefore, it is not updated in real time when the value is changed in the render thread (for example, the value is changed during animation).
-        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time, 
+        /// However, <see cref="CurrentSize"/>, <see cref="CurrentPosition"/>, <see cref="CurrentColor"/>, and <see cref="CurrentScale"/> properties are updated in real time,
         /// and users can get the current actual values through them.
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]