Summary: Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs. find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$ replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree. Reviewed By: TheSavior, yungsters Differential Revision: D7007050 fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
108 lines
2.5 KiB
C#
108 lines
2.5 KiB
C#
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Facebook.Yoga
|
|
{
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct YogaValue
|
|
{
|
|
private float value;
|
|
private YogaUnit unit;
|
|
|
|
public YogaUnit Unit
|
|
{
|
|
get
|
|
{
|
|
return unit;
|
|
}
|
|
}
|
|
|
|
public float Value
|
|
{
|
|
get
|
|
{
|
|
return value;
|
|
}
|
|
}
|
|
|
|
public static YogaValue Point(float value)
|
|
{
|
|
return new YogaValue
|
|
{
|
|
value = value,
|
|
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Point
|
|
};
|
|
}
|
|
|
|
public bool Equals(YogaValue other)
|
|
{
|
|
return Unit == other.Unit && (Value.Equals(other.Value) || Unit == YogaUnit.Undefined);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
return obj is YogaValue && Equals((YogaValue) obj);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
return (Value.GetHashCode() * 397) ^ (int) Unit;
|
|
}
|
|
}
|
|
|
|
public static YogaValue Undefined()
|
|
{
|
|
return new YogaValue
|
|
{
|
|
value = YogaConstants.Undefined,
|
|
unit = YogaUnit.Undefined
|
|
};
|
|
}
|
|
|
|
public static YogaValue Auto()
|
|
{
|
|
return new YogaValue
|
|
{
|
|
value = 0f,
|
|
unit = YogaUnit.Auto
|
|
};
|
|
}
|
|
|
|
public static YogaValue Percent(float value)
|
|
{
|
|
return new YogaValue
|
|
{
|
|
value = value,
|
|
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Percent
|
|
};
|
|
}
|
|
|
|
public static implicit operator YogaValue(float pointValue)
|
|
{
|
|
return Point(pointValue);
|
|
}
|
|
|
|
#if WINDOWS_UWP_ARM
|
|
internal static YogaValue MarshalValue(IntPtr ptr)
|
|
{
|
|
return Marshal.PtrToStructure<YogaValue>(ptr);
|
|
}
|
|
#else
|
|
internal static YogaValue MarshalValue(YogaValue value)
|
|
{
|
|
return value;
|
|
}
|
|
#endif
|
|
}
|
|
}
|