[NUI] remove internal child properly when child view of FlexLayout is removed (#2522)
authorYeongJong Lee <cleanlyj@naver.com>
Thu, 21 Jan 2021 06:30:07 +0000 (15:30 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Tue, 26 Jan 2021 08:27:40 +0000 (17:27 +0900)
In `FlexLayout`, when we add new view, the existing view shrink.
but when removed they are in shrinked state. they should change back.

To fix this issue, this patch remove internal child(child of yoga
layout) when child view of `FlexLayout` is removed.

For now, `OnChildRemove` API will work correctly.

Thank you Aman Jeph for the report.

Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/internal/Layouting/Interop/Interop.FlexLayout.cs
src/Tizen.NUI/src/public/Layouting/FlexLayout.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs

index 3ce6e22..7d4252f 100755 (executable)
@@ -21,7 +21,7 @@ namespace Tizen.NUI
             public static extern global::System.IntPtr AddChildWithMargin(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, Tizen.NUI.FlexLayout.ChildMeasureCallback jarg4, int jarg5);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_RemoveChild")]
-            public static extern global::System.IntPtr RemoveChild(global::System.Runtime.InteropServices.HandleRef jarg1, LayoutItem jarg2);
+            public static extern global::System.IntPtr RemoveChild(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_CalculateLayout")]
             public static extern global::System.IntPtr CalculateLayout(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, float jarg3, bool jarg4);
index 941b3da..800f001 100755 (executable)
@@ -703,12 +703,17 @@ namespace Tizen.NUI
         /// Callback when child is removed from container.<br />
         /// </summary>
         /// <param name="child">The Layout child.</param>
+        /// <exception cref="ArgumentNullException"> Thrown when child is null. </exception>
         /// <since_tizen> 6 </since_tizen>
         protected override void OnChildRemove(LayoutItem child)
         {
+            if (null == child)
+            {
+                throw new ArgumentNullException(nameof(child));
+            }
             // When child View is removed from it's parent View (that is a Layout) then remove it from the layout too.
             // FlexLayout refers to the child as a View not LayoutItem.
-            Interop.FlexLayout.RemoveChild(swigCPtr, child);
+            Interop.FlexLayout.RemoveChild(swigCPtr, child.Owner.SwigCPtr);
         }
 
         /// <summary>
index fc19957..1ec6c48 100755 (executable)
@@ -141,7 +141,7 @@ namespace Tizen.NUI
                 // If child removed then set all siblings not being added to a ChangeOnRemove transition.
                 SetConditionsForAnimationOnLayoutGroup(TransitionCondition.ChangeOnRemove);
             }
-
+            OnChildRemove(layoutItem);
             RequestLayout();
         }