Bump yoga to 1.18.0 and typescript to 3.7.2 (#181)
* Updates yoga to v1.18.0 * Testing the flex layout a bit
This commit is contained in:
parent
ae81e2aae5
commit
3c57b550df
15863
package-lock.json
generated
15863
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -47,7 +47,7 @@
|
||||
"prettier": "^1.18.2",
|
||||
"serve": "^11.1.0",
|
||||
"ts-jest": "^24.1.0",
|
||||
"typescript": "^3.6.3"
|
||||
"typescript": "^3.7.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <yoga/YGEnums.h>
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
#include "YGMacros.h"
|
||||
#include "YGValue.h"
|
||||
|
||||
static_assert(
|
||||
@ -39,7 +41,7 @@ namespace detail {
|
||||
// 0x40000000 0x7f7fffff
|
||||
// - Zero is supported, negative zero is not
|
||||
// - values outside of the representable range are clamped
|
||||
class CompactValue {
|
||||
class YOGA_EXPORT CompactValue {
|
||||
friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
|
||||
|
||||
public:
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "CompactValue.h"
|
||||
#include "YGNode.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGConfig.h"
|
||||
|
||||
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
struct YGConfig {
|
||||
struct YOGA_EXPORT YGConfig {
|
||||
using LogWithContextFn = int (*)(YGConfigRef config, YGNodeRef node,
|
||||
YGLogLevel level, void* context,
|
||||
const char* format, va_list args);
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGEnums.h"
|
||||
|
||||
const char* YGAlignToString(const YGAlign value) {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "YGMacros.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGLayout.h"
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Bitfield.h"
|
||||
#include "YGFloatOptional.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -20,6 +21,14 @@
|
||||
#define WIN_EXPORT
|
||||
#endif
|
||||
|
||||
#ifndef YOGA_EXPORT
|
||||
#ifdef _MSC_VER
|
||||
#define YOGA_EXPORT
|
||||
#else
|
||||
#define YOGA_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NS_ENUM
|
||||
// Cannot use NSInteger as NSInteger has a different size than int (which is the
|
||||
// default type of a enum). Therefor when linking the Yoga C library into obj-c
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGNode.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -178,7 +179,7 @@ void YGNode::setMeasureFunc(YGMeasureFunc measureFunc) {
|
||||
setMeasureFunc(m);
|
||||
}
|
||||
|
||||
void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
|
||||
YOGA_EXPORT void YGNode::setMeasureFunc(MeasureWithContextFn measureFunc) {
|
||||
flags_.at<measureUsesContext_>() = true;
|
||||
decltype(YGNode::measure_) m;
|
||||
m.withContext = measureFunc;
|
||||
@ -364,7 +365,7 @@ YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGNode::clearChildren() {
|
||||
YOGA_EXPORT void YGNode::clearChildren() {
|
||||
children_.clear();
|
||||
children_.shrink_to_fit();
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
|
||||
@ -19,7 +20,7 @@
|
||||
|
||||
YGConfigRef YGConfigGetDefault();
|
||||
|
||||
struct YGNode {
|
||||
struct YOGA_EXPORT YGNode {
|
||||
using MeasureWithContextFn = YGSize (*)(YGNode*, float, YGMeasureMode, float,
|
||||
YGMeasureMode, void*);
|
||||
using BaselineWithContextFn = float (*)(YGNode*, float, float, void*);
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "YGNodePrint.h"
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGStyle.h"
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@ -17,7 +18,7 @@
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
class YGStyle {
|
||||
class YOGA_EXPORT YGStyle {
|
||||
template <typename Enum>
|
||||
using Values =
|
||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
|
||||
@ -184,7 +185,7 @@ class YGStyle {
|
||||
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
|
||||
};
|
||||
|
||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
YOGA_EXPORT bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||
YOGA_EXPORT inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "YGValue.h"
|
||||
|
||||
const YGValue YGValueZero = {0, YGUnitPoint};
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
@ -26,9 +27,9 @@ typedef struct YGValue {
|
||||
YGUnit unit;
|
||||
} YGValue;
|
||||
|
||||
extern const YGValue YGValueAuto;
|
||||
extern const YGValue YGValueUndefined;
|
||||
extern const YGValue YGValueZero;
|
||||
YOGA_EXPORT extern const YGValue YGValueAuto;
|
||||
YOGA_EXPORT extern const YGValue YGValueUndefined;
|
||||
YOGA_EXPORT extern const YGValue YGValueZero;
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "Yoga.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
#include "Utils.h"
|
||||
@ -91,7 +93,7 @@ static int YGDefaultLog(const YGConfigRef config, const YGNodeRef node,
|
||||
#undef YG_UNUSED
|
||||
#endif
|
||||
|
||||
bool YGFloatIsUndefined(const float value) {
|
||||
YOGA_EXPORT bool YGFloatIsUndefined(const float value) {
|
||||
return facebook::yoga::isUndefined(value);
|
||||
}
|
||||
|
||||
@ -124,65 +126,79 @@ detail::CompactValue YGComputedEdgeValue(const YGStyle::Edges& edges,
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
void* YGNodeGetContext(YGNodeRef node) { return node->getContext(); }
|
||||
YOGA_EXPORT void* YGNodeGetContext(YGNodeRef node) {
|
||||
return node->getContext();
|
||||
}
|
||||
|
||||
void YGNodeSetContext(YGNodeRef node, void* context) {
|
||||
YOGA_EXPORT void YGNodeSetContext(YGNodeRef node, void* context) {
|
||||
return node->setContext(context);
|
||||
}
|
||||
|
||||
bool YGNodeHasMeasureFunc(YGNodeRef node) { return node->hasMeasureFunc(); }
|
||||
YOGA_EXPORT bool YGNodeHasMeasureFunc(YGNodeRef node) {
|
||||
return node->hasMeasureFunc();
|
||||
}
|
||||
|
||||
void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc) {
|
||||
YOGA_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node,
|
||||
YGMeasureFunc measureFunc) {
|
||||
node->setMeasureFunc(measureFunc);
|
||||
}
|
||||
|
||||
bool YGNodeHasBaselineFunc(YGNodeRef node) { return node->hasBaselineFunc(); }
|
||||
YOGA_EXPORT bool YGNodeHasBaselineFunc(YGNodeRef node) {
|
||||
return node->hasBaselineFunc();
|
||||
}
|
||||
|
||||
void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc) {
|
||||
YOGA_EXPORT void YGNodeSetBaselineFunc(YGNodeRef node,
|
||||
YGBaselineFunc baselineFunc) {
|
||||
node->setBaselineFunc(baselineFunc);
|
||||
}
|
||||
|
||||
YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node) {
|
||||
YOGA_EXPORT YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node) {
|
||||
return node->getDirtied();
|
||||
}
|
||||
|
||||
void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) {
|
||||
YOGA_EXPORT void YGNodeSetDirtiedFunc(YGNodeRef node,
|
||||
YGDirtiedFunc dirtiedFunc) {
|
||||
node->setDirtiedFunc(dirtiedFunc);
|
||||
}
|
||||
|
||||
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
|
||||
YOGA_EXPORT void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
|
||||
node->setPrintFunc(printFunc);
|
||||
}
|
||||
|
||||
bool YGNodeGetHasNewLayout(YGNodeRef node) { return node->getHasNewLayout(); }
|
||||
YOGA_EXPORT bool YGNodeGetHasNewLayout(YGNodeRef node) {
|
||||
return node->getHasNewLayout();
|
||||
}
|
||||
|
||||
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
|
||||
YOGA_EXPORT void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled) {
|
||||
config->printTree = enabled;
|
||||
}
|
||||
|
||||
void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
|
||||
YOGA_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout) {
|
||||
node->setHasNewLayout(hasNewLayout);
|
||||
}
|
||||
|
||||
YGNodeType YGNodeGetNodeType(YGNodeRef node) { return node->getNodeType(); }
|
||||
YOGA_EXPORT YGNodeType YGNodeGetNodeType(YGNodeRef node) {
|
||||
return node->getNodeType();
|
||||
}
|
||||
|
||||
void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
|
||||
YOGA_EXPORT void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType) {
|
||||
return node->setNodeType(nodeType);
|
||||
}
|
||||
|
||||
bool YGNodeIsDirty(YGNodeRef node) { return node->isDirty(); }
|
||||
YOGA_EXPORT bool YGNodeIsDirty(YGNodeRef node) { return node->isDirty(); }
|
||||
|
||||
bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) {
|
||||
YOGA_EXPORT bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) {
|
||||
return node->didUseLegacyFlag();
|
||||
}
|
||||
|
||||
void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(
|
||||
const YGNodeRef node) {
|
||||
return node->markDirtyAndPropogateDownwards();
|
||||
}
|
||||
|
||||
int32_t gConfigInstanceCount = 0;
|
||||
|
||||
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
||||
YOGA_EXPORT WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
||||
const YGNodeRef node = new YGNode{config};
|
||||
YGAssertWithConfig(config, node != nullptr,
|
||||
"Could not allocate memory for node");
|
||||
@ -191,14 +207,16 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
||||
return node;
|
||||
}
|
||||
|
||||
YGConfigRef YGConfigGetDefault() {
|
||||
YOGA_EXPORT YGConfigRef YGConfigGetDefault() {
|
||||
static YGConfigRef defaultConfig = YGConfigNew();
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
YGNodeRef YGNodeNew(void) { return YGNodeNewWithConfig(YGConfigGetDefault()); }
|
||||
YOGA_EXPORT YGNodeRef YGNodeNew(void) {
|
||||
return YGNodeNewWithConfig(YGConfigGetDefault());
|
||||
}
|
||||
|
||||
YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
||||
YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
||||
YGNodeRef node = new YGNode(*oldNode);
|
||||
YGAssertWithConfig(oldNode->getConfig(), node != nullptr,
|
||||
"Could not allocate memory for node");
|
||||
@ -236,7 +254,7 @@ static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) {
|
||||
return node;
|
||||
}
|
||||
|
||||
void YGNodeFree(const YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeFree(const YGNodeRef node) {
|
||||
if (YGNodeRef owner = node->getOwner()) {
|
||||
owner->removeChild(node);
|
||||
node->setOwner(nullptr);
|
||||
@ -264,8 +282,8 @@ static void YGConfigFreeRecursive(const YGNodeRef root) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeFreeRecursiveWithCleanupFunc(const YGNodeRef root,
|
||||
YGNodeCleanupFunc cleanup) {
|
||||
YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(const YGNodeRef root,
|
||||
YGNodeCleanupFunc cleanup) {
|
||||
uint32_t skipped = 0;
|
||||
while (YGNodeGetChildCount(root) > skipped) {
|
||||
const YGNodeRef child = YGNodeGetChild(root, skipped);
|
||||
@ -283,15 +301,15 @@ void YGNodeFreeRecursiveWithCleanupFunc(const YGNodeRef root,
|
||||
YGNodeFree(root);
|
||||
}
|
||||
|
||||
void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||
YOGA_EXPORT void YGNodeFreeRecursive(const YGNodeRef root) {
|
||||
return YGNodeFreeRecursiveWithCleanupFunc(root, nullptr);
|
||||
}
|
||||
|
||||
void YGNodeReset(YGNodeRef node) { node->reset(); }
|
||||
YOGA_EXPORT void YGNodeReset(YGNodeRef node) { node->reset(); }
|
||||
|
||||
int32_t YGConfigGetInstanceCount(void) { return gConfigInstanceCount; }
|
||||
|
||||
YGConfigRef YGConfigNew(void) {
|
||||
YOGA_EXPORT YGConfigRef YGConfigNew(void) {
|
||||
#ifdef ANDROID
|
||||
const YGConfigRef config = new YGConfig(YGAndroidLog);
|
||||
#else
|
||||
@ -301,7 +319,7 @@ YGConfigRef YGConfigNew(void) {
|
||||
return config;
|
||||
}
|
||||
|
||||
void YGConfigFree(const YGConfigRef config) {
|
||||
YOGA_EXPORT void YGConfigFree(const YGConfigRef config) {
|
||||
delete config;
|
||||
gConfigInstanceCount--;
|
||||
}
|
||||
@ -310,19 +328,20 @@ void YGConfigCopy(const YGConfigRef dest, const YGConfigRef src) {
|
||||
memcpy(dest, src, sizeof(YGConfig));
|
||||
}
|
||||
|
||||
void YGNodeSetIsReferenceBaseline(YGNodeRef node, bool isReferenceBaseline) {
|
||||
YOGA_EXPORT void YGNodeSetIsReferenceBaseline(YGNodeRef node,
|
||||
bool isReferenceBaseline) {
|
||||
if (node->isReferenceBaseline() != isReferenceBaseline) {
|
||||
node->setIsReferenceBaseline(isReferenceBaseline);
|
||||
node->markDirtyAndPropogate();
|
||||
}
|
||||
}
|
||||
|
||||
bool YGNodeIsReferenceBaseline(YGNodeRef node) {
|
||||
YOGA_EXPORT bool YGNodeIsReferenceBaseline(YGNodeRef node) {
|
||||
return node->isReferenceBaseline();
|
||||
}
|
||||
|
||||
void YGNodeInsertChild(const YGNodeRef owner, const YGNodeRef child,
|
||||
const uint32_t index) {
|
||||
YOGA_EXPORT void YGNodeInsertChild(const YGNodeRef owner, const YGNodeRef child,
|
||||
const uint32_t index) {
|
||||
YGAssertWithNode(owner, child->getOwner() == nullptr,
|
||||
"Child already has a owner, it must be removed first.");
|
||||
|
||||
@ -335,7 +354,8 @@ void YGNodeInsertChild(const YGNodeRef owner, const YGNodeRef child,
|
||||
owner->markDirtyAndPropogate();
|
||||
}
|
||||
|
||||
void YGNodeRemoveChild(const YGNodeRef owner, const YGNodeRef excludedChild) {
|
||||
YOGA_EXPORT void YGNodeRemoveChild(const YGNodeRef owner,
|
||||
const YGNodeRef excludedChild) {
|
||||
if (YGNodeGetChildCount(owner) == 0) {
|
||||
// This is an empty set. Nothing to remove.
|
||||
return;
|
||||
@ -354,7 +374,7 @@ void YGNodeRemoveChild(const YGNodeRef owner, const YGNodeRef excludedChild) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeRemoveAllChildren(const YGNodeRef owner) {
|
||||
YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef owner) {
|
||||
const uint32_t childCount = YGNodeGetChildCount(owner);
|
||||
if (childCount == 0) {
|
||||
// This is an empty set already. Nothing to do.
|
||||
@ -413,33 +433,38 @@ static void YGNodeSetChildrenInternal(YGNodeRef const owner,
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeSetChildren(const YGNodeRef owner, const YGNodeRef c[],
|
||||
const uint32_t count) {
|
||||
YOGA_EXPORT void YGNodeSetChildren(const YGNodeRef owner, const YGNodeRef c[],
|
||||
const uint32_t count) {
|
||||
const YGVector children = {c, c + count};
|
||||
YGNodeSetChildrenInternal(owner, children);
|
||||
}
|
||||
|
||||
void YGNodeSetChildren(YGNodeRef const owner,
|
||||
const std::vector<YGNodeRef>& children) {
|
||||
YOGA_EXPORT void YGNodeSetChildren(YGNodeRef const owner,
|
||||
const std::vector<YGNodeRef>& children) {
|
||||
YGNodeSetChildrenInternal(owner, children);
|
||||
}
|
||||
|
||||
YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index) {
|
||||
YOGA_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node,
|
||||
const uint32_t index) {
|
||||
if (index < node->getChildren().size()) {
|
||||
return node->getChild(index);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t YGNodeGetChildCount(const YGNodeRef node) {
|
||||
YOGA_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node) {
|
||||
return static_cast<uint32_t>(node->getChildren().size());
|
||||
}
|
||||
|
||||
YGNodeRef YGNodeGetOwner(const YGNodeRef node) { return node->getOwner(); }
|
||||
YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) {
|
||||
return node->getOwner();
|
||||
}
|
||||
|
||||
YGNodeRef YGNodeGetParent(const YGNodeRef node) { return node->getOwner(); }
|
||||
YOGA_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node) {
|
||||
return node->getOwner();
|
||||
}
|
||||
|
||||
void YGNodeMarkDirty(const YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeMarkDirty(const YGNodeRef node) {
|
||||
YGAssertWithNode(node, node->hasMeasureFunc(),
|
||||
"Only leaf nodes with custom measure functions"
|
||||
"should manually mark themselves as dirty");
|
||||
@ -447,20 +472,21 @@ void YGNodeMarkDirty(const YGNodeRef node) {
|
||||
node->markDirtyAndPropogate();
|
||||
}
|
||||
|
||||
void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
||||
YOGA_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode,
|
||||
const YGNodeRef srcNode) {
|
||||
if (!(dstNode->getStyle() == srcNode->getStyle())) {
|
||||
dstNode->setStyle(srcNode->getStyle());
|
||||
dstNode->markDirtyAndPropogate();
|
||||
}
|
||||
}
|
||||
|
||||
float YGNodeStyleGetFlexGrow(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT float YGNodeStyleGetFlexGrow(const YGNodeConstRef node) {
|
||||
return node->getStyle().flexGrow().isUndefined()
|
||||
? kDefaultFlexGrow
|
||||
: node->getStyle().flexGrow().unwrap();
|
||||
}
|
||||
|
||||
float YGNodeStyleGetFlexShrink(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT float YGNodeStyleGetFlexShrink(const YGNodeConstRef node) {
|
||||
return node->getStyle().flexShrink().isUndefined()
|
||||
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
||||
: kDefaultFlexShrink)
|
||||
@ -504,109 +530,119 @@ void updateIndexedStyleProp(YGNode* node, Ref (YGStyle::*prop)(), Idx idx,
|
||||
// decltype, MSVC will prefer the non-const version.
|
||||
#define MSVC_HINT(PROP) decltype(YGStyle{}.PROP())
|
||||
|
||||
void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) {
|
||||
YOGA_EXPORT void YGNodeStyleSetDirection(const YGNodeRef node,
|
||||
const YGDirection value) {
|
||||
updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value);
|
||||
}
|
||||
YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
|
||||
return node->getStyle().direction();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexDirection(const YGNodeRef node,
|
||||
const YGFlexDirection flexDirection) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexDirection(
|
||||
const YGNodeRef node, const YGFlexDirection flexDirection) {
|
||||
updateStyle<MSVC_HINT(flexDirection)>(node, &YGStyle::flexDirection,
|
||||
flexDirection);
|
||||
}
|
||||
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGFlexDirection
|
||||
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
|
||||
return node->getStyle().flexDirection();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetJustifyContent(const YGNodeRef node,
|
||||
const YGJustify justifyContent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetJustifyContent(const YGNodeRef node,
|
||||
const YGJustify justifyContent) {
|
||||
updateStyle<MSVC_HINT(justifyContent)>(node, &YGStyle::justifyContent,
|
||||
justifyContent);
|
||||
}
|
||||
YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
|
||||
return node->getStyle().justifyContent();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetAlignContent(const YGNodeRef node,
|
||||
const YGAlign alignContent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAlignContent(const YGNodeRef node,
|
||||
const YGAlign alignContent) {
|
||||
updateStyle<MSVC_HINT(alignContent)>(node, &YGStyle::alignContent,
|
||||
alignContent);
|
||||
}
|
||||
YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignContent();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAlignItems(const YGNodeRef node,
|
||||
const YGAlign alignItems) {
|
||||
updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems);
|
||||
}
|
||||
YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignItems();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAlignSelf(const YGNodeRef node,
|
||||
const YGAlign alignSelf) {
|
||||
updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf);
|
||||
}
|
||||
YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
|
||||
return node->getStyle().alignSelf();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetPositionType(const YGNodeRef node,
|
||||
const YGPositionType positionType) {
|
||||
YOGA_EXPORT void YGNodeStyleSetPositionType(const YGNodeRef node,
|
||||
const YGPositionType positionType) {
|
||||
updateStyle<MSVC_HINT(positionType)>(node, &YGStyle::positionType,
|
||||
positionType);
|
||||
}
|
||||
YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGPositionType
|
||||
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
||||
return node->getStyle().positionType();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexWrap(const YGNodeRef node,
|
||||
const YGWrap flexWrap) {
|
||||
updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap);
|
||||
}
|
||||
YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
||||
return node->getStyle().flexWrap();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
|
||||
YOGA_EXPORT void YGNodeStyleSetOverflow(const YGNodeRef node,
|
||||
const YGOverflow overflow) {
|
||||
updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow);
|
||||
}
|
||||
YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
|
||||
return node->getStyle().overflow();
|
||||
}
|
||||
|
||||
void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) {
|
||||
YOGA_EXPORT void YGNodeStyleSetDisplay(const YGNodeRef node,
|
||||
const YGDisplay display) {
|
||||
updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display);
|
||||
}
|
||||
YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
|
||||
return node->getStyle().display();
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||
updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex});
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
float YGNodeStyleGetFlex(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT float YGNodeStyleGetFlex(const YGNodeConstRef node) {
|
||||
return node->getStyle().flex().isUndefined()
|
||||
? YGUndefined
|
||||
: node->getStyle().flex().unwrap();
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexGrow(const YGNodeRef node,
|
||||
const float flexGrow) {
|
||||
updateStyle<MSVC_HINT(flexGrow)>(node, &YGStyle::flexGrow,
|
||||
YGFloatOptional{flexGrow});
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexShrink(const YGNodeRef node,
|
||||
const float flexShrink) {
|
||||
updateStyle<MSVC_HINT(flexShrink)>(node, &YGStyle::flexShrink,
|
||||
YGFloatOptional{flexShrink});
|
||||
}
|
||||
|
||||
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
YGValue flexBasis = node->getStyle().flexBasis();
|
||||
if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) {
|
||||
// TODO(T26792433): Get rid off the use of YGUndefined at client side
|
||||
@ -615,77 +651,85 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||
return flexBasis;
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasis(const YGNodeRef node,
|
||||
const float flexBasis) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisPercent(const YGNodeRef node,
|
||||
const float flexBasisPercent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasisPercent(const YGNodeRef node,
|
||||
const float flexBasisPercent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
|
||||
}
|
||||
|
||||
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
|
||||
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
|
||||
YOGA_EXPORT void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge,
|
||||
float points) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(position)>(node, &YGStyle::position, edge,
|
||||
value);
|
||||
}
|
||||
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge,
|
||||
float percent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(position)>(node, &YGStyle::position, edge,
|
||||
value);
|
||||
}
|
||||
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().position()[edge];
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge,
|
||||
float points) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &YGStyle::margin, edge,
|
||||
value);
|
||||
}
|
||||
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge,
|
||||
float percent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &YGStyle::margin, edge,
|
||||
value);
|
||||
}
|
||||
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
||||
updateIndexedStyleProp<MSVC_HINT(margin)>(node, &YGStyle::margin, edge,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().margin()[edge];
|
||||
}
|
||||
|
||||
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
|
||||
YOGA_EXPORT void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge,
|
||||
float points) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(padding)>(node, &YGStyle::padding, edge,
|
||||
value);
|
||||
}
|
||||
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge,
|
||||
float percent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(padding)>(node, &YGStyle::padding, edge,
|
||||
value);
|
||||
}
|
||||
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||
return node->getStyle().padding()[edge];
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetBorder(const YGNodeRef node, const YGEdge edge,
|
||||
const float border) {
|
||||
YOGA_EXPORT void YGNodeStyleSetBorder(const YGNodeRef node, const YGEdge edge,
|
||||
const float border) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(border);
|
||||
updateIndexedStyleProp<MSVC_HINT(border)>(node, &YGStyle::border, edge,
|
||||
value);
|
||||
}
|
||||
|
||||
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
||||
YOGA_EXPORT float YGNodeStyleGetBorder(const YGNodeConstRef node,
|
||||
const YGEdge edge) {
|
||||
auto border = node->getStyle().border()[edge];
|
||||
if (border.isUndefined() || border.isAuto()) {
|
||||
// TODO(T26792433): Rather than returning YGUndefined, change the api to
|
||||
@ -699,120 +743,128 @@ float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
|
||||
const YGFloatOptional op = node->getStyle().aspectRatio();
|
||||
return op.isUndefined() ? YGUndefined : op.unwrap();
|
||||
}
|
||||
|
||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
||||
YOGA_EXPORT void YGNodeStyleSetAspectRatio(const YGNodeRef node,
|
||||
const float aspectRatio) {
|
||||
updateStyle<MSVC_HINT(aspectRatio)>(node, &YGStyle::aspectRatio,
|
||||
YGFloatOptional{aspectRatio});
|
||||
}
|
||||
|
||||
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||
YOGA_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionWidth, value);
|
||||
}
|
||||
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionWidth, value);
|
||||
}
|
||||
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionWidth,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||
return node->getStyle().dimensions()[YGDimensionWidth];
|
||||
}
|
||||
|
||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||
YOGA_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionHeight, value);
|
||||
}
|
||||
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||
YOGA_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionHeight, value);
|
||||
}
|
||||
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||
YOGA_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||
updateIndexedStyleProp<MSVC_HINT(dimensions)>(node, &YGStyle::dimensions,
|
||||
YGDimensionHeight,
|
||||
detail::CompactValue::ofAuto());
|
||||
}
|
||||
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||
return node->getStyle().dimensions()[YGDimensionHeight];
|
||||
}
|
||||
|
||||
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinWidth(const YGNodeRef node,
|
||||
const float minWidth) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &YGStyle::minDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinWidthPercent(const YGNodeRef node,
|
||||
const float minWidth) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &YGStyle::minDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||
return node->getStyle().minDimensions()[YGDimensionWidth];
|
||||
};
|
||||
|
||||
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinHeight(const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &YGStyle::minDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
void YGNodeStyleSetMinHeightPercent(const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMinHeightPercent(const YGNodeRef node,
|
||||
const float minHeight) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
|
||||
node, &YGStyle::minDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||
return node->getStyle().minDimensions()[YGDimensionHeight];
|
||||
};
|
||||
|
||||
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxWidth(const YGNodeRef node,
|
||||
const float maxWidth) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node,
|
||||
const float maxWidth) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
|
||||
}
|
||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||
return node->getStyle().maxDimensions()[YGDimensionWidth];
|
||||
};
|
||||
|
||||
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxHeight(const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
void YGNodeStyleSetMaxHeightPercent(const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
YOGA_EXPORT void YGNodeStyleSetMaxHeightPercent(const YGNodeRef node,
|
||||
const float maxHeight) {
|
||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
|
||||
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
|
||||
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
|
||||
}
|
||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
YOGA_EXPORT YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||
return node->getStyle().maxDimensions()[YGDimensionHeight];
|
||||
};
|
||||
|
||||
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||
type YGNodeLayoutGet##name(const YGNodeRef node) { \
|
||||
return node->getLayout().instanceName; \
|
||||
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||
YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node) { \
|
||||
return node->getLayout().instanceName; \
|
||||
}
|
||||
|
||||
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
|
||||
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
|
||||
YOGA_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node, \
|
||||
const YGEdge edge) { \
|
||||
YGAssertWithNode(node, edge <= YGEdgeEnd, \
|
||||
"Cannot get layout properties of multi-edge shorthands"); \
|
||||
\
|
||||
@ -848,11 +900,12 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
|
||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
|
||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
|
||||
|
||||
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(const YGNodeRef node) {
|
||||
YOGA_EXPORT bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(
|
||||
const YGNodeRef node) {
|
||||
return node->getLayout().doesLegacyStretchFlagAffectsLayout();
|
||||
}
|
||||
|
||||
uint32_t gCurrentGenerationCount = 0;
|
||||
std::atomic<uint32_t> gCurrentGenerationCount(0);
|
||||
|
||||
bool YGLayoutNodeInternal(
|
||||
const YGNodeRef node, const float availableWidth,
|
||||
@ -871,7 +924,8 @@ static void YGNodePrintInternal(const YGNodeRef node,
|
||||
Log::log(node, YGLogLevelDebug, nullptr, str.c_str());
|
||||
}
|
||||
|
||||
void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) {
|
||||
YOGA_EXPORT void YGNodePrint(const YGNodeRef node,
|
||||
const YGPrintOptions options) {
|
||||
YGNodePrintInternal(node, options);
|
||||
}
|
||||
#endif
|
||||
@ -3156,9 +3210,11 @@ static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(
|
||||
(lastComputedSize <= size || YGFloatsEqual(size, lastComputedSize));
|
||||
}
|
||||
|
||||
float YGRoundValueToPixelGrid(const float value, const float pointScaleFactor,
|
||||
const bool forceCeil, const bool forceFloor) {
|
||||
float scaledValue = value * pointScaleFactor;
|
||||
YOGA_EXPORT float YGRoundValueToPixelGrid(const float value,
|
||||
const float pointScaleFactor,
|
||||
const bool forceCeil,
|
||||
const bool forceFloor) {
|
||||
double scaledValue = ((double)value) * pointScaleFactor;
|
||||
// We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
|
||||
// - fractial`.
|
||||
float fractial = fmodf(scaledValue, 1.0f);
|
||||
@ -3204,7 +3260,7 @@ float YGRoundValueToPixelGrid(const float value, const float pointScaleFactor,
|
||||
: scaledValue / pointScaleFactor;
|
||||
}
|
||||
|
||||
bool YGNodeCanUseCachedMeasurement(
|
||||
YOGA_EXPORT bool YGNodeCanUseCachedMeasurement(
|
||||
const YGMeasureMode widthMode, const float width,
|
||||
const YGMeasureMode heightMode, const float height,
|
||||
const YGMeasureMode lastWidthMode, const float lastWidth,
|
||||
@ -3481,8 +3537,8 @@ bool YGLayoutNodeInternal(
|
||||
return (needToVisitNode || cachedResults == nullptr);
|
||||
}
|
||||
|
||||
void YGConfigSetPointScaleFactor(const YGConfigRef config,
|
||||
const float pixelsInPoint) {
|
||||
YOGA_EXPORT void YGConfigSetPointScaleFactor(const YGConfigRef config,
|
||||
const float pixelsInPoint) {
|
||||
YGAssertWithConfig(config, pixelsInPoint >= 0.0f,
|
||||
"Scale factor should not be less than zero");
|
||||
|
||||
@ -3567,18 +3623,16 @@ static void unsetUseLegacyFlagRecursively(YGNodeRef node) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeCalculateLayoutWithContext(const YGNodeRef node,
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const YGDirection ownerDirection,
|
||||
void* layoutContext) {
|
||||
YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
|
||||
const YGNodeRef node, const float ownerWidth, const float ownerHeight,
|
||||
const YGDirection ownerDirection, void* layoutContext) {
|
||||
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
|
||||
LayoutData markerData = {};
|
||||
|
||||
// Increment the generation count. This will force the recursive routine to
|
||||
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||
// the input parameters don't change.
|
||||
gCurrentGenerationCount++;
|
||||
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
|
||||
node->resolveDimension();
|
||||
float width = YGUndefined;
|
||||
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
|
||||
@ -3619,12 +3673,13 @@ void YGNodeCalculateLayoutWithContext(const YGNodeRef node,
|
||||
heightMeasureMode = YGFloatIsUndefined(height) ? YGMeasureModeUndefined
|
||||
: YGMeasureModeExactly;
|
||||
}
|
||||
if (YGLayoutNodeInternal(node, width, height, ownerDirection,
|
||||
widthMeasureMode, heightMeasureMode, ownerWidth,
|
||||
ownerHeight, true, LayoutPassReason::kInitial,
|
||||
node->getConfig(), markerData, layoutContext,
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
if (YGLayoutNodeInternal(
|
||||
node, width, height, ownerDirection, widthMeasureMode,
|
||||
heightMeasureMode, ownerWidth, ownerHeight, true,
|
||||
LayoutPassReason::kInitial, node->getConfig(), markerData,
|
||||
layoutContext,
|
||||
0, // tree root
|
||||
gCurrentGenerationCount.load(std::memory_order_relaxed))) {
|
||||
node->setPosition(node->getLayout().direction(), ownerWidth, ownerHeight,
|
||||
ownerWidth);
|
||||
YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f);
|
||||
@ -3653,7 +3708,7 @@ void YGNodeCalculateLayoutWithContext(const YGNodeRef node,
|
||||
nodeWithoutLegacyFlag->resolveDimension();
|
||||
// Recursively mark nodes as dirty
|
||||
nodeWithoutLegacyFlag->markDirtyAndPropogateDownwards();
|
||||
gCurrentGenerationCount++;
|
||||
gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
|
||||
// Rerun the layout, and calculate the diff
|
||||
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
||||
LayoutData layoutMarkerData = {};
|
||||
@ -3663,7 +3718,7 @@ void YGNodeCalculateLayoutWithContext(const YGNodeRef node,
|
||||
LayoutPassReason::kInitial, nodeWithoutLegacyFlag->getConfig(),
|
||||
layoutMarkerData, layoutContext,
|
||||
0, // tree root
|
||||
gCurrentGenerationCount)) {
|
||||
gCurrentGenerationCount.load(std::memory_order_relaxed))) {
|
||||
nodeWithoutLegacyFlag->setPosition(
|
||||
nodeWithoutLegacyFlag->getLayout().direction(), ownerWidth,
|
||||
ownerHeight, ownerWidth);
|
||||
@ -3690,14 +3745,15 @@ void YGNodeCalculateLayoutWithContext(const YGNodeRef node,
|
||||
}
|
||||
}
|
||||
|
||||
void YGNodeCalculateLayout(const YGNodeRef node, const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const YGDirection ownerDirection) {
|
||||
YOGA_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const YGDirection ownerDirection) {
|
||||
YGNodeCalculateLayoutWithContext(node, ownerWidth, ownerHeight,
|
||||
ownerDirection, nullptr);
|
||||
}
|
||||
|
||||
void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
|
||||
YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
|
||||
if (logger != nullptr) {
|
||||
config->setLogger(logger);
|
||||
} else {
|
||||
@ -3709,7 +3765,7 @@ void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) {
|
||||
}
|
||||
}
|
||||
|
||||
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
YOGA_EXPORT void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
const YGConfigRef config, const bool shouldDiffLayout) {
|
||||
config->shouldDiffLayoutWithoutLegacyStretchBehaviour = shouldDiffLayout;
|
||||
}
|
||||
@ -3734,9 +3790,9 @@ void YGAssertWithConfig(const YGConfigRef config, const bool condition,
|
||||
}
|
||||
}
|
||||
|
||||
void YGConfigSetExperimentalFeatureEnabled(const YGConfigRef config,
|
||||
const YGExperimentalFeature feature,
|
||||
const bool enabled) {
|
||||
YOGA_EXPORT void YGConfigSetExperimentalFeatureEnabled(
|
||||
const YGConfigRef config, const YGExperimentalFeature feature,
|
||||
const bool enabled) {
|
||||
config->experimentalFeatures[feature] = enabled;
|
||||
}
|
||||
|
||||
@ -3745,11 +3801,12 @@ inline bool YGConfigIsExperimentalFeatureEnabled(
|
||||
return config->experimentalFeatures[feature];
|
||||
}
|
||||
|
||||
void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
|
||||
YOGA_EXPORT void YGConfigSetUseWebDefaults(const YGConfigRef config,
|
||||
const bool enabled) {
|
||||
config->useWebDefaults = enabled;
|
||||
}
|
||||
|
||||
void YGConfigSetUseLegacyStretchBehaviour(
|
||||
YOGA_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
|
||||
const YGConfigRef config, const bool useLegacyStretchBehaviour) {
|
||||
config->useLegacyStretchBehaviour = useLegacyStretchBehaviour;
|
||||
}
|
||||
@ -3758,14 +3815,16 @@ bool YGConfigGetUseWebDefaults(const YGConfigRef config) {
|
||||
return config->useWebDefaults;
|
||||
}
|
||||
|
||||
void YGConfigSetContext(const YGConfigRef config, void* context) {
|
||||
YOGA_EXPORT void YGConfigSetContext(const YGConfigRef config, void* context) {
|
||||
config->context = context;
|
||||
}
|
||||
|
||||
void* YGConfigGetContext(const YGConfigRef config) { return config->context; }
|
||||
YOGA_EXPORT void* YGConfigGetContext(const YGConfigRef config) {
|
||||
return config->context;
|
||||
}
|
||||
|
||||
void YGConfigSetCloneNodeFunc(const YGConfigRef config,
|
||||
const YGCloneNodeFunc callback) {
|
||||
YOGA_EXPORT void YGConfigSetCloneNodeFunc(const YGConfigRef config,
|
||||
const YGCloneNodeFunc callback) {
|
||||
config->setCloneNodeCallback(callback);
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// v1.18.0
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "event.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <yoga/YGEnums.h>
|
||||
@ -50,7 +51,7 @@ struct LayoutData {
|
||||
|
||||
const char* LayoutPassReasonToString(const LayoutPassReason value);
|
||||
|
||||
struct Event {
|
||||
struct YOGA_EXPORT Event {
|
||||
enum Type {
|
||||
NodeAllocation,
|
||||
NodeDeallocation,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "experiments.h"
|
||||
|
||||
#include "experiments-inl.h"
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include "YGConfig.h"
|
||||
@ -27,8 +28,8 @@ void vlog(YGConfig* config, YGNode* node, YGLogLevel level, void* context,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Log::log(YGNode* node, YGLogLevel level, void* context, const char* format,
|
||||
...) noexcept {
|
||||
YOGA_EXPORT void Log::log(YGNode* node, YGLogLevel level, void* context,
|
||||
const char* format, ...) noexcept {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vlog(node == nullptr ? nullptr : node->getConfig(), node, level, context,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "YGEnums.h"
|
||||
|
||||
27
src/demo.ts
27
src/demo.ts
@ -1,6 +1,33 @@
|
||||
import { QMainWindow } from './index';
|
||||
import { QWidget } from './lib/QtWidgets/QWidget';
|
||||
import { FlexLayout } from './lib/core/FlexLayout';
|
||||
import { QLabel } from './lib/QtWidgets/QLabel';
|
||||
|
||||
const win = new QMainWindow();
|
||||
const view = new QWidget();
|
||||
view.setLayout(new FlexLayout());
|
||||
view.setStyleSheet(`
|
||||
flex: 1;
|
||||
width: '100%';
|
||||
height: '100%';
|
||||
`);
|
||||
const hello = new QLabel();
|
||||
hello.setText('Hello');
|
||||
hello.setStyleSheet(`
|
||||
border: 1px solid blue;
|
||||
qproperty-alignment: AlignCenter;
|
||||
`);
|
||||
const world = new QLabel();
|
||||
world.setText('World');
|
||||
world.setStyleSheet(`
|
||||
border: 1px solid blue;
|
||||
qproperty-alignment: AlignCenter;
|
||||
`);
|
||||
if (view.layout) {
|
||||
view.layout.addWidget(hello);
|
||||
view.layout.addWidget(world);
|
||||
}
|
||||
win.setCentralWidget(view);
|
||||
win.show();
|
||||
|
||||
(global as any).win = win; // To prevent win from being garbage collected.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user