Fix Interops returning IntPtrs instead of floats
Fix measured child size when natural size zero.
Add Undefined constant map WrapContent to
Change-Id: Ie661294a155fb4cf971ddb96bba30472fb80168b
public static extern global::System.IntPtr FlexLayout_CalculateLayout( global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, float jarg3, bool jarg4);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetWidth")]
public static extern global::System.IntPtr FlexLayout_CalculateLayout( global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, float jarg3, bool jarg4);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetWidth")]
- public static extern global::System.IntPtr FlexLayout_GetWidth(global::System.Runtime.InteropServices.HandleRef jarg1);
+ public static extern float FlexLayout_GetWidth(global::System.Runtime.InteropServices.HandleRef jarg1);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetHeight")]
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetHeight")]
- public static extern global::System.IntPtr FlexLayout_GetHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
+ public static extern float FlexLayout_GetHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetNodeFrame")]
public static extern global::System.IntPtr FlexLayout_GetNodeFrame(global::System.Runtime.InteropServices.HandleRef jarg1, int index);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_FlexLayout_GetNodeFrame")]
public static extern global::System.IntPtr FlexLayout_GetNodeFrame(global::System.Runtime.InteropServices.HandleRef jarg1, int index);
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
using System.Runtime.InteropServices;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
using System.Runtime.InteropServices;
+using System.Diagnostics;
/// </summary>
public class FlexLayout : LayoutGroup, global::System.IDisposable
{
/// </summary>
public class FlexLayout : LayoutGroup, global::System.IDisposable
{
+ private static bool LayoutDebugFlex = false; // Debug flag
float Flex{ get; set;}
int AlignSelf{get; set;}
float Flex{ get; set;}
int AlignSelf{get; set;}
private IntPtr _rootFlex; // Pointer to the unmanged flex layout class.
private IntPtr _rootFlex; // Pointer to the unmanged flex layout class.
+ internal const float FlexUndefined = 10E20F; // Auto setting which is equivalent to WrapContent.
+
internal struct MeasuredSize
{
public MeasuredSize(float x, float y)
internal struct MeasuredSize
{
public MeasuredSize(float x, float y)
Size2D viewSize = new Size2D(8,8);
if(view)
{
Size2D viewSize = new Size2D(8,8);
if(view)
{
- viewSize = view.NaturalSize2D;
+ viewSize = view.Size2D;
+ }
+
+ // If size not set on child then use NaturalSize
+ if(viewSize.Width ==0 && viewSize.Height==0)
+ {
+ viewSize = view.NaturalSize2D;
+
+ Debug.WriteLineIf( LayoutDebugFlex, "FlexLayout measureChild View:" + view.Name
+ + "Size:" + viewSize.Width
+ + ","
+ + viewSize.Height);
+
return new MeasuredSize(viewSize.Width,viewSize.Height);
}
return new MeasuredSize(viewSize.Width,viewSize.Height);
}
Interop.FlexLayout.FlexLayout_SetMargin(swigCPtr, Extents.getCPtr(margin));
Interop.FlexLayout.FlexLayout_SetPadding(swigCPtr, Extents.getCPtr(padding));
Interop.FlexLayout.FlexLayout_SetMargin(swigCPtr, Extents.getCPtr(margin));
Interop.FlexLayout.FlexLayout_SetPadding(swigCPtr, Extents.getCPtr(padding));
- float width = 0.0f;
- float height = 0.0f;
+ float width = FlexUndefined; // Behaves as WrapContent (Flex Auto)
+ float height = FlexUndefined; // Behaves as WrapContent (Flex Auto)
if( widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly || widthMeasureSpec.Mode == MeasureSpecification.ModeType.AtMost )
{
if( widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly || widthMeasureSpec.Mode == MeasureSpecification.ModeType.AtMost )
{
Interop.FlexLayout.FlexLayout_CalculateLayout( swigCPtr, width, height, isLayoutRtl );
Interop.FlexLayout.FlexLayout_CalculateLayout( swigCPtr, width, height, isLayoutRtl );
- SetMeasuredDimensions( GetDefaultSize( new LayoutLength( (float)Interop.FlexLayout.FlexLayout_GetWidth(swigCPtr) ), widthMeasureSpec ),
- GetDefaultSize( new LayoutLength( (float)Interop.FlexLayout.FlexLayout_GetHeight(swigCPtr) ), heightMeasureSpec ) );
+ LayoutLength flexLayoutWidth = new LayoutLength( Interop.FlexLayout.FlexLayout_GetWidth(swigCPtr) );
+ LayoutLength flexLayoutHeight = new LayoutLength( Interop.FlexLayout.FlexLayout_GetHeight(swigCPtr) );
+
+ Debug.WriteLineIf( LayoutDebugFlex, "FlexLayout OnMeasure width:" + flexLayoutWidth.AsRoundedValue()
+ + " height:" + flexLayoutHeight.AsRoundedValue() );
+
+ SetMeasuredDimensions( GetDefaultSize(flexLayoutWidth, widthMeasureSpec ),
+ GetDefaultSize(flexLayoutHeight, heightMeasureSpec ) );