Update YogaConfig
Summary: - Bugfix: Retain managed YogaConfig to prevent releasing unmanaged YogaConfig - Use the same YogaConfig in the copy constructor - Expose Set/GetUseWebDefaults APIs - Split YogaConfig out from YogaNode.cs Closes https://github.com/facebook/yoga/pull/496 Reviewed By: emilsjolander Differential Revision: D4796178 Pulled By: splhack fbshipit-source-id: cafabdc051ca914af547acbbf3d2246a5618e8bb
This commit is contained in:
committed by
Facebook Github Bot
parent
f66f52d1ba
commit
1520749351
67
csharp/Facebook.Yoga/YogaConfig.cs
Normal file
67
csharp/Facebook.Yoga/YogaConfig.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public bool UseWebDefaults
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGConfigGetUseWebDefaults(_ygConfig);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGConfigSetUseWebDefaults(_ygConfig, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float PointScaleFactor
|
||||
{
|
||||
set
|
||||
{
|
||||
Native.YGConfigSetPointScaleFactor(_ygConfig, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user