[NUI] Sync master branch (#1149)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Fri, 29 Nov 2019 02:24:41 +0000 (11:24 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 29 Nov 2019 02:24:41 +0000 (11:24 +0900)
* [NUI] Padding bug in LayoutGroup fixed (#1136)

LayoutGroup measuring child without using the parent's padding.
Resulted in LinearLayout not reducing the childs size when padding applied to parent

* [NUI] Prevent Height and Width specs being overwritten (#1142)

When setting the WidthSpecification or HeightSpecification with an exact value
the Size.Width or Size.Height is set but this in turns triggers a callback which
sets Size(width,height) but uses the stored height or width value which may not be
the set Width or Height Specification hence sets them to 0;

Change-Id: I80a4e1166f35e4c09c116916262ac965de54b048

* [NUI] Workaround: fix CustomAlgorithmInterface crash error occurred only in emulator, will be removed later after a proper solution is found (#1144)

- fix CSharp_Dali_GetOriginalImageSize spelling error- fix CSharp_Dali_GetOriginalImageSize spelling error
- add "GetOriginalImageSizeTest.cs" as sample APP.

* [NUI] Publish LottieAnimationView : TCSACR-293 (#1129)

* Revert "[NUI] Publish LottieAnimationView : TCSACR-293 (#1129)"

This reverts commit 3860d0bc8135ba980c3cc63da61ff670e281eb00.

src/Tizen.NUI/src/internal/CustomAlgorithmInterface.cs
src/Tizen.NUI/src/internal/Interop/Interop.ImageLoading.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs
test/NUITestSample/NUITestSample/examples/GetOriginalImageSizeTest.cs [new file with mode: 0755]

index a9c8e49..88488f8 100755 (executable)
@@ -89,10 +89,23 @@ namespace Tizen.NUI
 
         private global::System.IntPtr SwigDirectorGetNextFocusableView(global::System.IntPtr current, global::System.IntPtr proposed, int direction)
         {
-            View currentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
-            View proposedView = Registry.GetManagedBaseHandleFromNativePtr(proposed) as View;
+            if (current == global::System.IntPtr.Zero && proposed == global::System.IntPtr.Zero)
+            {
+                return global::System.IntPtr.Zero;
+            }
+
+            try
+            {
+                View currentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
+                View proposedView = Registry.GetManagedBaseHandleFromNativePtr(proposed) as View;
 
-            return View.getCPtr(GetNextFocusableView(currentView, proposedView, (View.FocusDirection)direction)).Handle;
+                return View.getCPtr(GetNextFocusableView(currentView, proposedView, (View.FocusDirection)direction)).Handle;
+            }
+            catch (global::System.Exception ex)
+            {
+              Tizen.Log.Error("NUI","Registry Error: "+ ex);
+            }
+            return global::System.IntPtr.Zero;
         }
 
         internal delegate global::System.IntPtr SwigDelegateCustomAlgorithmInterface_0(global::System.IntPtr current, global::System.IntPtr proposed, int direction);
index 2428c65..f599a37 100755 (executable)
@@ -38,7 +38,7 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetClosestImageSize__SWIG_4")]
             public static extern global::System.IntPtr GetClosestImageSize__SWIG_4(string jarg1);
 
-            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetOriginalImageSPize")]
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetOriginalImageSize")]
             public static extern global::System.IntPtr GetOriginalImageSize(string jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DownloadImageSynchronously__SWIG_0")]
index eaf413c..e1d2823 100755 (executable)
@@ -1777,8 +1777,18 @@ namespace Tizen.NUI.BaseComponents
                 if (_widthPolicy >= 0)
                 {
                     _measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-                    Size2D.Width = _widthPolicy;
 
+                    if(_heightPolicy>=0) // Policy an exact value
+                    {
+                        Size2D.Width = _widthPolicy;
+                    }
+                    else
+                    {
+                        // Store _heightPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
+                        // Size2D height will store the specification value (negative number) this will then be applied to the
+                        // HeightSpecification when the Size2D callback is invoked.
+                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                    }
                 }
                 _layout?.RequestLayout();
             }
@@ -1800,7 +1810,18 @@ namespace Tizen.NUI.BaseComponents
                 if (_heightPolicy >= 0)
                 {
                     _measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-                    Size2D.Height = _heightPolicy;
+
+                    if(_widthPolicy>=0) // Policy an exact value
+                    {
+                        Size2D.Height = _heightPolicy;
+                    }
+                    else
+                    {
+                        // Store widthPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
+                        // Size2D height will store the specification value (negative number) this will then be applied to the
+                        // HeightSpecification when the Size2D callback is invoked.
+                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                    }
 
                 }
                _layout?.RequestLayout();
index c661768..070231d 100755 (executable)
@@ -461,7 +461,7 @@ namespace Tizen.NUI
         {
             View childOwner = child.Owner;
 
-            Extents padding = child.Padding; // Padding of this layout's owner, not of the child being measured.
+            Extents padding = Padding; // Padding of this layout's owner, not of the child being measured.
 
             MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification( parentWidthMeasureSpec,
                                                                                        new LayoutLength(padding.Start + padding.End ),
diff --git a/test/NUITestSample/NUITestSample/examples/GetOriginalImageSizeTest.cs b/test/NUITestSample/NUITestSample/examples/GetOriginalImageSizeTest.cs
new file mode 100755 (executable)
index 0000000..058b84d
--- /dev/null
@@ -0,0 +1,60 @@
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using mypath = Tizen.Applications.Application.Current;
+
+namespace mytest
+{
+    public class myTestApp : NUIApplication
+    {
+        public myTestApp() : base()
+        {
+        }
+        public myTestApp(string styleSheet) : base(styleSheet)
+        {
+        }
+
+        Window win;
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+            win = Window.Instance;
+            win.BackgroundColor = Color.Cyan;
+            View v1 = new View();
+            v1.Size2D = new Size2D(100, 100);
+            v1.BackgroundColor = Color.Blue;
+            win.GetDefaultLayer().Add(v1);
+
+            ImageView iv = new ImageView();
+            iv.ResourceUrl = mypath.DirectoryInfo.Resource + @"/images/Dali/DaliDemo/Logo-for-demo.png";
+            iv.Position2D = new Position2D(50, 200);
+            win.GetDefaultLayer().Add(iv);
+
+            Size2D imageSize = ImageLoading.GetOriginalImageSize(iv.ResourceUrl);
+            TextLabel tl = new TextLabel();
+            tl.Position2D = new Position2D(iv.Position2D.X, iv.Position2D.Y + imageSize.Height);
+            tl.MultiLine = true;
+            tl.Text = $"ResourceUrl: {iv.ResourceUrl} \nOriginalImageSize: W({imageSize.Width}), H({imageSize.Height})";
+            win.GetDefaultLayer().Add(tl);
+
+            //==================
+            iv = new ImageView();
+            iv.ResourceUrl = mypath.DirectoryInfo.Resource + @"/images/Dali/DaliDemo/demo-tile-texture.9.png";
+            iv.Position2D = new Position2D(50, 600);
+            win.GetDefaultLayer().Add(iv);
+
+            imageSize = ImageLoading.GetOriginalImageSize(iv.ResourceUrl);
+            tl = new TextLabel();
+            tl.Position2D = new Position2D(iv.Position2D.X, iv.Position2D.Y + imageSize.Height);
+            tl.MultiLine = true;
+            tl.Text = $"ResourceUrl: {iv.ResourceUrl} \nOriginalImageSize: W({imageSize.Width}), H({imageSize.Height})";
+            win.GetDefaultLayer().Add(tl);
+        }
+
+        //[STAThread]
+        //static void Main(string[] args)
+        //{
+        //    new myTestApp().Run(args);
+        //}
+    }
+}