[NUI] Add API for changing layout sibling order (#1477)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Thu, 19 Mar 2020 05:19:33 +0000 (14:19 +0900)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2020 05:19:33 +0000 (14:19 +0900)
When changing sibling order of view, layout sibling order should be changed
to apply new position of order changed view.

Add API for changing layout sibling order and call it when changing view sibling order.

src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs

index a4b51ee..5342bf9 100755 (executable)
@@ -881,6 +881,10 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SiblingOrderProperty, value);
+
+                LayoutGroup layout = Layout as LayoutGroup;
+                layout?.ChangeLayoutSiblingOrder(value);
+
                 NotifyPropertyChanged();
             }
         }
index 495d4ea..fa65dbc 100755 (executable)
@@ -313,6 +313,9 @@ namespace Tizen.NUI.BaseComponents
                 parentChildren.Remove(this);
                 parentChildren.Add(this);
 
+                LayoutGroup layout = Layout as LayoutGroup;
+                layout?.ChangeLayoutSiblingOrder(parentChildren.Count-1);
+
                 Interop.NDalic.RaiseToTop(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending)
                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
@@ -337,6 +340,9 @@ namespace Tizen.NUI.BaseComponents
                 parentChildren.Remove(this);
                 parentChildren.Insert(0, this);
 
+                LayoutGroup layout = Layout as LayoutGroup;
+                layout?.ChangeLayoutSiblingOrder(0);
+
                 Interop.NDalic.LowerToBottom(swigCPtr);
                 if (NDalicPINVOKE.SWIGPendingException.Pending)
                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
index 45cd082..1e53bb6 100755 (executable)
@@ -126,6 +126,30 @@ namespace Tizen.NUI
             RequestLayout();
         }
 
+
+        /// <summary>
+        /// Sets the sibling order of the layout item so the layout can be defined within the same parent.
+        /// </summary>
+        /// <param name="order">the sibling order of the layout item</param>
+        /// <since_tizen> 6 </since_tizen>
+        /// 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 ChangeLayoutSiblingOrder(int order)
+        {
+            if(Owner != null && Owner.Parent != null)
+            {
+                LayoutGroup parent = Owner.Parent.Layout as LayoutGroup;
+
+                if(parent != null && parent.LayoutChildren.Count>order)
+                {
+                    parent.LayoutChildren.Remove(this);
+                    parent.LayoutChildren.Insert(order,this);
+                }
+            }
+
+            RequestLayout();
+        }
+
         // Attaches to View ChildAdded signal so called when a View is added to a view.
         private void AddChildToLayoutGroup(View child)
         {