[NUI] Add API for changing layout sibling order (#1478)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Thu, 19 Mar 2020 05:20:01 +0000 (14:20 +0900)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2020 05:20:01 +0000 (14:20 +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 a4b51ee58ddd9c3074b76b623168993030c5c499..5342bf960516607252e34350a51f5e2e10f9aa3a 100755 (executable)
@@ -881,6 +881,10 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SiblingOrderProperty, value);
+
+                LayoutGroup layout = Layout as LayoutGroup;
+                layout?.ChangeLayoutSiblingOrder(value);
+
                 NotifyPropertyChanged();
             }
         }
index 5e86a2b2950ded1dc2bddcbbc7b95a74d9ee2072..f384b327ad13dfa5322533da6e5851d8bc3d56ea 100755 (executable)
@@ -312,6 +312,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();
@@ -336,6 +339,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 45cd082e92374a83e2d375e5a961064815331df3..1e53bb666efd2c910174e5e2c4ce653f62b4eefb 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)
         {