Compare commits
371 Commits
v1.1.0
...
v2016.12.19.00
Author | SHA1 | Date | |
---|---|---|---|
|
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 | ||
|
22b0fdb3e6 | ||
|
a0d560a24b | ||
|
dc10fdd958 | ||
|
b90f6e21bd | ||
|
d54f09e32b | ||
|
49a21e657b | ||
|
2d58a36619 | ||
|
f56e8a5163 | ||
|
e78cf02a30 | ||
|
55fc795686 | ||
|
b16c22a8f3 | ||
|
56ec33a463 | ||
|
367c3a28be | ||
|
653150a7c4 | ||
|
542fc50409 | ||
|
4f192481ee | ||
|
0bb2955c5c | ||
|
191ac98b89 | ||
|
32c175ac55 | ||
|
4b61cdccea | ||
|
b9c4c403a9 | ||
|
56aa279fef | ||
|
7e4bb732ff | ||
|
32ba5ae647 | ||
|
2fa6f5087d | ||
|
c2aac9f46e | ||
|
ef81d4b0c7 | ||
|
667858990c | ||
|
d80bac4234 | ||
|
d1c555fede | ||
|
ac4d0ab2a1 | ||
|
603321e1ab | ||
|
129437f49e | ||
|
204aba80b9 | ||
|
e6702e1168 | ||
|
b99172d28b | ||
|
7a3df9999b | ||
|
e0e88f97b6 | ||
|
b4d0e1a17c | ||
|
e40af30fa5 | ||
|
cd054ecf26 | ||
|
aaa977f645 | ||
|
70e01a4476 | ||
|
3e2c13f418 | ||
|
0dbbfc5910 | ||
|
f222d22ba8 | ||
|
087d1f3a82 | ||
|
c382d513fb | ||
|
8a7183f465 | ||
|
ff602d4606 | ||
|
f5912a97e4 | ||
|
a253c6fbb7 | ||
|
863378d74e | ||
|
f1fcd5e382 | ||
|
6a6efe0764 | ||
|
e54af5e854 | ||
|
502f3c7010 | ||
|
12ebaa56b6 | ||
|
3e567fdcae | ||
|
1baa239389 | ||
|
b50090a04e | ||
|
ba2905dd1d | ||
|
997088ffbb | ||
|
ffb90e6ff2 | ||
|
1c22a1aa53 | ||
|
7082734c6b | ||
|
366a61af8d | ||
|
18fe0959f0 | ||
|
1ffce3edb1 | ||
|
6165d7a2be | ||
|
01a3881426 | ||
|
9c1896043d | ||
|
0f822bbef2 | ||
|
e00e30ca15 | ||
|
b938017ccf | ||
|
630ae0972b | ||
|
d8662805d5 | ||
|
26e7490fc9 | ||
|
d94363ea7e | ||
|
af5e6771d7 | ||
|
ced779b259 | ||
|
a65e6930cf | ||
|
267e17f23a | ||
|
df6368e048 | ||
|
ba20d75992 | ||
|
620cb3f507 | ||
|
3201e24780 | ||
|
2cac77eaa1 | ||
|
46823878a5 | ||
|
b59ce09109 | ||
|
c34299edc9 | ||
|
1ba81d9ec7 | ||
|
d6d817c142 | ||
|
01c2ac3369 | ||
|
0cc1b83569 | ||
|
c8d77b2aae | ||
|
01507044b3 | ||
|
2168d68007 | ||
|
4d0e657653 | ||
|
4452c7be5c | ||
|
15f5c4cea5 | ||
|
97fef59f96 | ||
|
e9b9973cae | ||
|
69c374e74e | ||
|
4c57029a28 | ||
|
c28429efc8 | ||
|
ab4ce535b9 | ||
|
7fee10691c | ||
|
4d964bdbc3 | ||
|
ef538a45cd | ||
|
dc5e613285 | ||
|
1488f822c3 | ||
|
7673de823f | ||
|
26bcc1e072 | ||
|
2e090cb1c8 | ||
|
daed6f5b8a | ||
|
e4ad7d3c12 | ||
|
fa2ffc72a4 | ||
|
d1d9326fa4 | ||
|
9c3970dd75 | ||
|
6152ca46c8 | ||
|
9fb1b29f14 | ||
|
82dafa75cf | ||
|
eb4f1cdc96 | ||
|
501ed57784 | ||
|
bfb9b926b3 | ||
|
b21efa45e6 | ||
|
c619c0be5a | ||
|
63d3e8f3f3 | ||
|
770fa6d254 | ||
|
eedee80f25 | ||
|
0254e3e97f | ||
|
05ba3a2565 | ||
|
89440f630f | ||
|
832d07902e | ||
|
b45a7e3737 | ||
|
14009ec470 | ||
|
203e3dc9b8 | ||
|
7548164edb | ||
|
722bfb9032 | ||
|
2a8a4e10c6 | ||
|
8df9320f4c | ||
|
df6b4d3682 | ||
|
8939bcb96d | ||
|
d3fc24e842 | ||
|
7f6b942146 | ||
|
29fa232129 | ||
|
41b64478c4 | ||
|
23acf2156f | ||
|
1de914737a | ||
|
033658196f | ||
|
136ec25e8c | ||
|
62dba4c741 | ||
|
871a7cf310 | ||
|
cdf4ee1e59 | ||
|
588d2c91ba | ||
|
f61fbd269e | ||
|
d506e6ab94 | ||
|
56f6efdecf | ||
|
90844d62c5 | ||
|
c233bafeb2 | ||
|
b57abb2f60 | ||
|
56279110c0 | ||
|
01115b8bbd | ||
|
47bd1bb943 | ||
|
2870d3ce4d | ||
|
23f2878808 | ||
|
11f85ce91e | ||
|
1f300a58fb | ||
|
dbf3b11946 | ||
|
3b1515f2b7 | ||
|
6b16dc4060 | ||
|
9c93c7fc42 | ||
|
15d5cb0169 | ||
|
dba5faabb2 | ||
|
ff8f17ac99 | ||
|
017fb2c734 | ||
|
8fd14c710c | ||
|
1415a5d7fd | ||
|
2592894d2d | ||
|
dcaef7ecb0 | ||
|
2dcd8b4074 | ||
|
1951242a52 | ||
|
d4121401d7 | ||
|
0be3b1013f | ||
|
21a05417cd | ||
|
8fcb265830 | ||
|
64fffcb8f3 | ||
|
059384f277 | ||
|
57725e849a | ||
|
b51e832e4e | ||
|
d9191431ff | ||
|
251a499ba6 | ||
|
3c33184dbb | ||
|
583830b3df | ||
|
36eaae88e0 | ||
|
284634c880 | ||
|
94bbbde930 | ||
|
1051c39a59 | ||
|
1abb2d1714 | ||
|
c28148caff | ||
|
e3fa40e694 | ||
|
89c00a7a3b | ||
|
2808e547c6 | ||
|
8b4a61df1a | ||
|
43faff434a | ||
|
ea9a6ce06f | ||
|
beb51fac1b | ||
|
d33befeb98 | ||
|
2fc622adbd | ||
|
1fd3a16116 | ||
|
aa70125f6c | ||
|
9985e398b3 | ||
|
b629bcacab | ||
|
f65febb1af | ||
|
ccbfee3841 | ||
|
9eb75e27cc | ||
|
15afb4207c | ||
|
f1ae87cd73 | ||
|
e8465aee45 | ||
|
ca72b2b796 | ||
|
4bcefd8845 | ||
|
0672f5572f | ||
|
9d34b4e110 | ||
|
dab03cb800 | ||
|
dd2346f8ac | ||
|
dde2b349f2 | ||
|
7cd6305371 | ||
|
f28dacf280 | ||
|
a960203567 | ||
|
48e5304276 | ||
|
53ff4f59ca | ||
|
28bc42a988 | ||
|
c373056d80 | ||
|
f68521aa69 | ||
|
fdd5c8ce82 | ||
|
7a1e353404 | ||
|
6a44dbc43b | ||
|
597354a43b | ||
|
1ce14cd097 | ||
|
d125911894 | ||
|
e307dc22d1 | ||
|
916170f6ac | ||
|
57021eba9d | ||
|
a43b813517 | ||
|
e5a3f7bf5b | ||
|
af5b14335e | ||
|
118f64f206 | ||
|
450472766d | ||
|
759cb707a4 | ||
|
328db9ca1c | ||
|
f15b563166 | ||
|
7f27046cc5 | ||
|
faad5cdf4d | ||
|
256d080fd2 | ||
|
efe1595f0e | ||
|
9278ff462e | ||
|
b32d384337 | ||
|
f5caf93c6e | ||
|
c74eae50ac | ||
|
7af5e3d68d | ||
|
9689062f6c | ||
|
ac44d2ea6e | ||
|
9ab97af05d | ||
|
cdf18b9c2b | ||
|
c7d02257e3 | ||
|
c72321f8a9 | ||
|
a0805d0b90 | ||
|
5207b90420 | ||
|
5e7d95b403 | ||
|
041960fcbc | ||
|
46c842c71a | ||
|
b26794a375 | ||
|
8ffff2bfaf | ||
|
fdd8552c4e | ||
|
93809b69c8 | ||
|
667106e423 | ||
|
57874a1a9e | ||
|
8b7f353746 | ||
|
ca34ff4446 | ||
|
d878091c4b | ||
|
c4fa32cfd3 | ||
|
6e05325f08 | ||
|
a1f36b53f5 | ||
|
383d8a6b3d | ||
|
7b0c008300 | ||
|
45e595e6ae | ||
|
2a816bf5a7 | ||
|
71eb25d1cc | ||
|
c06752e052 | ||
|
bd92550d57 | ||
|
9260363fef | ||
|
9d62cee68b | ||
|
16f43dac87 | ||
|
8177bfe702 | ||
|
8779d942ea | ||
|
f3dd51ab97 | ||
|
b0d00ad338 | ||
|
7bd6b2b7dd | ||
|
68e0b0cc58 | ||
|
5b56be412c | ||
|
3454511947 | ||
|
b157ab4a00 | ||
|
8d5cdd4e6c | ||
|
425345aa8d | ||
|
dd8e5cd65d | ||
|
64704dd708 | ||
|
dc7059d340 | ||
|
acd295e470 | ||
|
5d5630d3c8 | ||
|
c9094f94d0 | ||
|
f3b6fb3be0 | ||
|
3d7bc48fa6 | ||
|
219bdaed15 | ||
|
f2aa5ba604 | ||
|
53769ccbc5 | ||
|
2733ebf1d0 | ||
|
45227c0b9a | ||
|
e848706911 | ||
|
79d7291906 | ||
|
bae4eb1830 | ||
|
609d4ae69d | ||
|
99c3a88df4 | ||
|
4364c6ebb2 | ||
|
b7856ce26a |
2
.buckconfig
Normal file
2
.buckconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
[cxx]
|
||||
gtest_dep = //lib/gtest:gtest
|
20
.eslintrc
20
.eslintrc
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"extends": "./node_modules/fbjs-scripts/eslint/.eslintrc",
|
||||
"globals": {
|
||||
"jasmine": true,
|
||||
"describe": true,
|
||||
"beforeEach": true,
|
||||
"afterEach": true,
|
||||
"spyOn": true,
|
||||
"it": true,
|
||||
"xit": true,
|
||||
"expect": true,
|
||||
"require": true,
|
||||
"global": true,
|
||||
"__dirname": true,
|
||||
"module": true,
|
||||
"console": true,
|
||||
"setTimeout": true,
|
||||
"define": true
|
||||
}
|
||||
}
|
17
.gitignore
vendored
17
.gitignore
vendored
@@ -1,7 +1,10 @@
|
||||
a.out
|
||||
*.class
|
||||
/**/java/out/*
|
||||
/**/.idea/workspace.xml
|
||||
/lib/
|
||||
/node_modules/
|
||||
npm-debug.log
|
||||
.DS_STORE
|
||||
|
||||
/buck-cache/
|
||||
/buck-out/
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/gentest/test.html
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "lib/gtest/googletest"]
|
||||
path = lib/gtest/googletest
|
||||
url = https://github.com/google/googletest.git
|
10
.hgignore
Normal file
10
.hgignore
Normal file
@@ -0,0 +1,10 @@
|
||||
.DS_STORE
|
||||
|
||||
/buck-cache/
|
||||
/buck-out/
|
||||
/.buckconfig.local
|
||||
/.buckd
|
||||
/gentest/test.html
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
36
.travis.yml
36
.travis.yml
@@ -1,14 +1,30 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
# 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.
|
||||
|
||||
sudo: false
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: cpp
|
||||
compiler: clang
|
||||
|
||||
before_install:
|
||||
- npm install grunt-cli -g
|
||||
- brew update
|
||||
- brew tap facebook/fb
|
||||
- brew install buck
|
||||
- brew cask install java
|
||||
- brew outdated xctool || brew upgrade xctool
|
||||
- brew install mono
|
||||
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
|
||||
- export PATH=$JAVA_HOME/bin:$PATH
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- gcc
|
||||
|
||||
script:
|
||||
- buck test //:yoga
|
||||
- buck test //java:java
|
||||
- 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
|
||||
|
42
BUCK
Normal file
42
BUCK
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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_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', '-fPIC']
|
||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11']
|
||||
|
||||
cxx_library(
|
||||
name = 'yoga',
|
||||
soname = 'libyogacore.$(ext)',
|
||||
srcs = glob(['yoga/*.c']),
|
||||
tests=[':YogaTests'],
|
||||
exported_headers = subdir_glob([('', 'yoga/*.h')]),
|
||||
header_namespace = '',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
deps = [] if THIS_IS_FBOBJC else [
|
||||
yoga_dep('lib/fb:ndklog'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
cxx_test(
|
||||
name = 'YogaTests',
|
||||
contacts = ['emilsj@fb.com'],
|
||||
srcs = glob(['tests/*.cpp']),
|
||||
compiler_flags = TEST_COMPILER_FLAGS,
|
||||
deps = [
|
||||
':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`.
|
||||
@@ -29,10 +26,8 @@ disclosure of security bugs. In those cases, please go through the process
|
||||
outlined on that page and do not file a public issue.
|
||||
|
||||
## Coding Style
|
||||
* 2 spaces for indentation rather than tabs
|
||||
* 80 character line length
|
||||
* ...
|
||||
* 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.
|
189
Gruntfile.js
189
Gruntfile.js
@@ -1,189 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
var path = require('path');
|
||||
var isWindows = (/^win/).test(process.platform);
|
||||
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// config
|
||||
var config = {
|
||||
delimiter: path.delimiter,
|
||||
libName: 'css-layout',
|
||||
distFolder: 'dist',
|
||||
srcFolder: 'src',
|
||||
testFolder: 'src/__tests__',
|
||||
javaLibFolder: 'src/java/lib',
|
||||
javaSource: 'src/java/tests/com/facebook/csslayout/*.java',
|
||||
javaTestFiles: 'org.junit.runner.JUnitCore com.facebook.csslayout.LayoutEngineTest com.facebook.csslayout.LayoutCachingTest com.facebook.csslayout.CSSNodeTest'
|
||||
};
|
||||
|
||||
// C compilation configuration
|
||||
if (isWindows) {
|
||||
// Windows build, assumes cl is in the path (see https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx).
|
||||
config.cTestOutput = 'c_test.exe';
|
||||
config.cTestCompile = 'cl -nologo -Zi -Tpsrc/__tests__/Layout-test.c -Tpsrc/Layout.c -Tpsrc/Layout-test-utils.c -link -incremental:no -out:"<%= config.cTestOutput %>"';
|
||||
config.cTestExecute = '<%= config.cTestOutput %>';
|
||||
config.cTestClean = ['<%= config.cTestOutput %>', '*.obj', '*.pdb'];
|
||||
} else {
|
||||
// GCC build (OSX, Linux, ...), assumes gcc is in the path.
|
||||
config.cTestOutput = 'c_test';
|
||||
config.cTestCompile = 'gcc -std=c99 -Werror -Wno-padded src/__tests__/Layout-test.c src/Layout.c src/Layout-test-utils.c -lm -o "./<%= config.cTestOutput %>"';
|
||||
config.cTestExecute = './<%= config.cTestOutput %>';
|
||||
config.cTestClean = ['<%= config.cTestOutput %>'];
|
||||
}
|
||||
|
||||
grunt.initConfig({
|
||||
config: config,
|
||||
|
||||
mkdir: {
|
||||
dist: {
|
||||
options: {
|
||||
create: ['<%= config.distFolder %>']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
clean: {
|
||||
dist: ['<%= config.distFolder %>'],
|
||||
cTest: config.cTestClean,
|
||||
javaTest: ['**/*.class']
|
||||
},
|
||||
|
||||
eslint: {
|
||||
options: {
|
||||
configFile: '.eslintrc'
|
||||
},
|
||||
target: ['<%= config.srcFolder %>/**/*.js', './Gruntfile.js']
|
||||
},
|
||||
|
||||
includereplace: {
|
||||
options: {
|
||||
prefix: '// @@'
|
||||
},
|
||||
main: {
|
||||
src: '<%= config.srcFolder %>/<%= config.libName %>.js',
|
||||
dest: '<%= config.distFolder %>/<%= config.libName %>.js'
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
sourceMapIncludeSources: true
|
||||
},
|
||||
main: {
|
||||
files: {
|
||||
'<%= config.distFolder %>/<%= config.libName %>.min.js':
|
||||
['<%= config.distFolder %>/<%= config.libName %>.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
karma: {
|
||||
main: {
|
||||
options: {
|
||||
files: [
|
||||
'<%= config.srcFolder %>/Layout.js',
|
||||
'<%= config.srcFolder %>/Layout-test-utils.js',
|
||||
'<%= config.testFolder %>/Layout-test.js',
|
||||
'<%= config.testFolder %>/Layout-consts-test.js'
|
||||
],
|
||||
browsers: ['Chrome'],
|
||||
frameworks: ['jasmine'],
|
||||
singleRun: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
execute: {
|
||||
transpile: {
|
||||
src: ['<%= config.srcFolder %>/transpile.js']
|
||||
}
|
||||
},
|
||||
|
||||
concat: {
|
||||
options: {
|
||||
separator: '\n',
|
||||
// Replace all 'use strict' statements in the code with a single one at the top
|
||||
banner: [
|
||||
'/*',
|
||||
' * #define CSS_LAYOUT_IMPLEMENTATION',
|
||||
' * before you include this file in *one* C or C++ file to create the implementation.',
|
||||
' */\n'
|
||||
].join('\n'),
|
||||
process: function(src, filepath) {
|
||||
if (path.extname(filepath) === '.c') {
|
||||
return [
|
||||
'#ifdef CSS_LAYOUT_IMPLEMENTATION',
|
||||
src,
|
||||
'#endif // CSS_LAYOUT_IMPLEMENTATION'
|
||||
].join('\n');
|
||||
} else {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
},
|
||||
dist: {
|
||||
src: ['<%= config.srcFolder %>/Layout.h', '<%= config.srcFolder %>/Layout.c'],
|
||||
dest: '<%= config.distFolder %>/css-layout.h'
|
||||
}
|
||||
},
|
||||
|
||||
shell: {
|
||||
cCompile: {
|
||||
command: config.cTestCompile
|
||||
},
|
||||
cTestExecute: {
|
||||
command: config.cTestExecute
|
||||
},
|
||||
javaCompile: {
|
||||
command: 'javac -cp <%= config.javaLibFolder %>/junit4.jar<%= config.delimiter %><%= config.javaLibFolder %>/jsr305.jar<%= config.delimiter %><%= config.javaLibFolder %>/infer-annotations-1.4.jar' + ' -sourcepath ./src/java/src<%= config.delimiter %>./src/java/tests' + ' <%= config.javaSource %>'
|
||||
},
|
||||
javaTestExecute: {
|
||||
command: 'java -cp ./src/java/src<%= config.delimiter %>./src/java/tests<%= config.delimiter %><%= config.javaLibFolder %>/junit4.jar<%= config.delimiter %><%= config.javaLibFolder %>/infer-annotations-1.4.jar <%= config.javaTestFiles %>'
|
||||
},
|
||||
javaPackage: {
|
||||
command: 'jar cf <%= config.distFolder %>/<%= config.libName %>.jar <%= config.javaSource %>'
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
files: ['src/Layout.js'],
|
||||
tasks: ['ci']
|
||||
}
|
||||
});
|
||||
|
||||
// Compiles and runs the Java tests
|
||||
grunt.registerTask('test-java', ['shell:javaCompile', 'shell:javaTestExecute', 'clean:javaTest']);
|
||||
|
||||
// Compiles and runs the C tests
|
||||
grunt.registerTask('test-c', ['shell:cCompile', 'shell:cTestExecute', 'clean:cTest']);
|
||||
|
||||
// Transpiles the JavaScript to C and Java, running tests
|
||||
grunt.registerTask('transpile', ['execute:transpile', 'test-c', 'test-java']);
|
||||
|
||||
// Lints and tests the JavaScritp using Chrome
|
||||
grunt.registerTask('test-javascript', ['eslint', 'karma']);
|
||||
|
||||
// Packages the JavaScript as a single UMD module and minifies
|
||||
grunt.registerTask('package-javascript', ['includereplace', 'uglify']);
|
||||
|
||||
// Packages the Java as a JAR
|
||||
grunt.registerTask('package-java', ['shell:javaPackage']);
|
||||
|
||||
// Packages the C code as a single header
|
||||
grunt.registerTask('package-c', ['concat']);
|
||||
|
||||
// package all languages
|
||||
grunt.registerTask('package-all', ['package-javascript', 'package-java', 'package-c']);
|
||||
|
||||
// Default build, performs the full works!
|
||||
grunt.registerTask('build', ['test-javascript', 'transpile', 'clean:dist', 'mkdir:dist', 'package-all']);
|
||||
|
||||
// The JavaScript unit tests require Chrome (they need a faithful flexbox implementation
|
||||
// to test against), so under CI this step is skipped.
|
||||
grunt.registerTask('ci', ['eslint', 'transpile', 'clean:dist', 'mkdir:dist', 'package-all']);
|
||||
|
||||
grunt.registerTask('default', ['build']);
|
||||
};
|
4
LICENSE
4
LICENSE
@@ -1,8 +1,8 @@
|
||||
BSD License
|
||||
|
||||
For css-layout software
|
||||
For yoga software
|
||||
|
||||
Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
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
|
||||
|
155
README.md
155
README.md
@@ -1,147 +1,28 @@
|
||||
css-layout [](https://travis-ci.org/facebook/css-layout)
|
||||
==========
|
||||
# Yoga [](https://travis-ci.org/facebook/yoga)
|
||||
|
||||
This project implements a subset of CSS including flexbox and the box model using pure JavaScript, then transpiled to C and Java. The goal is to have a small standalone library to layout elements. It doesn't rely on the DOM at all.
|
||||
## 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 Java, C and JavaScript version of the code is available via [npm](https://www.npmjs.com/package/css-layout) or directly from the `dist` folder of this repo. The JavaScript version is also available via [cdnjs](https://cdnjs.com/libraries/css-layout).
|
||||
## 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 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`.
|
||||
|
||||
In order to make sure that the code is correct, it is developed in JavaScript using TDD where each commit adds a unit test and the associated code to make it work. All the unit tests are tested against Chrome's implementation of CSS.
|
||||
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.
|
||||
|
||||
The JavaScript version has been implemented in a way that can be easily transpiled to C and Java via regexes. The layout function doesn't do any allocation nor uses any of the dynamic aspect of JavaScript. The tests are also transpiled to make sure that the implementations are correct everywhere.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
A single function `computeLayout` is exposed that
|
||||
- takes a tree of nodes: `{ style: { ... }, children: [ nodes ] }`
|
||||
- computes the layout and writes it back to the node tree.
|
||||
|
||||
For example,
|
||||
|
||||
```javascript
|
||||
// create an initial tree of nodes
|
||||
var nodeTree = {
|
||||
"style": {
|
||||
"padding": 50
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"style": {
|
||||
"padding": 10,
|
||||
"alignSelf": "stretch"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// compute the layout
|
||||
computeLayout(nodeTree);
|
||||
|
||||
// the layout information is written back to the node tree, with
|
||||
// each node now having a layout property:
|
||||
|
||||
// JSON.stringify(nodeTree, null, 2);
|
||||
{
|
||||
"style": {
|
||||
"padding": 50
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"style": {
|
||||
"padding": 10,
|
||||
"alignSelf": "stretch"
|
||||
},
|
||||
"layout": {
|
||||
"width": 20,
|
||||
"height": 20,
|
||||
"top": 50,
|
||||
"left": 50,
|
||||
"right": 50,
|
||||
"bottom": 50,
|
||||
"direction": "ltr"
|
||||
},
|
||||
"children": [],
|
||||
"lineIndex": 0
|
||||
}
|
||||
],
|
||||
"layout": {
|
||||
"width": 120,
|
||||
"height": 120,
|
||||
"top": 0,
|
||||
"left": 0,
|
||||
"right": 0,
|
||||
"bottom": 0,
|
||||
"direction": "ltr"
|
||||
}
|
||||
}
|
||||
```html
|
||||
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
Supported Attributes
|
||||
--------------------
|
||||
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.
|
||||
|
||||
Name | Value
|
||||
----:|------
|
||||
width, height | positive number
|
||||
minWidth, minHeight | positive number
|
||||
maxWidth, maxHeight | positive number
|
||||
left, right, top, bottom | number
|
||||
margin, marginLeft, marginRight, marginTop, marginBottom | number
|
||||
padding, paddingLeft, paddingRight, paddingTop, paddingBottom | positive number
|
||||
borderWidth, borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth | positive number
|
||||
flexDirection | 'column', 'row'
|
||||
justifyContent | 'flex-start', 'center', 'flex-end', 'space-between', 'space-around'
|
||||
alignItems, alignSelf | 'flex-start', 'center', 'flex-end', 'stretch'
|
||||
flex | positive number
|
||||
flexWrap | 'wrap', 'nowrap'
|
||||
position | 'relative', 'absolute'
|
||||
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.
|
||||
|
||||
- `inherit` value is not implemented because it's a way to disambiguate between multiple colliding rules. This should be done in a pre-processing step, not in the actual layout algorithm.
|
||||
### .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`.
|
||||
|
||||
## 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.
|
||||
|
||||
|
||||
Default values
|
||||
--------------
|
||||
Since we are only using flexbox, we can use defaults that are much more sensible. This is the configuration to use in order to get the same behavior using the DOM and CSS. You can try those default settings with 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;
|
||||
}
|
||||
```
|
||||
|
||||
- `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`.
|
||||
|
||||
Native Usage Notes
|
||||
------------------
|
||||
|
||||
The C equivalent of `computeLayout` is [`layoutNode`](dist/css-layout.h#L1378).
|
||||
|
||||
In order for layout to properly layout reflowable text, the `measure` function must be set on the `css_node` structure. The property can be found in [`css-layout.h`](dist/css-layout.h#L146). This function must take a void pointer to a `context` that will affect the size of the node and the `width` as computed by the layout engine, and must return a `css_dim_t` structure defining the actual needed size of the node. For the most part, the `context` field can be the text inside the node. No C implementation of this function is provided in provided - it depends on your use of css-layout. However an implementation of the function in JavaScript can be used for reference in the [test utilities](src/Layout-test-utils.js#L383).
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
||||
The core logic resides with `Layout.js`, which is transpiled into equivalent C and Java implementations.
|
||||
|
||||
The JavaScript build process is managed via Grunt. The build performs linting, runs the tests against Chrome, transpiles and packages the code (JavaScript and Java) into the `dist` folder. For JavaScript, the build output uses the Universal Module Format (UMD) so that it can be used via AMD / RequireJS, CommonJS or included directly into an HTML page.
|
||||
|
||||
While developing you can just run the lint / Chrome-based tests a follows:
|
||||
|
||||
```
|
||||
grunt test-javascript
|
||||
```
|
||||
## 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.
|
||||
|
35
YOGA_DEFS
Normal file
35
YOGA_DEFS
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
YOGA_ROOT = '//...'
|
||||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
||||
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
||||
JUNIT_TARGET = '//lib/junit:junit'
|
||||
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
|
||||
SOLOADER_TARGET = '//lib/soloader:soloader'
|
||||
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',
|
||||
]
|
||||
|
||||
BASE_COMPILER_FLAGS = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
]
|
||||
|
||||
def yoga_dep(dep):
|
||||
return '//' + dep
|
||||
|
||||
class allow_unsafe_import:
|
||||
def __enter__(self):
|
||||
pass
|
||||
def __exit__(self, type, value, traceback):
|
||||
pass
|
58
YogaKit/BUCK
Normal file
58
YogaKit/BUCK
Normal file
@@ -0,0 +1,58 @@
|
||||
# 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_defs('//YOGA_DEFS')
|
||||
|
||||
COMPILER_FLAGS = [
|
||||
'-fobjc-arc',
|
||||
'-Wconditional-uninitialized',
|
||||
'-Wdangling-else',
|
||||
'-Wdeprecated-declarations',
|
||||
'-Wimplicit-retain-self',
|
||||
'-Wincomplete-implementation',
|
||||
'-Wobjc-method-access',
|
||||
'-Wobjc-missing-super-calls',
|
||||
'-Wmismatched-return-types',
|
||||
'-Wreturn-type',
|
||||
'-Wno-global-constructors',
|
||||
'-Wno-shadow',
|
||||
'-Wunused-const-variable',
|
||||
'-Wunused-function',
|
||||
'-Wunused-property-ivar',
|
||||
'-Wunused-result',
|
||||
'-Wunused-value',
|
||||
]
|
||||
|
||||
apple_library(
|
||||
name = 'YogaKit',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
srcs = glob(['*.m']),
|
||||
exported_headers = glob(['*.h']),
|
||||
frameworks = [
|
||||
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
|
||||
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
||||
],
|
||||
deps = [
|
||||
yoga_dep(':yoga'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
apple_test(
|
||||
name = 'YogaKitTests',
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
info_plist = 'Tests/Info.plist',
|
||||
srcs = glob(['Tests/**/*.m']),
|
||||
frameworks = [
|
||||
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
|
||||
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
|
||||
],
|
||||
deps = [
|
||||
':YogaKit',
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
22
YogaKit/Tests/Info.plist
Normal file
22
YogaKit/Tests/Info.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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>com.facebook.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
271
YogaKit/Tests/YogaKitTests.m
Normal file
271
YogaKit/Tests/YogaKitTests.m
Normal file
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* 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 <XCTest/XCTest.h>
|
||||
|
||||
#import <YogaKit/UIView+Yoga.h>
|
||||
|
||||
@interface YogaKitTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation YogaKitTests
|
||||
|
||||
#ifndef TRAVIS_CI
|
||||
|
||||
- (void)testNodesAreDeallocedWithSingleView
|
||||
{
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view yg_setFlexBasis:1];
|
||||
XCTAssertEqual(1, YGNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
- (void)testNodesAreDeallocedCascade
|
||||
{
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[view yg_setFlexBasis:1];
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview yg_setFlexBasis:1];
|
||||
[view addSubview:subview];
|
||||
}
|
||||
XCTAssertEqual(11, YGNodeGetInstanceCount());
|
||||
view = nil;
|
||||
|
||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (void)testUsesYoga
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertFalse([view yg_usesYoga]);
|
||||
|
||||
[view yg_setUsesYoga:YES];
|
||||
XCTAssertTrue([view yg_usesYoga]);
|
||||
|
||||
[view yg_setUsesYoga:NO];
|
||||
XCTAssertFalse([view yg_usesYoga]);
|
||||
}
|
||||
|
||||
- (void)testSizeThatFitsAsserts
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
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 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 yg_setUsesYoga:YES];
|
||||
[longTextLabel yg_setFlexShrink:1];
|
||||
[container addSubview:longTextLabel];
|
||||
|
||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[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 yg_intrinsicSize];
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
|
||||
}
|
||||
|
||||
- (void)testFrameAndOriginPlacement
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(320, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview yg_setUsesYoga:YES];
|
||||
[subview yg_setFlexGrow:1];
|
||||
|
||||
[container addSubview:subview];
|
||||
}
|
||||
[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));
|
||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
|
||||
|
||||
CGFloat totalWidth = 0;
|
||||
for (UIView *view in container.subviews) {
|
||||
totalWidth += view.bounds.size.width;
|
||||
}
|
||||
|
||||
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
||||
}
|
||||
|
||||
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(300, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[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 yg_setIncludeInLayout:NO];
|
||||
[container yg_applyLayout];
|
||||
|
||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
|
||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
|
||||
|
||||
// this frame shouldn't have been modified since last time.
|
||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
||||
}
|
||||
|
||||
- (void)testThatWeRespectIncludeInLayoutFlag
|
||||
{
|
||||
const CGSize containerSize = CGSizeMake(300, 50);
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[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 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));
|
||||
|
||||
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
|
||||
}
|
||||
|
||||
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[container yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setIncludeInLayout:YES];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[container yg_applyLayout];
|
||||
XCTAssertEqual(1, [container yg_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 yg_setUsesYoga:YES];
|
||||
[container yg_setFlexDirection:YGFlexDirectionRow];
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview1 yg_setUsesYoga:YES];
|
||||
[subview1 yg_setFlexGrow:1];
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview2 yg_setUsesYoga:YES];
|
||||
[subview2 yg_setFlexGrow:1];
|
||||
[container addSubview:subview2];
|
||||
|
||||
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[subview3 yg_setUsesYoga:YES];
|
||||
[subview3 yg_setFlexGrow:1];
|
||||
[subview3 yg_setIncludeInLayout:NO];
|
||||
[container addSubview:subview3];
|
||||
|
||||
[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 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));
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
72
YogaKit/UIView+Yoga.h
Normal file
72
YogaKit/UIView+Yoga.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@end
|
379
YogaKit/UIView+Yoga.m
Normal file
379
YogaKit/UIView+Yoga.m
Normal file
@@ -0,0 +1,379 @@
|
||||
/**
|
||||
* 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]);
|
||||
}
|
||||
|
||||
#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 void YGAttachNodesFromViewHierachy(UIView *view) {
|
||||
YGNodeRef node = [view ygNode];
|
||||
|
||||
// Only leaf nodes should have a measure function
|
||||
if (![view yg_usesYoga] || view.subviews.count == 0) {
|
||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||
YGRemoveAllChildren(node);
|
||||
} else {
|
||||
YGNodeSetMeasureFunc(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 yg_includeInLayout]) {
|
||||
[subviewsToInclude addObject:subview];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL shouldReconstructChildList = NO;
|
||||
if (YGNodeGetChildCount(node) != subviewsToInclude.count) {
|
||||
shouldReconstructChildList = YES;
|
||||
} else {
|
||||
for (int i = 0; i < subviewsToInclude.count; i++) {
|
||||
if (YGNodeGetChild(node, i) != [subviewsToInclude[i] ygNode]) {
|
||||
shouldReconstructChildList = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldReconstructChildList) {
|
||||
YGRemoveAllChildren(node);
|
||||
|
||||
for (int i = 0 ; i < subviewsToInclude.count; i++) {
|
||||
UIView *const subview = subviewsToInclude[i];
|
||||
YGNodeInsertChild(node, [subview ygNode], i);
|
||||
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),
|
||||
},
|
||||
};
|
||||
|
||||
const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0;
|
||||
if (!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>
|
Binary file not shown.
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0810"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||
BuildableName = "YogaKitSample.app"
|
||||
BlueprintName = "YogaKitSample"
|
||||
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||
BuildableName = "YogaKitSample.app"
|
||||
BlueprintName = "YogaKitSample"
|
||||
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||
BuildableName = "YogaKitSample.app"
|
||||
BlueprintName = "YogaKitSample"
|
||||
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||
BuildableName = "YogaKitSample.app"
|
||||
BlueprintName = "YogaKitSample"
|
||||
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@@ -0,0 +1,22 @@
|
||||
<?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>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>YogaKitSample.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>13687D421DF8748300E7C260</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
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]));
|
||||
}
|
||||
}
|
27
benchmark/BUCK
Normal file
27
benchmark/BUCK
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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_defs('//YOGA_DEFS')
|
||||
|
||||
cxx_binary(
|
||||
name = 'benchmark',
|
||||
srcs = glob(['*.c']),
|
||||
headers = subdir_glob([('', '*.h')]),
|
||||
header_namespace = '',
|
||||
compiler_flags = [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-fexceptions',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-O3',
|
||||
'-std=c11',
|
||||
],
|
||||
deps = [
|
||||
yoga_dep(':yoga'),
|
||||
],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
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);
|
||||
});
|
||||
|
||||
});
|
73
benchmark/YGBenchmark.h
Normal file
73
benchmark/YGBenchmark.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 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 <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#define NUM_REPETITIONS 1000
|
||||
|
||||
#define YGBENCHMARKS(BLOCK) \
|
||||
int main(int argc, char const *argv[]) { \
|
||||
clock_t __start; \
|
||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||
{ BLOCK } \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define YGBENCHMARK(NAME, BLOCK) \
|
||||
__start = clock(); \
|
||||
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
||||
{ BLOCK } \
|
||||
__endTimes[__i] = clock(); \
|
||||
} \
|
||||
__printBenchmarkResult(NAME, __start, __endTimes);
|
||||
|
||||
int __compareDoubles(const void *a, const void *b) {
|
||||
double arg1 = *(const double *) a;
|
||||
double arg2 = *(const double *) b;
|
||||
|
||||
if (arg1 < arg2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (arg1 > arg2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
|
||||
double timesInMs[NUM_REPETITIONS];
|
||||
double mean = 0;
|
||||
clock_t lastEnd = start;
|
||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
|
||||
lastEnd = endTimes[i];
|
||||
mean += timesInMs[i];
|
||||
}
|
||||
mean /= NUM_REPETITIONS;
|
||||
|
||||
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
|
||||
double median = timesInMs[NUM_REPETITIONS / 2];
|
||||
|
||||
double variance = 0;
|
||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||
variance += pow(timesInMs[i] - mean, 2);
|
||||
}
|
||||
variance /= NUM_REPETITIONS;
|
||||
double stddev = sqrt(variance);
|
||||
|
||||
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
|
||||
}
|
270
csharp/.gitignore
vendored
Normal file
270
csharp/.gitignore
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/
|
||||
csharp/tests/Facebook.Yoga/YogaTest.dll
|
||||
csharp/tests/Facebook.Yoga/YogaTest.dll.mdb
|
||||
csharp/tests/Facebook.Yoga/libyoga.dylib
|
||||
csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
270
csharp/.hgignore
Normal file
270
csharp/.hgignore
Normal file
@@ -0,0 +1,270 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/
|
||||
csharp/tests/Facebook.Yoga/YogaTest.dll
|
||||
csharp/tests/Facebook.Yoga/YogaTest.dll.mdb
|
||||
csharp/tests/Facebook.Yoga/libyoga.dylib
|
||||
csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
63
csharp/BUCK
Normal file
63
csharp/BUCK
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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_defs('//YOGA_DEFS')
|
||||
|
||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
|
||||
|
||||
csharp_library(
|
||||
name = 'yogalibnet46',
|
||||
dll_name = 'Facebook.Yoga.dll',
|
||||
framework_ver = 'net46',
|
||||
srcs = glob(['**/*.cs']),
|
||||
)
|
||||
|
||||
csharp_library(
|
||||
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'],
|
||||
)
|
46
csharp/Facebook.Yoga.sln
Normal file
46
csharp/Facebook.Yoga.sln
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
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}") = "Yoga", "Yoga\Yoga.vcxproj", "{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.xproj", "{75BB7605-E54B-4EDE-8F5A-FF1F24464236}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x64.Build.0 = Debug|x64
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.Build.0 = Debug|Win32
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.ActiveCfg = Release|x64
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.Build.0 = Release|x64
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x86.ActiveCfg = Release|Win32
|
||||
{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x86.Build.0 = Release|Win32
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x64.Build.0 = Release|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{75BB7605-E54B-4EDE-8F5A-FF1F24464236}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
21
csharp/Facebook.Yoga/Facebook.Yoga.xproj
Normal file
21
csharp/Facebook.Yoga/Facebook.Yoga.xproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>75bb7605-e54b-4ede-8f5a-ff1f24464236</ProjectGuid>
|
||||
<RootNamespace>Facebook.Yoga</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
18
csharp/Facebook.Yoga/MeasureFunction.cs
Normal file
18
csharp/Facebook.Yoga/MeasureFunction.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 delegate long MeasureFunction(
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode);
|
||||
}
|
34
csharp/Facebook.Yoga/MeasureOutput.cs
Normal file
34
csharp/Facebook.Yoga/MeasureOutput.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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 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);
|
||||
}
|
||||
}
|
||||
}
|
283
csharp/Facebook.Yoga/Native.cs
Normal file
283
csharp/Facebook.Yoga/Native.cs
Normal file
@@ -0,0 +1,283 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGInteropSetLogger(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr YGNodeNew();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeFree(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeReset(IntPtr 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(IntPtr node, IntPtr child, uint index);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeRemoveChild(IntPtr node, IntPtr child);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr YGNodeGetChild(IntPtr node, uint index);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern uint YGNodeGetChildCount(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeCalculateLayout(IntPtr node,
|
||||
float availableWidth,
|
||||
float availableHeight,
|
||||
YogaDirection parentDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeMarkDirty(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGNodeIsDirty(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodePrint(IntPtr node, YogaPrintOptions options);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGValueIsUndefined(float value);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
|
||||
|
||||
#region YG_NODE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeSetContext(IntPtr node, IntPtr context);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern IntPtr YGNodeGetContext(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeSetMeasureFunc(
|
||||
IntPtr node,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
public static extern YogaMeasureFunc YGNodeGetMeasureFunc(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
|
||||
|
||||
[DllImport(DllName)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool YGNodeGetHasNewLayout(IntPtr node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_STYLE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaDirection YGNodeStyleGetDirection(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaJustify YGNodeStyleGetJustifyContent(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignContent(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignItems(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaAlign YGNodeStyleGetAlignSelf(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaPositionType YGNodeStyleGetPositionType(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaWrap YGNodeStyleGetFlexWrap(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaOverflow YGNodeStyleGetOverflow(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlex(IntPtr node, float flex);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexGrow(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexShrink(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetFlexBasis(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetWidth(IntPtr node, float width);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetHeight(IntPtr node, float height);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMinWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMinHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMaxWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMaxHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetAspectRatio(IntPtr node);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_STYLE_EDGE_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeStyleGetBorder(IntPtr node, YogaEdge edge);
|
||||
|
||||
#endregion
|
||||
|
||||
#region YG_NODE_LAYOUT_PROPERTY
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetLeft(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetTop(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetRight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetBottom(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetWidth(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern float YGNodeLayoutGetHeight(IntPtr node);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern YogaDirection YGNodeLayoutGetDirection(IntPtr node);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
32
csharp/Facebook.Yoga/Properties/AssemblyInfo.cs
Normal file
32
csharp/Facebook.Yoga/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Facebook, Inc.")]
|
||||
[assembly: AssemblyProduct("Facebook.Yoga")]
|
||||
[assembly: AssemblyTrademark("Copyright (c) 2014-present, Facebook, Inc.")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("75bb7605-e54b-4ede-8f5a-ff1f24464236")]
|
||||
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
[assembly: AssemblyVersion("3.0.0.0")]
|
31
csharp/Facebook.Yoga/Spacing.cs
Normal file
31
csharp/Facebook.Yoga/Spacing.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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 Spacing
|
||||
{
|
||||
public float? Top;
|
||||
public float? Bottom;
|
||||
public float? Left;
|
||||
public float? Right;
|
||||
|
||||
public Spacing(
|
||||
float? top = null,
|
||||
float? bottom = null,
|
||||
float? left = null,
|
||||
float? right = null)
|
||||
{
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
Left = left;
|
||||
Right = right;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -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,
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -7,13 +7,13 @@
|
||||
* 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 static readonly float Undefined = float.NaN;
|
||||
public const float Undefined = float.NaN;
|
||||
|
||||
public static bool IsUndefined(float value)
|
||||
public static bool IsUndefined(float value)
|
||||
{
|
||||
return float.IsNaN(value);
|
||||
}
|
17
csharp/Facebook.Yoga/YogaDimension.cs
Normal file
17
csharp/Facebook.Yoga/YogaDimension.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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 YogaDimension
|
||||
{
|
||||
Width,
|
||||
Height,
|
||||
}
|
||||
}
|
8
src/csharp/Facebook.CSSLayout/CSSDirection.cs → csharp/Facebook.Yoga/YogaDirection.cs
Executable file → Normal file
8
src/csharp/Facebook.CSSLayout/CSSDirection.cs → csharp/Facebook.Yoga/YogaDirection.cs
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -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 enum CSSDirection
|
||||
public enum YogaDirection
|
||||
{
|
||||
Inherit,
|
||||
LTR,
|
||||
RTL
|
||||
RTL,
|
||||
}
|
||||
}
|
24
csharp/Facebook.Yoga/YogaEdge.cs
Normal file
24
csharp/Facebook.Yoga/YogaEdge.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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 YogaEdge
|
||||
{
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
Bottom,
|
||||
Start,
|
||||
End,
|
||||
Horizontal,
|
||||
Vertical,
|
||||
All,
|
||||
}
|
||||
}
|
17
csharp/Facebook.Yoga/YogaExperimentalFeature.cs
Normal file
17
csharp/Facebook.Yoga/YogaExperimentalFeature.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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 YogaExperimentalFeature
|
||||
{
|
||||
Rounding,
|
||||
WebFlexBasis,
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -7,13 +7,13 @@
|
||||
* 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,
|
||||
Row,
|
||||
RowReverse
|
||||
RowReverse,
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -7,14 +7,14 @@
|
||||
* 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,
|
||||
FlexEnd,
|
||||
SpaceBetween,
|
||||
SpaceAround
|
||||
SpaceAround,
|
||||
}
|
||||
}
|
20
csharp/Facebook.Yoga/YogaLogLevel.cs
Normal file
20
csharp/Facebook.Yoga/YogaLogLevel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 YogaLogLevel
|
||||
{
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Verbose,
|
||||
}
|
||||
}
|
45
csharp/Facebook.Yoga/YogaLogger.cs
Normal file
45
csharp/Facebook.Yoga/YogaLogger.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 YogaLogger
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Func(YogaLogLevel level, string message);
|
||||
|
||||
private static bool _initialized;
|
||||
private static Func _managedLogger = null;
|
||||
|
||||
public static Func Logger = null;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
_managedLogger = (level, message) => {
|
||||
if (Logger != null)
|
||||
{
|
||||
Logger(level, message);
|
||||
}
|
||||
|
||||
if (level == YogaLogLevel.Error)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
};
|
||||
Native.YGInteropSetLogger(_managedLogger);
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
csharp/Facebook.Yoga/YogaMeasureFunc.cs
Normal file
22
csharp/Facebook.Yoga/YogaMeasureFunc.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate YogaSize YogaMeasureFunc(
|
||||
IntPtr node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode);
|
||||
}
|
18
csharp/Facebook.Yoga/YogaMeasureMode.cs
Normal file
18
csharp/Facebook.Yoga/YogaMeasureMode.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 YogaMeasureMode
|
||||
{
|
||||
Undefined,
|
||||
Exactly,
|
||||
AtMost,
|
||||
}
|
||||
}
|
233
csharp/Facebook.Yoga/YogaNode.Create.cs
Normal file
233
csharp/Facebook.Yoga/YogaNode.Create.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public partial class YogaNode
|
||||
{
|
||||
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,
|
||||
float? flexBasis = null,
|
||||
Spacing position = null,
|
||||
Spacing margin = null,
|
||||
Spacing padding = null,
|
||||
Spacing border = null,
|
||||
float? width = null,
|
||||
float? height = null,
|
||||
float? maxWidth = null,
|
||||
float? maxHeight = null,
|
||||
float? minWidth = null,
|
||||
float? minHeight = null)
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
|
||||
if (styleDirection.HasValue)
|
||||
{
|
||||
node.StyleDirection = styleDirection.Value;
|
||||
}
|
||||
|
||||
if (flexDirection.HasValue)
|
||||
{
|
||||
node.FlexDirection = flexDirection.Value;
|
||||
}
|
||||
|
||||
if (justifyContent.HasValue)
|
||||
{
|
||||
node.JustifyContent = justifyContent.Value;
|
||||
}
|
||||
|
||||
if (alignContent.HasValue)
|
||||
{
|
||||
node.AlignContent = alignContent.Value;
|
||||
}
|
||||
|
||||
if (alignItems.HasValue)
|
||||
{
|
||||
node.AlignItems = alignItems.Value;
|
||||
}
|
||||
|
||||
if (alignSelf.HasValue)
|
||||
{
|
||||
node.AlignSelf = alignSelf.Value;
|
||||
}
|
||||
|
||||
if (positionType.HasValue)
|
||||
{
|
||||
node.PositionType = positionType.Value;
|
||||
}
|
||||
|
||||
if (wrap.HasValue)
|
||||
{
|
||||
node.Wrap = wrap.Value;
|
||||
}
|
||||
|
||||
if (overflow.HasValue)
|
||||
{
|
||||
node.Overflow = overflow.Value;
|
||||
}
|
||||
|
||||
if (flex.HasValue)
|
||||
{
|
||||
node.Flex = flex.Value;
|
||||
}
|
||||
|
||||
if (flexGrow.HasValue)
|
||||
{
|
||||
node.FlexGrow = flexGrow.Value;
|
||||
}
|
||||
|
||||
if (flexShrink.HasValue)
|
||||
{
|
||||
node.FlexShrink = flexShrink.Value;
|
||||
}
|
||||
|
||||
if (flexBasis.HasValue)
|
||||
{
|
||||
node.FlexBasis = flexBasis.Value;
|
||||
}
|
||||
|
||||
if (position != null)
|
||||
{
|
||||
if (position.Top.HasValue)
|
||||
{
|
||||
node.SetPosition(YogaEdge.Top, position.Top.Value);
|
||||
}
|
||||
|
||||
if (position.Bottom.HasValue)
|
||||
{
|
||||
node.SetPosition(YogaEdge.Bottom, position.Bottom.Value);
|
||||
}
|
||||
|
||||
if (position.Left.HasValue)
|
||||
{
|
||||
node.SetPosition(YogaEdge.Left, position.Left.Value);
|
||||
}
|
||||
|
||||
if (position.Right.HasValue)
|
||||
{
|
||||
node.SetPosition(YogaEdge.Right, position.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (margin != null)
|
||||
{
|
||||
if (margin.Top.HasValue)
|
||||
{
|
||||
node.SetMargin(YogaEdge.Top, margin.Top.Value);
|
||||
}
|
||||
|
||||
if (margin.Bottom.HasValue)
|
||||
{
|
||||
node.SetMargin(YogaEdge.Bottom, margin.Bottom.Value);
|
||||
}
|
||||
|
||||
if (margin.Left.HasValue)
|
||||
{
|
||||
node.SetMargin(YogaEdge.Left, margin.Left.Value);
|
||||
}
|
||||
|
||||
if (margin.Right.HasValue)
|
||||
{
|
||||
node.SetMargin(YogaEdge.Right, margin.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (padding != null)
|
||||
{
|
||||
if (padding.Top.HasValue)
|
||||
{
|
||||
node.SetPadding(YogaEdge.Top, padding.Top.Value);
|
||||
}
|
||||
|
||||
if (padding.Bottom.HasValue)
|
||||
{
|
||||
node.SetPadding(YogaEdge.Bottom, padding.Bottom.Value);
|
||||
}
|
||||
|
||||
if (padding.Left.HasValue)
|
||||
{
|
||||
node.SetPadding(YogaEdge.Left, padding.Left.Value);
|
||||
}
|
||||
|
||||
if (padding.Right.HasValue)
|
||||
{
|
||||
node.SetPadding(YogaEdge.Right, padding.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (border != null)
|
||||
{
|
||||
if (border.Top.HasValue)
|
||||
{
|
||||
node.SetBorder(YogaEdge.Top, border.Top.Value);
|
||||
}
|
||||
|
||||
if (border.Bottom.HasValue)
|
||||
{
|
||||
node.SetBorder(YogaEdge.Bottom, border.Bottom.Value);
|
||||
}
|
||||
|
||||
if (border.Left.HasValue)
|
||||
{
|
||||
node.SetBorder(YogaEdge.Left, border.Left.Value);
|
||||
}
|
||||
|
||||
if (border.Right.HasValue)
|
||||
{
|
||||
node.SetBorder(YogaEdge.Right, border.Right.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (width.HasValue)
|
||||
{
|
||||
node.Width = width.Value;
|
||||
}
|
||||
|
||||
if (height.HasValue)
|
||||
{
|
||||
node.Height = height.Value;
|
||||
}
|
||||
|
||||
if (minWidth.HasValue)
|
||||
{
|
||||
node.MinWidth = minWidth.Value;
|
||||
}
|
||||
|
||||
if (minHeight.HasValue)
|
||||
{
|
||||
node.MinHeight = minHeight.Value;
|
||||
}
|
||||
|
||||
if (maxWidth.HasValue)
|
||||
{
|
||||
node.MaxWidth = maxWidth.Value;
|
||||
}
|
||||
|
||||
if (maxHeight.HasValue)
|
||||
{
|
||||
node.MaxHeight = maxHeight.Value;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
584
csharp/Facebook.Yoga/YogaNode.cs
Normal file
584
csharp/Facebook.Yoga/YogaNode.cs
Normal file
@@ -0,0 +1,584 @@
|
||||
/**
|
||||
* 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 IntPtr _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 == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
~YogaNode()
|
||||
{
|
||||
Native.YGNodeFree(_ygNode);
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
long output = _measureFunction(this, width, widthMode, height, heightMode);
|
||||
return new YogaSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) };
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* 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.
|
||||
*/
|
||||
package com.facebook.csslayout;
|
||||
|
||||
public enum CSSAlign {
|
||||
AUTO,
|
||||
FLEX_START,
|
||||
CENTER,
|
||||
FLEX_END,
|
||||
STRETCH,
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum YogaOverflow
|
||||
{
|
||||
Visible,
|
||||
Hidden,
|
||||
Scroll,
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
@@ -7,11 +7,11 @@
|
||||
* 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
|
||||
Absolute,
|
||||
}
|
||||
}
|
18
csharp/Facebook.Yoga/YogaPrintOptions.cs
Normal file
18
csharp/Facebook.Yoga/YogaPrintOptions.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 YogaPrintOptions
|
||||
{
|
||||
Layout = 1,
|
||||
Style = 2,
|
||||
Children = 4,
|
||||
}
|
||||
}
|
20
csharp/Facebook.Yoga/YogaSize.cs
Normal file
20
csharp/Facebook.Yoga/YogaSize.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct YogaSize
|
||||
{
|
||||
public float width;
|
||||
public float height;
|
||||
}
|
||||
}
|
@@ -1,16 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
* 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
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public enum CSSWrap
|
||||
public enum YogaWrap
|
||||
{
|
||||
NoWrap,
|
||||
Wrap
|
||||
Wrap,
|
||||
}
|
||||
}
|
14
csharp/Facebook.Yoga/project.json
Normal file
14
csharp/Facebook.Yoga/project.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"language": "en",
|
||||
"version": "3.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.0"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netstandard1.6": {
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
27
csharp/Yoga/YGInterop.cpp
Normal file
27
csharp/Yoga/YGInterop.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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 "YGInterop.h"
|
||||
|
||||
static YGInteropLoggerFunc gManagedFunc;
|
||||
|
||||
static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) {
|
||||
int result = 0;
|
||||
if (gManagedFunc) {
|
||||
char buffer[256];
|
||||
result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
(*gManagedFunc)(level, buffer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) {
|
||||
gManagedFunc = managedFunc;
|
||||
YGSetLogger(&unmanagedLogger);
|
||||
}
|
20
csharp/Yoga/YGInterop.h
Normal file
20
csharp/Yoga/YGInterop.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 <yoga/Yoga.h>
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message);
|
||||
|
||||
WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc);
|
||||
|
||||
YG_EXTERN_C_END
|
184
csharp/Yoga/Yoga.vcxproj
Executable file
184
csharp/Yoga/Yoga.vcxproj
Executable file
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectName>yoga</ProjectName>
|
||||
<RootNamespace>Yoga</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<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="..\..\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'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
54
csharp/Yoga/Yoga.vcxproj.filters
Executable file
54
csharp/Yoga/Yoga.vcxproj.filters
Executable file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\yoga\Yoga.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\yoga\YGMacros.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\yoga\YGNodeList.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="YGInterop.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\yoga\Yoga.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\yoga\YGNodeList.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="YGInterop.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
27
csharp/Yoga/dllmain.cpp
Normal file
27
csharp/Yoga/dllmain.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||
#include "stdafx.h"
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
17
csharp/Yoga/stdafx.cpp
Normal file
17
csharp/Yoga/stdafx.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// Yoga.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
25
csharp/Yoga/stdafx.h
Normal file
25
csharp/Yoga/stdafx.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
17
csharp/Yoga/targetver.h
Normal file
17
csharp/Yoga/targetver.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||
|
||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||
|
||||
#include <SDKDDKVer.h>
|
314
csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs
Normal file
314
csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs
Normal file
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGAbsolutePositionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_end_bottom()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_start_top_end_bottom()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_width_height_start_top_end_bottom()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Overflow = YogaOverflow.Hidden;
|
||||
root.Width = 50f;
|
||||
root.Height = 50f;
|
||||
|
||||
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);
|
||||
|
||||
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 = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(50f, 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(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(50f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(-50f, 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(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_absolute_layout_within_border()
|
||||
{
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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 = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10f, root.LayoutX);
|
||||
Assert.AreEqual(10f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(40f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(10f, root.LayoutX);
|
||||
Assert.AreEqual(10f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(40f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
415
csharp/tests/Facebook.Yoga/YGAlignContentTest.cs
Normal file
415
csharp/tests/Facebook.Yoga/YGAlignContentTest.cs
Normal file
@@ -0,0 +1,415 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGAlignContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_content_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.FlexEnd;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root_child3.Height = 10f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root_child4.Height = 10f;
|
||||
root.Insert(4, root_child4);
|
||||
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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_content_stretch()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignContent = YogaAlign.Stretch;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 50f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.Width = 50f;
|
||||
root.Insert(4, root_child4);
|
||||
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(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child4.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(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
175
csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs
Normal file
175
csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGAlignItemsTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_items_stretch()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.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(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(45f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(45f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexStart;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
178
csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs
Normal file
178
csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGAlignSelfTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_align_self_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(45f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(45f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_self_flex_end_override_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.FlexStart;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
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 = 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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
212
csharp/tests/Facebook.Yoga/YGBorderTest.cs
Normal file
212
csharp/tests/Facebook.Yoga/YGBorderTest.cs
Normal file
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGBorderTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_border_no_size()
|
||||
{
|
||||
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);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_container_match_child()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetBorder(YogaEdge.Left, 10f);
|
||||
root.SetBorder(YogaEdge.Top, 10f);
|
||||
root.SetBorder(YogaEdge.Right, 10f);
|
||||
root.SetBorder(YogaEdge.Bottom, 10f);
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_flex_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_stretch_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_border_center_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(35f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(35f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
413
csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs
Normal file
413
csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs
Normal file
@@ -0,0 +1,413 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGFlexDirectionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_direction_column_no_height()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row_no_width()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.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(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_column_reverse()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.ColumnReverse;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
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(90f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(80f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(70f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.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(90f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(80f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(70f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_direction_row_reverse()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.RowReverse;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
419
csharp/tests/Facebook.Yoga/YGFlexTest.cs
Normal file
419
csharp/tests/Facebook.Yoga/YGFlexTest.cs
Normal file
@@ -0,0 +1,419 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGFlexTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
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(75f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(75f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, 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(75f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(75f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_grow_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
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(75f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(75f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(25f, 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(25f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(75f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(25f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 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.FlexBasis = 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);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_flex_shrink_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 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.FlexBasis = 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_shrink_to_zero()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Height = 75f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexShrink = 1f;
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(75f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(50f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(75f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(50f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_basis_overrides_main_size()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
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(60f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(60f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child2.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(60f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(60f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_shrink_at_most()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
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 = 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(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child0_child0.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(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
358
csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs
Normal file
358
csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs
Normal file
@@ -0,0 +1,358 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGFlexWrapTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_wrap_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 30f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 30f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(60f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(30f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(60f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(60f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child1.LayoutX);
|
||||
Assert.AreEqual(30f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child2.LayoutX);
|
||||
Assert.AreEqual(60f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 30f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 30f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.AlignItems = YogaAlign.FlexEnd;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 20f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child0.LayoutX);
|
||||
Assert.AreEqual(20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrap_row_align_items_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 30f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 30f;
|
||||
root_child1.Height = 20f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 30f;
|
||||
root_child2.Height = 30f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.Width = 30f;
|
||||
root_child3.Height = 30f;
|
||||
root.Insert(3, root_child3);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(30f, root_child1.LayoutX);
|
||||
Assert.AreEqual(5f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(60f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(60f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(30f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child1.LayoutX);
|
||||
Assert.AreEqual(5f, root_child1.LayoutY);
|
||||
Assert.AreEqual(30f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(30f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(70f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(30f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child3.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
683
csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs
Normal file
683
csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs
Normal file
@@ -0,0 +1,683 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGJustifyContentTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(82f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(72f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(72f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(82f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(20f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(36f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(56f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(56f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(36f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_between()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.SpaceBetween;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(92f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_row_space_around()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.SpaceAround;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(12f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(46f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(12f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(102f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(10f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(10f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_flex_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(72f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(82f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(92f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(72f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(82f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(92f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_center()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(36f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(56f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(36f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(56f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_between()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.SpaceBetween;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(92f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(92f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_column_space_around()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.SpaceAround;
|
||||
root.Width = 102f;
|
||||
root.Height = 102f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(12f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(102f, root.LayoutWidth);
|
||||
Assert.AreEqual(102f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(12f, root_child0.LayoutY);
|
||||
Assert.AreEqual(102f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(46f, root_child1.LayoutY);
|
||||
Assert.AreEqual(102f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(102f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
434
csharp/tests/Facebook.Yoga/YGMarginTest.cs
Normal file
434
csharp/tests/Facebook.Yoga/YGMarginTest.cs
Normal file
@@ -0,0 +1,434 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGMarginTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_margin_start()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, 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(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_top()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_end()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.End, 10f);
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, 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(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_bottom()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.FlexEnd;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.SetMargin(YogaEdge.Bottom, 10f);
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(80f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_flex_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(90f, 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(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(90f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_flex_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(YogaEdge.Top, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.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(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(90f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_and_stretch_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.SetMargin(YogaEdge.Start, 10f);
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(90f, 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(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(90f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_margin_with_sibling_row()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 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.FlexGrow = 1f;
|
||||
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_margin_with_sibling_column()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 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.FlexGrow = 1f;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
458
csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs
Normal file
458
csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs
Normal file
@@ -0,0 +1,458 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGMinMaxDimensionTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_max_width()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.MaxWidth = 50f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.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(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_max_height()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.MaxHeight = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.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(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_min_height()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.MinHeight = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
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(80f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(80f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, 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(80f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(80f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_min_width()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 100f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.MinWidth = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
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(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(20f, 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(20f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(20f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_min_max()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.Width = 100f;
|
||||
root.MinHeight = 100f;
|
||||
root.MaxHeight = 200f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 60f;
|
||||
root_child0.Height = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
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(20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.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(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_items_min_max()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.MinWidth = 100f;
|
||||
root.MaxWidth = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 60f;
|
||||
root_child0.Height = 60f;
|
||||
root.Insert(0, root_child0);
|
||||
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(20f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.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(20f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(60f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_justify_content_overflow_min_max()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.MinHeight = 100f;
|
||||
root.MaxHeight = 110f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 50f;
|
||||
root_child0.Height = 50f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.Width = 50f;
|
||||
root_child1.Height = 50f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.Width = 50f;
|
||||
root_child2.Height = 50f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(110f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(-20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(30f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(50f, root.LayoutWidth);
|
||||
Assert.AreEqual(110f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(-20f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(30f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(80f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_max_width()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.MaxWidth = 100f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.Height = 20f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
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(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_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(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(100f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_max_width()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 200f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||
root_child0.MaxWidth = 300f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.Height = 20f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
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(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_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(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
256
csharp/tests/Facebook.Yoga/YGPaddingTest.cs
Normal file
256
csharp/tests/Facebook.Yoga/YGPaddingTest.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGPaddingTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_padding_no_size()
|
||||
{
|
||||
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);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(20f, root.LayoutWidth);
|
||||
Assert.AreEqual(20f, root.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_container_match_child()
|
||||
{
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPadding(YogaEdge.Left, 10f);
|
||||
root.SetPadding(YogaEdge.Top, 10f);
|
||||
root.SetPadding(YogaEdge.Right, 10f);
|
||||
root.SetPadding(YogaEdge.Bottom, 10f);
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(30f, root.LayoutWidth);
|
||||
Assert.AreEqual(30f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_flex_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.Width = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.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(80f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(80f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_stretch_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(10f, root_child0.LayoutX);
|
||||
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||
Assert.AreEqual(80f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_padding_center_child()
|
||||
{
|
||||
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;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.Width = 10f;
|
||||
root_child0.Height = 10f;
|
||||
root.Insert(0, root_child0);
|
||||
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(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(35f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.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(35f, root_child0.LayoutY);
|
||||
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
807
csharp/tests/Facebook.Yoga/YGRoundingTest.cs
Normal file
807
csharp/tests/Facebook.Yoga/YGRoundingTest.cs
Normal file
@@ -0,0 +1,807 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[TestFixture]
|
||||
public class YGRoundingTest
|
||||
{
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 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.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root.Insert(2, root_child2);
|
||||
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(33f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(33f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(34f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(67f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(33f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.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(67f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(33f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(33f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(34f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(33f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 113f;
|
||||
root.Height = 100f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode();
|
||||
root_child3.FlexGrow = 1f;
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode();
|
||||
root_child4.FlexGrow = 1f;
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(113f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(23f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(23f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(22f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(23f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(68f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(22f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(23f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(113f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(90f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(23f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(68f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(22f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(45f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(23f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(23f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(22f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(23f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child4.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_flex_shrink_row()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 101f;
|
||||
root.Height = 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.FlexBasis = 25f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexBasis = 25f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(101f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(51f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(51f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(25f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(76f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(25f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(101f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(51f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(25f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(25f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(25f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_flex_basis_overrides_main_size()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_total_fractial()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 87.4f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 0.7f;
|
||||
root_child0.FlexBasis = 50.3f;
|
||||
root_child0.Height = 20.3f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1.6f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1.1f;
|
||||
root_child2.Height = 10.7f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(87f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(59f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(59f, root_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(87f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(59f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(59f, root_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_total_fractial_nested()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 87.4f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 0.7f;
|
||||
root_child0.FlexBasis = 50.3f;
|
||||
root_child0.Height = 20.3f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode();
|
||||
root_child0_child0.FlexGrow = 1f;
|
||||
root_child0_child0.FlexBasis = 0.3f;
|
||||
root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f);
|
||||
root_child0_child0.Height = 9.9f;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child1 = new YogaNode();
|
||||
root_child0_child1.FlexGrow = 4f;
|
||||
root_child0_child1.FlexBasis = 0.3f;
|
||||
root_child0_child1.SetPosition(YogaEdge.Top, 13.3f);
|
||||
root_child0_child1.Height = 1.1f;
|
||||
root_child0.Insert(1, root_child0_child1);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1.6f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1.1f;
|
||||
root_child2.Height = 10.7f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(87f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(59f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(-13f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(12f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(25f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(47f, root_child0_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(59f, root_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(87f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(59f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(-13f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(12f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||
Assert.AreEqual(25f, root_child0_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
|
||||
Assert.AreEqual(47f, root_child0_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(59f, root_child1.LayoutY);
|
||||
Assert.AreEqual(87f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(30f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(87f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_1()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_2()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.Width = 100f;
|
||||
root.Height = 113.6f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(114f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(65f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(114f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(65f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_3()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPosition(YogaEdge.Top, 0.3f);
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(114f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(114f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_4()
|
||||
{
|
||||
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode();
|
||||
root.SetPosition(YogaEdge.Top, 0.7f);
|
||||
root.Width = 100f;
|
||||
root.Height = 113.4f;
|
||||
|
||||
YogaNode root_child0 = new YogaNode();
|
||||
root_child0.FlexGrow = 1f;
|
||||
root_child0.FlexBasis = 50f;
|
||||
root_child0.Height = 20f;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode();
|
||||
root_child1.FlexGrow = 1f;
|
||||
root_child1.Height = 10f;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode();
|
||||
root_child2.FlexGrow = 1f;
|
||||
root_child2.Height = 10f;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(1f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(1f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(113f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
361
csharp/tests/Facebook.Yoga/YogaNodeTest.cs
Normal file
361
csharp/tests/Facebook.Yoga/YogaNodeTest.cs
Normal file
@@ -0,0 +1,361 @@
|
||||
/**
|
||||
* 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 YogaNodeTest
|
||||
{
|
||||
[Test]
|
||||
public void TestAddChildGetParent()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
|
||||
Assert.IsNull(child.Parent);
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
|
||||
parent.Insert(0, child);
|
||||
|
||||
Assert.AreEqual(1, parent.Count);
|
||||
Assert.AreEqual(child, parent[0]);
|
||||
Assert.AreEqual(parent, child.Parent);
|
||||
|
||||
parent.RemoveAt(0);
|
||||
|
||||
Assert.IsNull(child.Parent);
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChildren()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.Fail(node.ToString());
|
||||
}
|
||||
|
||||
YogaNode child0 = new YogaNode();
|
||||
Assert.AreEqual(-1, parent.IndexOf(child0));
|
||||
parent.Insert(0, child0);
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.AreEqual(0, parent.IndexOf(node));
|
||||
}
|
||||
|
||||
YogaNode child1 = new YogaNode();
|
||||
parent.Insert(1, child1);
|
||||
int index = 0;
|
||||
foreach (YogaNode node in parent) {
|
||||
Assert.AreEqual(index++, parent.IndexOf(node));
|
||||
}
|
||||
|
||||
parent.RemoveAt(0);
|
||||
Assert.AreEqual(-1, parent.IndexOf(child0));
|
||||
Assert.AreEqual(0, parent.IndexOf(child1));
|
||||
|
||||
parent.Clear();
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
|
||||
parent.Clear();
|
||||
Assert.AreEqual(0, parent.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.NullReferenceException")]
|
||||
public void TestRemoveAtFromEmpty()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
parent.RemoveAt(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.ArgumentOutOfRangeException")]
|
||||
public void TestRemoveAtOutOfRange()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
parent.RemoveAt(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestCannotAddChildToMultipleParents()
|
||||
{
|
||||
YogaNode parent1 = new YogaNode();
|
||||
YogaNode parent2 = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
|
||||
parent1.Insert(0, child);
|
||||
parent2.Insert(0, child);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReset()
|
||||
{
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
node.Reset();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestResetParent()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
parent.Reset();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestResetChild()
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
parent.Insert(0, child);
|
||||
child.Reset();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClear()
|
||||
{
|
||||
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, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMeasureFunc()
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
});
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual(100, node.LayoutWidth);
|
||||
Assert.AreEqual(150, node.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMeasureFuncWithFloat()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestChildWithMeasureFunc()
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
});
|
||||
YogaNode child = new YogaNode();
|
||||
node.Insert(0, child);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException("System.InvalidOperationException")]
|
||||
public void TestMeasureFuncWithChild()
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
YogaNode child = new YogaNode();
|
||||
node.Insert(0, child);
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(100, 150);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrint()
|
||||
{
|
||||
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();
|
||||
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyStyle()
|
||||
{
|
||||
YogaNode node0 = new YogaNode();
|
||||
Assert.IsTrue(YogaConstants.IsUndefined(node0.MaxHeight));
|
||||
|
||||
YogaNode node1 = new YogaNode();
|
||||
node1.MaxHeight = 100;
|
||||
|
||||
node0.CopyStyle(node1);
|
||||
Assert.AreEqual(100, node0.MaxHeight);
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
private void ForceGC()
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration);
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
TestDestructorForGC(instanceCount);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestDestructorForGC(int instanceCount)
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.IsNotNull(node);
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
node = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDestructorWithChildren()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
TestDestructorWithChildrenForGC1(instanceCount);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestDestructorWithChildrenForGC1(int instanceCount)
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
|
||||
TestDestructorWithChildrenForGC2(node, instanceCount + 1);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
|
||||
TestDestructorWithChildrenForGC2(node, instanceCount + 2);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 3, YogaNode.GetInstanceCount());
|
||||
|
||||
node = null;
|
||||
}
|
||||
|
||||
private void TestDestructorWithChildrenForGC2(YogaNode parent, int instanceCount)
|
||||
{
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
|
||||
parent.Insert(0, child);
|
||||
child = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParentDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
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, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestParentDestructorForGC(YogaNode child, int instanceCount)
|
||||
{
|
||||
YogaNode parent = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
parent.Insert(0, child);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClearWithChildDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode node = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
TestClearWithChildDestructorForGC(node, instanceCount + 1);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
node.Clear();
|
||||
Assert.AreEqual(0, node.Count);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
}
|
||||
|
||||
private void TestClearWithChildDestructorForGC(YogaNode parent, int instanceCount)
|
||||
{
|
||||
YogaNode child = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
parent.Insert(0, child);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMeasureFuncWithDestructor()
|
||||
{
|
||||
ForceGC();
|
||||
int instanceCount = YogaNode.GetInstanceCount();
|
||||
YogaNode parent = new YogaNode();
|
||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||
TestMeasureFuncWithDestructorForGC(parent);
|
||||
ForceGC();
|
||||
Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount());
|
||||
parent.CalculateLayout();
|
||||
Assert.AreEqual(120, (int)parent.LayoutWidth);
|
||||
Assert.AreEqual(130, (int)parent.LayoutHeight);
|
||||
}
|
||||
|
||||
private void TestMeasureFuncWithDestructorForGC(YogaNode parent)
|
||||
{
|
||||
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
|
17
dist/README.md
vendored
17
dist/README.md
vendored
@@ -1,17 +0,0 @@
|
||||
Releases can be found on [npm](https://www.npmjs.com/package/css-layout).
|
||||
|
||||
#Release Process
|
||||
|
||||
```bash
|
||||
# Ensure that the local codebase is up to date
|
||||
git fetch upstream master && git checkout FETCH_HEAD
|
||||
|
||||
# increment the version number and tag the release
|
||||
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]
|
||||
|
||||
# push the the commit and tag back to upstream
|
||||
git push --tags upstream HEAD:master
|
||||
|
||||
# publish this new version to npm
|
||||
npm publish
|
||||
```
|
1410
dist/css-layout.h
vendored
1410
dist/css-layout.h
vendored
File diff suppressed because it is too large
Load Diff
BIN
dist/css-layout.jar
vendored
BIN
dist/css-layout.jar
vendored
Binary file not shown.
1109
dist/css-layout.js
vendored
1109
dist/css-layout.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/css-layout.min.js
vendored
2
dist/css-layout.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/css-layout.min.js.map
vendored
1
dist/css-layout.min.js.map
vendored
File diff suppressed because one or more lines are too long
189
enums.py
Normal file
189
enums.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# 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.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
|
||||
ENUMS = {
|
||||
'Direction': [
|
||||
'Inherit',
|
||||
'LTR',
|
||||
'RTL',
|
||||
],
|
||||
'FlexDirection': [
|
||||
'Column',
|
||||
'ColumnReverse',
|
||||
'Row',
|
||||
'RowReverse',
|
||||
],
|
||||
'Justify': [
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'SpaceBetween',
|
||||
'SpaceAround',
|
||||
],
|
||||
'Overflow': [
|
||||
'Visible',
|
||||
'Hidden',
|
||||
'Scroll',
|
||||
],
|
||||
'Align': [
|
||||
'Auto',
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'Stretch',
|
||||
],
|
||||
'PositionType': [
|
||||
'Relative',
|
||||
'Absolute',
|
||||
],
|
||||
'Wrap': [
|
||||
'NoWrap',
|
||||
'Wrap',
|
||||
],
|
||||
'MeasureMode': [
|
||||
'Undefined',
|
||||
'Exactly',
|
||||
'AtMost',
|
||||
],
|
||||
'Dimension': [
|
||||
'Width',
|
||||
'Height',
|
||||
],
|
||||
'Edge': [
|
||||
'Left',
|
||||
'Top',
|
||||
'Right',
|
||||
'Bottom',
|
||||
'Start',
|
||||
'End',
|
||||
'Horizontal',
|
||||
'Vertical',
|
||||
'All',
|
||||
],
|
||||
'LogLevel': [
|
||||
'Error',
|
||||
'Warn',
|
||||
'Info',
|
||||
'Debug',
|
||||
'Verbose',
|
||||
],
|
||||
'ExperimentalFeature': [
|
||||
'Rounding',
|
||||
# Mimic web flex-basis behavior.
|
||||
'WebFlexBasis',
|
||||
],
|
||||
'PrintOptions': [
|
||||
('Layout', 1),
|
||||
('Style', 2),
|
||||
('Children', 4),
|
||||
],
|
||||
}
|
||||
|
||||
LICENSE = """/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
"""
|
||||
|
||||
def to_java_upper(symbol):
|
||||
symbol = str(symbol)
|
||||
out = ''
|
||||
for i in range(0, len(symbol)):
|
||||
c = symbol[i]
|
||||
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
|
||||
out += '_'
|
||||
out += c.upper()
|
||||
return out
|
||||
|
||||
|
||||
root = os.path.dirname(__file__)
|
||||
|
||||
# write out C header
|
||||
with open(root + '/yoga/YGEnums.h', 'w') as f:
|
||||
f.write(LICENSE)
|
||||
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 YG%s {\n' % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
||||
else:
|
||||
f.write(' YG%s%s,\n' % (name, value))
|
||||
f.write(' YG%sCount,\n' % name)
|
||||
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/yoga/Yoga%s.java' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
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):
|
||||
f.write(' %s(%d)' % (to_java_upper(value[0]), value[1]))
|
||||
else:
|
||||
f.write(' %s(%d)' % (to_java_upper(value), values.index(value)))
|
||||
if values.index(value) is len(values) - 1:
|
||||
f.write(';\n')
|
||||
else:
|
||||
f.write(',\n')
|
||||
else:
|
||||
f.write('__EMPTY(-1);')
|
||||
f.write('\n')
|
||||
f.write(' private int mIntValue;\n')
|
||||
f.write('\n')
|
||||
f.write(' Yoga%s(int intValue) {\n' % name)
|
||||
f.write(' mIntValue = intValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public int intValue() {\n')
|
||||
f.write(' return mIntValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public static Yoga%s fromInt(int value) {\n' % name)
|
||||
f.write(' switch (value) {\n')
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0])))
|
||||
else:
|
||||
f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value)))
|
||||
f.write(' default: throw new IllegalArgumentException("Unkown enum value: " + value);\n')
|
||||
f.write(' }\n')
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
||||
|
||||
# write out csharp files
|
||||
for name, values in ENUMS.items():
|
||||
with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
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]))
|
||||
else:
|
||||
f.write(' %s,\n' % value)
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
34
format.sh
Executable file
34
format.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
clang-format \
|
||||
-style="{ \
|
||||
AlignAfterOpenBracket: Align, \
|
||||
AlignEscapedNewlinesLeft: true, \
|
||||
AlignOperands: true, \
|
||||
AllowAllParametersOfDeclarationOnNextLine: false, \
|
||||
AllowShortBlocksOnASingleLine: false, \
|
||||
AllowShortCaseLabelsOnASingleLine: false, \
|
||||
AllowShortFunctionsOnASingleLine: false, \
|
||||
AllowShortIfStatementsOnASingleLine: false, \
|
||||
AllowShortLoopsOnASingleLine: false, \
|
||||
BinPackArguments: false, \
|
||||
BinPackParameters: false, \
|
||||
BreakBeforeBraces: Attach, \
|
||||
ColumnLimit: 100, \
|
||||
ContinuationIndentWidth: 4, \
|
||||
IndentCaseLabels: true, \
|
||||
IndentWidth: 2, \
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false, \
|
||||
Language: Cpp, \
|
||||
PenaltyBreakBeforeFirstCallParameter: 100, \
|
||||
PenaltyBreakString: 1000, \
|
||||
PenaltyExcessCharacter: 100, \
|
||||
PenaltyReturnTypeOnItsOwnLine: 100, \
|
||||
PointerAlignment: Right, \
|
||||
SortIncludes: true, \
|
||||
SpaceAfterCStyleCast: true, \
|
||||
UseTab: Never, \
|
||||
}" "$@" \
|
||||
-i $(dirname $0)/yoga/*.{h,c,cpp} \
|
||||
$(dirname $0)/benchmarks/*.{h,c,cpp} \
|
||||
$(dirname $0)/java/jni/*.{h,c,cpp}
|
26
gentest/fixtures/YGAbsolutePositionTest.html
Normal file
26
gentest/fixtures/YGAbsolutePositionTest.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
|
||||
<div style="position: absolute; start: 0px; top: 0px;">
|
||||
<div style="width: 100px; height: 100px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_within_border" style="height:100px; width:100px; border-width: 10px; margin: 10px; padding: 10px;">
|
||||
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
|
||||
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
|
||||
</div>
|
31
gentest/fixtures/YGAlignContentTest.html
Normal file
31
gentest/fixtures/YGAlignContentTest.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
</div>
|
15
gentest/fixtures/YGAlignItemsTest.html
Normal file
15
gentest/fixtures/YGAlignItemsTest.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div id="align_items_stretch" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
15
gentest/fixtures/YGAlignSelfTest.html
Normal file
15
gentest/fixtures/YGAlignSelfTest.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div id="align_self_center" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: center;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_start" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user