[NUI] Fix Window.Add and Remove to use Layer.Add and Remove directly
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 29 Apr 2022 01:10:57 +0000 (10:10 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 3 May 2022 09:00:21 +0000 (02:00 -0700)
Previously, Window.Add and Remove did not use Layer.Add and Remove.
This caused LayoutCount was updated duplicately.
e.g.
- Calling window.Remove(view) twice decreases LayoutCount duplicately.
Moreover, users could not get ChildAdded and ChildRemoved events from
Window's RootLayer.

Now, Window.Add and Remove use Layer.Add and Remove directly.

src/Tizen.NUI/src/public/Window/Window.cs

index 86f380a..5e71d7d 100644 (file)
@@ -937,15 +937,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Add(View view)
         {
-            Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
-            if (null != view)
-            {
-                view.InternalParent = this.GetRootLayer();
-
-                this.GetRootLayer().LayoutCount += view.LayoutCount;
-            }
+            this.GetRootLayer().Add(view);
         }
 
         /// <summary>
@@ -955,14 +947,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Remove(View view)
         {
-            Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
-            this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
-            if (null != view)
-            {
-                view.InternalParent = null;
-
-                this.GetRootLayer().LayoutCount -= view.LayoutCount;
-            }
+            this.GetRootLayer().Remove(view);
         }
 
         /// <summary>