Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1451 X-link: https://github.com/facebook/react-native/pull/41327 The special meaning of `0.0` is now explained in the function header, and we aren't doing any sort of insensitive compare here, so the code after should be equivalent and a bit simpler. Reviewed By: yungsters Differential Revision: D51014264 fbshipit-source-id: 60f4a2df039f74089d5c7fabd4b7d8ac6234ba72
97 lines
2.6 KiB
C++
97 lines
2.6 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <yoga/Yoga.h>
|
|
#include <yoga/debug/AssertFatal.h>
|
|
#include <yoga/debug/Log.h>
|
|
|
|
using namespace facebook;
|
|
using namespace facebook::yoga;
|
|
|
|
YGConfigRef YGConfigNew(void) {
|
|
return new yoga::Config(getDefaultLogger());
|
|
}
|
|
|
|
void YGConfigFree(const YGConfigRef config) {
|
|
delete resolveRef(config);
|
|
}
|
|
|
|
YGConfigConstRef YGConfigGetDefault() {
|
|
return &yoga::Config::getDefault();
|
|
}
|
|
|
|
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
|
|
resolveRef(config)->setUseWebDefaults(enabled);
|
|
}
|
|
|
|
bool YGConfigGetUseWebDefaults(const YGConfigConstRef config) {
|
|
return resolveRef(config)->useWebDefaults();
|
|
}
|
|
|
|
void YGConfigSetPointScaleFactor(
|
|
const YGConfigRef config,
|
|
const float pixelsInPoint) {
|
|
yoga::assertFatalWithConfig(
|
|
resolveRef(config),
|
|
pixelsInPoint >= 0.0f,
|
|
"Scale factor should not be less than zero");
|
|
|
|
resolveRef(config)->setPointScaleFactor(pixelsInPoint);
|
|
}
|
|
|
|
float YGConfigGetPointScaleFactor(const YGConfigConstRef config) {
|
|
return resolveRef(config)->getPointScaleFactor();
|
|
}
|
|
|
|
void YGConfigSetErrata(YGConfigRef config, YGErrata errata) {
|
|
resolveRef(config)->setErrata(scopedEnum(errata));
|
|
}
|
|
|
|
YGErrata YGConfigGetErrata(YGConfigConstRef config) {
|
|
return unscopedEnum(resolveRef(config)->getErrata());
|
|
}
|
|
|
|
void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
|
|
if (logger != nullptr) {
|
|
resolveRef(config)->setLogger(logger);
|
|
} else {
|
|
resolveRef(config)->setLogger(getDefaultLogger());
|
|
}
|
|
}
|
|
|
|
void YGConfigSetContext(const YGConfigRef config, void* context) {
|
|
resolveRef(config)->setContext(context);
|
|
}
|
|
|
|
void* YGConfigGetContext(const YGConfigConstRef config) {
|
|
return resolveRef(config)->getContext();
|
|
}
|
|
|
|
void YGConfigSetExperimentalFeatureEnabled(
|
|
const YGConfigRef config,
|
|
const YGExperimentalFeature feature,
|
|
const bool enabled) {
|
|
resolveRef(config)->setExperimentalFeatureEnabled(
|
|
scopedEnum(feature), enabled);
|
|
}
|
|
|
|
bool YGConfigIsExperimentalFeatureEnabled(
|
|
const YGConfigConstRef config,
|
|
const YGExperimentalFeature feature) {
|
|
return resolveRef(config)->isExperimentalFeatureEnabled(scopedEnum(feature));
|
|
}
|
|
|
|
void YGConfigSetCloneNodeFunc(
|
|
const YGConfigRef config,
|
|
const YGCloneNodeFunc callback) {
|
|
resolveRef(config)->setCloneNodeCallback(callback);
|
|
}
|
|
|
|
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
|
|
resolveRef(config)->setShouldPrintTree(enabled);
|
|
}
|