[NUI] Update MeasureCallback interface for latest Dali::Toolkit (#2043)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 23 Sep 2020 03:06:06 +0000 (12:06 +0900)
committerGitHub <noreply@github.com>
Wed, 23 Sep 2020 03:06:06 +0000 (12:06 +0900)
Making MeasureCallback return a struct is causing the .NET runtime on
Windows 10 messes up with argument values. We changed the signature of
MeasureCallback on Dali::Toolkit to make the return value be an out
parameter.

The detailed explanation of what's the problem can be found at [1].

Moreover, we declare MeasureCallback as Cdecl, as it is declared this
way in the C++ header file.

[1] https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-toolkit/+/242665/

Co-authored-by: Wander Lairson Costa <wander.lairson@gmail.com>
src/Tizen.NUI/src/public/Layouting/FlexLayout.cs

index 16604a4..73e1c12 100755 (executable)
@@ -94,8 +94,8 @@ namespace Tizen.NUI
                 width = x;
                 height = y;
             }
-            float width;
-            float height;
+            public float width;
+            public float height;
         };
 
         /// <summary>
@@ -223,8 +223,8 @@ namespace Tizen.NUI
         /// <since_tizen> 8 </since_tizen>
         public static void SetFlexGrow(View view, float value) => SetAttachedValue(view, FlexGrowProperty, value);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        internal delegate MeasuredSize ChildMeasureCallback(global::System.IntPtr child, float width, int measureModeWidth, float height, int measureModeHeight);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void ChildMeasureCallback( global::System.IntPtr child, float width, int measureModeWidth, float height, int measureModeHeight, out MeasuredSize measureSize );
 
         event ChildMeasureCallback measureChildDelegate; // Stores a delegate to the child measure callback. Used for all children of this FlexLayout.
 
@@ -526,7 +526,7 @@ namespace Tizen.NUI
             Absolute
         }
 
-        private MeasuredSize measureChild(global::System.IntPtr childPtr, float width, int measureModeWidth, float height, int measureModeHeight)
+        private void measureChild(global::System.IntPtr childPtr, float width, int measureModeWidth, float height, int measureModeHeight, out MeasuredSize measureSize)
         {
             // We need to measure child layout
             View child = Registry.GetManagedBaseHandleFromNativePtr(childPtr) as View;
@@ -549,7 +549,8 @@ namespace Tizen.NUI
 
             childLayout.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
 
-            return new MeasuredSize(childLayout.MeasuredWidth.Size.AsRoundedValue(), childLayout.MeasuredHeight.Size.AsRoundedValue());
+            measureSize.width = childLayout.MeasuredWidth.Size.AsRoundedValue();
+            measureSize.height = childLayout.MeasuredHeight.Size.AsRoundedValue();
         }
 
         void InsertChild(LayoutItem child)