Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cd78291de5 | ||
|
ab595d1875 | ||
|
597544e30a | ||
|
9f59a13836 | ||
|
12017e49bd | ||
|
abad796c44 | ||
|
92137273a2 | ||
|
f1ab289022 | ||
|
a302b76d59 | ||
|
4717594e93 | ||
|
df0f76bba5 | ||
|
e43c9f66ff | ||
|
0df58d8aa2 | ||
|
ff1a0e1eb8 | ||
|
ed765fe508 | ||
|
1b5eb7da5e | ||
|
071f576db9 | ||
|
3d10ba5f72 | ||
|
85b8386ba1 | ||
|
7ec3607446 | ||
|
835bb1cd9c | ||
|
9d35dce63e | ||
|
74fb205083 | ||
|
ba0bb10366 | ||
|
0296511f2c | ||
|
04fe81f88f | ||
|
98bbc15435 | ||
|
25b206ac53 | ||
|
88a4e44fd4 | ||
|
642ea07d6f | ||
|
e85c5ce39d | ||
|
cf753af247 | ||
|
12efe604bb | ||
|
f36f545d75 | ||
|
8fcd544c81 | ||
|
73662ebf83 | ||
|
47a8ec06a1 | ||
|
b611fac20b | ||
|
b11155423c | ||
|
40371cbf2d | ||
|
613590b0d8 | ||
|
4710a65f7a | ||
|
901f65ca05 | ||
|
72cf6806de | ||
|
1b7ae2ed3d | ||
|
c6100d0771 | ||
|
6339467b6d | ||
|
dda24b1e23 | ||
|
f7cc614d67 | ||
|
4bbf35832e | ||
|
b9feb10420 | ||
|
42b6f6b6e5 | ||
|
07cf47baad | ||
|
686289814d | ||
|
bb37e65ab1 | ||
|
31b961d8b3 | ||
|
4a578284a5 | ||
|
c5bbcd78ae | ||
|
4fbe0495b4 | ||
|
ff3d2e1691 | ||
|
684a36d6cf | ||
|
7d74e1cb66 | ||
|
b32b6029de | ||
|
5fa42cd1b0 | ||
|
6318801470 | ||
|
97d524fa96 | ||
|
c31df519e0 | ||
|
0240d09949 |
42
.gitignore
vendored
42
.gitignore
vendored
@@ -5,6 +5,48 @@
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/gentest/test.html
|
||||
.buckversion
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
||||
|
||||
# Xcode
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xcuserstate
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
Pods/
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
42
.hgignore
42
.hgignore
@@ -5,6 +5,48 @@
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/gentest/test.html
|
||||
.buckversion
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
||||
|
||||
# Xcode
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xcuserstate
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
Pods/
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
@@ -21,10 +21,10 @@ before_install:
|
||||
- export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
script:
|
||||
- buck test //:CSSLayout
|
||||
- buck test //:yoga
|
||||
- buck test //java:java
|
||||
- buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
|
||||
- sh csharp/tests/Facebook.CSSLayout/test_macos.sh
|
||||
- buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
|
||||
- sh csharp/tests/Facebook.Yoga/test_macos.sh
|
||||
- buck run //benchmark:benchmark
|
||||
- git checkout HEAD^
|
||||
- buck run //benchmark:benchmark
|
||||
|
30
BUCK
30
BUCK
@@ -5,43 +5,37 @@
|
||||
# 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.
|
||||
|
||||
include_defs('//CSSLAYOUT_DEFS')
|
||||
|
||||
BASE_COMPILER_FLAGS = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
]
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
GMOCK_OVERRIDE_FLAGS = [
|
||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||
'-Wno-inconsistent-missing-override',
|
||||
]
|
||||
|
||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11']
|
||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC']
|
||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11']
|
||||
|
||||
cxx_library(
|
||||
name = 'CSSLayout',
|
||||
srcs = glob(['CSSLayout/*.c']),
|
||||
tests=[':tests'],
|
||||
exported_headers = subdir_glob([('', 'CSSLayout/*.h')]),
|
||||
name = 'yoga',
|
||||
soname = 'libyogacore.$(ext)',
|
||||
srcs = glob(['yoga/*.c']),
|
||||
tests=[':YogaTests'],
|
||||
exported_headers = subdir_glob([('', 'yoga/*.h')]),
|
||||
header_namespace = '',
|
||||
force_static = True,
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
deps = [],
|
||||
deps = [] if THIS_IS_FBOBJC else [
|
||||
yoga_dep('lib/fb:ndklog'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
cxx_test(
|
||||
name = 'tests',
|
||||
name = 'YogaTests',
|
||||
contacts = ['emilsj@fb.com'],
|
||||
srcs = glob(['tests/*.cpp']),
|
||||
compiler_flags = TEST_COMPILER_FLAGS,
|
||||
deps = [
|
||||
':CSSLayout',
|
||||
':yoga',
|
||||
GTEST_TARGET,
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
|
@@ -1,10 +1,7 @@
|
||||
# Contributing to css-layout
|
||||
# Contributing to yoga
|
||||
We want to make contributing to this project as easy and transparent as
|
||||
possible.
|
||||
|
||||
## Our Development Process
|
||||
All the development is happening on GitHub first and we have internal tools to sync down to Facebook codebase.
|
||||
|
||||
## Pull Requests
|
||||
We actively welcome your pull requests.
|
||||
1. Fork the repo and create your branch from `master`.
|
||||
@@ -32,5 +29,5 @@ outlined on that page and do not file a public issue.
|
||||
* format.sh
|
||||
|
||||
## License
|
||||
By contributing to css-layout, you agree that your contributions will be licensed
|
||||
By contributing to yoga, you agree that your contributions will be licensed
|
||||
under its BSD license.
|
||||
|
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
typedef enum CSSOverflow {
|
||||
CSSOverflowVisible,
|
||||
CSSOverflowHidden,
|
||||
CSSOverflowScroll,
|
||||
CSSOverflowCount,
|
||||
} CSSOverflow;
|
||||
|
||||
typedef enum CSSJustify {
|
||||
CSSJustifyFlexStart,
|
||||
CSSJustifyCenter,
|
||||
CSSJustifyFlexEnd,
|
||||
CSSJustifySpaceBetween,
|
||||
CSSJustifySpaceAround,
|
||||
CSSJustifyCount,
|
||||
} CSSJustify;
|
||||
|
||||
typedef enum CSSFlexDirection {
|
||||
CSSFlexDirectionColumn,
|
||||
CSSFlexDirectionColumnReverse,
|
||||
CSSFlexDirectionRow,
|
||||
CSSFlexDirectionRowReverse,
|
||||
CSSFlexDirectionCount,
|
||||
} CSSFlexDirection;
|
||||
|
||||
typedef enum CSSAlign {
|
||||
CSSAlignAuto,
|
||||
CSSAlignFlexStart,
|
||||
CSSAlignCenter,
|
||||
CSSAlignFlexEnd,
|
||||
CSSAlignStretch,
|
||||
CSSAlignCount,
|
||||
} CSSAlign;
|
||||
|
||||
typedef enum CSSEdge {
|
||||
CSSEdgeLeft,
|
||||
CSSEdgeTop,
|
||||
CSSEdgeRight,
|
||||
CSSEdgeBottom,
|
||||
CSSEdgeStart,
|
||||
CSSEdgeEnd,
|
||||
CSSEdgeHorizontal,
|
||||
CSSEdgeVertical,
|
||||
CSSEdgeAll,
|
||||
CSSEdgeCount,
|
||||
} CSSEdge;
|
||||
|
||||
typedef enum CSSWrap {
|
||||
CSSWrapNoWrap,
|
||||
CSSWrapWrap,
|
||||
CSSWrapCount,
|
||||
} CSSWrap;
|
||||
|
||||
typedef enum CSSDirection {
|
||||
CSSDirectionInherit,
|
||||
CSSDirectionLTR,
|
||||
CSSDirectionRTL,
|
||||
CSSDirectionCount,
|
||||
} CSSDirection;
|
||||
|
||||
typedef enum CSSExperimentalFeature {
|
||||
CSSExperimentalFeatureRounding,
|
||||
CSSExperimentalFeatureWebFlexBasis,
|
||||
CSSExperimentalFeatureCount,
|
||||
} CSSExperimentalFeature;
|
||||
|
||||
typedef enum CSSLogLevel {
|
||||
CSSLogLevelError,
|
||||
CSSLogLevelWarn,
|
||||
CSSLogLevelInfo,
|
||||
CSSLogLevelDebug,
|
||||
CSSLogLevelVerbose,
|
||||
CSSLogLevelCount,
|
||||
} CSSLogLevel;
|
||||
|
||||
typedef enum CSSDimension {
|
||||
CSSDimensionWidth,
|
||||
CSSDimensionHeight,
|
||||
CSSDimensionCount,
|
||||
} CSSDimension;
|
||||
|
||||
typedef enum CSSMeasureMode {
|
||||
CSSMeasureModeUndefined,
|
||||
CSSMeasureModeExactly,
|
||||
CSSMeasureModeAtMost,
|
||||
CSSMeasureModeCount,
|
||||
} CSSMeasureMode;
|
||||
|
||||
typedef enum CSSPositionType {
|
||||
CSSPositionTypeRelative,
|
||||
CSSPositionTypeAbsolute,
|
||||
CSSPositionTypeCount,
|
||||
} CSSPositionType;
|
||||
|
||||
typedef enum CSSPrintOptions {
|
||||
CSSPrintOptionsLayout = 1,
|
||||
CSSPrintOptionsStyle = 2,
|
||||
CSSPrintOptionsChildren = 4,
|
||||
CSSPrintOptionsCount,
|
||||
} CSSPrintOptions;
|
File diff suppressed because it is too large
Load Diff
@@ -1,184 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
// Not defined in MSVC++
|
||||
#ifndef NAN
|
||||
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||
#define NAN (*(const float *) __nan)
|
||||
#endif
|
||||
|
||||
#define CSSUndefined NAN
|
||||
|
||||
#include "CSSEnums.h"
|
||||
#include "CSSMacros.h"
|
||||
|
||||
CSS_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct CSSSize {
|
||||
float width;
|
||||
float height;
|
||||
} CSSSize;
|
||||
|
||||
typedef struct CSSNode *CSSNodeRef;
|
||||
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode);
|
||||
typedef void (*CSSPrintFunc)(CSSNodeRef node);
|
||||
typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args);
|
||||
|
||||
typedef void *(*CSSMalloc)(size_t size);
|
||||
typedef void *(*CSSCalloc)(size_t count, size_t size);
|
||||
typedef void *(*CSSRealloc)(void *ptr, size_t size);
|
||||
typedef void (*CSSFree)(void *ptr);
|
||||
|
||||
// CSSNode
|
||||
WIN_EXPORT CSSNodeRef CSSNodeNew(void);
|
||||
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
|
||||
WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
|
||||
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
|
||||
WIN_EXPORT void CSSNodeReset(const CSSNodeRef node);
|
||||
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
|
||||
|
||||
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node,
|
||||
const CSSNodeRef child,
|
||||
const uint32_t index);
|
||||
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
|
||||
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
|
||||
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
|
||||
|
||||
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
|
||||
const float availableWidth,
|
||||
const float availableHeight,
|
||||
const CSSDirection parentDirection);
|
||||
|
||||
// Mark a node as dirty. Only valid for nodes with a custom measure function
|
||||
// set.
|
||||
// CSSLayout knows when to mark all other nodes as dirty but because nodes with
|
||||
// measure functions
|
||||
// depends on information not known to CSSLayout they must perform this dirty
|
||||
// marking manually.
|
||||
WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node);
|
||||
WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node);
|
||||
|
||||
WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions options);
|
||||
|
||||
WIN_EXPORT bool CSSValueIsUndefined(const float value);
|
||||
|
||||
WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
|
||||
const float width,
|
||||
const CSSMeasureMode heightMode,
|
||||
const float height,
|
||||
const CSSMeasureMode lastWidthMode,
|
||||
const float lastWidth,
|
||||
const CSSMeasureMode lastHeightMode,
|
||||
const float lastHeight,
|
||||
const float lastComputedWidth,
|
||||
const float lastComputedHeight,
|
||||
const float marginRow,
|
||||
const float marginColumn);
|
||||
|
||||
WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode);
|
||||
|
||||
#define CSS_NODE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
|
||||
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
|
||||
|
||||
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
|
||||
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
|
||||
|
||||
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
||||
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \
|
||||
const CSSEdge edge, \
|
||||
const type paramName); \
|
||||
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const CSSEdge edge);
|
||||
|
||||
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
|
||||
WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
|
||||
|
||||
CSS_NODE_PROPERTY(void *, Context, context);
|
||||
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
|
||||
CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc);
|
||||
CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(CSSDirection, Direction, direction);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSFlexDirection, FlexDirection, flexDirection);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSJustify, JustifyContent, justifyContent);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignContent, alignContent);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSWrap, FlexWrap, flexWrap);
|
||||
CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow);
|
||||
|
||||
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
|
||||
CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
|
||||
CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
|
||||
CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
|
||||
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, Width, width);
|
||||
CSS_NODE_STYLE_PROPERTY(float, Height, height);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
// Aspect ratio control the size of the undefined dimension of a node.
|
||||
// - On a node with a set width/height aspect ratio control the size of the unset dimension
|
||||
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
|
||||
// unset
|
||||
// - On a node with a measure function aspect ratio works as though the measure function measures
|
||||
// the flex basis
|
||||
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
|
||||
// unset
|
||||
// - Aspect ratio takes min/max dimensions into account
|
||||
CSS_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
|
||||
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Left);
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Top);
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Right);
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Bottom);
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Width);
|
||||
CSS_NODE_LAYOUT_PROPERTY(float, Height);
|
||||
CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
|
||||
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature,
|
||||
bool enabled);
|
||||
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
|
||||
|
||||
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
|
||||
CSSCalloc cssCalloc,
|
||||
CSSRealloc cssRealloc,
|
||||
CSSFree cssFree);
|
||||
|
||||
CSS_EXTERN_C_END
|
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "CSSNodeList.h"
|
||||
|
||||
extern CSSMalloc gCSSMalloc;
|
||||
extern CSSRealloc gCSSRealloc;
|
||||
extern CSSFree gCSSFree;
|
||||
|
||||
struct CSSNodeList {
|
||||
uint32_t capacity;
|
||||
uint32_t count;
|
||||
CSSNodeRef *items;
|
||||
};
|
||||
|
||||
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
|
||||
const CSSNodeListRef list = gCSSMalloc(sizeof(struct CSSNodeList));
|
||||
CSS_ASSERT(list != NULL, "Could not allocate memory for list");
|
||||
|
||||
list->capacity = initialCapacity;
|
||||
list->count = 0;
|
||||
list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity);
|
||||
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void CSSNodeListFree(const CSSNodeListRef list) {
|
||||
if (list) {
|
||||
gCSSFree(list->items);
|
||||
gCSSFree(list);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CSSNodeListCount(const CSSNodeListRef list) {
|
||||
if (list) {
|
||||
return list->count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node) {
|
||||
if (!*listp) {
|
||||
*listp = CSSNodeListNew(4);
|
||||
}
|
||||
CSSNodeListInsert(listp, node, (*listp)->count);
|
||||
}
|
||||
|
||||
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index) {
|
||||
if (!*listp) {
|
||||
*listp = CSSNodeListNew(4);
|
||||
}
|
||||
CSSNodeListRef list = *listp;
|
||||
|
||||
if (list->count == list->capacity) {
|
||||
list->capacity *= 2;
|
||||
list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity);
|
||||
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
|
||||
}
|
||||
|
||||
for (uint32_t i = list->count; i > index; i--) {
|
||||
list->items[i] = list->items[i - 1];
|
||||
}
|
||||
|
||||
list->count++;
|
||||
list->items[index] = node;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index) {
|
||||
const CSSNodeRef removed = list->items[index];
|
||||
list->items[index] = NULL;
|
||||
|
||||
for (uint32_t i = index; i < list->count - 1; i++) {
|
||||
list->items[i] = list->items[i + 1];
|
||||
list->items[i + 1] = NULL;
|
||||
}
|
||||
|
||||
list->count--;
|
||||
return removed;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) {
|
||||
for (uint32_t i = 0; i < list->count; i++) {
|
||||
if (list->items[i] == node) {
|
||||
return CSSNodeListRemove(list, i);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) {
|
||||
if (CSSNodeListCount(list) > 0) {
|
||||
return list->items[index];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "CSSLayout.h"
|
||||
#include "CSSMacros.h"
|
||||
|
||||
CSS_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct CSSNodeList *CSSNodeListRef;
|
||||
|
||||
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity);
|
||||
void CSSNodeListFree(const CSSNodeListRef list);
|
||||
uint32_t CSSNodeListCount(const CSSNodeListRef list);
|
||||
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node);
|
||||
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index);
|
||||
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index);
|
||||
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node);
|
||||
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index);
|
||||
|
||||
CSS_EXTERN_C_END
|
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <CSSLayout/CSSLayout.h>
|
||||
|
||||
@interface UIView (CSSLayout)
|
||||
|
||||
/**
|
||||
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
||||
*/
|
||||
@property (nonatomic, readwrite, assign, setter=css_setIncludeInLayout:) BOOL css_includeInLayout;
|
||||
|
||||
/**
|
||||
The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO.
|
||||
*/
|
||||
@property (nonatomic, readwrite, assign, setter=css_setUsesFlexbox:) BOOL css_usesFlexbox;
|
||||
|
||||
- (void)css_setDirection:(CSSDirection)direction;
|
||||
- (void)css_setFlexDirection:(CSSFlexDirection)flexDirection;
|
||||
- (void)css_setJustifyContent:(CSSJustify)justifyContent;
|
||||
- (void)css_setAlignContent:(CSSAlign)alignContent;
|
||||
- (void)css_setAlignItems:(CSSAlign)alignItems;
|
||||
- (void)css_setAlignSelf:(CSSAlign)alignSelf;
|
||||
- (void)css_setPositionType:(CSSPositionType)positionType;
|
||||
- (void)css_setFlexWrap:(CSSWrap)flexWrap;
|
||||
|
||||
- (void)css_setFlexGrow:(CGFloat)flexGrow;
|
||||
- (void)css_setFlexShrink:(CGFloat)flexShrink;
|
||||
- (void)css_setFlexBasis:(CGFloat)flexBasis;
|
||||
|
||||
- (void)css_setPosition:(CGFloat)position forEdge:(CSSEdge)edge;
|
||||
- (void)css_setMargin:(CGFloat)margin forEdge:(CSSEdge)edge;
|
||||
- (void)css_setPadding:(CGFloat)padding forEdge:(CSSEdge)edge;
|
||||
|
||||
- (void)css_setWidth:(CGFloat)width;
|
||||
- (void)css_setHeight:(CGFloat)height;
|
||||
- (void)css_setMinWidth:(CGFloat)minWidth;
|
||||
- (void)css_setMinHeight:(CGFloat)minHeight;
|
||||
- (void)css_setMaxWidth:(CGFloat)maxWidth;
|
||||
- (void)css_setMaxHeight:(CGFloat)maxHeight;
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
- (void)css_setAspectRatio:(CGFloat)aspectRatio;
|
||||
|
||||
/**
|
||||
Get the resolved direction of this node. This won't be CSSDirectionInherit
|
||||
*/
|
||||
- (CSSDirection)css_resolvedDirection;
|
||||
|
||||
/**
|
||||
Perform a layout calculation and update the frames of the views in the hierarchy with th results
|
||||
*/
|
||||
- (void)css_applyLayout;
|
||||
|
||||
/**
|
||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||
*/
|
||||
- (CGSize)css_intrinsicSize;
|
||||
|
||||
/**
|
||||
Returns the number of children that are using Flexbox.
|
||||
*/
|
||||
- (NSUInteger)css_numberOfChildren;
|
||||
|
||||
@end
|
@@ -1,379 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "UIView+CSSLayout.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@interface CSSNodeBridge : NSObject
|
||||
@property (nonatomic, assign, readonly) CSSNodeRef cnode;
|
||||
@end
|
||||
|
||||
@implementation CSSNodeBridge
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ([super init]) {
|
||||
_cnode = CSSNodeNew();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CSSNodeFree(_cnode);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation UIView (CSSLayout)
|
||||
|
||||
- (BOOL)css_usesFlexbox
|
||||
{
|
||||
NSNumber *usesFlexbox = objc_getAssociatedObject(self, @selector(css_usesFlexbox));
|
||||
return [usesFlexbox boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)css_includeInLayout
|
||||
{
|
||||
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(css_includeInLayout));
|
||||
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)css_numberOfChildren
|
||||
{
|
||||
return CSSNodeChildCount([self cssNode]);
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)css_setIncludeInLayout:(BOOL)includeInLayout
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
self,
|
||||
@selector(css_includeInLayout),
|
||||
@(includeInLayout),
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)css_setUsesFlexbox:(BOOL)enabled
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
self,
|
||||
@selector(css_usesFlexbox),
|
||||
@(enabled),
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)css_setDirection:(CSSDirection)direction
|
||||
{
|
||||
CSSNodeStyleSetDirection([self cssNode], direction);
|
||||
}
|
||||
|
||||
- (void)css_setFlexDirection:(CSSFlexDirection)flexDirection
|
||||
{
|
||||
CSSNodeStyleSetFlexDirection([self cssNode], flexDirection);
|
||||
}
|
||||
|
||||
- (void)css_setJustifyContent:(CSSJustify)justifyContent
|
||||
{
|
||||
CSSNodeStyleSetJustifyContent([self cssNode], justifyContent);
|
||||
}
|
||||
|
||||
- (void)css_setAlignContent:(CSSAlign)alignContent
|
||||
{
|
||||
CSSNodeStyleSetAlignContent([self cssNode], alignContent);
|
||||
}
|
||||
|
||||
- (void)css_setAlignItems:(CSSAlign)alignItems
|
||||
{
|
||||
CSSNodeStyleSetAlignItems([self cssNode], alignItems);
|
||||
}
|
||||
|
||||
- (void)css_setAlignSelf:(CSSAlign)alignSelf
|
||||
{
|
||||
CSSNodeStyleSetAlignSelf([self cssNode], alignSelf);
|
||||
}
|
||||
|
||||
- (void)css_setPositionType:(CSSPositionType)positionType
|
||||
{
|
||||
CSSNodeStyleSetPositionType([self cssNode], positionType);
|
||||
}
|
||||
|
||||
- (void)css_setFlexWrap:(CSSWrap)flexWrap
|
||||
{
|
||||
CSSNodeStyleSetFlexWrap([self cssNode], flexWrap);
|
||||
}
|
||||
|
||||
- (void)css_setFlexGrow:(CGFloat)flexGrow
|
||||
{
|
||||
CSSNodeStyleSetFlexGrow([self cssNode], flexGrow);
|
||||
}
|
||||
|
||||
- (void)css_setFlexShrink:(CGFloat)flexShrink
|
||||
{
|
||||
CSSNodeStyleSetFlexShrink([self cssNode], flexShrink);
|
||||
}
|
||||
|
||||
- (void)css_setFlexBasis:(CGFloat)flexBasis
|
||||
{
|
||||
CSSNodeStyleSetFlexBasis([self cssNode], flexBasis);
|
||||
}
|
||||
|
||||
- (void)css_setPosition:(CGFloat)position forEdge:(CSSEdge)edge
|
||||
{
|
||||
CSSNodeStyleSetPosition([self cssNode], edge, position);
|
||||
}
|
||||
|
||||
- (void)css_setMargin:(CGFloat)margin forEdge:(CSSEdge)edge
|
||||
{
|
||||
CSSNodeStyleSetMargin([self cssNode], edge, margin);
|
||||
}
|
||||
|
||||
- (void)css_setPadding:(CGFloat)padding forEdge:(CSSEdge)edge
|
||||
{
|
||||
CSSNodeStyleSetPadding([self cssNode], edge, padding);
|
||||
}
|
||||
|
||||
- (void)css_setWidth:(CGFloat)width
|
||||
{
|
||||
CSSNodeStyleSetWidth([self cssNode], width);
|
||||
}
|
||||
|
||||
- (void)css_setHeight:(CGFloat)height
|
||||
{
|
||||
CSSNodeStyleSetHeight([self cssNode], height);
|
||||
}
|
||||
|
||||
- (void)css_setMinWidth:(CGFloat)minWidth
|
||||
{
|
||||
CSSNodeStyleSetMinWidth([self cssNode], minWidth);
|
||||
}
|
||||
|
||||
- (void)css_setMinHeight:(CGFloat)minHeight
|
||||
{
|
||||
CSSNodeStyleSetMinHeight([self cssNode], minHeight);
|
||||
}
|
||||
|
||||
- (void)css_setMaxWidth:(CGFloat)maxWidth
|
||||
{
|
||||
CSSNodeStyleSetMaxWidth([self cssNode], maxWidth);
|
||||
}
|
||||
|
||||
- (void)css_setMaxHeight:(CGFloat)maxHeight
|
||||
{
|
||||
CSSNodeStyleSetMaxHeight([self cssNode], maxHeight);
|
||||
}
|
||||
|
||||
- (void)css_setAspectRatio:(CGFloat)aspectRatio
|
||||
{
|
||||
CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio);
|
||||
}
|
||||
|
||||
#pragma mark - Layout and Sizing
|
||||
|
||||
- (CSSDirection)css_resolvedDirection
|
||||
{
|
||||
return CSSNodeLayoutGetDirection([self cssNode]);
|
||||
}
|
||||
|
||||
- (void)css_applyLayout
|
||||
{
|
||||
[self calculateLayoutWithSize:self.bounds.size];
|
||||
CSSApplyLayoutToViewHierarchy(self);
|
||||
}
|
||||
|
||||
- (CGSize)css_intrinsicSize
|
||||
{
|
||||
const CGSize constrainedSize = {
|
||||
.width = CSSUndefined,
|
||||
.height = CSSUndefined,
|
||||
};
|
||||
return [self calculateLayoutWithSize:constrainedSize];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (CSSNodeRef)cssNode
|
||||
{
|
||||
CSSNodeBridge *node = objc_getAssociatedObject(self, @selector(cssNode));
|
||||
if (!node) {
|
||||
node = [CSSNodeBridge new];
|
||||
CSSNodeSetContext(node.cnode, (__bridge void *) self);
|
||||
objc_setAssociatedObject(self, @selector(cssNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
return node.cnode;
|
||||
}
|
||||
|
||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||
{
|
||||
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
|
||||
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
|
||||
|
||||
CSSAttachNodesFromViewHierachy(self);
|
||||
|
||||
const CSSNodeRef node = [self cssNode];
|
||||
CSSNodeCalculateLayout(
|
||||
node,
|
||||
size.width,
|
||||
size.height,
|
||||
CSSNodeStyleGetDirection(node));
|
||||
|
||||
return (CGSize) {
|
||||
.width = CSSNodeLayoutGetWidth(node),
|
||||
.height = CSSNodeLayoutGetHeight(node),
|
||||
};
|
||||
}
|
||||
|
||||
static CSSSize CSSMeasureView(
|
||||
CSSNodeRef node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode)
|
||||
{
|
||||
const CGFloat constrainedWidth = (widthMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
||||
const CGFloat constrainedHeight = (heightMode == CSSMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
||||
|
||||
UIView *view = (__bridge UIView*) CSSNodeGetContext(node);
|
||||
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||
.width = constrainedWidth,
|
||||
.height = constrainedHeight,
|
||||
}];
|
||||
|
||||
return (CSSSize) {
|
||||
.width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||
.height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||
};
|
||||
}
|
||||
|
||||
static CGFloat CSSSanitizeMeasurement(
|
||||
CGFloat constrainedSize,
|
||||
CGFloat measuredSize,
|
||||
CSSMeasureMode measureMode)
|
||||
{
|
||||
CGFloat result;
|
||||
if (measureMode == CSSMeasureModeExactly) {
|
||||
result = constrainedSize;
|
||||
} else if (measureMode == CSSMeasureModeAtMost) {
|
||||
result = MIN(constrainedSize, measuredSize);
|
||||
} else {
|
||||
result = measuredSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void CSSAttachNodesFromViewHierachy(UIView *view) {
|
||||
CSSNodeRef node = [view cssNode];
|
||||
|
||||
// Only leaf nodes should have a measure function
|
||||
if (![view css_usesFlexbox] || view.subviews.count == 0) {
|
||||
CSSNodeSetMeasureFunc(node, CSSMeasureView);
|
||||
CSSRemoveAllChildren(node);
|
||||
} else {
|
||||
CSSNodeSetMeasureFunc(node, NULL);
|
||||
|
||||
// Create a list of all the subviews that we are going to use for layout.
|
||||
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||
for (UIView *subview in view.subviews) {
|
||||
if ([subview css_includeInLayout]) {
|
||||
[subviewsToInclude addObject:subview];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL shouldReconstructChildList = NO;
|
||||
if (CSSNodeChildCount(node) != subviewsToInclude.count) {
|
||||
shouldReconstructChildList = YES;
|
||||
} else {
|
||||
for (int i = 0; i < subviewsToInclude.count; i++) {
|
||||
if (CSSNodeGetChild(node, i) != [subviewsToInclude[i] cssNode]) {
|
||||
shouldReconstructChildList = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldReconstructChildList) {
|
||||
CSSRemoveAllChildren(node);
|
||||
|
||||
for (int i = 0 ; i < subviewsToInclude.count; i++) {
|
||||
UIView *const subview = subviewsToInclude[i];
|
||||
CSSNodeInsertChild(node, [subview cssNode], i);
|
||||
CSSAttachNodesFromViewHierachy(subview);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CSSRemoveAllChildren(const CSSNodeRef node)
|
||||
{
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (CSSNodeChildCount(node) > 0) {
|
||||
CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
static CGFloat CSSRoundPixelValue(CGFloat value)
|
||||
{
|
||||
static CGFloat scale;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^(){
|
||||
scale = [UIScreen mainScreen].scale;
|
||||
});
|
||||
|
||||
return round(value * scale) / scale;
|
||||
}
|
||||
|
||||
static void CSSApplyLayoutToViewHierarchy(UIView *view) {
|
||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||
if (![view css_includeInLayout]) {
|
||||
return;
|
||||
}
|
||||
|
||||
CSSNodeRef node = [view cssNode];
|
||||
const CGPoint topLeft = {
|
||||
CSSNodeLayoutGetLeft(node),
|
||||
CSSNodeLayoutGetTop(node),
|
||||
};
|
||||
|
||||
const CGPoint bottomRight = {
|
||||
topLeft.x + CSSNodeLayoutGetWidth(node),
|
||||
topLeft.y + CSSNodeLayoutGetHeight(node),
|
||||
};
|
||||
|
||||
view.frame = (CGRect) {
|
||||
.origin = {
|
||||
.x = CSSRoundPixelValue(topLeft.x),
|
||||
.y = CSSRoundPixelValue(topLeft.y),
|
||||
},
|
||||
.size = {
|
||||
.width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x),
|
||||
.height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y),
|
||||
},
|
||||
};
|
||||
|
||||
const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0;
|
||||
if (!isLeaf) {
|
||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||
CSSApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
BSD License
|
||||
|
||||
For css-layout software
|
||||
For yoga software
|
||||
|
||||
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
|
||||
|
9
LICENSE-examples
Normal file
9
LICENSE-examples
Normal file
@@ -0,0 +1,9 @@
|
||||
The examples provided by Facebook are for non-commercial testing and evaluation
|
||||
purposes only. Facebook reserves all rights not expressly granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
PATENTS
2
PATENTS
@@ -1,6 +1,6 @@
|
||||
Additional Grant of Patent Rights Version 2
|
||||
|
||||
"Software" means the CSS Layout software distributed by Facebook, Inc.
|
||||
"Software" means the yoga software distributed by Facebook, Inc.
|
||||
|
||||
Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software
|
||||
(“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
|
||||
|
161
README.md
161
README.md
@@ -1,159 +1,30 @@
|
||||
# CSSLayout [](https://travis-ci.org/facebook/css-layout)
|
||||
# Yoga [](https://travis-ci.org/facebook/yoga)
|
||||
|
||||
## Goals
|
||||
CSSLayout is a cross-platform implementation of flexbox. The goal of CSSLayout is allow native developers to have the same expressive layout system as developers developing for the modern web are used to. CSSLayout allows developers for web, android, iOS, and windows to use the same layout primitives across platforms. This saves time, increases collaboration between platform teams, and makes it easier for developers to work on multiple platforms.
|
||||
## Building
|
||||
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
||||
|
||||
The goal of CSSLayout is not to re-implement all of css. CSSLayout only targets flexbox, and does not have any plans on implementing support for tables, floats, or any other css concepts. CSSLayout also does not plan on supporting styling properties which do not affect layout such as color or background properties.
|
||||
## Testing
|
||||
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
|
||||
|
||||
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
|
||||
|
||||
## Differences from web
|
||||
CSSLayout tries to stay as close as possible to the web implementation of flexbox. There are however certain cases where CSSLayout differs from the web implementation.
|
||||
|
||||
### Default values
|
||||
CSSLayout has chosen to make changes to the default values of certain properties. These default values were chosen based on our usage of the library. When testing layout with tools such as JSFiddle you can apply the following css style to ensure the defaults match those of CSSLayout. Or fork the [following JSFiddle](http://jsfiddle.net/vjeux/y11txxv9/).
|
||||
|
||||
```css
|
||||
div, span {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
flex-shrink: 0;
|
||||
align-content: flex-start;
|
||||
|
||||
border: 0 solid black;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
```
|
||||
|
||||
- `box-sizing: border-box` is the most convenient way to express the relation between `width` and `borderWidth`.
|
||||
- Everything is `display: flex` by default. All the behaviors of `block` and `inline-block` can be expressed in term of `flex` but not the opposite.
|
||||
- All the flex elements are oriented from top to bottom, left to right and do not shrink. This is how things are laid out using the default CSS settings and what you'd expect.
|
||||
- Everything is `position: relative`. This makes `position: absolute` target the direct parent and not some parent which is either `relative` or `absolute`. If you want to position an element relative to something else, you should move it in the DOM instead of relying of CSS. It also makes `top, left, right, bottom` do something when not specifying `position: absolute`.
|
||||
|
||||
### Size units
|
||||
CSSLayout currently only supports pixel sizes. The reason being that we have not seen the need for any other units. We would like to support percentage units sometime in the future.
|
||||
|
||||
### -start and -end properties
|
||||
We think supporting RTL locales is very important. Therefor CSSLayout supports non-standards -start and -end suffixed versions of margin, padding, border, and position.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### C
|
||||
The full API can be found in `CSSLayout/CSSLayout.h`.
|
||||
|
||||
```c
|
||||
CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeStyleSetHeight(child, 10);
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
}
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
|
||||
// Get for resulting layout
|
||||
CSSNodeLayoutGetLeft(root);
|
||||
CSSNodeLayoutGetTop(root);
|
||||
CSSNodeLayoutGetWidth(root);
|
||||
CSSNodeLayoutGetHeight(root);
|
||||
```
|
||||
|
||||
### Java
|
||||
The full API can be found in `java/com/facebook/csslayout/CSSNode.java`.
|
||||
|
||||
```java
|
||||
CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
CSSNode child = new CSSNode();
|
||||
child.setStyleHeight(10);
|
||||
root.addChildAt(child, 0);
|
||||
}
|
||||
|
||||
root.calculateLayout(new CSSLayoutContext());
|
||||
|
||||
// Get for resulting layout
|
||||
root.getLayoutX();
|
||||
root.getLayoutY();
|
||||
root.getLayoutWidth();
|
||||
root.getLayoutHeight();
|
||||
```
|
||||
|
||||
### UIKit
|
||||
The full API can be found in `CSSLayoutKit/UIView+CSSLayout.h`.
|
||||
|
||||
```objective-c
|
||||
UIView *root = [UIView new];
|
||||
[root css_setUsesFlexbox:YES];
|
||||
[root css_setWidth:100];
|
||||
[root css_setHeight:100];
|
||||
|
||||
for (NSUInteger i = 0; i < 10; i++) {
|
||||
UIView *child = [UIView new];
|
||||
[child css_setUsesFlexbox:YES];
|
||||
[child css_setHeight:10];
|
||||
[root addSubview:child];
|
||||
}
|
||||
|
||||
// Resulting layout will be set on the UIView hierarchy frames.
|
||||
[root css_applyLayout];
|
||||
```
|
||||
|
||||
### .NET
|
||||
The full API can be found in `csharp/Facebook.CSSLayout/CSSNode.cs`.
|
||||
|
||||
```csharp
|
||||
var root = new CSSNode();
|
||||
root.StyleWidth = 100;
|
||||
root.StyleHeight = 100;
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var child = new CSSNode();
|
||||
child.StyleHeight = 10;
|
||||
root.Insert(0, child);
|
||||
}
|
||||
|
||||
// Get for resulting layout
|
||||
root.LayoutX;
|
||||
root.LayoutY;
|
||||
root.LayoutWidth;
|
||||
root.LayoutHeight;
|
||||
```
|
||||
|
||||
## Contributing
|
||||
To contribute to CSSLayout you need to first install [buck](https://buckbuild.com) which is the build system used by CSSLayout. CSSLayout is implemented in C with language bindings for Java, Objective-C, and .NET. When making changes to `CSSLayout/CSSLayout.h` please ensure to update `java/jni/CSSJNI.h`, `java/com/facebook/csslayout/CSSNode.java`, `uikit/CSSLayout/UIView+CSSLayout.m`, and `csharp/Facebook.CSSLayout/CSSNode.cs` to reflect the API change. Before submitting any code please run `format.sh` to ensure the code matches the project's code style.
|
||||
|
||||
Before making any larger changes to CSSLayout please open an issue with a RFC so the changes can be discussed first. Generally we are very open to changes and improvements that will benefit the community.
|
||||
|
||||
### Testing
|
||||
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add at least one test to ensure we don't break anything in the future. Tests are located in `tests/CSSLayoutTest.cpp`. Run the tests by executing `buck test //:CSSLayout`.
|
||||
|
||||
Instead of manually writing a test which ensures parity with web implementations of flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in CSSLayout, in `gentest/fixtures` folder, such as the following.
|
||||
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
|
||||
|
||||
```html
|
||||
<div style="width: 100px; height: 100px; align-items: center;">
|
||||
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:CSSLayout` to validate the behavior. One test case will be generated for every root `div` in the input html.
|
||||
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html.
|
||||
|
||||
You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script.
|
||||
|
||||
#### .NET
|
||||
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.CSSLayout/test_macos.sh`.
|
||||
### .NET
|
||||
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`.
|
||||
|
||||
### Benchmarks
|
||||
Benchmarks are located in `benchmarks/CSSBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed.
|
||||
## Code style
|
||||
For the main C implementation of Yoga clang-format is used to ensure a consistent code style. Please run `bash format.sh` before submitting a pull request. For other languages just try to follow the current code style.
|
||||
|
||||
## Benchmarks
|
||||
Benchmarks are located in `benchmarks/YGBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
CSSLAYOUT_ROOT = '//...'
|
||||
YOGA_ROOT = '//...'
|
||||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
||||
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
||||
JUNIT_TARGET = '//lib/junit:junit'
|
||||
@@ -9,12 +9,23 @@ GTEST_TARGET = '//lib/gtest:gtest'
|
||||
JNI_TARGET = '//lib/jni:jni'
|
||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
||||
|
||||
THIS_IS_FBOBJC = False
|
||||
|
||||
CXX_LIBRARY_WHITELIST = [
|
||||
'//:yoga',
|
||||
'//lib/fb:fbjni',
|
||||
'//java:jni',
|
||||
]
|
||||
|
||||
def csslayout_dep(dep):
|
||||
BASE_COMPILER_FLAGS = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
]
|
||||
|
||||
def yoga_dep(dep):
|
||||
return '//' + dep
|
||||
|
||||
class allow_unsafe_import:
|
@@ -5,9 +5,9 @@
|
||||
# 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.
|
||||
|
||||
include_defs('//CSSLAYOUT_DEFS')
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
UIKIT_CSSLAYOUT_COMPILER_FLAGS = [
|
||||
COMPILER_FLAGS = [
|
||||
'-fobjc-arc',
|
||||
'-Wconditional-uninitialized',
|
||||
'-Wdangling-else',
|
||||
@@ -28,9 +28,8 @@ UIKIT_CSSLAYOUT_COMPILER_FLAGS = [
|
||||
]
|
||||
|
||||
apple_library(
|
||||
name = 'CSSLayoutKit',
|
||||
compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS,
|
||||
tests = [':CSSLayoutKitTests'],
|
||||
name = 'YogaKit',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
srcs = glob(['*.m']),
|
||||
exported_headers = glob(['*.h']),
|
||||
frameworks = [
|
||||
@@ -38,14 +37,14 @@ apple_library(
|
||||
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
||||
],
|
||||
deps = [
|
||||
csslayout_dep(':CSSLayout'),
|
||||
yoga_dep(':yoga'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
apple_test(
|
||||
name = 'CSSLayoutKitTests',
|
||||
compiler_flags = UIKIT_CSSLAYOUT_COMPILER_FLAGS,
|
||||
name = 'YogaKitTests',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
info_plist = 'Tests/Info.plist',
|
||||
srcs = glob(['Tests/**/*.m']),
|
||||
frameworks = [
|
||||
@@ -53,7 +52,7 @@ apple_test(
|
||||
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
|
||||
],
|
||||
deps = [
|
||||
':CSSLayoutKit',
|
||||
':YogaKit',
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
@@ -9,90 +9,90 @@
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "UIView+CSSLayout.h"
|
||||
#import <YogaKit/UIView+Yoga.h>
|
||||
|
||||
@interface CSSLayoutKitTests : XCTestCase
|
||||
@interface YogaKitTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation CSSLayoutKitTests
|
||||
@implementation YogaKitTests
|
||||
|
||||
#ifndef TRAVIS_CI
|
||||
|
||||
- (void)testNodesAreDeallocedWithSingleView
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
XCTAssertEqual(1, CSSNodeGetInstanceCount());
|
||||
[view yg_setFlexBasis:1];
|
||||
XCTAssertEqual(1, YGNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
- (void)testNodesAreDeallocedCascade
|
||||
{
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view css_setFlexBasis:1];
|
||||
[view yg_setFlexBasis:1];
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setFlexBasis:1];
|
||||
[subview yg_setFlexBasis:1];
|
||||
[view addSubview:subview];
|
||||
}
|
||||
XCTAssertEqual(11, CSSNodeGetInstanceCount());
|
||||
XCTAssertEqual(11, YGNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (void)testUsesFlexbox
|
||||
- (void)testUsesYoga
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
XCTAssertFalse([view yg_usesYoga]);
|
||||
|
||||
[view css_setUsesFlexbox:YES];
|
||||
XCTAssertTrue([view css_usesFlexbox]);
|
||||
[view yg_setUsesYoga:YES];
|
||||
XCTAssertTrue([view yg_usesYoga]);
|
||||
|
||||
[view css_setUsesFlexbox:NO];
|
||||
XCTAssertFalse([view css_usesFlexbox]);
|
||||
[view yg_setUsesYoga:NO];
|
||||
XCTAssertFalse([view yg_usesYoga]);
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsAsserts
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
||||
XCTAssertThrows([view css_intrinsicSize]);
|
||||
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
||||
XCTAssertThrows([view yg_intrinsicSize]);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsSmoke
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container css_setAlignItems:CSSAlignFlexStart];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
[container yg_setAlignItems:YGAlignFlexStart];
|
||||
|
||||
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
|
||||
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
longTextLabel.numberOfLines = 1;
|
||||
[longTextLabel css_setUsesFlexbox:YES];
|
||||
[longTextLabel css_setFlexShrink:1];
|
||||
[longTextLabel yg_setUsesYoga:YES];
|
||||
[longTextLabel yg_setFlexShrink:1];
|
||||
[container addSubview:longTextLabel];
|
||||
|
||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[textBadgeView css_setUsesFlexbox:YES];
|
||||
[textBadgeView css_setMargin:3.0 forEdge:CSSEdgeLeft];
|
||||
[textBadgeView css_setWidth:10];
|
||||
[textBadgeView css_setHeight:10];
|
||||
[textBadgeView yg_setUsesYoga:YES];
|
||||
[textBadgeView yg_setMargin:3.0 forEdge:YGEdgeLeft];
|
||||
[textBadgeView yg_setWidth:10];
|
||||
[textBadgeView yg_setHeight:10];
|
||||
[container addSubview:textBadgeView];
|
||||
|
||||
const CGSize containerSize = [container css_intrinsicSize];
|
||||
const CGSize containerSize = [container yg_intrinsicSize];
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
|
||||
}
|
||||
|
||||
@@ -101,17 +101,17 @@
|
||||
const CGSize containerSize = CGSizeMake(320, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview css_setUsesFlexbox:YES];
|
||||
[subview css_setFlexGrow:1];
|
||||
[subview yg_setUsesYoga:YES];
|
||||
[subview yg_setFlexGrow:1];
|
||||
|
||||
[container addSubview:subview];
|
||||
}
|
||||
[container css_applyLayout];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
|
||||
@@ -130,33 +130,33 @@
|
||||
const CGSize containerSize = CGSizeMake(300, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setFlexGrow:1];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setFlexGrow:1];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setFlexGrow:1];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
|
||||
|
||||
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
|
||||
[subview2 css_setIncludeInLayout:NO];
|
||||
[container css_applyLayout];
|
||||
[subview2 yg_setIncludeInLayout:NO];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
|
||||
@@ -170,32 +170,32 @@
|
||||
const CGSize containerSize = CGSizeMake(300, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setFlexGrow:1];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setFlexGrow:1];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setFlexGrow:1];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
[container yg_applyLayout];
|
||||
|
||||
for (UIView *view in container.subviews) {
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
||||
}
|
||||
|
||||
[subview3 css_setIncludeInLayout:NO];
|
||||
[container css_applyLayout];
|
||||
[subview3 yg_setIncludeInLayout:NO];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
||||
@@ -207,65 +207,140 @@
|
||||
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setIncludeInLayout:NO];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setIncludeInLayout:NO];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setIncludeInLayout:YES];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setIncludeInLayout:YES];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
XCTAssertEqual(1, [container css_numberOfChildren]);
|
||||
[container yg_applyLayout];
|
||||
XCTAssertEqual(1, [container yg_numberOfChildren]);
|
||||
|
||||
[subview2 css_setIncludeInLayout:YES];
|
||||
[container css_applyLayout];
|
||||
XCTAssertEqual(2, [container css_numberOfChildren]);
|
||||
[subview2 yg_setIncludeInLayout:YES];
|
||||
[container yg_applyLayout];
|
||||
XCTAssertEqual(2, [container yg_numberOfChildren]);
|
||||
}
|
||||
|
||||
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||
[container css_setUsesFlexbox:YES];
|
||||
[container css_setFlexDirection:CSSFlexDirectionRow];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 css_setUsesFlexbox:YES];
|
||||
[subview1 css_setFlexGrow:1];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 css_setUsesFlexbox:YES];
|
||||
[subview2 css_setFlexGrow:1];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 css_setUsesFlexbox:YES];
|
||||
[subview3 css_setFlexGrow:1];
|
||||
[subview3 css_setIncludeInLayout:NO];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[subview3 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container css_applyLayout];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
|
||||
|
||||
[subview3 css_setIncludeInLayout:YES];
|
||||
[container css_applyLayout];
|
||||
[subview3 yg_setIncludeInLayout:YES];
|
||||
[container yg_applyLayout];
|
||||
for (UIView *view in container.subviews) {
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testyg_isLeafFlag
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertTrue(view.yg_isLeaf);
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view addSubview:subview];
|
||||
}
|
||||
XCTAssertTrue(view.yg_isLeaf);
|
||||
|
||||
[view yg_setUsesYoga:YES];
|
||||
[view yg_setWidth:50.0];
|
||||
XCTAssertTrue(view.yg_isLeaf);
|
||||
|
||||
UIView *const subview = view.subviews[0];
|
||||
[subview yg_setUsesYoga:YES];
|
||||
[subview yg_setWidth:50.0];
|
||||
XCTAssertFalse(view.yg_isLeaf);
|
||||
}
|
||||
|
||||
- (void)testThatWeCorrectlyAttachNestedViews
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionColumn];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setWidth:100];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[subview1 yg_setFlexDirection:YGFlexDirectionColumn];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setWidth:150];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[subview2 yg_setFlexDirection:YGFlexDirectionColumn];
|
||||
[container addSubview:subview2];
|
||||
|
||||
for (UIView *view in @[subview1, subview2]) {
|
||||
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[someView yg_setUsesYoga:YES];
|
||||
[someView yg_setFlexGrow:1];
|
||||
[view addSubview:someView];
|
||||
}
|
||||
[container yg_applyLayout];
|
||||
|
||||
// Add the same amount of new views, reapply layout.
|
||||
for (UIView *view in @[subview1, subview2]) {
|
||||
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[someView yg_setUsesYoga:YES];
|
||||
[someView yg_setFlexGrow:1];
|
||||
[view addSubview:someView];
|
||||
}
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
||||
for (UIView *subview in subview1.subviews) {
|
||||
const CGSize subviewSize = subview.bounds.size;
|
||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize));
|
||||
XCTAssertFalse(isnan(subviewSize.height));
|
||||
XCTAssertFalse(isnan(subviewSize.width));
|
||||
}
|
||||
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
||||
for (UIView *subview in subview2.subviews) {
|
||||
const CGSize subviewSize = subview.bounds.size;
|
||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size));
|
||||
XCTAssertFalse(isnan(subviewSize.height));
|
||||
XCTAssertFalse(isnan(subviewSize.width));
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
77
YogaKit/UIView+Yoga.h
Normal file
77
YogaKit/UIView+Yoga.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <yoga/Yoga.h>
|
||||
|
||||
@interface UIView (Yoga)
|
||||
|
||||
/**
|
||||
The property that decides if we should include this view when calculating layout. Defaults to YES.
|
||||
*/
|
||||
@property (nonatomic, readwrite, assign, setter=yg_setIncludeInLayout:) BOOL yg_includeInLayout;
|
||||
|
||||
/**
|
||||
The property that decides during layout/sizing whether or not yg_* properties should be applied. Defaults to NO.
|
||||
*/
|
||||
@property (nonatomic, readwrite, assign, setter=yg_setUsesYoga:) BOOL yg_usesYoga;
|
||||
|
||||
- (void)yg_setDirection:(YGDirection)direction;
|
||||
- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection;
|
||||
- (void)yg_setJustifyContent:(YGJustify)justifyContent;
|
||||
- (void)yg_setAlignContent:(YGAlign)alignContent;
|
||||
- (void)yg_setAlignItems:(YGAlign)alignItems;
|
||||
- (void)yg_setAlignSelf:(YGAlign)alignSelf;
|
||||
- (void)yg_setPositionType:(YGPositionType)positionType;
|
||||
- (void)yg_setFlexWrap:(YGWrap)flexWrap;
|
||||
|
||||
- (void)yg_setFlexGrow:(CGFloat)flexGrow;
|
||||
- (void)yg_setFlexShrink:(CGFloat)flexShrink;
|
||||
- (void)yg_setFlexBasis:(CGFloat)flexBasis;
|
||||
|
||||
- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge;
|
||||
- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge;
|
||||
- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge;
|
||||
|
||||
- (void)yg_setWidth:(CGFloat)width;
|
||||
- (void)yg_setHeight:(CGFloat)height;
|
||||
- (void)yg_setMinWidth:(CGFloat)minWidth;
|
||||
- (void)yg_setMinHeight:(CGFloat)minHeight;
|
||||
- (void)yg_setMaxWidth:(CGFloat)maxWidth;
|
||||
- (void)yg_setMaxHeight:(CGFloat)maxHeight;
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
- (void)yg_setAspectRatio:(CGFloat)aspectRatio;
|
||||
|
||||
/**
|
||||
Get the resolved direction of this node. This won't be YGDirectionInherit
|
||||
*/
|
||||
- (YGDirection)yg_resolvedDirection;
|
||||
|
||||
/**
|
||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results
|
||||
*/
|
||||
- (void)yg_applyLayout;
|
||||
|
||||
/**
|
||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||
*/
|
||||
- (CGSize)yg_intrinsicSize;
|
||||
|
||||
/**
|
||||
Returns the number of children that are using Flexbox.
|
||||
*/
|
||||
- (NSUInteger)yg_numberOfChildren;
|
||||
|
||||
/**
|
||||
Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout.
|
||||
*/
|
||||
- (BOOL)yg_isLeaf;
|
||||
|
||||
@end
|
397
YogaKit/UIView+Yoga.m
Normal file
397
YogaKit/UIView+Yoga.m
Normal file
@@ -0,0 +1,397 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "UIView+Yoga.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@interface YGNodeBridge : NSObject
|
||||
@property (nonatomic, assign, readonly) YGNodeRef cnode;
|
||||
@end
|
||||
|
||||
@implementation YGNodeBridge
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ([super init]) {
|
||||
_cnode = YGNodeNew();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
YGNodeFree(_cnode);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation UIView (Yoga)
|
||||
|
||||
- (BOOL)yg_usesYoga
|
||||
{
|
||||
NSNumber *usesYoga = objc_getAssociatedObject(self, @selector(yg_usesYoga));
|
||||
return [usesYoga boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)yg_includeInLayout
|
||||
{
|
||||
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(yg_includeInLayout));
|
||||
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)yg_numberOfChildren
|
||||
{
|
||||
return YGNodeGetChildCount([self ygNode]);
|
||||
}
|
||||
|
||||
- (BOOL)yg_isLeaf
|
||||
{
|
||||
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
|
||||
if ([self yg_usesYoga]) {
|
||||
for (UIView *subview in self.subviews) {
|
||||
if ([subview yg_usesYoga] && [subview yg_includeInLayout]) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)yg_setIncludeInLayout:(BOOL)includeInLayout
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
self,
|
||||
@selector(yg_includeInLayout),
|
||||
@(includeInLayout),
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)yg_setUsesYoga:(BOOL)enabled
|
||||
{
|
||||
objc_setAssociatedObject(
|
||||
self,
|
||||
@selector(yg_usesYoga),
|
||||
@(enabled),
|
||||
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)yg_setDirection:(YGDirection)direction
|
||||
{
|
||||
YGNodeStyleSetDirection([self ygNode], direction);
|
||||
}
|
||||
|
||||
- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection
|
||||
{
|
||||
YGNodeStyleSetFlexDirection([self ygNode], flexDirection);
|
||||
}
|
||||
|
||||
- (void)yg_setJustifyContent:(YGJustify)justifyContent
|
||||
{
|
||||
YGNodeStyleSetJustifyContent([self ygNode], justifyContent);
|
||||
}
|
||||
|
||||
- (void)yg_setAlignContent:(YGAlign)alignContent
|
||||
{
|
||||
YGNodeStyleSetAlignContent([self ygNode], alignContent);
|
||||
}
|
||||
|
||||
- (void)yg_setAlignItems:(YGAlign)alignItems
|
||||
{
|
||||
YGNodeStyleSetAlignItems([self ygNode], alignItems);
|
||||
}
|
||||
|
||||
- (void)yg_setAlignSelf:(YGAlign)alignSelf
|
||||
{
|
||||
YGNodeStyleSetAlignSelf([self ygNode], alignSelf);
|
||||
}
|
||||
|
||||
- (void)yg_setPositionType:(YGPositionType)positionType
|
||||
{
|
||||
YGNodeStyleSetPositionType([self ygNode], positionType);
|
||||
}
|
||||
|
||||
- (void)yg_setFlexWrap:(YGWrap)flexWrap
|
||||
{
|
||||
YGNodeStyleSetFlexWrap([self ygNode], flexWrap);
|
||||
}
|
||||
|
||||
- (void)yg_setFlexGrow:(CGFloat)flexGrow
|
||||
{
|
||||
YGNodeStyleSetFlexGrow([self ygNode], flexGrow);
|
||||
}
|
||||
|
||||
- (void)yg_setFlexShrink:(CGFloat)flexShrink
|
||||
{
|
||||
YGNodeStyleSetFlexShrink([self ygNode], flexShrink);
|
||||
}
|
||||
|
||||
- (void)yg_setFlexBasis:(CGFloat)flexBasis
|
||||
{
|
||||
YGNodeStyleSetFlexBasis([self ygNode], flexBasis);
|
||||
}
|
||||
|
||||
- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge
|
||||
{
|
||||
YGNodeStyleSetPosition([self ygNode], edge, position);
|
||||
}
|
||||
|
||||
- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge
|
||||
{
|
||||
YGNodeStyleSetMargin([self ygNode], edge, margin);
|
||||
}
|
||||
|
||||
- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge
|
||||
{
|
||||
YGNodeStyleSetPadding([self ygNode], edge, padding);
|
||||
}
|
||||
|
||||
- (void)yg_setWidth:(CGFloat)width
|
||||
{
|
||||
YGNodeStyleSetWidth([self ygNode], width);
|
||||
}
|
||||
|
||||
- (void)yg_setHeight:(CGFloat)height
|
||||
{
|
||||
YGNodeStyleSetHeight([self ygNode], height);
|
||||
}
|
||||
|
||||
- (void)yg_setMinWidth:(CGFloat)minWidth
|
||||
{
|
||||
YGNodeStyleSetMinWidth([self ygNode], minWidth);
|
||||
}
|
||||
|
||||
- (void)yg_setMinHeight:(CGFloat)minHeight
|
||||
{
|
||||
YGNodeStyleSetMinHeight([self ygNode], minHeight);
|
||||
}
|
||||
|
||||
- (void)yg_setMaxWidth:(CGFloat)maxWidth
|
||||
{
|
||||
YGNodeStyleSetMaxWidth([self ygNode], maxWidth);
|
||||
}
|
||||
|
||||
- (void)yg_setMaxHeight:(CGFloat)maxHeight
|
||||
{
|
||||
YGNodeStyleSetMaxHeight([self ygNode], maxHeight);
|
||||
}
|
||||
|
||||
- (void)yg_setAspectRatio:(CGFloat)aspectRatio
|
||||
{
|
||||
YGNodeStyleSetAspectRatio([self ygNode], aspectRatio);
|
||||
}
|
||||
|
||||
#pragma mark - Layout and Sizing
|
||||
|
||||
- (YGDirection)yg_resolvedDirection
|
||||
{
|
||||
return YGNodeLayoutGetDirection([self ygNode]);
|
||||
}
|
||||
|
||||
- (void)yg_applyLayout
|
||||
{
|
||||
[self calculateLayoutWithSize:self.bounds.size];
|
||||
YGApplyLayoutToViewHierarchy(self);
|
||||
}
|
||||
|
||||
- (CGSize)yg_intrinsicSize
|
||||
{
|
||||
const CGSize constrainedSize = {
|
||||
.width = YGUndefined,
|
||||
.height = YGUndefined,
|
||||
};
|
||||
return [self calculateLayoutWithSize:constrainedSize];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (YGNodeRef)ygNode
|
||||
{
|
||||
YGNodeBridge *node = objc_getAssociatedObject(self, @selector(ygNode));
|
||||
if (!node) {
|
||||
node = [YGNodeBridge new];
|
||||
YGNodeSetContext(node.cnode, (__bridge void *) self);
|
||||
objc_setAssociatedObject(self, @selector(ygNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
return node.cnode;
|
||||
}
|
||||
|
||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||
{
|
||||
NSAssert([NSThread isMainThread], @"YG Layout calculation must be done on main.");
|
||||
NSAssert([self yg_usesYoga], @"YG Layout is not enabled for this view.");
|
||||
|
||||
YGAttachNodesFromViewHierachy(self);
|
||||
|
||||
const YGNodeRef node = [self ygNode];
|
||||
YGNodeCalculateLayout(
|
||||
node,
|
||||
size.width,
|
||||
size.height,
|
||||
YGNodeStyleGetDirection(node));
|
||||
|
||||
return (CGSize) {
|
||||
.width = YGNodeLayoutGetWidth(node),
|
||||
.height = YGNodeLayoutGetHeight(node),
|
||||
};
|
||||
}
|
||||
|
||||
static YGSize YGMeasureView(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode)
|
||||
{
|
||||
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
||||
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
||||
|
||||
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
||||
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||
.width = constrainedWidth,
|
||||
.height = constrainedHeight,
|
||||
}];
|
||||
|
||||
return (YGSize) {
|
||||
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||
};
|
||||
}
|
||||
|
||||
static CGFloat YGSanitizeMeasurement(
|
||||
CGFloat constrainedSize,
|
||||
CGFloat measuredSize,
|
||||
YGMeasureMode measureMode)
|
||||
{
|
||||
CGFloat result;
|
||||
if (measureMode == YGMeasureModeExactly) {
|
||||
result = constrainedSize;
|
||||
} else if (measureMode == YGMeasureModeAtMost) {
|
||||
result = MIN(constrainedSize, measuredSize);
|
||||
} else {
|
||||
result = measuredSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
|
||||
{
|
||||
if (YGNodeGetChildCount(node) != subviews.count) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
for (int i=0; i<subviews.count; i++) {
|
||||
if (YGNodeGetChild(node, i) != subviews[i].ygNode) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static void YGAttachNodesFromViewHierachy(UIView *const view)
|
||||
{
|
||||
const YGNodeRef node = [view ygNode];
|
||||
|
||||
// Only leaf nodes should have a measure function
|
||||
if (view.yg_isLeaf) {
|
||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||
YGRemoveAllChildren(node);
|
||||
} else {
|
||||
YGNodeSetMeasureFunc(node, NULL);
|
||||
|
||||
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||
for (UIView *subview in view.subviews) {
|
||||
if ([subview yg_includeInLayout]) {
|
||||
[subviewsToInclude addObject:subview];
|
||||
}
|
||||
}
|
||||
|
||||
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
||||
YGRemoveAllChildren(node);
|
||||
for (int i=0; i<subviewsToInclude.count; i++) {
|
||||
YGNodeInsertChild(node, [subviewsToInclude[i] ygNode], i);
|
||||
}
|
||||
}
|
||||
|
||||
for (UIView *const subview in subviewsToInclude) {
|
||||
YGAttachNodesFromViewHierachy(subview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void YGRemoveAllChildren(const YGNodeRef node)
|
||||
{
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (YGNodeGetChildCount(node) > 0) {
|
||||
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
static CGFloat YGRoundPixelValue(CGFloat value)
|
||||
{
|
||||
static CGFloat scale;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^(){
|
||||
scale = [UIScreen mainScreen].scale;
|
||||
});
|
||||
|
||||
return round(value * scale) / scale;
|
||||
}
|
||||
|
||||
static void YGApplyLayoutToViewHierarchy(UIView *view)
|
||||
{
|
||||
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||
if (![view yg_includeInLayout]) {
|
||||
return;
|
||||
}
|
||||
|
||||
YGNodeRef node = [view ygNode];
|
||||
const CGPoint topLeft = {
|
||||
YGNodeLayoutGetLeft(node),
|
||||
YGNodeLayoutGetTop(node),
|
||||
};
|
||||
|
||||
const CGPoint bottomRight = {
|
||||
topLeft.x + YGNodeLayoutGetWidth(node),
|
||||
topLeft.y + YGNodeLayoutGetHeight(node),
|
||||
};
|
||||
|
||||
view.frame = (CGRect) {
|
||||
.origin = {
|
||||
.x = YGRoundPixelValue(topLeft.x),
|
||||
.y = YGRoundPixelValue(topLeft.y),
|
||||
},
|
||||
.size = {
|
||||
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
||||
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
||||
},
|
||||
};
|
||||
|
||||
if (!view.yg_isLeaf) {
|
||||
for (NSUInteger i=0; i<view.subviews.count; i++) {
|
||||
YGApplyLayoutToViewHierarchy(view.subviews[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
376
YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj
Normal file
376
YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,376 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
13687D481DF8748400E7C260 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D471DF8748400E7C260 /* main.m */; };
|
||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; };
|
||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; };
|
||||
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
|
||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; };
|
||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; };
|
||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
|
||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; };
|
||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; };
|
||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
|
||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
|
||||
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
|
||||
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
13687D771DF878A000E7C260 /* yoga */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = include/yoga;
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
13687D781DF878C600E7C260 /* YGEnums.h in yoga */,
|
||||
13687D791DF878C600E7C260 /* YGMacros.h in yoga */,
|
||||
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */,
|
||||
);
|
||||
name = yoga;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
13687D7B1DF878CE00E7C260 /* YogaKit */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = include/YogaKit;
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */,
|
||||
);
|
||||
name = YogaKit;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
13687D471DF8748400E7C260 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
13687D491DF8748400E7C260 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
13687D4A1DF8748400E7C260 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
13687D4C1DF8748400E7C260 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
|
||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
|
||||
13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
|
||||
13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
|
||||
13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
|
||||
13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
|
||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+Yoga.h"; sourceTree = "<group>"; };
|
||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+Yoga.m"; sourceTree = "<group>"; };
|
||||
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
13687D401DF8748300E7C260 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */,
|
||||
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
13687D3A1DF8748300E7C260 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D5D1DF8778F00E7C260 /* yoga */,
|
||||
13687D641DF8778F00E7C260 /* YogaKit */,
|
||||
13687D451DF8748400E7C260 /* YogaKitSample */,
|
||||
13687D441DF8748400E7C260 /* Products */,
|
||||
13687D831DF87D1E00E7C260 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D441DF8748400E7C260 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D431DF8748400E7C260 /* YogaKitSample.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D451DF8748400E7C260 /* YogaKitSample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D491DF8748400E7C260 /* AppDelegate.h */,
|
||||
13687D4A1DF8748400E7C260 /* AppDelegate.m */,
|
||||
13687D4C1DF8748400E7C260 /* ViewController.h */,
|
||||
13687D4D1DF8748400E7C260 /* ViewController.m */,
|
||||
13687D521DF8748400E7C260 /* Assets.xcassets */,
|
||||
13687D571DF8748400E7C260 /* Info.plist */,
|
||||
13687D461DF8748400E7C260 /* Supporting Files */,
|
||||
);
|
||||
path = YogaKitSample;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D461DF8748400E7C260 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D471DF8748400E7C260 /* main.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D5D1DF8778F00E7C260 /* yoga */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D5E1DF8778F00E7C260 /* YGEnums.h */,
|
||||
13687D5F1DF8778F00E7C260 /* YGMacros.h */,
|
||||
13687D601DF8778F00E7C260 /* YGNodeList.c */,
|
||||
13687D611DF8778F00E7C260 /* YGNodeList.h */,
|
||||
13687D621DF8778F00E7C260 /* Yoga.c */,
|
||||
13687D631DF8778F00E7C260 /* Yoga.h */,
|
||||
);
|
||||
name = yoga;
|
||||
path = ../../yoga;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D641DF8778F00E7C260 /* YogaKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D691DF8778F00E7C260 /* UIView+Yoga.h */,
|
||||
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */,
|
||||
);
|
||||
name = YogaKit;
|
||||
path = ..;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
13687D831DF87D1E00E7C260 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13687D861DF87D2400E7C260 /* Foundation.framework */,
|
||||
13687D841DF87D1E00E7C260 /* UIKit.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
13687D421DF8748300E7C260 /* YogaKitSample */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
|
||||
buildPhases = (
|
||||
13687D771DF878A000E7C260 /* yoga */,
|
||||
13687D7B1DF878CE00E7C260 /* YogaKit */,
|
||||
13687D3F1DF8748300E7C260 /* Sources */,
|
||||
13687D401DF8748300E7C260 /* Frameworks */,
|
||||
13687D411DF8748300E7C260 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = YogaKitSample;
|
||||
productName = YogaKitSample;
|
||||
productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
13687D3B1DF8748300E7C260 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0810;
|
||||
ORGANIZATIONNAME = facebook;
|
||||
TargetAttributes = {
|
||||
13687D421DF8748300E7C260 = {
|
||||
CreatedOnToolsVersion = 8.1;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 13687D3A1DF8748300E7C260;
|
||||
productRefGroup = 13687D441DF8748400E7C260 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
13687D421DF8748300E7C260 /* YogaKitSample */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
13687D411DF8748300E7C260 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
13687D3F1DF8748300E7C260 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */,
|
||||
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
|
||||
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
|
||||
13687D821DF87CF200E7C260 /* Yoga.c in Sources */,
|
||||
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */,
|
||||
13687D481DF8748400E7C260 /* main.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
13687D581DF8748400E7C260 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
13687D591DF8748400E7C260 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVES = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
13687D5B1DF8748400E7C260 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = YogaKitSample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
13687D5C1DF8748400E7C260 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = YogaKitSample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
13687D581DF8748400E7C260 /* Debug */,
|
||||
13687D591DF8748400E7C260 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
13687D5B1DF8748400E7C260 /* Debug */,
|
||||
13687D5C1DF8748400E7C260 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 13687D3B1DF8748300E7C260 /* Project object */;
|
||||
}
|
7
YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:YogaKitSample.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
16
YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h
Normal file
16
YogaKit/YogaKitSample/YogaKitSample/AppDelegate.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
||||
|
27
YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m
Normal file
27
YogaKit/YogaKitSample/YogaKitSample/AppDelegate.m
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.rootViewController = [ViewController new];
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
36
YogaKit/YogaKitSample/YogaKitSample/Info.plist
Normal file
36
YogaKit/YogaKitSample/YogaKitSample/Info.plist
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string></string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
15
YogaKit/YogaKitSample/YogaKitSample/ViewController.h
Normal file
15
YogaKit/YogaKitSample/YogaKitSample/ViewController.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
|
||||
|
||||
@end
|
||||
|
60
YogaKit/YogaKitSample/YogaKitSample/ViewController.m
Normal file
60
YogaKit/YogaKitSample/YogaKitSample/ViewController.m
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "ViewController.h"
|
||||
|
||||
#import <YogaKit/UIView+Yoga.h>
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
UIView *root = self.view;
|
||||
root.backgroundColor = [UIColor redColor];
|
||||
[root yg_setUsesYoga:YES];
|
||||
[root yg_setWidth:self.view.bounds.size.width];
|
||||
[root yg_setHeight:self.view.bounds.size.height];
|
||||
[root yg_setAlignItems:YGAlignCenter];
|
||||
[root yg_setJustifyContent:YGJustifyCenter];
|
||||
|
||||
UIView *child1 = [UIView new];
|
||||
child1.backgroundColor = [UIColor blueColor];
|
||||
[child1 yg_setUsesYoga:YES];
|
||||
[child1 yg_setWidth:100];
|
||||
[child1 yg_setHeight:100];
|
||||
|
||||
UIView *child2 = [UIView new];
|
||||
child2.backgroundColor = [UIColor greenColor];
|
||||
child2.frame = (CGRect) {
|
||||
.size = {
|
||||
.width = 200,
|
||||
.height = 100,
|
||||
}
|
||||
};
|
||||
|
||||
UIView *child3 = [UIView new];
|
||||
child3.backgroundColor = [UIColor yellowColor];
|
||||
child3.frame = (CGRect) {
|
||||
.size = {
|
||||
.width = 100,
|
||||
.height = 100,
|
||||
}
|
||||
};
|
||||
|
||||
[child2 addSubview:child3];
|
||||
[root addSubview:child1];
|
||||
[root addSubview:child2];
|
||||
[root yg_applyLayout];
|
||||
}
|
||||
|
||||
|
||||
@end
|
16
YogaKit/YogaKitSample/YogaKitSample/main.m
Normal file
16
YogaKit/YogaKitSample/YogaKitSample/main.m
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
# 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.
|
||||
|
||||
include_defs('//CSSLAYOUT_DEFS')
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
cxx_binary(
|
||||
name = 'benchmark',
|
||||
@@ -21,7 +21,7 @@ cxx_binary(
|
||||
'-std=c11',
|
||||
],
|
||||
deps = [
|
||||
csslayout_dep(':CSSLayout'),
|
||||
yoga_dep(':yoga'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
@@ -1,118 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "CSSBenchmark.h"
|
||||
|
||||
#include <CSSLayout/CSSLayout.h>
|
||||
|
||||
static CSSSize _measure(CSSNodeRef node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode) {
|
||||
return (CSSSize){
|
||||
.width = widthMode == CSSMeasureModeUndefined ? 10 : width,
|
||||
.height = heightMode == CSSMeasureModeUndefined ? 10 : width,
|
||||
};
|
||||
}
|
||||
|
||||
CSS_BENCHMARKS({
|
||||
|
||||
CSS_BENCHMARK("Stack with flex", {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetWidth(root, 100);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeSetMeasureFunc(child, _measure);
|
||||
CSSNodeStyleSetFlex(child, 1);
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
}
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
CSSNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
CSS_BENCHMARK("Align stretch in undefined axis", {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeStyleSetHeight(child, 20);
|
||||
CSSNodeSetMeasureFunc(child, _measure);
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
}
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
CSSNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
CSS_BENCHMARK("Nested flex", {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeStyleSetFlex(child, 1);
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
|
||||
for (uint32_t ii = 0; ii < 10; ii++) {
|
||||
const CSSNodeRef grandChild = CSSNodeNew();
|
||||
CSSNodeSetMeasureFunc(grandChild, _measure);
|
||||
CSSNodeStyleSetFlex(grandChild, 1);
|
||||
CSSNodeInsertChild(child, grandChild, 0);
|
||||
}
|
||||
}
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
CSSNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
CSS_BENCHMARK("Huge nested layout", {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const CSSNodeRef child = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexGrow(child, 1);
|
||||
CSSNodeStyleSetWidth(child, 10);
|
||||
CSSNodeStyleSetHeight(child, 10);
|
||||
CSSNodeInsertChild(root, child, 0);
|
||||
|
||||
for (uint32_t ii = 0; ii < 10; ii++) {
|
||||
const CSSNodeRef grandChild = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(grandChild, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetFlexGrow(grandChild, 1);
|
||||
CSSNodeStyleSetWidth(grandChild, 10);
|
||||
CSSNodeStyleSetHeight(grandChild, 10);
|
||||
CSSNodeInsertChild(child, grandChild, 0);
|
||||
|
||||
for (uint32_t iii = 0; iii < 10; iii++) {
|
||||
const CSSNodeRef grandGrandChild = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexGrow(grandGrandChild, 1);
|
||||
CSSNodeStyleSetWidth(grandGrandChild, 10);
|
||||
CSSNodeStyleSetHeight(grandGrandChild, 10);
|
||||
CSSNodeInsertChild(grandChild, grandGrandChild, 0);
|
||||
|
||||
for (uint32_t iii = 0; iii < 10; iii++) {
|
||||
const CSSNodeRef grandGrandGrandChild = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(grandGrandGrandChild, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
||||
CSSNodeStyleSetWidth(grandGrandGrandChild, 10);
|
||||
CSSNodeStyleSetHeight(grandGrandGrandChild, 10);
|
||||
CSSNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
CSSNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
});
|
118
benchmark/YGBenchmark.c
Normal file
118
benchmark/YGBenchmark.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "YGBenchmark.h"
|
||||
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
static YGSize _measure(YGNodeRef node,
|
||||
float width,
|
||||
YGMeasureMode widthMode,
|
||||
float height,
|
||||
YGMeasureMode heightMode) {
|
||||
return (YGSize){
|
||||
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
|
||||
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
|
||||
};
|
||||
}
|
||||
|
||||
YGBENCHMARKS({
|
||||
|
||||
YGBENCHMARK("Stack with flex", {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidth(root, 100);
|
||||
YGNodeStyleSetHeight(root, 100);
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const YGNodeRef child = YGNodeNew();
|
||||
YGNodeSetMeasureFunc(child, _measure);
|
||||
YGNodeStyleSetFlex(child, 1);
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
}
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
YGNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
YGBENCHMARK("Align stretch in undefined axis", {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const YGNodeRef child = YGNodeNew();
|
||||
YGNodeStyleSetHeight(child, 20);
|
||||
YGNodeSetMeasureFunc(child, _measure);
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
}
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
YGNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
YGBENCHMARK("Nested flex", {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const YGNodeRef child = YGNodeNew();
|
||||
YGNodeStyleSetFlex(child, 1);
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
|
||||
for (uint32_t ii = 0; ii < 10; ii++) {
|
||||
const YGNodeRef grandChild = YGNodeNew();
|
||||
YGNodeSetMeasureFunc(grandChild, _measure);
|
||||
YGNodeStyleSetFlex(grandChild, 1);
|
||||
YGNodeInsertChild(child, grandChild, 0);
|
||||
}
|
||||
}
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
YGNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
YGBENCHMARK("Huge nested layout", {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
|
||||
for (uint32_t i = 0; i < 10; i++) {
|
||||
const YGNodeRef child = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(child, 1);
|
||||
YGNodeStyleSetWidth(child, 10);
|
||||
YGNodeStyleSetHeight(child, 10);
|
||||
YGNodeInsertChild(root, child, 0);
|
||||
|
||||
for (uint32_t ii = 0; ii < 10; ii++) {
|
||||
const YGNodeRef grandChild = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);
|
||||
YGNodeStyleSetFlexGrow(grandChild, 1);
|
||||
YGNodeStyleSetWidth(grandChild, 10);
|
||||
YGNodeStyleSetHeight(grandChild, 10);
|
||||
YGNodeInsertChild(child, grandChild, 0);
|
||||
|
||||
for (uint32_t iii = 0; iii < 10; iii++) {
|
||||
const YGNodeRef grandGrandChild = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(grandGrandChild, 1);
|
||||
YGNodeStyleSetWidth(grandGrandChild, 10);
|
||||
YGNodeStyleSetHeight(grandGrandChild, 10);
|
||||
YGNodeInsertChild(grandChild, grandGrandChild, 0);
|
||||
|
||||
for (uint32_t iii = 0; iii < 10; iii++) {
|
||||
const YGNodeRef grandGrandGrandChild = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
|
||||
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
||||
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
|
||||
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
|
||||
YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
YGNodeFreeRecursive(root);
|
||||
});
|
||||
|
||||
});
|
@@ -17,7 +17,7 @@
|
||||
|
||||
#define NUM_REPETITIONS 1000
|
||||
|
||||
#define CSS_BENCHMARKS(BLOCK) \
|
||||
#define YGBENCHMARKS(BLOCK) \
|
||||
int main(int argc, char const *argv[]) { \
|
||||
clock_t __start; \
|
||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||
@@ -25,7 +25,7 @@
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define CSS_BENCHMARK(NAME, BLOCK) \
|
||||
#define YGBENCHMARK(NAME, BLOCK) \
|
||||
__start = clock(); \
|
||||
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
||||
{ BLOCK } \
|
6
csharp/.gitignore
vendored
6
csharp/.gitignore
vendored
@@ -34,6 +34,10 @@ bld/
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
tests/Facebook.Yoga/NUnit-[0-9\.]*/
|
||||
tests/Facebook.Yoga/YogaTest.dll
|
||||
tests/Facebook.Yoga/YogaTest.dll.mdb
|
||||
tests/Facebook.Yoga/libyoga.dylib
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
@@ -262,4 +266,4 @@ paket-files/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyc
|
||||
|
@@ -34,6 +34,10 @@ bld/
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
tests/Facebook.Yoga/NUnit-[0-9\.]*/
|
||||
tests/Facebook.Yoga/YogaTest.dll
|
||||
tests/Facebook.Yoga/YogaTest.dll.mdb
|
||||
tests/Facebook.Yoga/libyoga.dylib
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
@@ -262,4 +266,4 @@ paket-files/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyc
|
||||
|
51
csharp/BUCK
51
csharp/BUCK
@@ -5,16 +5,59 @@
|
||||
# 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.
|
||||
|
||||
include_defs('//YOGA_DEFS')
|
||||
|
||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
|
||||
|
||||
csharp_library(
|
||||
name = 'csslibnet46',
|
||||
dll_name = 'Facebook.CSSLayout.dll',
|
||||
name = 'yogalibnet46',
|
||||
dll_name = 'Facebook.Yoga.dll',
|
||||
framework_ver = 'net46',
|
||||
srcs = glob(['**/*.cs']),
|
||||
)
|
||||
|
||||
csharp_library(
|
||||
name = 'csslibnet45',
|
||||
dll_name = 'Facebook.CSSLayout.dll',
|
||||
name = 'yogalibnet45',
|
||||
dll_name = 'Facebook.Yoga.dll',
|
||||
framework_ver = 'net45',
|
||||
srcs = glob(['**/*.cs']),
|
||||
)
|
||||
|
||||
cxx_library(
|
||||
name = 'yoganet',
|
||||
soname = 'libyoga.$(ext)',
|
||||
srcs = glob(['Yoga/YGInterop.cpp']),
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
link_style = 'static',
|
||||
link_whole = True,
|
||||
deps = [yoga_dep(':yoga')],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
with allow_unsafe_import():
|
||||
import os
|
||||
|
||||
if os.path.isdir('/Applications/Xcode.app'):
|
||||
yoganet_ios_srcs = []
|
||||
for arch in ['iphonesimulator-x86_64', 'iphoneos-arm64', 'iphoneos-armv7']:
|
||||
name = 'yoganet-' + arch
|
||||
yoganet_ios_srcs.append(':' + name)
|
||||
genrule(
|
||||
name = name,
|
||||
srcs = [
|
||||
yoga_dep(':yoga#%s,static' % arch),
|
||||
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
|
||||
yoga_dep('csharp:yoganet#%s,static' % arch),
|
||||
],
|
||||
out = 'libyoga-%s.a' % arch,
|
||||
cmd = 'libtool -static -o $OUT $SRCS',
|
||||
visibility = [yoga_dep('csharp:yoganet-ios')],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = 'yoganet-ios',
|
||||
srcs = yoganet_ios_srcs,
|
||||
out = 'libyoga.a',
|
||||
cmd = 'lipo $SRCS -create -output $OUT',
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public enum CSSDirection
|
||||
{
|
||||
Inherit,
|
||||
LTR,
|
||||
RTL,
|
||||
[System.Obsolete("Use LTR instead")]
|
||||
LeftToRight = LTR,
|
||||
[System.Obsolete("Use RTL instead")]
|
||||
RightToLeft = RTL,
|
||||
}
|
||||
}
|
@@ -1,584 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public partial class CSSNode : IEnumerable<CSSNode>
|
||||
{
|
||||
private IntPtr _cssNode;
|
||||
private WeakReference _parent;
|
||||
private List<CSSNode> _children;
|
||||
private MeasureFunction _measureFunction;
|
||||
private CSSMeasureFunc _cssMeasureFunc;
|
||||
private object _data;
|
||||
|
||||
public CSSNode()
|
||||
{
|
||||
CSSLogger.Initialize();
|
||||
|
||||
_cssNode = Native.CSSNodeNew();
|
||||
if (_cssNode == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
~CSSNode()
|
||||
{
|
||||
Native.CSSNodeFree(_cssNode);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_measureFunction = null;
|
||||
_data = null;
|
||||
|
||||
Native.CSSNodeReset(_cssNode);
|
||||
}
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeIsDirty(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void MarkDirty()
|
||||
{
|
||||
Native.CSSNodeMarkDirty(_cssNode);
|
||||
}
|
||||
|
||||
public bool HasNewLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeGetHasNewLayout(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkHasNewLayout()
|
||||
{
|
||||
Native.CSSNodeSetHasNewLayout(_cssNode, true);
|
||||
}
|
||||
|
||||
public CSSNode Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parent != null ? _parent.Target as CSSNode : null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMeasureDefined
|
||||
{
|
||||
get
|
||||
{
|
||||
return _measureFunction != null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyStyle(CSSNode srcNode)
|
||||
{
|
||||
Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode);
|
||||
}
|
||||
|
||||
public CSSDirection StyleDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetDirection(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetDirection(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSFlexDirection FlexDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetFlexDirection(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlexDirection(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSJustify JustifyContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetJustifyContent(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetJustifyContent(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSAlign AlignItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetAlignItems(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetAlignItems(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSAlign AlignSelf
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetAlignSelf(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetAlignSelf(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSAlign AlignContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetAlignContent(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetAlignContent(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSPositionType PositionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetPositionType(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetPositionType(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSWrap Wrap
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetFlexWrap(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlexWrap(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float Flex
|
||||
{
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlex(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexGrow
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetFlexGrow(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlexGrow(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexShrink
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetFlexShrink(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlexShrink(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexBasis
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetFlexBasis(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetFlexBasis(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetMargin(CSSEdge edge)
|
||||
{
|
||||
return Native.CSSNodeStyleGetMargin(_cssNode, edge);
|
||||
}
|
||||
|
||||
public void SetMargin(CSSEdge edge, float value)
|
||||
{
|
||||
Native.CSSNodeStyleSetMargin(_cssNode, edge, value);
|
||||
}
|
||||
|
||||
public float GetPadding(CSSEdge edge)
|
||||
{
|
||||
return Native.CSSNodeStyleGetPadding(_cssNode, edge);
|
||||
}
|
||||
|
||||
public void SetPadding(CSSEdge edge, float padding)
|
||||
{
|
||||
Native.CSSNodeStyleSetPadding(_cssNode, edge, padding);
|
||||
}
|
||||
|
||||
public float GetBorder(CSSEdge edge)
|
||||
{
|
||||
return Native.CSSNodeStyleGetBorder(_cssNode, edge);
|
||||
}
|
||||
|
||||
public void SetBorder(CSSEdge edge, float border)
|
||||
{
|
||||
Native.CSSNodeStyleSetBorder(_cssNode, edge, border);
|
||||
}
|
||||
|
||||
public float GetPosition(CSSEdge edge)
|
||||
{
|
||||
return Native.CSSNodeStyleGetPosition(_cssNode, edge);
|
||||
}
|
||||
|
||||
public void SetPosition(CSSEdge edge, float position)
|
||||
{
|
||||
Native.CSSNodeStyleSetPosition(_cssNode, edge, position);
|
||||
}
|
||||
|
||||
public float StyleWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetWidth(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetWidth(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetHeight(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetHeight(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleMaxWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetMaxWidth(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetMaxWidth(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleMaxHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetMaxHeight(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetMaxHeight(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleMinWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetMinWidth(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetMinWidth(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleMinHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetMinHeight(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetMinHeight(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleAspectRatio
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetAspectRatio(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetAspectRatio(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutX
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeLayoutGetLeft(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutY
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeLayoutGetTop(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeLayoutGetWidth(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeLayoutGetHeight(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSDirection LayoutDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeLayoutGetDirection(_cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
public CSSOverflow Overflow
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.CSSNodeStyleGetOverflow(_cssNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.CSSNodeStyleSetOverflow(_cssNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public object Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CSSNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _children[index];
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _children != null ? _children.Count : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkLayoutSeen()
|
||||
{
|
||||
Native.CSSNodeSetHasNewLayout(_cssNode, false);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void Insert(int index, CSSNode node)
|
||||
{
|
||||
if (_children == null)
|
||||
{
|
||||
_children = new List<CSSNode>(4);
|
||||
}
|
||||
_children.Insert(index, node);
|
||||
node._parent = new WeakReference(this);
|
||||
Native.CSSNodeInsertChild(_cssNode, node._cssNode, (uint)index);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
var child = _children[index];
|
||||
child._parent = null;
|
||||
_children.RemoveAt(index);
|
||||
Native.CSSNodeRemoveChild(_cssNode, child._cssNode);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_children != null)
|
||||
{
|
||||
while (_children.Count > 0)
|
||||
{
|
||||
RemoveAt(_children.Count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int IndexOf(CSSNode node)
|
||||
{
|
||||
return _children != null ? _children.IndexOf(node) : -1;
|
||||
}
|
||||
|
||||
public void SetMeasureFunction(MeasureFunction measureFunction)
|
||||
{
|
||||
_measureFunction = measureFunction;
|
||||
_cssMeasureFunc = measureFunction != null ? MeasureInternal : (CSSMeasureFunc)null;
|
||||
Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc);
|
||||
}
|
||||
|
||||
public void CalculateLayout()
|
||||
{
|
||||
Native.CSSNodeCalculateLayout(
|
||||
_cssNode,
|
||||
CSSConstants.Undefined,
|
||||
CSSConstants.Undefined,
|
||||
Native.CSSNodeStyleGetDirection(_cssNode));
|
||||
}
|
||||
|
||||
private CSSSize MeasureInternal(
|
||||
IntPtr node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode)
|
||||
{
|
||||
if (_measureFunction == null)
|
||||
{
|
||||
throw new InvalidOperationException("Measure function is not defined.");
|
||||
}
|
||||
|
||||
long output = _measureFunction(this, width, widthMode, height, heightMode);
|
||||
return new CSSSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) };
|
||||
}
|
||||
|
||||
public string Print(CSSPrintOptions options =
|
||||
CSSPrintOptions.Layout|CSSPrintOptions.Style|CSSPrintOptions.Children)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
CSSLogger.Func orig = CSSLogger.Logger;
|
||||
CSSLogger.Logger = (level, message) => {sb.Append(message);};
|
||||
Native.CSSNodePrint(_cssNode, options);
|
||||
CSSLogger.Logger = orig;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public IEnumerator<CSSNode> GetEnumerator()
|
||||
{
|
||||
return _children != null ? ((IEnumerable<CSSNode>)_children).GetEnumerator() :
|
||||
System.Linq.Enumerable.Empty<CSSNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _children != null ? ((IEnumerable<CSSNode>)_children).GetEnumerator() :
|
||||
System.Linq.Enumerable.Empty<CSSNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
public static int GetInstanceCount()
|
||||
{
|
||||
return Native.CSSNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
public static void SetExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
bool enabled)
|
||||
{
|
||||
Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled);
|
||||
}
|
||||
|
||||
public static bool IsExperimentalFeatureEnabled(CSSExperimentalFeature feature)
|
||||
{
|
||||
return Native.CSSLayoutIsExperimentalFeatureEnabled(feature);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
public class MeasureOutput
|
||||
{
|
||||
public static long Make(double width, double height)
|
||||
{
|
||||
return Make((int) width, (int) height);
|
||||
}
|
||||
|
||||
public static long Make(int width, int height)
|
||||
{
|
||||
return (long)(((ulong) width) << 32 | ((uint) height));
|
||||
}
|
||||
|
||||
public static int GetWidth(long measureOutput)
|
||||
{
|
||||
return (int) (0xFFFFFFFF & (measureOutput >> 32));
|
||||
}
|
||||
|
||||
public static int GetHeight(long measureOutput)
|
||||
{
|
||||
return (int) (0xFFFFFFFF & measureOutput);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,286 +0,0 @@
|
||||
/**
|
||||
* 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.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
internal static class Native
|
||||
{
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
private const string DllName = "__Internal";
|
||||
#else
|
||||
private const string DllName = "CSSLayout";
|
||||
#endif
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSInteropSetLogger(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] CSSLogger.Func func);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr CSSNodeNew();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeInit(IntPtr cssNode);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeFree(IntPtr cssNode);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeReset(IntPtr cssNode);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern int CSSNodeGetInstanceCount();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSLayoutSetExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature,
|
||||
bool enabled);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern bool CSSLayoutIsExperimentalFeatureEnabled(
|
||||
CSSExperimentalFeature feature);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeRemoveChild(IntPtr node, IntPtr child);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr CSSNodeGetChild(IntPtr node, uint index);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern uint CSSNodeChildCount(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeCalculateLayout(IntPtr node,
|
||||
float availableWidth,
|
||||
float availableHeight,
|
||||
CSSDirection parentDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeMarkDirty(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool CSSNodeIsDirty(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodePrint(IntPtr node, CSSPrintOptions options);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool CSSValueIsUndefined(float value);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
|
||||
|
||||
#region CSS_NODE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeSetContext(IntPtr node, IntPtr context);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr CSSNodeGetContext(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeSetMeasureFunc(
|
||||
IntPtr node,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] CSSMeasureFunc measureFunc);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
public static extern CSSMeasureFunc CSSNodeGetMeasureFunc(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool CSSNodeGetHasNewLayout(IntPtr node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CSS_NODE_STYLE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetDirection(IntPtr node, CSSDirection direction);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSDirection CSSNodeStyleGetDirection(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, CSSFlexDirection flexDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, CSSJustify justifyContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSJustify CSSNodeStyleGetJustifyContent(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetAlignContent(IntPtr node, CSSAlign alignContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSAlign CSSNodeStyleGetAlignContent(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetAlignItems(IntPtr node, CSSAlign alignItems);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSAlign CSSNodeStyleGetAlignItems(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, CSSAlign alignSelf);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSAlign CSSNodeStyleGetAlignSelf(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetPositionType(IntPtr node, CSSPositionType positionType);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSPositionType CSSNodeStyleGetPositionType(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, CSSWrap flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSWrap CSSNodeStyleGetFlexWrap(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetOverflow(IntPtr node, CSSOverflow flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSOverflow CSSNodeStyleGetOverflow(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetFlexGrow(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetFlexShrink(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetFlexBasis(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetWidth(IntPtr node, float width);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetHeight(IntPtr node, float height);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetMinWidth(IntPtr node, float minWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetMinWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetMinHeight(IntPtr node, float minHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetMinHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetMaxWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetMaxHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetAspectRatio(IntPtr node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CSS_NODE_STYLE_EDGE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetPosition(IntPtr node, CSSEdge edge, float position);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetPosition(IntPtr node, CSSEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetMargin(IntPtr node, CSSEdge edge, float margin);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetMargin(IntPtr node, CSSEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetPadding(IntPtr node, CSSEdge edge, float padding);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetPadding(IntPtr node, CSSEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void CSSNodeStyleSetBorder(IntPtr node, CSSEdge edge, float border);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeStyleGetBorder(IntPtr node, CSSEdge edge);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CSS_NODE_LAYOUT_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetLeft(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetTop(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetRight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetBottom(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float CSSNodeLayoutGetHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern CSSDirection CSSNodeLayoutGetDirection(IntPtr node);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSSLayout", "CSSLayout\CSSLayout.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.CSSLayout", "Facebook.CSSLayout\Facebook.CSSLayout.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}"
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
@@ -8,7 +8,7 @@
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>75bb7605-e54b-4ede-8f5a-ff1f24464236</ProjectGuid>
|
||||
<RootNamespace>Facebook.CSSLayout</RootNamespace>
|
||||
<RootNamespace>Facebook.Yoga</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
@@ -7,12 +7,12 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public delegate long MeasureFunction(
|
||||
CSSNode node,
|
||||
public delegate YogaSize MeasureFunction(
|
||||
YogaNode node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode);
|
||||
YogaMeasureMode heightMode);
|
||||
}
|
19
csharp/Facebook.Yoga/MeasureOutput.cs
Normal file
19
csharp/Facebook.Yoga/MeasureOutput.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public class MeasureOutput
|
||||
{
|
||||
public static YogaSize Make(float width, float height)
|
||||
{
|
||||
return new YogaSize { width = width, height = height};
|
||||
}
|
||||
}
|
||||
}
|
293
csharp/Facebook.Yoga/Native.cs
Normal file
293
csharp/Facebook.Yoga/Native.cs
Normal file
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* 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.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
internal static class Native
|
||||
{
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
||||
private const string DllName = "__Internal";
|
||||
#else
|
||||
private const string DllName = "yoga";
|
||||
#endif
|
||||
|
||||
internal class YGNodeHandle : SafeHandle
|
||||
{
|
||||
private YGNodeHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
Native.YGNodeFree(this.handle);
|
||||
GC.KeepAlive(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGInteropSetLogger(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YGNodeHandle YGNodeNew();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeFree(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeReset(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern int YGNodeGetInstanceCount();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGSetExperimentalFeatureEnabled(
|
||||
YogaExperimentalFeature feature,
|
||||
bool enabled);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern bool YGIsExperimentalFeatureEnabled(
|
||||
YogaExperimentalFeature feature);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeInsertChild(YGNodeHandle node, YGNodeHandle child, uint index);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeCalculateLayout(YGNodeHandle node,
|
||||
float availableWidth,
|
||||
float availableHeight,
|
||||
YogaDirection parentDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeMarkDirty(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGNodeIsDirty(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodePrint(YGNodeHandle node, YogaPrintOptions options);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGValueIsUndefined(float value);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode);
|
||||
|
||||
#region YG_NODE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeSetMeasureFunc(
|
||||
YGNodeHandle node,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
public static extern YogaMeasureFunc YGNodeGetMeasureFunc(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeSetHasNewLayout(YGNodeHandle node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_STYLE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaDirection YGNodeStyleGetDirection(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetJustifyContent(YGNodeHandle node, YogaJustify justifyContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaJustify YGNodeStyleGetJustifyContent(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignContent(YGNodeHandle node, YogaAlign alignContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignContent(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignItems(YGNodeHandle node, YogaAlign alignItems);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignItems(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignSelf(YGNodeHandle node, YogaAlign alignSelf);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignSelf(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPositionType(YGNodeHandle node, YogaPositionType positionType);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaPositionType YGNodeStyleGetPositionType(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexWrap(YGNodeHandle node, YogaWrap flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaWrap YGNodeStyleGetFlexWrap(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetOverflow(YGNodeHandle node, YogaOverflow flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaOverflow YGNodeStyleGetOverflow(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlex(YGNodeHandle node, float flex);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexGrow(YGNodeHandle node, float flexGrow);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexGrow(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexShrink(YGNodeHandle node, float flexShrink);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexShrink(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexBasis(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetWidth(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetHeight(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMinWidth(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMinHeight(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMaxWidth(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMaxHeight(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_STYLE_EDGE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_LAYOUT_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetLeft(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetTop(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetRight(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetBottom(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetWidth(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetHeight(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@ using System.Runtime.InteropServices;
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Facebook, Inc.")]
|
||||
[assembly: AssemblyProduct("Facebook.CSSLayout")]
|
||||
[assembly: AssemblyProduct("Facebook.Yoga")]
|
||||
[assembly: AssemblyTrademark("Copyright (c) 2014-present, Facebook, Inc.")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
@@ -7,7 +7,7 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public class Spacing
|
||||
{
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSAlign
|
||||
public enum YogaAlign
|
||||
{
|
||||
Auto,
|
||||
FlexStart,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public static class CSSConstants
|
||||
public static class YogaConstants
|
||||
{
|
||||
public const float Undefined = float.NaN;
|
||||
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSDimension
|
||||
public enum YogaDimension
|
||||
{
|
||||
Width,
|
||||
Height,
|
18
csharp/Facebook.Yoga/YogaDirection.cs
Normal file
18
csharp/Facebook.Yoga/YogaDirection.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum YogaDirection
|
||||
{
|
||||
Inherit,
|
||||
LTR,
|
||||
RTL,
|
||||
}
|
||||
}
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSEdge
|
||||
public enum YogaEdge
|
||||
{
|
||||
Left,
|
||||
Top,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSExperimentalFeature
|
||||
public enum YogaExperimentalFeature
|
||||
{
|
||||
Rounding,
|
||||
WebFlexBasis,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSFlexDirection
|
||||
public enum YogaFlexDirection
|
||||
{
|
||||
Column,
|
||||
ColumnReverse,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSJustify
|
||||
public enum YogaJustify
|
||||
{
|
||||
FlexStart,
|
||||
Center,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSLogLevel
|
||||
public enum YogaLogLevel
|
||||
{
|
||||
Error,
|
||||
Warn,
|
@@ -10,12 +10,12 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
internal static class CSSLogger
|
||||
internal static class YogaLogger
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Func(CSSLogLevel level, string message);
|
||||
public delegate void Func(YogaLogLevel level, string message);
|
||||
|
||||
private static bool _initialized;
|
||||
private static Func _managedLogger = null;
|
||||
@@ -32,12 +32,12 @@ namespace Facebook.CSSLayout
|
||||
Logger(level, message);
|
||||
}
|
||||
|
||||
if (level == CSSLogLevel.Error)
|
||||
if (level == YogaLogLevel.Error)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
};
|
||||
Native.CSSInteropSetLogger(_managedLogger);
|
||||
Native.YGInteropSetLogger(_managedLogger);
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
@@ -10,13 +10,13 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate CSSSize CSSMeasureFunc(
|
||||
IntPtr node,
|
||||
public delegate YogaSize YogaMeasureFunc(
|
||||
IntPtr node,
|
||||
float width,
|
||||
CSSMeasureMode widthMode,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
CSSMeasureMode heightMode);
|
||||
YogaMeasureMode heightMode);
|
||||
}
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSMeasureMode
|
||||
public enum YogaMeasureMode
|
||||
{
|
||||
Undefined,
|
||||
Exactly,
|
@@ -9,20 +9,20 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public partial class CSSNode
|
||||
public partial class YogaNode
|
||||
{
|
||||
public static CSSNode Create(
|
||||
CSSDirection? styleDirection = null,
|
||||
CSSFlexDirection? flexDirection = null,
|
||||
CSSJustify? justifyContent = null,
|
||||
CSSAlign? alignContent = null,
|
||||
CSSAlign? alignItems = null,
|
||||
CSSAlign? alignSelf = null,
|
||||
CSSPositionType? positionType = null,
|
||||
CSSWrap? wrap = null,
|
||||
CSSOverflow? overflow = null,
|
||||
public static YogaNode Create(
|
||||
YogaDirection? styleDirection = null,
|
||||
YogaFlexDirection? flexDirection = null,
|
||||
YogaJustify? justifyContent = null,
|
||||
YogaAlign? alignContent = null,
|
||||
YogaAlign? alignItems = null,
|
||||
YogaAlign? alignSelf = null,
|
||||
YogaPositionType? positionType = null,
|
||||
YogaWrap? wrap = null,
|
||||
YogaOverflow? overflow = null,
|
||||
float? flex = null,
|
||||
float? flexGrow = null,
|
||||
float? flexShrink = null,
|
||||
@@ -31,14 +31,14 @@ namespace Facebook.CSSLayout
|
||||
Spacing margin = null,
|
||||
Spacing padding = null,
|
||||
Spacing border = null,
|
||||
float? styleWidth = null,
|
||||
float? styleHeight = null,
|
||||
float? styleMaxWidth = null,
|
||||
float? styleMaxHeight = null,
|
||||
float? styleMinWidth = null,
|
||||
float? styleMinHeight = null)
|
||||
float? width = null,
|
||||
float? height = null,
|
||||
float? maxWidth = null,
|
||||
float? maxHeight = null,
|
||||
float? minWidth = null,
|
||||
float? minHeight = null)
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
|
||||
if (styleDirection.HasValue)
|
||||
{
|
||||
@@ -109,22 +109,22 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
if (position.Top.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Top, position.Top.Value);
|
||||
node.SetPosition(YogaEdge.Top, position.Top.Value);
|
||||
}
|
||||
|
||||
if (position.Bottom.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Bottom, position.Bottom.Value);
|
||||
node.SetPosition(YogaEdge.Bottom, position.Bottom.Value);
|
||||
}
|
||||
|
||||
if (position.Left.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Left, position.Left.Value);
|
||||
node.SetPosition(YogaEdge.Left, position.Left.Value);
|
||||
}
|
||||
|
||||
if (position.Right.HasValue)
|
||||
{
|
||||
node.SetPosition(CSSEdge.Right, position.Right.Value);
|
||||
node.SetPosition(YogaEdge.Right, position.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,22 +132,22 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
if (margin.Top.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Top, margin.Top.Value);
|
||||
node.SetMargin(YogaEdge.Top, margin.Top.Value);
|
||||
}
|
||||
|
||||
if (margin.Bottom.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value);
|
||||
node.SetMargin(YogaEdge.Bottom, margin.Bottom.Value);
|
||||
}
|
||||
|
||||
if (margin.Left.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Left, margin.Left.Value);
|
||||
node.SetMargin(YogaEdge.Left, margin.Left.Value);
|
||||
}
|
||||
|
||||
if (margin.Right.HasValue)
|
||||
{
|
||||
node.SetMargin(CSSEdge.Right, margin.Right.Value);
|
||||
node.SetMargin(YogaEdge.Right, margin.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,22 +155,22 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
if (padding.Top.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Top, padding.Top.Value);
|
||||
node.SetPadding(YogaEdge.Top, padding.Top.Value);
|
||||
}
|
||||
|
||||
if (padding.Bottom.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value);
|
||||
node.SetPadding(YogaEdge.Bottom, padding.Bottom.Value);
|
||||
}
|
||||
|
||||
if (padding.Left.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Left, padding.Left.Value);
|
||||
node.SetPadding(YogaEdge.Left, padding.Left.Value);
|
||||
}
|
||||
|
||||
if (padding.Right.HasValue)
|
||||
{
|
||||
node.SetPadding(CSSEdge.Right, padding.Right.Value);
|
||||
node.SetPadding(YogaEdge.Right, padding.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,57 +178,56 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
if (border.Top.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Top, border.Top.Value);
|
||||
node.SetBorder(YogaEdge.Top, border.Top.Value);
|
||||
}
|
||||
|
||||
if (border.Bottom.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Bottom, border.Bottom.Value);
|
||||
node.SetBorder(YogaEdge.Bottom, border.Bottom.Value);
|
||||
}
|
||||
|
||||
if (border.Left.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Left, border.Left.Value);
|
||||
node.SetBorder(YogaEdge.Left, border.Left.Value);
|
||||
}
|
||||
|
||||
if (border.Right.HasValue)
|
||||
{
|
||||
node.SetBorder(CSSEdge.Right, border.Right.Value);
|
||||
node.SetBorder(YogaEdge.Right, border.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (styleWidth.HasValue)
|
||||
if (width.HasValue)
|
||||
{
|
||||
node.StyleWidth = styleWidth.Value;
|
||||
node.Width = width.Value;
|
||||
}
|
||||
|
||||
if (styleHeight.HasValue)
|
||||
if (height.HasValue)
|
||||
{
|
||||
node.StyleHeight = styleHeight.Value;
|
||||
node.Height = height.Value;
|
||||
}
|
||||
|
||||
if (styleMinWidth.HasValue)
|
||||
if (minWidth.HasValue)
|
||||
{
|
||||
node.StyleMinWidth = styleMinWidth.Value;
|
||||
node.MinWidth = minWidth.Value;
|
||||
}
|
||||
|
||||
if (styleMinHeight.HasValue)
|
||||
if (minHeight.HasValue)
|
||||
{
|
||||
node.StyleMinHeight = styleMinHeight.Value;
|
||||
node.MinHeight = minHeight.Value;
|
||||
}
|
||||
|
||||
if (styleMaxWidth.HasValue)
|
||||
if (maxWidth.HasValue)
|
||||
{
|
||||
node.StyleMaxWidth = styleMaxWidth.Value;
|
||||
node.MaxWidth = maxWidth.Value;
|
||||
}
|
||||
|
||||
if (styleMaxHeight.HasValue)
|
||||
if (maxHeight.HasValue)
|
||||
{
|
||||
node.StyleMaxHeight = styleMaxHeight.Value;
|
||||
node.MaxHeight = maxHeight.Value;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
578
csharp/Facebook.Yoga/YogaNode.cs
Normal file
578
csharp/Facebook.Yoga/YogaNode.cs
Normal file
@@ -0,0 +1,578 @@
|
||||
/**
|
||||
* 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;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public partial class YogaNode : IEnumerable<YogaNode>
|
||||
{
|
||||
private Native.YGNodeHandle _ygNode;
|
||||
private WeakReference _parent;
|
||||
private List<YogaNode> _children;
|
||||
private MeasureFunction _measureFunction;
|
||||
private YogaMeasureFunc _ygMeasureFunc;
|
||||
private object _data;
|
||||
|
||||
public YogaNode()
|
||||
{
|
||||
YogaLogger.Initialize();
|
||||
|
||||
_ygNode = Native.YGNodeNew();
|
||||
if (_ygNode.IsInvalid)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_measureFunction = null;
|
||||
_data = null;
|
||||
|
||||
Native.YGNodeReset(_ygNode);
|
||||
}
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeIsDirty(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void MarkDirty()
|
||||
{
|
||||
Native.YGNodeMarkDirty(_ygNode);
|
||||
}
|
||||
|
||||
public bool HasNewLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeGetHasNewLayout(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkHasNewLayout()
|
||||
{
|
||||
Native.YGNodeSetHasNewLayout(_ygNode, true);
|
||||
}
|
||||
|
||||
public YogaNode Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parent != null ? _parent.Target as YogaNode : null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMeasureDefined
|
||||
{
|
||||
get
|
||||
{
|
||||
return _measureFunction != null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyStyle(YogaNode srcNode)
|
||||
{
|
||||
Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode);
|
||||
}
|
||||
|
||||
public YogaDirection StyleDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetDirection(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetDirection(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaFlexDirection FlexDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetFlexDirection(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlexDirection(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaJustify JustifyContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetJustifyContent(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetJustifyContent(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaAlign AlignItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetAlignItems(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetAlignItems(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaAlign AlignSelf
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetAlignSelf(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetAlignSelf(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaAlign AlignContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetAlignContent(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetAlignContent(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaPositionType PositionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetPositionType(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetPositionType(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaWrap Wrap
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetFlexWrap(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlexWrap(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float Flex
|
||||
{
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlex(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexGrow
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetFlexGrow(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlexGrow(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexShrink
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetFlexShrink(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlexShrink(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float FlexBasis
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetFlexBasis(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetFlexBasis(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetMargin(YogaEdge edge)
|
||||
{
|
||||
return Native.YGNodeStyleGetMargin(_ygNode, edge);
|
||||
}
|
||||
|
||||
public void SetMargin(YogaEdge edge, float value)
|
||||
{
|
||||
Native.YGNodeStyleSetMargin(_ygNode, edge, value);
|
||||
}
|
||||
|
||||
public float GetPadding(YogaEdge edge)
|
||||
{
|
||||
return Native.YGNodeStyleGetPadding(_ygNode, edge);
|
||||
}
|
||||
|
||||
public void SetPadding(YogaEdge edge, float padding)
|
||||
{
|
||||
Native.YGNodeStyleSetPadding(_ygNode, edge, padding);
|
||||
}
|
||||
|
||||
public float GetBorder(YogaEdge edge)
|
||||
{
|
||||
return Native.YGNodeStyleGetBorder(_ygNode, edge);
|
||||
}
|
||||
|
||||
public void SetBorder(YogaEdge edge, float border)
|
||||
{
|
||||
Native.YGNodeStyleSetBorder(_ygNode, edge, border);
|
||||
}
|
||||
|
||||
public float GetPosition(YogaEdge edge)
|
||||
{
|
||||
return Native.YGNodeStyleGetPosition(_ygNode, edge);
|
||||
}
|
||||
|
||||
public void SetPosition(YogaEdge edge, float position)
|
||||
{
|
||||
Native.YGNodeStyleSetPosition(_ygNode, edge, position);
|
||||
}
|
||||
|
||||
public float Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetWidth(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetWidth(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetHeight(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetHeight(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float MaxWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetMaxWidth(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetMaxWidth(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float MaxHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetMaxHeight(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetMaxHeight(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float MinWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetMinWidth(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetMinWidth(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float MinHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetMinHeight(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetMinHeight(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleAspectRatio
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetAspectRatio(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetAspectRatio(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutX
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeLayoutGetLeft(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutY
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeLayoutGetTop(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeLayoutGetWidth(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public float LayoutHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeLayoutGetHeight(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaDirection LayoutDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeLayoutGetDirection(_ygNode);
|
||||
}
|
||||
}
|
||||
|
||||
public YogaOverflow Overflow
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.YGNodeStyleGetOverflow(_ygNode);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Native.YGNodeStyleSetOverflow(_ygNode, value);
|
||||
}
|
||||
}
|
||||
|
||||
public object Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
}
|
||||
}
|
||||
|
||||
public YogaNode this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _children[index];
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return _children != null ? _children.Count : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkLayoutSeen()
|
||||
{
|
||||
Native.YGNodeSetHasNewLayout(_ygNode, false);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void Insert(int index, YogaNode node)
|
||||
{
|
||||
if (_children == null)
|
||||
{
|
||||
_children = new List<YogaNode>(4);
|
||||
}
|
||||
_children.Insert(index, node);
|
||||
node._parent = new WeakReference(this);
|
||||
Native.YGNodeInsertChild(_ygNode, node._ygNode, (uint)index);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
var child = _children[index];
|
||||
child._parent = null;
|
||||
_children.RemoveAt(index);
|
||||
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_children != null)
|
||||
{
|
||||
while (_children.Count > 0)
|
||||
{
|
||||
RemoveAt(_children.Count-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int IndexOf(YogaNode node)
|
||||
{
|
||||
return _children != null ? _children.IndexOf(node) : -1;
|
||||
}
|
||||
|
||||
public void SetMeasureFunction(MeasureFunction measureFunction)
|
||||
{
|
||||
_measureFunction = measureFunction;
|
||||
_ygMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
|
||||
Native.YGNodeSetMeasureFunc(_ygNode, _ygMeasureFunc);
|
||||
}
|
||||
|
||||
public void CalculateLayout()
|
||||
{
|
||||
Native.YGNodeCalculateLayout(
|
||||
_ygNode,
|
||||
YogaConstants.Undefined,
|
||||
YogaConstants.Undefined,
|
||||
Native.YGNodeStyleGetDirection(_ygNode));
|
||||
}
|
||||
|
||||
private YogaSize MeasureInternal(
|
||||
IntPtr node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode)
|
||||
{
|
||||
if (_measureFunction == null)
|
||||
{
|
||||
throw new InvalidOperationException("Measure function is not defined.");
|
||||
}
|
||||
|
||||
return _measureFunction(this, width, widthMode, height, heightMode);
|
||||
}
|
||||
|
||||
public string Print(YogaPrintOptions options =
|
||||
YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
YogaLogger.Func orig = YogaLogger.Logger;
|
||||
YogaLogger.Logger = (level, message) => {sb.Append(message);};
|
||||
Native.YGNodePrint(_ygNode, options);
|
||||
YogaLogger.Logger = orig;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public IEnumerator<YogaNode> GetEnumerator()
|
||||
{
|
||||
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
||||
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
||||
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
public static int GetInstanceCount()
|
||||
{
|
||||
return Native.YGNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
public static void SetExperimentalFeatureEnabled(
|
||||
YogaExperimentalFeature feature,
|
||||
bool enabled)
|
||||
{
|
||||
Native.YGSetExperimentalFeatureEnabled(feature, enabled);
|
||||
}
|
||||
|
||||
public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
|
||||
{
|
||||
return Native.YGIsExperimentalFeatureEnabled(feature);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSOverflow
|
||||
public enum YogaOverflow
|
||||
{
|
||||
Visible,
|
||||
Hidden,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSPositionType
|
||||
public enum YogaPositionType
|
||||
{
|
||||
Relative,
|
||||
Absolute,
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSPrintOptions
|
||||
public enum YogaPrintOptions
|
||||
{
|
||||
Layout = 1,
|
||||
Style = 2,
|
@@ -9,10 +9,10 @@
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct CSSSize
|
||||
public struct YogaSize
|
||||
{
|
||||
public float width;
|
||||
public float height;
|
@@ -7,9 +7,9 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSWrap
|
||||
public enum YogaWrap
|
||||
{
|
||||
NoWrap,
|
||||
Wrap,
|
@@ -3,7 +3,8 @@
|
||||
"version": "3.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.0"
|
||||
"NETStandard.Library": "1.6.0",
|
||||
"System.Runtime.Handles": "4.3.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
3
csharp/Unity/.gitignore
vendored
Normal file
3
csharp/Unity/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Yoga
|
||||
yoga.dll
|
||||
yoga.unitypackage
|
64
csharp/Unity/pack.sh
Executable file
64
csharp/Unity/pack.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
# 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.
|
||||
|
||||
set -e
|
||||
|
||||
cd "$( dirname "$0" )"
|
||||
|
||||
if [ \! -f yoga.dll ]; then
|
||||
echo "Launch win.bat on Windows and copy yoga.dll to here"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function build {
|
||||
buck build $1
|
||||
echo "$root/`buck targets --show-output $1|tail -1|awk '{print $2}'`"
|
||||
}
|
||||
|
||||
function copy {
|
||||
mkdir -p $3
|
||||
cp $1 $3/$2
|
||||
}
|
||||
|
||||
rm -rf Yoga yoga.unitypackage
|
||||
|
||||
root=`buck root|tail -f`
|
||||
mac=$(build '//csharp:yoganet#default,shared')
|
||||
armv7=$(build '//csharp:yoganet#android-armv7,shared')
|
||||
ios=$(build '//csharp:yoganet-ios')
|
||||
win=yoga.dll
|
||||
|
||||
Unity -quit -batchMode -createProject Yoga
|
||||
|
||||
copy $win ${win##*/} Yoga/Assets/Facebook.Yoga/Plugins/x86_64
|
||||
copy $mac yoga Yoga/Assets/Facebook.Yoga/Plugins/x86_64/yoga.bundle/Contents/MacOS
|
||||
armv7path=Assets/Plugins/Android/libs/armeabi-v7a
|
||||
copy $armv7 ${armv7##*/} Yoga/$armv7path
|
||||
iospath=Assets/Plugins/iOS
|
||||
copy $ios ${ios##*/} Yoga/$iospath
|
||||
libs="$armv7path/${armv7##*/} $iospath/${ios##*/}"
|
||||
|
||||
scripts=Yoga/Assets/Facebook.Yoga/Scripts/Facebook.Yoga
|
||||
mkdir -p $scripts
|
||||
(cd ../Facebook.Yoga; tar cf - *.cs)|tar -C $scripts -xf -
|
||||
|
||||
tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests
|
||||
mkdir -p $tests
|
||||
(cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf -
|
||||
|
||||
function onerror {
|
||||
local xml=Yoga/EditorTestResults.xml
|
||||
if [ -f $xml ]; then cat $xml|grep 'success="False"'; fi
|
||||
}
|
||||
trap onerror EXIT
|
||||
Unity -quit -batchMode -projectPath `pwd`/Yoga -runEditorTests
|
||||
|
||||
pkg="`pwd`/yoga.unitypackage"
|
||||
Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs $pkg
|
||||
|
||||
echo "Success: $pkg"
|
2
csharp/Unity/win.bat
Executable file
2
csharp/Unity/win.bat
Executable file
@@ -0,0 +1,2 @@
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ..\Yoga\Yoga.vcxproj /p:configuration=Release /property:Platform=x64
|
||||
xcopy "..\Yoga\x64\Release\yoga.dll" %~dp0 /s /d /y
|
@@ -7,11 +7,11 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include "CSSInterop.h"
|
||||
#include "YGInterop.h"
|
||||
|
||||
static CSSInteropLoggerFunc gManagedFunc;
|
||||
static YGInteropLoggerFunc gManagedFunc;
|
||||
|
||||
static int unmanagedLogger(CSSLogLevel level, const char *format, va_list args) {
|
||||
static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) {
|
||||
int result = 0;
|
||||
if (gManagedFunc) {
|
||||
char buffer[256];
|
||||
@@ -21,7 +21,7 @@ static int unmanagedLogger(CSSLogLevel level, const char *format, va_list args)
|
||||
return result;
|
||||
}
|
||||
|
||||
void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc) {
|
||||
void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) {
|
||||
gManagedFunc = managedFunc;
|
||||
CSSLayoutSetLogger(&unmanagedLogger);
|
||||
YGSetLogger(&unmanagedLogger);
|
||||
}
|
@@ -9,12 +9,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CSSLayout/CSSLayout.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
CSS_EXTERN_C_BEGIN
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
typedef void (*CSSInteropLoggerFunc)(CSSLogLevel level, const char *message);
|
||||
typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message);
|
||||
|
||||
WIN_EXPORT void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc);
|
||||
WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc);
|
||||
|
||||
CSS_EXTERN_C_END
|
||||
YG_EXTERN_C_END
|
@@ -21,7 +21,8 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>CSSLayout</RootNamespace>
|
||||
<ProjectName>yoga</ProjectName>
|
||||
<RootNamespace>Yoga</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
@@ -87,7 +88,7 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -102,7 +103,7 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -119,7 +120,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -138,7 +139,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -150,17 +151,17 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\CSSLayout\CSSLayout.h" />
|
||||
<ClInclude Include="..\..\CSSLayout\CSSMacros.h" />
|
||||
<ClInclude Include="..\..\CSSLayout\CSSNodeList.h" />
|
||||
<ClInclude Include="CSSInterop.h" />
|
||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
||||
<ClInclude Include="YGInterop.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\CSSLayout\CSSLayout.c" />
|
||||
<ClCompile Include="..\..\CSSLayout\CSSNodeList.c" />
|
||||
<ClCompile Include="CSSInterop.cpp" />
|
||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
||||
<ClCompile Include="YGInterop.cpp" />
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@@ -180,4 +181,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@@ -21,16 +21,16 @@
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\CSSLayout\CSSLayout.h">
|
||||
<ClInclude Include="..\..\yoga\Yoga.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\CSSLayout\CSSMacros.h">
|
||||
<ClInclude Include="..\..\yoga\YGMacros.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\CSSLayout\CSSNodeList.h">
|
||||
<ClInclude Include="..\..\yoga\YGNodeList.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CSSInterop.h">
|
||||
<ClInclude Include="YGInterop.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@@ -41,14 +41,14 @@
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CSSLayout\CSSLayout.c">
|
||||
<ClCompile Include="..\..\yoga\Yoga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\CSSLayout\CSSNodeList.c">
|
||||
<ClCompile Include="..\..\yoga\YGNodeList.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CSSInterop.cpp">
|
||||
<ClCompile Include="YGInterop.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// CSSLayout.pch will be the pre-compiled header
|
||||
// Yoga.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* 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 NUnit.Framework;
|
||||
using System;
|
||||
|
||||
/**
|
||||
* Tests for {@link CSSNode}.
|
||||
*/
|
||||
namespace Facebook.CSSLayout
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSNodeCreateTest
|
||||
{
|
||||
[Test]
|
||||
public void TestSimple()
|
||||
{
|
||||
CSSNode nodeDefault = new CSSNode();
|
||||
CSSNode nodeCreated = CSSNode.Create(flexDirection: CSSFlexDirection.Row);
|
||||
Assert.AreEqual(CSSFlexDirection.Row, nodeCreated.FlexDirection);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsTrue(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSame()
|
||||
{
|
||||
CSSNode nodeDefault = new CSSNode();
|
||||
CSSNode nodeCreated = CSSNode.Create();
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultiple()
|
||||
{
|
||||
CSSNode node = CSSNode.Create(
|
||||
positionType: CSSPositionType.Absolute,
|
||||
wrap: CSSWrap.Wrap,
|
||||
position: new Spacing(top:6, right:4),
|
||||
margin: new Spacing(bottom:5, left:3));
|
||||
|
||||
Assert.AreEqual(CSSFlexDirection.Column, node.FlexDirection);
|
||||
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(6, node.GetPosition(CSSEdge.Top));
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Bottom)));
|
||||
Assert.AreEqual(4, node.GetPosition(CSSEdge.Right));
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Left)));
|
||||
Assert.AreEqual(0, node.GetMargin(CSSEdge.Top));
|
||||
Assert.AreEqual(5, node.GetMargin(CSSEdge.Bottom));
|
||||
Assert.AreEqual(3, node.GetMargin(CSSEdge.Left));
|
||||
Assert.AreEqual(0, node.GetMargin(CSSEdge.Right));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFull()
|
||||
{
|
||||
CSSNode node = CSSNode.Create(
|
||||
styleDirection: CSSDirection.RTL,
|
||||
flexDirection: CSSFlexDirection.RowReverse,
|
||||
|
||||
justifyContent: CSSJustify.SpaceAround,
|
||||
alignContent: CSSAlign.Center,
|
||||
alignItems: CSSAlign.FlexEnd,
|
||||
alignSelf: CSSAlign.Stretch,
|
||||
|
||||
positionType: CSSPositionType.Absolute,
|
||||
wrap: CSSWrap.Wrap,
|
||||
overflow: CSSOverflow.Scroll,
|
||||
|
||||
flex: 1,
|
||||
flexGrow: 2,
|
||||
flexShrink: 3,
|
||||
flexBasis: 4,
|
||||
|
||||
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
|
||||
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
|
||||
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
|
||||
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
|
||||
|
||||
styleWidth: 21,
|
||||
styleHeight: 22,
|
||||
styleMinWidth: 23,
|
||||
styleMinHeight: 24,
|
||||
styleMaxWidth: 25,
|
||||
styleMaxHeight: 26);
|
||||
|
||||
Assert.AreEqual(CSSDirection.RTL, node.StyleDirection);
|
||||
Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection);
|
||||
|
||||
Assert.AreEqual(CSSJustify.SpaceAround, node.JustifyContent);
|
||||
Assert.AreEqual(CSSAlign.Center, node.AlignContent);
|
||||
Assert.AreEqual(CSSAlign.FlexEnd, node.AlignItems);
|
||||
Assert.AreEqual(CSSAlign.Stretch, node.AlignSelf);
|
||||
|
||||
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(CSSOverflow.Scroll, node.Overflow);
|
||||
|
||||
Assert.AreEqual(2, node.FlexGrow);
|
||||
Assert.AreEqual(3, node.FlexShrink);
|
||||
Assert.AreEqual(4, node.FlexBasis);
|
||||
node.FlexGrow = CSSConstants.Undefined;
|
||||
Assert.AreEqual(1, node.FlexGrow);
|
||||
|
||||
Assert.AreEqual(5, node.GetPosition(CSSEdge.Top));
|
||||
Assert.AreEqual(6, node.GetPosition(CSSEdge.Bottom));
|
||||
Assert.AreEqual(7, node.GetPosition(CSSEdge.Left));
|
||||
Assert.AreEqual(8, node.GetPosition(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(9, node.GetMargin(CSSEdge.Top));
|
||||
Assert.AreEqual(10, node.GetMargin(CSSEdge.Bottom));
|
||||
Assert.AreEqual(11, node.GetMargin(CSSEdge.Left));
|
||||
Assert.AreEqual(12, node.GetMargin(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(13, node.GetPadding(CSSEdge.Top));
|
||||
Assert.AreEqual(14, node.GetPadding(CSSEdge.Bottom));
|
||||
Assert.AreEqual(15, node.GetPadding(CSSEdge.Left));
|
||||
Assert.AreEqual(16, node.GetPadding(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(17, node.GetBorder(CSSEdge.Top));
|
||||
Assert.AreEqual(18, node.GetBorder(CSSEdge.Bottom));
|
||||
Assert.AreEqual(19, node.GetBorder(CSSEdge.Left));
|
||||
Assert.AreEqual(20, node.GetBorder(CSSEdge.Right));
|
||||
|
||||
Assert.AreEqual(21, node.StyleWidth);
|
||||
Assert.AreEqual(22, node.StyleHeight);
|
||||
Assert.AreEqual(23, node.StyleMinWidth);
|
||||
Assert.AreEqual(24, node.StyleMinHeight);
|
||||
Assert.AreEqual(25, node.StyleMaxWidth);
|
||||
Assert.AreEqual(26, node.StyleMaxHeight);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
if clang --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute clang. You need to install Xcode and command line tools."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if mcs --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute mcs. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if mono --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$( dirname "$0" )"
|
||||
|
||||
NUNIT=NUnit-2.6.4/bin
|
||||
if [ -d $NUNIT \
|
||||
-a -f $NUNIT/nunit-console.exe \
|
||||
-a -f $NUNIT/lib/nunit-console-runner.dll \
|
||||
-a -f $NUNIT/lib/nunit.core.dll \
|
||||
-a -f $NUNIT/lib/nunit.core.interfaces.dll \
|
||||
-a -f $NUNIT/lib/nunit.util.dll ]; then true; else
|
||||
curl -L -O https://github.com/nunit/nunitv2/releases/download/2.6.4/NUnit-2.6.4.zip
|
||||
unzip -qq NUnit-2.6.4.zip
|
||||
rm NUnit-2.6.4.zip
|
||||
fi
|
||||
|
||||
clang -g -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp
|
||||
mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs
|
||||
MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe CSSLayoutTest.dll
|
@@ -7,31 +7,31 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAbsolutePositionTest
|
||||
public class YGAbsolutePositionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10f);
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.Start, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -44,7 +44,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -61,18 +61,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.End, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10f);
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.End, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Bottom, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -85,7 +85,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -102,18 +102,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_absolute_layout_start_top_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10f);
|
||||
root_child0.SetPosition(CSSEdge.End, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10f);
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.Start, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 10f);
|
||||
root_child0.SetPosition(YogaEdge.End, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Bottom, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -126,7 +126,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -143,20 +143,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top_end_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Top, 10f);
|
||||
root_child0.SetPosition(CSSEdge.End, 10f);
|
||||
root_child0.SetPosition(CSSEdge.Bottom, 10f);
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.Start, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 10f);
|
||||
root_child0.SetPosition(YogaEdge.End, 10f);
|
||||
root_child0.SetPosition(YogaEdge.Bottom, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -169,7 +169,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -186,23 +186,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.Overflow = CSSOverflow.Hidden;
|
||||
root.StyleWidth = 50f;
|
||||
root.StyleHeight = 50f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Overflow = YogaOverflow.Hidden;
|
||||
root.Width = 50f;
|
||||
root.Height = 50f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Start, 0f);
|
||||
root_child0.SetPosition(CSSEdge.Top, 0f);
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.Start, 0f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 0f);
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
root_child0_child0.StyleWidth = 100f;
|
||||
root_child0_child0.StyleHeight = 100f;
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.Width = 100f;
|
||||
root_child0_child0.Height = 100f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -220,7 +220,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -242,38 +242,38 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_absolute_layout_within_border()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetMargin(CSSEdge.Left, 10f);
|
||||
root.SetMargin(CSSEdge.Top, 10f);
|
||||
root.SetMargin(CSSEdge.Right, 10f);
|
||||
root.SetMargin(CSSEdge.Bottom, 10f);
|
||||
root.SetPadding(CSSEdge.Left, 10f);
|
||||
root.SetPadding(CSSEdge.Top, 10f);
|
||||
root.SetPadding(CSSEdge.Right, 10f);
|
||||
root.SetPadding(CSSEdge.Bottom, 10f);
|
||||
root.SetBorder(CSSEdge.Left, 10f);
|
||||
root.SetBorder(CSSEdge.Top, 10f);
|
||||
root.SetBorder(CSSEdge.Right, 10f);
|
||||
root.SetBorder(CSSEdge.Bottom, 10f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetMargin(YogaEdge.Left, 10f);
|
||||
root.SetMargin(YogaEdge.Top, 10f);
|
||||
root.SetMargin(YogaEdge.Right, 10f);
|
||||
root.SetMargin(YogaEdge.Bottom, 10f);
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.PositionType = CSSPositionType.Absolute;
|
||||
root_child0.SetPosition(CSSEdge.Left, 0f);
|
||||
root_child0.SetPosition(CSSEdge.Top, 0f);
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 50f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.PositionType = YogaPositionType.Absolute;
|
||||
root_child0.SetPosition(YogaEdge.Left, 0f);
|
||||
root_child0.SetPosition(YogaEdge.Top, 0f);
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.PositionType = CSSPositionType.Absolute;
|
||||
root_child1.SetPosition(CSSEdge.Right, 0f);
|
||||
root_child1.SetPosition(CSSEdge.Bottom, 0f);
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 50f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.PositionType = YogaPositionType.Absolute;
|
||||
root_child1.SetPosition(YogaEdge.Right, 0f);
|
||||
root_child1.SetPosition(YogaEdge.Bottom, 0f);
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10f, root.LayoutX);
|
||||
@@ -291,7 +291,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10f, root.LayoutX);
|
@@ -7,49 +7,49 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignContentTest
|
||||
public class YGAlignContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_content_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50f;
|
||||
root_child3.StyleHeight = 10f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50f;
|
||||
root_child4.StyleHeight = 10f;
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -82,7 +82,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -119,37 +119,37 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_content_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.FlexEnd;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.FlexEnd;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50f;
|
||||
root_child3.StyleHeight = 10f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50f;
|
||||
root_child4.StyleHeight = 10f;
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -182,7 +182,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -219,37 +219,37 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_content_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.Center;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50f;
|
||||
root_child3.StyleHeight = 10f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50f;
|
||||
root_child4.StyleHeight = 10f;
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -282,7 +282,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -319,32 +319,32 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_content_stretch()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignContent = CSSAlign.Stretch;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.Stretch;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 50f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
root_child4.StyleWidth = 50f;
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -377,7 +377,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,27 +7,27 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignItemsTest
|
||||
public class YGAlignItemsTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_items_stretch()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -40,7 +40,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -57,16 +57,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_items_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -79,7 +79,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -96,16 +96,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_items_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexStart;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexStart;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -118,7 +118,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -135,16 +135,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_items_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexEnd;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -157,7 +157,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,29 +7,29 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutAlignSelfTest
|
||||
public class YGAlignSelfTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_self_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.Center;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.AlignSelf = YogaAlign.Center;
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -42,7 +42,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -59,16 +59,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_self_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexEnd;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.AlignSelf = YogaAlign.FlexEnd;
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -81,7 +81,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -98,16 +98,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_self_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexStart;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.AlignSelf = YogaAlign.FlexStart;
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -120,7 +120,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -137,17 +137,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_self_flex_end_override_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.FlexStart;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexStart;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.AlignSelf = CSSAlign.FlexEnd;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.AlignSelf = YogaAlign.FlexEnd;
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -160,7 +160,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,25 +7,25 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutBorderTest
|
||||
public class YGBorderTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_border_no_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10f);
|
||||
root.SetBorder(CSSEdge.Top, 10f);
|
||||
root.SetBorder(CSSEdge.Right, 10f);
|
||||
root.SetBorder(CSSEdge.Bottom, 10f);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -33,7 +33,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -45,17 +45,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_border_container_match_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10f);
|
||||
root.SetBorder(CSSEdge.Top, 10f);
|
||||
root.SetBorder(CSSEdge.Right, 10f);
|
||||
root.SetBorder(CSSEdge.Bottom, 10f);
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -68,7 +68,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -85,19 +85,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_border_flex_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10f);
|
||||
root.SetBorder(CSSEdge.Top, 10f);
|
||||
root.SetBorder(CSSEdge.Right, 10f);
|
||||
root.SetBorder(CSSEdge.Bottom, 10f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -110,7 +110,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -127,18 +127,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_border_stretch_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetBorder(CSSEdge.Left, 10f);
|
||||
root.SetBorder(CSSEdge.Top, 10f);
|
||||
root.SetBorder(CSSEdge.Right, 10f);
|
||||
root.SetBorder(CSSEdge.Bottom, 10f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -151,7 +151,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -168,20 +168,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_border_center_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.SetBorder(CSSEdge.Start, 10f);
|
||||
root.SetBorder(CSSEdge.End, 20f);
|
||||
root.SetBorder(CSSEdge.Bottom, 20f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.SetBorder(YogaEdge.Start, 10f);
|
||||
root.SetBorder(YogaEdge.End, 20f);
|
||||
root.SetBorder(YogaEdge.Bottom, 20f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -194,7 +194,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,34 +7,34 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexDirectionTest
|
||||
public class YGFlexDirectionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_direction_column_no_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -57,7 +57,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -84,22 +84,22 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_direction_row_no_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -122,7 +122,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -149,22 +149,22 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_direction_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -187,7 +187,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -214,23 +214,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_direction_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -253,7 +253,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -280,23 +280,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_direction_column_reverse()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.ColumnReverse;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.ColumnReverse;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -319,7 +319,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -346,23 +346,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_direction_row_reverse()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.RowReverse;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.RowReverse;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -385,7 +385,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,32 +7,32 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexTest
|
||||
public class YGFlexTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -50,7 +50,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -72,20 +72,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -103,7 +103,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(25f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -125,19 +125,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexShrink = 1f;
|
||||
root_child0.FlexBasis = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexBasis = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -155,7 +155,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -177,20 +177,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexShrink = 1f;
|
||||
root_child0.FlexBasis = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexBasis = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -208,7 +208,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -230,25 +230,25 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_shrink_to_zero()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleHeight = 75f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Height = 75f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 50f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexShrink = 1f;
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 50f;
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
root_child2.StyleHeight = 50f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -271,7 +271,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -298,26 +298,26 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_basis_overrides_main_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -340,7 +340,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -367,18 +367,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_grow_shrink_at_most()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.FlexShrink = 1f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -396,7 +396,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,43 +7,43 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutFlexWrapTest
|
||||
public class YGFlexWrapTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_wrap_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30f;
|
||||
root_child0.StyleHeight = 30f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 30f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30f;
|
||||
root_child1.StyleHeight = 30f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 30f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30f;
|
||||
root_child2.StyleHeight = 30f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30f;
|
||||
root_child3.StyleHeight = 30f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -71,7 +71,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -103,31 +103,31 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_wrap_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30f;
|
||||
root_child0.StyleHeight = 30f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 30f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30f;
|
||||
root_child1.StyleHeight = 30f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 30f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30f;
|
||||
root_child2.StyleHeight = 30f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30f;
|
||||
root_child3.StyleHeight = 30f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -155,7 +155,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -187,32 +187,32 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.AlignItems = CSSAlign.FlexEnd;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.AlignItems = YogaAlign.FlexEnd;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30f;
|
||||
root_child1.StyleHeight = 20f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 20f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30f;
|
||||
root_child2.StyleHeight = 30f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30f;
|
||||
root_child3.StyleHeight = 30f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -240,7 +240,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -272,32 +272,32 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.Wrap = CSSWrap.Wrap;
|
||||
root.StyleWidth = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 30f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 30f;
|
||||
root_child1.StyleHeight = 20f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 20f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 30f;
|
||||
root_child2.StyleHeight = 30f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
root_child3.StyleWidth = 30f;
|
||||
root_child3.StyleHeight = 30f;
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -325,7 +325,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,36 +7,36 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutJustifyContentTest
|
||||
public class YGJustifyContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -59,7 +59,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -86,24 +86,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -126,7 +126,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -153,24 +153,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_row_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -193,7 +193,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -220,24 +220,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_between()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.SpaceBetween;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.SpaceBetween;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -260,7 +260,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -287,24 +287,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_around()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.SpaceAround;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.SpaceAround;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -327,7 +327,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -354,21 +354,21 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -391,7 +391,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -418,23 +418,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -457,7 +457,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -484,23 +484,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_column_center()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -523,7 +523,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -550,23 +550,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_between()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.SpaceBetween;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.SpaceBetween;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -589,7 +589,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -616,23 +616,23 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_around()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.SpaceAround;
|
||||
root.StyleWidth = 102f;
|
||||
root.StyleHeight = 102f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.SpaceAround;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleHeight = 10f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleHeight = 10f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -655,7 +655,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,29 +7,29 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutMarginTest
|
||||
public class YGMarginTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_margin_start()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Start, 10f);
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -42,7 +42,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -59,15 +59,15 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_top()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Top, 10f);
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -80,7 +80,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -97,17 +97,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_end()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.End, 10f);
|
||||
root_child0.StyleWidth = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.End, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -120,7 +120,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -137,16 +137,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_bottom()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.FlexEnd;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.SetMargin(CSSEdge.Bottom, 10f);
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Bottom, 10f);
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -159,7 +159,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -176,16 +176,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_and_flex_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10f);
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -198,7 +198,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(90f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -215,15 +215,15 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_and_flex_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10f);
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -236,7 +236,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -253,16 +253,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(CSSEdge.Top, 10f);
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -275,7 +275,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -292,15 +292,15 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(CSSEdge.Start, 10f);
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -313,7 +313,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(90f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -330,19 +330,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_with_sibling_row()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -360,7 +360,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -382,18 +382,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_margin_with_sibling_column()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -411,7 +411,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
@@ -7,28 +7,28 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutMinMaxDimensionTest
|
||||
public class YGMinMaxDimensionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_max_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleMaxWidth = 50f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.MaxWidth = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -41,7 +41,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -58,16 +58,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_max_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleMaxHeight = 50f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.MaxHeight = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -80,7 +80,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -97,19 +97,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_min_height()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.StyleMinHeight = 60f;
|
||||
root_child0.MinHeight = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -127,7 +127,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -149,20 +149,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_min_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.StyleMinWidth = 60f;
|
||||
root_child0.MinWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -180,7 +180,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -202,17 +202,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleMinHeight = 100f;
|
||||
root.StyleMaxHeight = 200f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 100f;
|
||||
root.MinHeight = 100f;
|
||||
root.MaxHeight = 200f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 60f;
|
||||
root_child0.StyleHeight = 60f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 60f;
|
||||
root_child0.Height = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -225,7 +225,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -242,17 +242,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_align_items_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.StyleMinWidth = 100f;
|
||||
root.StyleMaxWidth = 200f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.MinWidth = 100f;
|
||||
root.MaxWidth = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 60f;
|
||||
root_child0.StyleHeight = 60f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 60f;
|
||||
root_child0.Height = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -265,7 +265,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -282,26 +282,26 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_justify_content_overflow_min_max()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.StyleMinHeight = 100f;
|
||||
root.StyleMaxHeight = 110f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.MinHeight = 100f;
|
||||
root.MaxHeight = 110f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 50f;
|
||||
root_child0.StyleHeight = 50f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
root_child1.StyleWidth = 50f;
|
||||
root_child1.StyleHeight = 50f;
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
root_child2.StyleWidth = 50f;
|
||||
root_child2.StyleHeight = 50f;
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -324,7 +324,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -351,20 +351,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_grow_within_max_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 200f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexDirection = CSSFlexDirection.Row;
|
||||
root_child0.StyleMaxWidth = 100f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.MaxWidth = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.StyleHeight = 20f;
|
||||
root_child0_child0.Height = 20f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -382,7 +382,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -404,20 +404,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_max_width()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 200f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.FlexDirection = CSSFlexDirection.Row;
|
||||
root_child0.StyleMaxWidth = 300f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.MaxWidth = 300f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.StyleHeight = 20f;
|
||||
root_child0_child0.Height = 20f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -435,7 +435,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -454,5 +454,226 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_min_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.MinWidth = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_min_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.MinHeight = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_max_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.MaxWidth = 100f;
|
||||
root_child0.Height = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexShrink = 1f;
|
||||
root_child0_child0.FlexBasis = 100f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child1 = new YogaNode();
|
||||
root_child0_child1.Width = 50f;
|
||||
root_child0.Insert(1, root_child0_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(200f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(200f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(100f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_max_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.MaxHeight = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexShrink = 1f;
|
||||
root_child0.FlexBasis = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -7,25 +7,25 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutPaddingTest
|
||||
public class YGPaddingTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_padding_no_size()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10f);
|
||||
root.SetPadding(CSSEdge.Top, 10f);
|
||||
root.SetPadding(CSSEdge.Right, 10f);
|
||||
root.SetPadding(CSSEdge.Bottom, 10f);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -33,7 +33,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -45,17 +45,17 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_padding_container_match_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10f);
|
||||
root.SetPadding(CSSEdge.Top, 10f);
|
||||
root.SetPadding(CSSEdge.Right, 10f);
|
||||
root.SetPadding(CSSEdge.Bottom, 10f);
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -68,7 +68,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -85,19 +85,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_padding_flex_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10f);
|
||||
root.SetPadding(CSSEdge.Top, 10f);
|
||||
root.SetPadding(CSSEdge.Right, 10f);
|
||||
root.SetPadding(CSSEdge.Bottom, 10f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -110,7 +110,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -127,18 +127,18 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_padding_stretch_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPadding(CSSEdge.Left, 10f);
|
||||
root.SetPadding(CSSEdge.Top, 10f);
|
||||
root.SetPadding(CSSEdge.Right, 10f);
|
||||
root.SetPadding(CSSEdge.Bottom, 10f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -151,7 +151,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -168,20 +168,20 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void Test_padding_center_child()
|
||||
{
|
||||
CSSNode root = new CSSNode();
|
||||
root.JustifyContent = CSSJustify.Center;
|
||||
root.AlignItems = CSSAlign.Center;
|
||||
root.SetPadding(CSSEdge.Start, 10f);
|
||||
root.SetPadding(CSSEdge.End, 20f);
|
||||
root.SetPadding(CSSEdge.Bottom, 20f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.SetPadding(YogaEdge.Start, 10f);
|
||||
root.SetPadding(YogaEdge.End, 20f);
|
||||
root.SetPadding(YogaEdge.Bottom, 20f);
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
root_child0.StyleWidth = 10f;
|
||||
root_child0.StyleHeight = 10f;
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -194,7 +194,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -208,5 +208,49 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_child_with_padding_align_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.AlignItems = YogaAlign.FlexEnd;
|
||||
root.Width = 200f;
|
||||
root.Height = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetPadding(YogaEdge.Left, 20f);
|
||||
root_child0.SetPadding(YogaEdge.Top, 20f);
|
||||
root_child0.SetPadding(YogaEdge.Right, 20f);
|
||||
root_child0.SetPadding(YogaEdge.Bottom, 20f);
|
||||
root_child0.Width = 100f;
|
||||
root_child0.Height = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(200f, root.LayoutWidth);
|
||||
Assert.AreEqual(200f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(100f, root_child0.LayoutX);
|
||||
Assert.AreEqual(100f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(200f, root.LayoutWidth);
|
||||
Assert.AreEqual(200f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(100f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -7,38 +7,38 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSLayoutRoundingTest
|
||||
public class YGRoundingTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -61,7 +61,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(33f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -84,39 +84,39 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(33f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 113f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 113f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
CSSNode root_child3 = new CSSNode();
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.FlexGrow = 1f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
CSSNode root_child4 = new CSSNode();
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.FlexGrow = 1f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -149,7 +149,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(23f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -182,32 +182,32 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(23f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child4.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_shrink_row()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.FlexDirection = CSSFlexDirection.Row;
|
||||
root.StyleWidth = 101f;
|
||||
root.StyleHeight = 100f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 101f;
|
||||
root.Height = 100f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexShrink = 1f;
|
||||
root_child0.FlexBasis = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexBasis = 25f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexBasis = 25f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -230,7 +230,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(25f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -253,34 +253,34 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(25f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_overrides_main_size()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 113f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -303,7 +303,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -326,34 +326,34 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_total_fractial()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 87.4f;
|
||||
root.StyleHeight = 113.4f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 87.4f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 0.7f;
|
||||
root_child0.FlexBasis = 50.3f;
|
||||
root_child0.StyleHeight = 20.3f;
|
||||
root_child0.Height = 20.3f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1.6f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1.1f;
|
||||
root_child2.StyleHeight = 10.7f;
|
||||
root_child2.Height = 10.7f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -376,7 +376,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -399,48 +399,48 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_total_fractial_nested()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 87.4f;
|
||||
root.StyleHeight = 113.4f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 87.4f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 0.7f;
|
||||
root_child0.FlexBasis = 50.3f;
|
||||
root_child0.StyleHeight = 20.3f;
|
||||
root_child0.Height = 20.3f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child0_child0 = new CSSNode();
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.FlexBasis = 0.3f;
|
||||
root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f);
|
||||
root_child0_child0.StyleHeight = 9.9f;
|
||||
root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f);
|
||||
root_child0_child0.Height = 9.9f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
CSSNode root_child0_child1 = new CSSNode();
|
||||
YogaNode root_child0_child1 = new YogaNode();
|
||||
root_child0_child1.FlexGrow = 4f;
|
||||
root_child0_child1.FlexBasis = 0.3f;
|
||||
root_child0_child1.SetPosition(CSSEdge.Top, 13.3f);
|
||||
root_child0_child1.StyleHeight = 1.1f;
|
||||
root_child0_child1.SetPosition(YogaEdge.Top, 13.3f);
|
||||
root_child0_child1.Height = 1.1f;
|
||||
root_child0.Insert(1, root_child0_child1);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1.6f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1.1f;
|
||||
root_child2.StyleHeight = 10.7f;
|
||||
root_child2.Height = 10.7f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -473,7 +473,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -506,34 +506,34 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_1()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 113.4f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -556,7 +556,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -579,34 +579,34 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_2()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 113.6f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113.6f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -629,7 +629,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -652,35 +652,35 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_3()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPosition(CSSEdge.Top, 0.3f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 113.4f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPosition(YogaEdge.Top, 0.3f);
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -703,7 +703,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -726,35 +726,35 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_4()
|
||||
{
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
CSSNode root = new CSSNode();
|
||||
root.SetPosition(CSSEdge.Top, 0.7f);
|
||||
root.StyleWidth = 100f;
|
||||
root.StyleHeight = 113.4f;
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPosition(YogaEdge.Top, 0.7f);
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
CSSNode root_child0 = new CSSNode();
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.StyleHeight = 20f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
CSSNode root_child1 = new CSSNode();
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.StyleHeight = 10f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
CSSNode root_child2 = new CSSNode();
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.StyleHeight = 10f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = CSSDirection.LTR;
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -777,7 +777,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = CSSDirection.RTL;
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
@@ -800,7 +800,7 @@ namespace Facebook.CSSLayout
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
}
|
143
csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs
Normal file
143
csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* 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 NUnit.Framework;
|
||||
using System;
|
||||
|
||||
/**
|
||||
* Tests for {@link YogaNode}.
|
||||
*/
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YogaNodeCreateTest
|
||||
{
|
||||
[Test]
|
||||
public void TestSimple()
|
||||
{
|
||||
YogaNode nodeDefault = new YogaNode();
|
||||
YogaNode nodeCreated = YogaNode.Create(flexDirection: YogaFlexDirection.Row);
|
||||
Assert.AreEqual(YogaFlexDirection.Row, nodeCreated.FlexDirection);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsTrue(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSame()
|
||||
{
|
||||
YogaNode nodeDefault = new YogaNode();
|
||||
YogaNode nodeCreated = YogaNode.Create();
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
nodeDefault.CopyStyle(nodeCreated);
|
||||
Assert.IsFalse(nodeDefault.IsDirty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultiple()
|
||||
{
|
||||
YogaNode node = YogaNode.Create(
|
||||
positionType: YogaPositionType.Absolute,
|
||||
wrap: YogaWrap.Wrap,
|
||||
position: new Spacing(top:6, right:4),
|
||||
margin: new Spacing(bottom:5, left:3));
|
||||
|
||||
Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection);
|
||||
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(6, node.GetPosition(YogaEdge.Top));
|
||||
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom)));
|
||||
Assert.AreEqual(4, node.GetPosition(YogaEdge.Right));
|
||||
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left)));
|
||||
Assert.AreEqual(0, node.GetMargin(YogaEdge.Top));
|
||||
Assert.AreEqual(5, node.GetMargin(YogaEdge.Bottom));
|
||||
Assert.AreEqual(3, node.GetMargin(YogaEdge.Left));
|
||||
Assert.AreEqual(0, node.GetMargin(YogaEdge.Right));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFull()
|
||||
{
|
||||
YogaNode node = YogaNode.Create(
|
||||
styleDirection: YogaDirection.RTL,
|
||||
flexDirection: YogaFlexDirection.RowReverse,
|
||||
|
||||
justifyContent: YogaJustify.SpaceAround,
|
||||
alignContent: YogaAlign.Center,
|
||||
alignItems: YogaAlign.FlexEnd,
|
||||
alignSelf: YogaAlign.Stretch,
|
||||
|
||||
positionType: YogaPositionType.Absolute,
|
||||
wrap: YogaWrap.Wrap,
|
||||
overflow: YogaOverflow.Scroll,
|
||||
|
||||
flex: 1,
|
||||
flexGrow: 2,
|
||||
flexShrink: 3,
|
||||
flexBasis: 4,
|
||||
|
||||
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
|
||||
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
|
||||
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
|
||||
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
|
||||
|
||||
width: 21,
|
||||
height: 22,
|
||||
minWidth: 23,
|
||||
minHeight: 24,
|
||||
maxWidth: 25,
|
||||
maxHeight: 26);
|
||||
|
||||
Assert.AreEqual(YogaDirection.RTL, node.StyleDirection);
|
||||
Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection);
|
||||
|
||||
Assert.AreEqual(YogaJustify.SpaceAround, node.JustifyContent);
|
||||
Assert.AreEqual(YogaAlign.Center, node.AlignContent);
|
||||
Assert.AreEqual(YogaAlign.FlexEnd, node.AlignItems);
|
||||
Assert.AreEqual(YogaAlign.Stretch, node.AlignSelf);
|
||||
|
||||
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
|
||||
Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
|
||||
Assert.AreEqual(YogaOverflow.Scroll, node.Overflow);
|
||||
|
||||
Assert.AreEqual(2, node.FlexGrow);
|
||||
Assert.AreEqual(3, node.FlexShrink);
|
||||
Assert.AreEqual(4, node.FlexBasis);
|
||||
node.FlexGrow = YogaConstants.Undefined;
|
||||
Assert.AreEqual(1, node.FlexGrow);
|
||||
|
||||
Assert.AreEqual(5, node.GetPosition(YogaEdge.Top));
|
||||
Assert.AreEqual(6, node.GetPosition(YogaEdge.Bottom));
|
||||
Assert.AreEqual(7, node.GetPosition(YogaEdge.Left));
|
||||
Assert.AreEqual(8, node.GetPosition(YogaEdge.Right));
|
||||
|
||||
Assert.AreEqual(9, node.GetMargin(YogaEdge.Top));
|
||||
Assert.AreEqual(10, node.GetMargin(YogaEdge.Bottom));
|
||||
Assert.AreEqual(11, node.GetMargin(YogaEdge.Left));
|
||||
Assert.AreEqual(12, node.GetMargin(YogaEdge.Right));
|
||||
|
||||
Assert.AreEqual(13, node.GetPadding(YogaEdge.Top));
|
||||
Assert.AreEqual(14, node.GetPadding(YogaEdge.Bottom));
|
||||
Assert.AreEqual(15, node.GetPadding(YogaEdge.Left));
|
||||
Assert.AreEqual(16, node.GetPadding(YogaEdge.Right));
|
||||
|
||||
Assert.AreEqual(17, node.GetBorder(YogaEdge.Top));
|
||||
Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom));
|
||||
Assert.AreEqual(19, node.GetBorder(YogaEdge.Left));
|
||||
Assert.AreEqual(20, node.GetBorder(YogaEdge.Right));
|
||||
|
||||
Assert.AreEqual(21, node.Width);
|
||||
Assert.AreEqual(22, node.Height);
|
||||
Assert.AreEqual(23, node.MinWidth);
|
||||
Assert.AreEqual(24, node.MinHeight);
|
||||
Assert.AreEqual(25, node.MaxWidth);
|
||||
Assert.AreEqual(26, node.MaxHeight);
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,18 +11,18 @@ using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
/**
|
||||
* Tests for {@link CSSNode}.
|
||||
* Tests for {@link YogaNode}.
|
||||
*/
|
||||
namespace Facebook.CSSLayout
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class CSSNodeTest
|
||||
public class YogaNodeTest
|
||||
{
|
||||
[Test]
|
||||
public void TestAddChildGetParent()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
|
||||
Assert.IsNull(child.Parent);
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
@@ -42,22 +42,22 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestChildren()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
foreach (CSSNode node in parent) {
|
||||
YogaNode parent = new YogaNode();
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.Fail(node.ToString());
|
||||
}
|
||||
|
||||
CSSNode child0 = new CSSNode();
|
||||
YogaNode child0 = new YogaNode();
|
||||
Assert.AreEqual(-1, parent.IndexOf(child0));
|
||||
parent.Insert(0, child0);
|
||||
foreach (CSSNode node in parent) {
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.AreEqual(0, parent.IndexOf(node));
|
||||
}
|
||||
|
||||
CSSNode child1 = new CSSNode();
|
||||
YogaNode child1 = new YogaNode();
|
||||
parent.Insert(1, child1);
|
||||
int index = 0;
|
||||
foreach (CSSNode node in parent) {
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.AreEqual(index++, parent.IndexOf(node));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Facebook.CSSLayout
|
||||
[ExpectedException("System.NullReferenceException")]
|
||||
public void TestRemoveAtFromEmpty()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
YogaNode parent = new YogaNode();
|
||||
parent.RemoveAt(0);
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace Facebook.CSSLayout
|
||||
[ExpectedException("System.ArgumentOutOfRangeException")]
|
||||
public void TestRemoveAtOutOfRange()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
parent.RemoveAt(1);
|
||||
}
|
||||
@@ -94,9 +94,9 @@ namespace Facebook.CSSLayout
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestCannotAddChildToMultipleParents()
|
||||
{
|
||||
CSSNode parent1 = new CSSNode();
|
||||
CSSNode parent2 = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode parent1 = new YogaNode();
|
||||
YogaNode parent2 = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
|
||||
parent1.Insert(0, child);
|
||||
parent2.Insert(0, child);
|
||||
@@ -105,19 +105,19 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestReset()
|
||||
{
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
CSSNode node = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
node.Reset();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestResetParent()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
parent.Reset();
|
||||
}
|
||||
@@ -126,8 +126,8 @@ namespace Facebook.CSSLayout
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestResetChild()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
child.Reset();
|
||||
}
|
||||
@@ -135,24 +135,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
CSSNode parent = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
CSSNode child = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount());
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode parent = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
parent.Insert(0, child);
|
||||
Assert.AreEqual(1, parent.Count);
|
||||
Assert.AreEqual(parent, child.Parent);
|
||||
parent.Clear();
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
Assert.IsNull(child.Parent);
|
||||
Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMeasureFunc()
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
});
|
||||
@@ -164,24 +164,24 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestMeasureFuncWithFloat()
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(123.4f, 81.7f);
|
||||
});
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual(123, node.LayoutWidth);
|
||||
Assert.AreEqual(81, node.LayoutHeight);
|
||||
Assert.AreEqual(123.4f, node.LayoutWidth);
|
||||
Assert.AreEqual(81.7f, node.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestChildWithMeasureFunc()
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
});
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode child = new YogaNode();
|
||||
node.Insert(0, child);
|
||||
}
|
||||
|
||||
@@ -189,8 +189,8 @@ namespace Facebook.CSSLayout
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestMeasureFuncWithChild()
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
node.Insert(0, child);
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
@@ -200,15 +200,15 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestPrint()
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
parent.StyleWidth = 100;
|
||||
parent.StyleHeight = 120;
|
||||
CSSNode child0 = new CSSNode();
|
||||
child0.StyleWidth = 30;
|
||||
child0.StyleHeight = 40;
|
||||
CSSNode child1 = new CSSNode();
|
||||
child1.StyleWidth = 35;
|
||||
child1.StyleHeight = 45;
|
||||
YogaNode parent = new YogaNode();
|
||||
parent.Width = 100;
|
||||
parent.Height = 120;
|
||||
YogaNode child0 = new YogaNode();
|
||||
child0.Width = 30;
|
||||
child0.Height = 40;
|
||||
YogaNode child1 = new YogaNode();
|
||||
child1.Width = 35;
|
||||
child1.Height = 45;
|
||||
parent.Insert(0, child0);
|
||||
parent.Insert(0, child1);
|
||||
parent.CalculateLayout();
|
||||
@@ -218,17 +218,16 @@ namespace Facebook.CSSLayout
|
||||
[Test]
|
||||
public void TestCopyStyle()
|
||||
{
|
||||
CSSNode node0 = new CSSNode();
|
||||
Assert.IsTrue(CSSConstants.IsUndefined(node0.StyleMaxHeight));
|
||||
YogaNode node0 = new YogaNode();
|
||||
Assert.IsTrue(YogaConstants.IsUndefined(node0.MaxHeight));
|
||||
|
||||
CSSNode node1 = new CSSNode();
|
||||
node1.StyleMaxHeight = 100;
|
||||
YogaNode node1 = new YogaNode();
|
||||
node1.MaxHeight = 100;
|
||||
|
||||
node0.CopyStyle(node1);
|
||||
Assert.AreEqual(100, node0.StyleMaxHeight);
|
||||
Assert.AreEqual(100, node0.MaxHeight);
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
private void ForceGC()
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration);
|
||||
@@ -239,17 +238,17 @@ namespace Facebook.CSSLayout
|
||||
public void TestDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
TestDestructorForGC(instanceCount);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestDestructorForGC(int instanceCount)
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.IsNotNull(node);
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
node = null;
|
||||
}
|
||||
|
||||
@@ -257,32 +256,32 @@ namespace Facebook.CSSLayout
|
||||
public void TestDestructorWithChildren()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
TestDestructorWithChildrenForGC1(instanceCount);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestDestructorWithChildrenForGC1(int instanceCount)
|
||||
{
|
||||
CSSNode node = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
|
||||
TestDestructorWithChildrenForGC2(node, instanceCount + 1);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
|
||||
TestDestructorWithChildrenForGC2(node, instanceCount + 2);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 3, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 3, YogaNode.GetInstanceCount());
|
||||
|
||||
node = null;
|
||||
}
|
||||
|
||||
private void TestDestructorWithChildrenForGC2(CSSNode parent, int instanceCount)
|
||||
private void TestDestructorWithChildrenForGC2(YogaNode parent, int instanceCount)
|
||||
{
|
||||
CSSNode child = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
|
||||
parent.Insert(0, child);
|
||||
child = null;
|
||||
@@ -292,21 +291,21 @@ namespace Facebook.CSSLayout
|
||||
public void TestParentDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
CSSNode child = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
|
||||
TestParentDestructorForGC(child, instanceCount + 1);
|
||||
ForceGC();
|
||||
|
||||
Assert.IsNull(child.Parent);
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestParentDestructorForGC(CSSNode child, int instanceCount)
|
||||
private void TestParentDestructorForGC(YogaNode child, int instanceCount)
|
||||
{
|
||||
CSSNode parent = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
YogaNode parent = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
parent.Insert(0, child);
|
||||
}
|
||||
|
||||
@@ -314,22 +313,22 @@ namespace Facebook.CSSLayout
|
||||
public void TestClearWithChildDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
CSSNode node = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
TestClearWithChildDestructorForGC(node, instanceCount + 1);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
node.Clear();
|
||||
Assert.AreEqual(0, node.Count);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestClearWithChildDestructorForGC(CSSNode parent, int instanceCount)
|
||||
private void TestClearWithChildDestructorForGC(YogaNode parent, int instanceCount)
|
||||
{
|
||||
CSSNode child = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
parent.Insert(0, child);
|
||||
}
|
||||
|
||||
@@ -337,25 +336,24 @@ namespace Facebook.CSSLayout
|
||||
public void TestMeasureFuncWithDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = CSSNode.GetInstanceCount();
|
||||
CSSNode parent = new CSSNode();
|
||||
Assert.AreEqual(instanceCount + 1, CSSNode.GetInstanceCount());
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode parent = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
TestMeasureFuncWithDestructorForGC(parent);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, CSSNode.GetInstanceCount());
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
parent.CalculateLayout();
|
||||
Assert.AreEqual(120, (int)parent.LayoutWidth);
|
||||
Assert.AreEqual(130, (int)parent.LayoutHeight);
|
||||
}
|
||||
|
||||
private void TestMeasureFuncWithDestructorForGC(CSSNode parent)
|
||||
private void TestMeasureFuncWithDestructorForGC(YogaNode parent)
|
||||
{
|
||||
CSSNode child = new CSSNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
child.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(120, 130);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
28
csharp/tests/Facebook.Yoga/test_macos.sh
Executable file
28
csharp/tests/Facebook.Yoga/test_macos.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
if mcs --version >/dev/null 2>&1 && mono --version >/dev/null 2>&1; then true; else
|
||||
echo "ERROR: Need to install Mono (brew install mono, or http://www.mono-project.com/download/)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$( dirname "$0" )"
|
||||
|
||||
NUNIT=NUnit-2.6.4/bin
|
||||
if [ -d $NUNIT \
|
||||
-a -f $NUNIT/nunit-console.exe \
|
||||
-a -f $NUNIT/lib/nunit-console-runner.dll \
|
||||
-a -f $NUNIT/lib/nunit.core.dll \
|
||||
-a -f $NUNIT/lib/nunit.core.interfaces.dll \
|
||||
-a -f $NUNIT/lib/nunit.util.dll ]; then true; else
|
||||
curl -L -O https://github.com/nunit/nunitv2/releases/download/2.6.4/NUnit-2.6.4.zip
|
||||
unzip -qq NUnit-2.6.4.zip
|
||||
rm NUnit-2.6.4.zip
|
||||
fi
|
||||
|
||||
TARGET=//csharp:yoganet#default,shared
|
||||
buck build $TARGET
|
||||
ROOT=`buck root|tail -1`
|
||||
DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'`
|
||||
cp $ROOT/$DYLIB .
|
||||
|
||||
mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs
|
||||
MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll
|
69
enums.py
69
enums.py
@@ -12,54 +12,54 @@ from __future__ import unicode_literals
|
||||
import os
|
||||
|
||||
ENUMS = {
|
||||
'CSSDirection': [
|
||||
'Direction': [
|
||||
'Inherit',
|
||||
'LTR',
|
||||
'RTL',
|
||||
],
|
||||
'CSSFlexDirection': [
|
||||
'FlexDirection': [
|
||||
'Column',
|
||||
'ColumnReverse',
|
||||
'Row',
|
||||
'RowReverse',
|
||||
],
|
||||
'CSSJustify': [
|
||||
'Justify': [
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'SpaceBetween',
|
||||
'SpaceAround',
|
||||
],
|
||||
'CSSOverflow': [
|
||||
'Overflow': [
|
||||
'Visible',
|
||||
'Hidden',
|
||||
'Scroll',
|
||||
],
|
||||
'CSSAlign': [
|
||||
'Align': [
|
||||
'Auto',
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'Stretch',
|
||||
],
|
||||
'CSSPositionType': [
|
||||
'PositionType': [
|
||||
'Relative',
|
||||
'Absolute',
|
||||
],
|
||||
'CSSWrap': [
|
||||
'Wrap': [
|
||||
'NoWrap',
|
||||
'Wrap',
|
||||
],
|
||||
'CSSMeasureMode': [
|
||||
'MeasureMode': [
|
||||
'Undefined',
|
||||
'Exactly',
|
||||
'AtMost',
|
||||
],
|
||||
'CSSDimension': [
|
||||
'Dimension': [
|
||||
'Width',
|
||||
'Height',
|
||||
],
|
||||
'CSSEdge': [
|
||||
'Edge': [
|
||||
'Left',
|
||||
'Top',
|
||||
'Right',
|
||||
@@ -70,19 +70,19 @@ ENUMS = {
|
||||
'Vertical',
|
||||
'All',
|
||||
],
|
||||
'CSSLogLevel': [
|
||||
'LogLevel': [
|
||||
'Error',
|
||||
'Warn',
|
||||
'Info',
|
||||
'Debug',
|
||||
'Verbose',
|
||||
],
|
||||
'CSSExperimentalFeature': [
|
||||
'ExperimentalFeature': [
|
||||
'Rounding',
|
||||
# Mimic web flex-basis behavior.
|
||||
'WebFlexBasis',
|
||||
],
|
||||
'CSSPrintOptions': [
|
||||
'PrintOptions': [
|
||||
('Layout', 1),
|
||||
('Style', 2),
|
||||
('Children', 4),
|
||||
@@ -111,31 +111,34 @@ def to_java_upper(symbol):
|
||||
return out
|
||||
|
||||
|
||||
root = os.path.dirname(__file__)
|
||||
root = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# write out C header
|
||||
with open(root + '/CSSLayout/CSSEnums.h', 'w') as f:
|
||||
# write out C headers
|
||||
with open(root + '/yoga/YGEnums.h', 'w') as f:
|
||||
f.write(LICENSE)
|
||||
remaining = len(ENUMS)
|
||||
f.write('#pragma once\n\n')
|
||||
f.write('#include "YGMacros.h"\n\n')
|
||||
f.write('YG_EXTERN_C_BEGIN\n\n')
|
||||
for name, values in ENUMS.items():
|
||||
f.write('typedef enum %s {\n' % name)
|
||||
f.write('#define YG%sCount %s\n' % (name, len(values)))
|
||||
f.write('typedef enum YG%s {\n' % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s%s = %d,\n' % (name, value[0], value[1]))
|
||||
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
||||
else:
|
||||
f.write(' %s%s,\n' % (name, value))
|
||||
f.write(' %sCount,\n' % name)
|
||||
f.write('} %s;\n' % name)
|
||||
if remaining > 1:
|
||||
f.write('\n')
|
||||
remaining = remaining - 1
|
||||
f.write(' YG%s%s,\n' % (name, value))
|
||||
f.write('} YG%s;\n' % name)
|
||||
f.write('\n')
|
||||
f.write('YG_EXTERN_C_END\n')
|
||||
|
||||
# write out java files
|
||||
for name, values in ENUMS.items():
|
||||
with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f:
|
||||
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
f.write('package com.facebook.csslayout;\n\n')
|
||||
f.write('public enum %s {\n' % name)
|
||||
f.write('package com.facebook.yoga;\n\n')
|
||||
f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n')
|
||||
f.write('@DoNotStrip\n')
|
||||
f.write('public enum Yoga%s {\n' % name)
|
||||
if len(values) > 0:
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
@@ -151,7 +154,7 @@ for name, values in ENUMS.items():
|
||||
f.write('\n')
|
||||
f.write(' private int mIntValue;\n')
|
||||
f.write('\n')
|
||||
f.write(' %s(int intValue) {\n' % name)
|
||||
f.write(' Yoga%s(int intValue) {\n' % name)
|
||||
f.write(' mIntValue = intValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
@@ -159,7 +162,7 @@ for name, values in ENUMS.items():
|
||||
f.write(' return mIntValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public static %s fromInt(int value) {\n' % name)
|
||||
f.write(' public static Yoga%s fromInt(int value) {\n' % name)
|
||||
f.write(' switch (value) {\n')
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
@@ -173,10 +176,10 @@ for name, values in ENUMS.items():
|
||||
|
||||
# write out csharp files
|
||||
for name, values in ENUMS.items():
|
||||
with open(root + '/csharp/Facebook.CSSLayout/%s.cs' % name, 'w') as f:
|
||||
with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
f.write('namespace Facebook.CSSLayout\n{\n')
|
||||
f.write(' public enum %s\n {\n' % name)
|
||||
f.write('namespace Facebook.Yoga\n{\n')
|
||||
f.write(' public enum Yoga%s\n {\n' % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s = %d,\n' % (value[0], value[1]))
|
||||
|
@@ -29,7 +29,6 @@ clang-format \
|
||||
SpaceAfterCStyleCast: true, \
|
||||
UseTab: Never, \
|
||||
}" "$@" \
|
||||
-i $(dirname $0)/CSSLayout/*.{h,c,cpp} \
|
||||
$(dirname $0)/tests/CSSLayoutTestUtils/*.{h,c,cpp} \
|
||||
-i $(dirname $0)/yoga/*.{h,c,cpp} \
|
||||
$(dirname $0)/benchmarks/*.{h,c,cpp} \
|
||||
$(dirname $0)/java/jni/*.{h,c,cpp}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user