[NUI] Integration from dalihub (#1039)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 25 Sep 2019 07:52:31 +0000 (16:52 +0900)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2019 07:52:31 +0000 (16:52 +0900)
* [NUI] Add UPATE_SIZE_HINT property

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
* [NUI] Make public-API as Hidden-API before ACR

-View::RotateBy
-Touch::GetAngle

Required for handling rotation of objects.

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
* [NUI] Modify BackgroundImageSynchronosLoading issue

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
* [NUI]Fix UPDATE_SIZE_HINT crash issue

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
* [NUI] Fix transition inheritance from parent

Change of logic so if child has a transition for the condition
then don't copy parents.

Previously only checked if transitions list was empty.

Change-Id: If168d493b70e236fc22845bb0a09e4e6ff5ca77a

* [NUI] Overriding Animation API

Change-Id: Ief7d52b1108729f0216c11d495770be2af2920d1

* [NUI] Layout Animation fix

Change-Id: I85fbb7af0e86860d3d2d667796b89ba29944b384

src/Tizen.NUI/src/internal/Interop/Interop.ViewProperty.cs
src/Tizen.NUI/src/internal/Layouting/LayoutController.cs
src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Touch.cs

index e765988..5d8205d 100755 (executable)
@@ -49,6 +49,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_View_Property_DOWN_FOCUSABLE_ACTOR_ID_get")]
             public static extern int View_Property_DOWN_FOCUSABLE_ACTOR_ID_get();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_Property_UPDATE_SIZE_HINT_get")]
+            public static extern int View_Property_UPDATE_SIZE_HINT_get();
         }
     }
 }
\ No newline at end of file
index 249f99d..8b3017e 100755 (executable)
@@ -20,6 +20,7 @@ using System.Runtime.InteropServices;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System;
+using System.ComponentModel;
 
 namespace Tizen.NUI
 {
@@ -38,6 +39,9 @@ namespace Tizen.NUI
 
         event Callback _instance;
 
+        // A Flag to check if it is already disposed.
+        private bool disposed = false;
+
         private Window _window;
 
         Animation _coreAnimation;
@@ -90,6 +94,40 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Get the Layouting animation object that transitions layouts and content.
+        /// Use OverrideCoreAnimation to explicitly control Playback.
+        /// </summary>
+        /// <returns> The layouting core Animation. </returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Animation GetCoreAnimation()
+        {
+            return _coreAnimation;
+        }
+
+        /// <summary>
+        /// Set or Get Layouting core animation override property.
+        /// Gives explicit control over the Layouting animation playback if set to True.
+        /// Reset to False if explicit control no longer required.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool OverrideCoreAnimation {get;set;} = false;
+
+        /// <summary>
+        /// Destructor which adds LayoutController to the Dispose queue.
+        /// </summary>
+        ~LayoutController()
+        {
+        }
+
+        /// <summary>
+        /// Explict Dispose.
+        /// </summary>
+        public void Dispose()
+        {
+           Dispose(DisposeTypes.Explicit);
+        }
+
+        /// <summary>
         /// Add transition data for a LayoutItem to the transition stack.
         /// </summary>
         /// <param name="transitionDataEntry">Transition data for a LayoutItem.</param>
@@ -252,7 +290,7 @@ namespace Tizen.NUI
 
                 bool readyToPlay = SetupCoreAnimation();
 
-                if (readyToPlay)
+                if (readyToPlay && OverrideCoreAnimation==false)
                 {
                     PlayAnimation();
                 }
@@ -311,8 +349,8 @@ namespace Tizen.NUI
         /// </summary>
         private void PlayAnimation()
         {
+            Debug.WriteLineIf( LayoutDebugController, "LayoutController Playing, Core Duration:" + _coreAnimation.Duration);
             _coreAnimation.Play();
-            Debug.WriteLineIf( LayoutDebugController, "LayoutController Core Duration:" + _coreAnimation.Duration);
         }
 
         private void AnimationFinished(object sender, EventArgs e)
@@ -345,6 +383,8 @@ namespace Tizen.NUI
                 // of the other stack.  Then the main removal stack iterated when AnimationFinished
                 // occurs again.
             }
+            Debug.WriteLineIf( LayoutDebugController, "LayoutController AnimationFinished");
+            _coreAnimation?.Clear();
         }
 
         /// <summary>
@@ -356,9 +396,15 @@ namespace Tizen.NUI
             // Initialize animation for this layout run.
             bool animationPending = false;
 
+            Debug.WriteLineIf( LayoutDebugController,
+                               "LayoutController SetupCoreAnimation for:" + _layoutTransitionDataQueue.Count);
+
             if (_layoutTransitionDataQueue.Count > 0 ) // Something to animate
             {
-                _coreAnimation = new Animation();
+                if (!_coreAnimation)
+                {
+                    _coreAnimation = new Animation();
+                }
                 _coreAnimation.EndAction = Animation.EndActions.StopFinal;
                 _coreAnimation.Finished += AnimationFinished;
 
@@ -419,6 +465,13 @@ namespace Tizen.NUI
                                          sizeTransitionComponents.Delay,
                                          sizeTransitionComponents.Duration,
                                          sizeTransitionComponents.AlphaFunction);
+
+                Debug.WriteLineIf( LayoutDebugController,
+                                  "LayoutController SetupAnimationForSize View:" + layoutPositionData.Item.Owner.Name +
+                                   " width:" + (layoutPositionData.Right-layoutPositionData.Left) +
+                                   " height:" + (layoutPositionData.Bottom-layoutPositionData.Top) +
+                                   " delay:" + sizeTransitionComponents.Delay +
+                                   " duration:" + sizeTransitionComponents.Duration );
             }
         }
 
@@ -493,22 +546,23 @@ namespace Tizen.NUI
 
             bool matchedCustomTransitions = false;
 
-            // Inherit parent transitions if none already set on View for the condition.
-            // Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.
 
             TransitionList transitionsForCurrentCondition = new TransitionList();
+            // Note, Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.
 
-            ILayoutParent layoutParent = layoutPositionData.Item.GetParent();
-            if (layoutParent !=null)
+            // Check if item to animate has it's own Transitions for this condition.
+            // If a key exists then a List of atleast 1 transition exists.
+            if (layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
             {
-                // Check if item to animate has it's own Transitions for this condition.
-                // If a key exists then a List of atleast 1 transition exists.
-                if ( layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
-                {
-                    // Child has transitions for the condition
-                    matchedCustomTransitions = layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition);
-                }
-                else
+                // Child has transitions for the condition
+                matchedCustomTransitions = layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition);
+            }
+
+            if (!matchedCustomTransitions)
+            {
+                // Inherit parent transitions as none already set on View for the condition.
+                ILayoutParent layoutParent = layoutPositionData.Item.GetParent();
+                if (layoutParent !=null)
                 {
                     // Item doesn't have it's own transitions for this condition so copy parents if
                     // has a parent with transitions.
@@ -520,13 +574,13 @@ namespace Tizen.NUI
                         // Copy parent transitions to temporary TransitionList. List contains transitions for the current condition.
                         LayoutTransitionsHelper.CopyTransitions(parentTransitionList,
                                                                 transitionsForCurrentCondition);
-
-                        matchedCustomTransitions = false; // Using parent transition as no custom match.
                     }
                 }
             }
 
-            // Position/Size transitions can be for a layout changing to another layout or an item being added or removed.
+
+            // Position/Size transitions can be displayed for a layout changing to another layout or an item being added or removed.
+
             // There can only be one position transition and one size position, they will be replaced if set multiple times.
             // transitionsForCurrentCondition represent all non position (custom) properties that should be animated.
 
index ba97aef..c45dc44 100755 (executable)
@@ -529,7 +529,7 @@ namespace Tizen.NUI
                                                          " left:" + _layoutPositionData.Left +
                                                          " top:" + _layoutPositionData.Top +
                                                          " right:" + _layoutPositionData.Right +
-                                                         " bottom:" + _layoutPositionData.Right );
+                                                         " bottom:" + _layoutPositionData.Bottom );
 
                 Window.Instance.LayoutController.AddTransitionDataEntry(_layoutPositionData);
 
index 8373923..3d3f64e 100755 (executable)
@@ -127,6 +127,7 @@ namespace Tizen.NUI.BaseComponents
             if (newValue != null)
             {
                 Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue((string)newValue));
+                view.BackgroundImageSynchronosLoading = view._backgroundImageSynchronosLoading;
             }
         },
         defaultValueCreator: (bindable) =>
@@ -1258,6 +1259,26 @@ namespace Tizen.NUI.BaseComponents
             Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.MARGIN).Get(temp);
             return temp;
         });
+
+        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty UpdateSizeHintProperty = BindableProperty.Create("UpdateSizeHint", typeof(Vector2), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var view = (View)bindable;
+            if (newValue != null)
+            {
+                Tizen.NUI.Object.SetProperty(view.swigCPtr, Interop.ViewProperty.View_Property_UPDATE_SIZE_HINT_get(), new Tizen.NUI.PropertyValue((Vector2)newValue));
+            }
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var view = (View)bindable;
+                       
+            Vector2 temp = new Vector2(0.0f, 0.0f);
+            Tizen.NUI.Object.GetProperty(view.swigCPtr, Interop.ViewProperty.View_Property_UPDATE_SIZE_HINT_get()).Get(temp);
+            return temp;
+        });
+
         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty XamlStyleProperty = BindableProperty.Create("XamlStyle", typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue);
@@ -3615,23 +3636,22 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                if (value != _backgroundImageSynchronosLoading)
+                _backgroundImageSynchronosLoading = value;
+                string bgUrl = "";
+                int visualType = 0;
+                Background.Find(Visual.Property.Type)?.Get(out visualType);
+                if (visualType == (int)Visual.Type.Image)
+                {
+                    Background.Find(ImageVisualProperty.URL)?.Get(out bgUrl);
+                }
+
+                if (bgUrl.Length != 0)
                 {
-                    string bgUrl = "";
                     PropertyMap bgMap = this.Background;
-                    int visualType = 0;
-                    bgMap.Find(Visual.Property.Type)?.Get(out visualType);
-                    if (visualType == (int)Visual.Type.Image)
-                    {
-                        bgMap.Find(ImageVisualProperty.URL)?.Get(out bgUrl);
-                    }
-                    if (bgUrl.Length != 0)
-                    {
-                        _backgroundImageSynchronosLoading = value;
-                        bgMap.Add("synchronousLoading", new PropertyValue(_backgroundImageSynchronosLoading));
-                        this.Background = bgMap;
-                    }
+                    bgMap.Add("synchronousLoading", new PropertyValue(_backgroundImageSynchronosLoading));
+                    Background = bgMap;
                 }
+
             }
         }
 
@@ -4053,7 +4073,6 @@ namespace Tizen.NUI.BaseComponents
         public override void Add(View child)
         {
             bool hasLayout = (_layout != null);
-            Log.Info("NUI", "Add:" + child.Name + " to View:" + Name + " which has layout[" + hasLayout + "] + \n");
 
             if (null == child)
             {
@@ -4100,7 +4119,6 @@ namespace Tizen.NUI.BaseComponents
                 return;
 
             bool hasLayout = (_layout != null);
-            Log.Info("NUI","Removing View:" + child.Name + " layout[" + hasLayout.ToString() +"]\n");
 
             // If View has a layout then do a deferred child removal
             // Actual child removal is performed by the layouting system so
@@ -4855,21 +4873,27 @@ namespace Tizen.NUI.BaseComponents
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal void RotateBy(Degree angle, Vector3 axis)
+        /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void RotateBy(Degree angle, Vector3 axis)
         {
             Interop.ActorInternal.Actor_RotateBy__SWIG_0(swigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal void RotateBy(Radian angle, Vector3 axis)
+        /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void RotateBy(Radian angle, Vector3 axis)
         {
             Interop.ActorInternal.Actor_RotateBy__SWIG_1(swigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal void RotateBy(Rotation relativeRotation)
+        /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void RotateBy(Rotation relativeRotation)
         {
             Interop.ActorInternal.Actor_RotateBy__SWIG_2(swigCPtr, Rotation.getCPtr(relativeRotation));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
@@ -5941,6 +5965,20 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Vector2 UpdateSizeHint
+        {
+            get
+            {
+                return (Vector2)GetValue(UpdateSizeHintProperty);
+            }
+            set
+            {
+                SetValue(UpdateSizeHintProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
 
         private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
 
index 88344e5..35dc6a2 100755 (executable)
@@ -234,7 +234,9 @@ namespace Tizen.NUI
             return ret;
         }
 
-        internal Degree GetAngle(uint point)
+        /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Degree GetAngle(uint point)
         {
             Degree ret = new Degree(Interop.Touch.Touch_GetAngle(swigCPtr, point), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();