[NUI] ResizePolicy UseNaturalSize mapped to WrapContent (#613)
authorSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Fri, 14 Dec 2018 05:58:46 +0000 (14:58 +0900)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Fri, 14 Dec 2018 05:58:46 +0000 (14:58 +0900)
* Revert "[NUI] RootLayout resizes when Window size changes (#607)"

This reverts commit ba1de14b8e93135435897c31ebec91bbc6701879.
- There's a crash issue on this patch, so reverted it.

* [NUI] ResizePolicy UseNaturalSize mapped to WrapContent

Change-Id: I3fff98ea8672a3e7e0cba525f4f3fdf2a7b0be6a

* [NUI] Fix codacy error

- Clean-up code to fix issues detected by codacy.

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Window.cs

index 969972e..79c45d7 100755 (executable)
@@ -5105,7 +5105,7 @@ namespace Tizen.NUI.BaseComponents
                 {
                   case ResizePolicyType.UseNaturalSize :
                   {
-                    SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( NaturalSize.Width) );
+                    SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) );
                     break;
                   }
                   case ResizePolicyType.FillToParent :
@@ -5144,7 +5144,7 @@ namespace Tizen.NUI.BaseComponents
                 {
                   case ResizePolicyType.UseNaturalSize :
                   {
-                    SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( NaturalSize.Height) );
+                    SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) );
                     break;
                   }
                   case ResizePolicyType.FillToParent :
index ff80a3f..527c9ec 100755 (executable)
@@ -31,12 +31,10 @@ namespace Tizen.NUI
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
         private global::System.Runtime.InteropServices.HandleRef stageCPtr;
-
+        private readonly global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
         private Layer _rootLayer;
         private string _windowTitle;
 
-        private View rootLayout;
-
         private List<Layer> _childLayers = new List<Layer>();
         internal List<Layer> LayersChildren
         {
@@ -51,22 +49,17 @@ namespace Tizen.NUI
             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
             if (NDalicPINVOKE.Stage_IsInstalled())
             {
+                global::System.IntPtr rootLayoutIntPtr;
                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
-                // Create a root layout (AbsoluteLayout) that is "invisible" to the user but enables layouts added to the Window
+                // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to the Window
                 // Enables layouts added to the Window to have a parent layout.  As parent layout is needed to store measure spec properties.
                 // Currently without these measure specs the new layout added will always be the size of the window.
-
-                rootLayout = new View();
-                rootLayout.Name = "window_root_layout";
-                rootLayout.ParentOrigin = ParentOrigin.Center;
-                rootLayout.PivotPoint = PivotPoint.Center;
-                rootLayout.PositionUsesPivotPoint = true;
-                var layout = new AbsoluteLayout();
-                rootLayout.Layout = layout;
-
+                rootLayoutIntPtr = NDalicManualPINVOKE.Window_NewRootLayout();
+                // Store HandleRef used by Add()
+                rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
                 Layer rootLayer = GetRootLayer();
                 // Add the root layout created above to the root layer.
-                NDalicPINVOKE.Actor_Add(  Layer.getCPtr(rootLayer), View.getCPtr(rootLayout) );
+                NDalicPINVOKE.Actor_Add(  Layer.getCPtr(rootLayer), rootLayoutCPtr );
             }
         }
 
@@ -631,7 +624,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Add(View view)
         {
-            NDalicPINVOKE.Actor_Add( View.getCPtr(rootLayout), View.getCPtr(view) );
+            NDalicPINVOKE.Actor_Add( rootLayoutCPtr, View.getCPtr(view) );
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
             view.InternalParent = this.GetRootLayer();
@@ -644,7 +637,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public void Remove(View view)
         {
-            NDalicPINVOKE.Actor_Remove( View.getCPtr(rootLayout), View.getCPtr(view) );
+            NDalicPINVOKE.Actor_Remove( rootLayoutCPtr, View.getCPtr(view) );
             this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
             view.InternalParent = null;
         }
@@ -1471,7 +1464,6 @@ namespace Tizen.NUI
         internal void SetWindowSize(Size2D size)
         {
             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
-            rootLayout.Layout.RequestLayout();
             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
 
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
@@ -1505,7 +1497,6 @@ namespace Tizen.NUI
 
         internal void SetPositionSize(Rectangle positionSize)
         {
-            rootLayout.Layout.RequestLayout();
             NDalicPINVOKE.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }