2016-09-22 16:22:34 -07:00
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2016-10-19 11:01:24 -07:00
|
|
|
|
using System.Text;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
2017-02-16 11:07:51 -08:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
#endif
|
|
|
|
|
#if __IOS__
|
|
|
|
|
using ObjCRuntime;
|
|
|
|
|
#endif
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if ENABLE_IL2CPP
|
|
|
|
|
using AOT;
|
|
|
|
|
#endif
|
2017-02-16 11:07:51 -08:00
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
namespace Facebook.Yoga
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2017-03-01 09:19:55 -08:00
|
|
|
|
public class YogaConfig
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private Native.YGConfigHandle _ygConfig;
|
|
|
|
|
|
|
|
|
|
public YogaConfig()
|
|
|
|
|
{
|
|
|
|
|
_ygConfig = Native.YGConfigNew();
|
|
|
|
|
if (_ygConfig.IsInvalid)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Failed to allocate native memory");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal Native.YGConfigHandle Handle {
|
|
|
|
|
get {
|
|
|
|
|
return _ygConfig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetExperimentalFeatureEnabled(
|
|
|
|
|
YogaExperimentalFeature feature,
|
|
|
|
|
bool enabled)
|
|
|
|
|
{
|
|
|
|
|
Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
|
|
|
|
|
{
|
|
|
|
|
return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public partial class YogaNode : IEnumerable<YogaNode>
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-12-23 08:29:31 -08:00
|
|
|
|
private Native.YGNodeHandle _ygNode;
|
2016-10-07 11:07:51 -07:00
|
|
|
|
private WeakReference _parent;
|
2016-12-02 11:18:16 -08:00
|
|
|
|
private List<YogaNode> _children;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
private MeasureFunction _measureFunction;
|
2017-01-07 09:06:06 -08:00
|
|
|
|
private BaselineFunction _baselineFunction;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
private object _data;
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
2017-03-09 07:52:22 -08:00
|
|
|
|
private static YogaMeasureFunc _managedMeasure;
|
|
|
|
|
private static YogaBaselineFunc _managedBaseline;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
#else
|
|
|
|
|
private YogaMeasureFunc _managedMeasure;
|
|
|
|
|
private YogaBaselineFunc _managedBaseline;
|
|
|
|
|
#endif
|
2016-09-22 16:22:34 -07:00
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public YogaNode()
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
YogaLogger.Initialize();
|
2016-10-06 06:04:56 -07:00
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
|
_ygNode = Native.YGNodeNew();
|
2016-12-23 08:29:31 -08:00
|
|
|
|
if (_ygNode.IsInvalid)
|
2016-10-06 06:04:56 -07:00
|
|
|
|
{
|
2016-10-24 10:35:41 -07:00
|
|
|
|
throw new InvalidOperationException("Failed to allocate native memory");
|
2016-10-06 06:04:56 -07:00
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
|
public YogaNode(YogaConfig config)
|
|
|
|
|
{
|
|
|
|
|
YogaLogger.Initialize();
|
|
|
|
|
|
|
|
|
|
_ygNode = Native.YGNodeNewWithConfig(config.Handle);
|
|
|
|
|
if (_ygNode.IsInvalid)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Failed to allocate native memory");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-09 11:09:47 -08:00
|
|
|
|
public YogaNode(YogaNode srcNode)
|
|
|
|
|
: this()
|
|
|
|
|
{
|
|
|
|
|
CopyStyle(srcNode);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 10:35:41 -07:00
|
|
|
|
public void Reset()
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-10-26 07:24:44 -07:00
|
|
|
|
_measureFunction = null;
|
2017-01-07 09:06:06 -08:00
|
|
|
|
_baselineFunction = null;
|
2016-10-26 07:24:44 -07:00
|
|
|
|
_data = null;
|
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeReset(_ygNode);
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
|
|
|
|
_ygNode.ReleaseManaged();
|
|
|
|
|
#endif
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsDirty
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeIsDirty(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void MarkDirty()
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeMarkDirty(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasNewLayout
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeGetHasNewLayout(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MarkHasNewLayout()
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeSetHasNewLayout(_ygNode, true);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public YogaNode Parent
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
return _parent != null ? _parent.Target as YogaNode : null;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsMeasureDefined
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _measureFunction != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-07 09:06:06 -08:00
|
|
|
|
public bool IsBaselineDefined
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _baselineFunction != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public void CopyStyle(YogaNode srcNode)
|
2016-11-17 09:10:47 -08:00
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode);
|
2016-11-17 09:10:47 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaDirection StyleDirection
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetDirection(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
2016-10-26 06:51:39 -07:00
|
|
|
|
|
2016-09-22 16:22:34 -07:00
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetDirection(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaFlexDirection FlexDirection
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetFlexDirection(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetFlexDirection(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaJustify JustifyContent
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetJustifyContent(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetJustifyContent(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-06 09:31:22 -08:00
|
|
|
|
public YogaDisplay Display
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Native.YGNodeStyleGetDisplay(_ygNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetDisplay(_ygNode, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaAlign AlignItems
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetAlignItems(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetAlignItems(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaAlign AlignSelf
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetAlignSelf(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetAlignSelf(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaAlign AlignContent
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetAlignContent(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetAlignContent(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaPositionType PositionType
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetPositionType(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetPositionType(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaWrap Wrap
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetFlexWrap(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetFlexWrap(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Flex
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetFlex(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float FlexGrow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetFlexGrow(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetFlexGrow(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float FlexShrink
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetFlexShrink(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetFlexShrink(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue FlexBasis
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetFlexBasisPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
2017-02-14 14:26:09 -08:00
|
|
|
|
else if (value.Unit == YogaUnit.Auto)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetFlexBasisAuto(_ygNode);
|
|
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetFlexBasis(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue Width
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetWidthPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
2017-02-14 14:26:09 -08:00
|
|
|
|
else if (value.Unit == YogaUnit.Auto)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetWidthAuto(_ygNode);
|
|
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetWidth(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue Height
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetHeightPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
2017-02-14 14:26:09 -08:00
|
|
|
|
else if (value.Unit == YogaUnit.Auto)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetHeightAuto(_ygNode);
|
|
|
|
|
}
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetHeight(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue MaxWidth
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMaxWidthPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMaxWidth(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue MaxHeight
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMaxHeightPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMaxHeight(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue MinWidth
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMinWidthPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMinWidth(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
public YogaValue MinHeight
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-03-06 11:29:52 -08:00
|
|
|
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
|
if (value.Unit == YogaUnit.Percent)
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMinHeightPercent(_ygNode, value.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Native.YGNodeStyleSetMinHeight(_ygNode, value.Value);
|
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public float StyleAspectRatio
|
2016-11-21 10:12:26 -08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetAspectRatio(_ygNode);
|
2016-11-21 10:12:26 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetAspectRatio(_ygNode, value);
|
2016-11-21 10:12:26 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-22 16:22:34 -07:00
|
|
|
|
public float LayoutX
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeLayoutGetLeft(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float LayoutY
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeLayoutGetTop(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float LayoutWidth
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeLayoutGetWidth(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float LayoutHeight
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeLayoutGetHeight(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaDirection LayoutDirection
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeLayoutGetDirection(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public YogaOverflow Overflow
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeStyleGetOverflow(_ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleSetOverflow(_ygNode, value);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Data
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_data = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public YogaNode this[int index]
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _children[index];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Count
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-10-26 06:51:39 -07:00
|
|
|
|
return _children != null ? _children.Count : 0;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MarkLayoutSeen()
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeSetHasNewLayout(_ygNode, false);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ValuesEqual(float f1, float f2)
|
|
|
|
|
{
|
|
|
|
|
if (float.IsNaN(f1) || float.IsNaN(f2))
|
|
|
|
|
{
|
|
|
|
|
return float.IsNaN(f1) && float.IsNaN(f2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.Abs(f2 - f1) < float.Epsilon;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public void Insert(int index, YogaNode node)
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-10-26 06:51:39 -07:00
|
|
|
|
if (_children == null)
|
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
_children = new List<YogaNode>(4);
|
2016-10-26 06:51:39 -07:00
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
_children.Insert(index, node);
|
2016-10-07 11:07:51 -07:00
|
|
|
|
node._parent = new WeakReference(this);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeInsertChild(_ygNode, node._ygNode, (uint)index);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveAt(int index)
|
|
|
|
|
{
|
|
|
|
|
var child = _children[index];
|
|
|
|
|
child._parent = null;
|
|
|
|
|
_children.RemoveAt(index);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-25 07:38:06 -07:00
|
|
|
|
public void Clear()
|
|
|
|
|
{
|
2016-10-26 06:51:39 -07:00
|
|
|
|
if (_children != null)
|
2016-10-25 07:38:06 -07:00
|
|
|
|
{
|
2016-10-26 06:51:39 -07:00
|
|
|
|
while (_children.Count > 0)
|
|
|
|
|
{
|
2017-02-16 11:07:51 -08:00
|
|
|
|
RemoveAt(_children.Count-1);
|
2016-10-26 06:51:39 -07:00
|
|
|
|
}
|
2016-10-25 07:38:06 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public int IndexOf(YogaNode node)
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-10-26 06:51:39 -07:00
|
|
|
|
return _children != null ? _children.IndexOf(node) : -1;
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMeasureFunction(MeasureFunction measureFunction)
|
|
|
|
|
{
|
|
|
|
|
_measureFunction = measureFunction;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
if (measureFunction != null)
|
|
|
|
|
{
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
|
|
|
|
_managedMeasure = MeasureInternalAOT;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
_ygNode.SetContext(this);
|
|
|
|
|
#else
|
|
|
|
|
_managedMeasure = MeasureInternal;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2017-03-09 07:52:22 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_managedMeasure = null;
|
|
|
|
|
}
|
2017-02-16 11:07:51 -08:00
|
|
|
|
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-07 09:06:06 -08:00
|
|
|
|
public void SetBaselineFunction(BaselineFunction baselineFunction)
|
|
|
|
|
{
|
|
|
|
|
_baselineFunction = baselineFunction;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
if (baselineFunction != null)
|
|
|
|
|
{
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
|
|
|
|
_managedBaseline = BaselineInternalAOT;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
_ygNode.SetContext(this);
|
|
|
|
|
#else
|
|
|
|
|
_managedBaseline = BaselineInternal;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2017-03-09 07:52:22 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_managedBaseline = null;
|
|
|
|
|
}
|
2017-02-16 11:07:51 -08:00
|
|
|
|
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
|
2017-01-07 09:06:06 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-27 04:34:52 -07:00
|
|
|
|
public void CalculateLayout()
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeCalculateLayout(
|
|
|
|
|
_ygNode,
|
2016-12-02 05:47:43 -08:00
|
|
|
|
YogaConstants.Undefined,
|
|
|
|
|
YogaConstants.Undefined,
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodeStyleGetDirection(_ygNode));
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
2017-02-16 11:07:51 -08:00
|
|
|
|
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
|
2017-03-27 07:57:54 -07:00
|
|
|
|
private static YogaSize MeasureInternalAOT(
|
2017-02-16 11:07:51 -08:00
|
|
|
|
IntPtr ygNodePtr,
|
|
|
|
|
float width,
|
|
|
|
|
YogaMeasureMode widthMode,
|
|
|
|
|
float height,
|
|
|
|
|
YogaMeasureMode heightMode)
|
|
|
|
|
{
|
|
|
|
|
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
|
|
|
|
|
return node.MeasureInternal(IntPtr.Zero, width, widthMode, height, heightMode);
|
|
|
|
|
}
|
2017-02-16 11:07:50 -08:00
|
|
|
|
#endif
|
2017-02-16 11:07:51 -08:00
|
|
|
|
|
|
|
|
|
private YogaSize MeasureInternal(
|
2016-10-27 10:52:11 -07:00
|
|
|
|
IntPtr node,
|
2016-09-22 16:22:34 -07:00
|
|
|
|
float width,
|
2016-12-02 05:47:43 -08:00
|
|
|
|
YogaMeasureMode widthMode,
|
2016-09-22 16:22:34 -07:00
|
|
|
|
float height,
|
2016-12-02 05:47:43 -08:00
|
|
|
|
YogaMeasureMode heightMode)
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2017-02-16 11:07:51 -08:00
|
|
|
|
if (_measureFunction == null)
|
2016-10-13 07:52:46 -07:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Measure function is not defined.");
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-16 11:07:51 -08:00
|
|
|
|
return _measureFunction(this, width, widthMode, height, heightMode);
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-27 07:57:54 -07:00
|
|
|
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
2017-02-16 11:07:51 -08:00
|
|
|
|
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
|
2017-03-27 07:57:54 -07:00
|
|
|
|
private static float BaselineInternalAOT(
|
2017-02-16 11:07:51 -08:00
|
|
|
|
IntPtr ygNodePtr,
|
|
|
|
|
float width,
|
|
|
|
|
float height)
|
2017-01-07 09:06:06 -08:00
|
|
|
|
{
|
2017-02-16 11:07:51 -08:00
|
|
|
|
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
|
|
|
|
|
return node.BaselineInternal(IntPtr.Zero, width, height);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-02-16 11:07:50 -08:00
|
|
|
|
|
2017-02-16 11:07:51 -08:00
|
|
|
|
private float BaselineInternal(IntPtr node, float width, float height)
|
|
|
|
|
{
|
|
|
|
|
if (_baselineFunction == null)
|
2017-01-07 09:06:06 -08:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Baseline function is not defined.");
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-16 11:07:51 -08:00
|
|
|
|
return _baselineFunction(this, width, height);
|
2017-01-07 09:06:06 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
|
public string Print(YogaPrintOptions options =
|
2017-02-16 11:07:51 -08:00
|
|
|
|
YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children)
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-10-19 11:01:24 -07:00
|
|
|
|
StringBuilder sb = new StringBuilder();
|
2016-12-02 11:18:16 -08:00
|
|
|
|
YogaLogger.Func orig = YogaLogger.Logger;
|
2017-02-16 11:07:51 -08:00
|
|
|
|
YogaLogger.Logger = (level, message) => {sb.Append(message);};
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Native.YGNodePrint(_ygNode, options);
|
2016-12-02 11:18:16 -08:00
|
|
|
|
YogaLogger.Logger = orig;
|
2016-10-19 11:01:24 -07:00
|
|
|
|
return sb.ToString();
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
|
public IEnumerator<YogaNode> GetEnumerator()
|
2016-09-22 16:22:34 -07:00
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
|
|
|
|
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
|
{
|
2016-12-02 11:18:16 -08:00
|
|
|
|
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
|
|
|
|
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
2016-10-07 11:07:50 -07:00
|
|
|
|
|
|
|
|
|
public static int GetInstanceCount()
|
|
|
|
|
{
|
2016-12-03 04:40:18 -08:00
|
|
|
|
return Native.YGNodeGetInstanceCount();
|
2016-10-07 11:07:50 -07:00
|
|
|
|
}
|
2016-09-22 16:22:34 -07:00
|
|
|
|
}
|
2016-10-07 11:07:48 -07:00
|
|
|
|
}
|