Compare commits

...

391 Commits
1.3.0 ... 1.8.0

Author SHA1 Message Date
Michael Lee
a874992e7c Set missing header_namespace
Summary: When we don't explicitly set header_namespace, we can get differing behavior between Android and iOS. Even when it is not explicitly necessary, we are going to try to enforce this properly.

Reviewed By: scottrice

Differential Revision: D7141155

fbshipit-source-id: 74d1488c3909f89ad9d6d0ee0de335b789dc2ccd
2018-03-02 17:05:25 -08:00
Héctor Ramos
31fc287d35 Check PATENTS does not creep into files
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.

Let the script run, prior to fixing the errant files. The script outputs the following:

```
PATENTS crept into some new files?
 --- /dev/fd/63	2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62	2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
 scripts/circleci/check_license.sh
Exited with code 1
```

Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143

Reviewed By: sophiebits

Differential Revision: D7119356

Pulled By: hramos

fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
2018-03-01 08:35:23 -08:00
Daniel Büchele
892913a69d Google analytics tracking
Summary:
Adds tracking for:
- short URL created
- value in interactive documentation changed

Reviewed By: priteshrnandgaonkar

Differential Revision: D7123493

fbshipit-source-id: 2fc19fa6c9b5614043af508a82e898b3ccefcbaa
2018-03-01 06:42:01 -08:00
Marcus Wu
99026e42a9 Fixed min-max docs typo
Summary:
Fixed `Max / Min Width and Height` docs typo.
Closes https://github.com/facebook/yoga/pull/720

Reviewed By: emilsjolander

Differential Revision: D7110855

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 253d96e5d1208b94b6248ffab5f59caaef6ada2b
2018-03-01 06:19:41 -08:00
Pritesh Nandgaonkar
3a82d2b1a8 Change NaN with large number
Summary:
Changed NaN with large number to support `-ffast-math` compiler flag.For  `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`.  Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing.

Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15%

Reviewed By: emilsjolander

Differential Revision: D6969537

fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
2018-03-01 04:03:19 -08:00
Pritesh Nandgaonkar
b28292e454 Make two separate yoga targets for QE
Summary: Setup QE for yoga perf changes

Reviewed By: emilsjolander

Differential Revision: D7059278

fbshipit-source-id: dd11b018edc8ea930d5eba09c6c01e349bb8b63c
2018-03-01 04:03:18 -08:00
Daniel Büchele
2ff18bc948 remove old docs folder
Summary: removing the old `docs` folder as we are switching to `gh-pages` branch.

Reviewed By: emilsjolander

Differential Revision: D7110147

fbshipit-source-id: a27e6fc3a115f2f62b8a0dd5833d872e24698021
2018-02-28 03:43:27 -08:00
Daniel Büchele
d0bee487e0 add tracking for code generators
Summary: Tracks a Google Analytics event once the code generator is opened.

Reviewed By: emilsjolander

Differential Revision: D7097182

fbshipit-source-id: 637a96db981f5e90c9f7ce155ba8669b8dac98fa
2018-02-27 07:13:53 -08:00
Daniel Büchele
419e29c5a6 adding --ignore-scripts flag to yarn
Summary: Travis builds for the website were failing. The problem was due to `yoga-layout` not compiling. However, we don't need to compile `yoga-layout` at all, because we are only using the asm.js version. This adds the `--ignore-scripts` flag to the `yarn` command, to ignore the post-install script which tries to compile yoga.

Reviewed By: emilsjolander

Differential Revision: D7097154

fbshipit-source-id: 3bf9efda0e2ae6166181dad66621cf6fc9586e88
2018-02-27 06:11:55 -08:00
Daniel Büchele
295d111f0e travis node version
Summary: Travis defaults to node version 0.10 (!). Explicitly setting the node version to 8.

Reviewed By: emilsjolander

Differential Revision: D7056888

fbshipit-source-id: f6e31cc75009dc4f322c1750c2ce540afdd641ce
2018-02-23 02:27:00 -08:00
Daniel Büchele
da5eb2db67 Remove travis builds
Summary: Removes travis build as they were currently not in use and prevented website from being deployed.

Reviewed By: emilsjolander

Differential Revision: D7055369

fbshipit-source-id: f227b1da1fea748c526b9faeedef063f9eeff61f
2018-02-22 08:19:56 -08:00
Daniel Büchele
3408e4d4fa adding travis deploy
Summary: Adds a deploy step to travis.yml file to depoly the docs to github pages.

Reviewed By: emilsjolander

Differential Revision: D7028804

fbshipit-source-id: bb91c6b1ad2a306a6957a48679f164128c5b1be1
2018-02-21 09:47:08 -08:00
Pascal Hartig
6d7eca8e42 Fix typo in docs
Summary:
"feature" should be "features" but it's already used twice in that paragraph so
I replaced it with "showcases" instead.

Reviewed By: emilsjolander

Differential Revision: D7042770

fbshipit-source-id: 0287f8746feca5c9f651950c8e9c24d2e86d55e9
2018-02-21 09:13:31 -08:00
Michael Lee
5726a71b62 Specify a platform argument for //yoga/java:jni
Summary: Specify that the jni rule is really for android

Reviewed By: emilsjolander

Differential Revision: D7015911

fbshipit-source-id: 5fbff4bb15d2d1256261b13417653b68bb6dc5aa
2018-02-20 15:02:21 -08:00
Kazuki Sakamoto
f73b5057ac Fix native build
Summary:
- Fix OSS build regarding is_apple_platform
- Update buck
- Drop 32bit build for Apple target

Reviewed By: ttsugriy

Differential Revision: D7032331

fbshipit-source-id: bb6a24bd404a107729a30b5ac4b419c238f7d42e
2018-02-20 14:13:39 -08:00
Pritesh Nandgaonkar
51051aad7f Added default constructor for YGCachedMeasurement
Summary: Added default constructor for YGCachedMeasurement. This diff uses the default initialiser to get rid off the older designated initializer syntax. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7020337

fbshipit-source-id: e084e234bf6a2ae22e53e739959683abca169b88
2018-02-20 06:22:21 -08:00
Pritesh Nandgaonkar
91d3c08248 Add constructor in YGLayout
Summary: Add default constructor in YGLayout and moved to separate file. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7019653

fbshipit-source-id: 5a2655626db0915fcebe7d4517e2d0b2e2484460
2018-02-20 06:22:21 -08:00
Pritesh Nandgaonkar
52f2cf319a Move YGStyle to seperate file and add constructors
Summary: Moved YGStyle to separate file and added default constructor to it. This diff also gets rid off of the default values, which were earlier declared in Yoga-interna.h and instead uses default constructor. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7016575

fbshipit-source-id: eb28df0ffb4cc813b23edaff80d7d4ebc56ce6af
2018-02-20 06:22:17 -08:00
Emil Sjölander
bbdb62e654 Use absolute paths in links
Summary: allow-large-files

Reviewed By: danielbuechele

Differential Revision: D7023260

fbshipit-source-id: a797d09b61530b13da10e02c21acef13c508470c
2018-02-19 02:57:52 -08:00
Daniel Büchele
e024943c4b bugfixes
Summary:
- adds favicon
- adds page titles
- fixes bug in react native code gen

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D7013492

fbshipit-source-id: d29a56a7caddf0da4fb19a0ba443c6906ccfff56
2018-02-19 02:38:16 -08:00
Sophie Alpert
7f44ec512e Update to MIT license
Summary: Manual changes.

Reviewed By: TheSavior, yungsters

Differential Revision: D7012152

fbshipit-source-id: de7459be3db13c687868b45059856f125c4f2eb1
2018-02-16 18:27:33 -08:00
Sophie Alpert
a2b6ddb7b1 Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:27:33 -08:00
Emil Sjölander
bdc37b0797 shipit
Reviewed By: danielbuechele

Differential Revision: D7010371

fbshipit-source-id: 9a111010755ee134bded7500c461342b944b4d62
2018-02-16 09:58:06 -08:00
Joel Marcey
82aaebfea2 Delete CNAME 2018-02-16 09:48:03 -08:00
Pritesh Nandgaonkar
48d82224ee Add redirect documentation
Summary: Add redirect documentation

Reviewed By: emilsjolander

Differential Revision: D7010032

fbshipit-source-id: fc370bc84e3afa0508ad38f910cf2bc20e991d84
2018-02-16 08:02:53 -08:00
Daniel Büchele
100afcfdb0 Add Yoga logo
Summary: Yoga logo was hotlinked from the old pages. This adds the logo to the sources

Reviewed By: emilsjolander

Differential Revision: D7009804

fbshipit-source-id: d913223e042b1bd9cf2ddab7c74d864e482d94b3
2018-02-16 07:22:06 -08:00
Daniel Büchele
b3436d5eba Default position to NaN
Summary: The position record defaulted to 0, which was wrong. No it defaults to NaN, which is the same as not having a value at all.

Reviewed By: emilsjolander

Differential Revision: D7009783

fbshipit-source-id: 83810da87e983f8d4d3e428f1f5fab0928bce58d
2018-02-16 07:22:06 -08:00
Daniel Büchele
c5371aca64 select value on focus
Summary: select the value of any input element once the field gets focus.

Reviewed By: emilsjolander

Differential Revision: D7009723

fbshipit-source-id: e1bc0f4b219958d8bdb79ef1a583cad86157b050
2018-02-16 07:22:06 -08:00
Pritesh Nandgaonkar
269619a419 Fixed Playground References for examples
Summary: Fixed Playground References for examples

Reviewed By: emilsjolander

Differential Revision: D7009922

fbshipit-source-id: 3025aebb383fb8e2be81e8ff59c0a071ce0860cb
2018-02-16 07:22:06 -08:00
Emil Sjölander
9b3104577c Tweak playground on landing page
Reviewed By: danielbuechele

Differential Revision: D7009909

fbshipit-source-id: a2734466efed6b9dc21f047be011b427bf67f830
2018-02-16 07:22:05 -08:00
Emil Sjölander
a1697d2307 Tweak landing page text
Reviewed By: danielbuechele

Differential Revision: D7009832

fbshipit-source-id: 69f7f68cc8d4f435f27c121bef4899c92f98a7a8
2018-02-16 07:22:05 -08:00
Emil Sjölander
056b75858c Tweak documentation
Reviewed By: danielbuechele

Differential Revision: D7009695

fbshipit-source-id: 145eca292e5cf95413caf5bc81b033419adb67a1
2018-02-16 07:22:05 -08:00
Emil Sjölander
c84ed90272 Allow playground on lg screens not just xl
Summary: This is now possible with the changes to centering the content

Reviewed By: danielbuechele

Differential Revision: D7009506

fbshipit-source-id: e2ff11d25dd6c388c82983d615e2a4c50b992583
2018-02-16 07:22:05 -08:00
Emil Sjölander
b21dd9891a Final tweaks
Reviewed By: danielbuechele

Differential Revision: D7009456

fbshipit-source-id: 65304f648141407bc15484840647050e712e89df
2018-02-16 07:22:05 -08:00
Emil Sjölander
bba81781af Copy review
Reviewed By: danielbuechele

Differential Revision: D7009457

fbshipit-source-id: d5053751a2bde369a65a740c03ace5bbd2eec02f
2018-02-16 07:22:05 -08:00
Pritesh Nandgaonkar
0c74a72fac Fix playground references
Summary: Fix playground references

Reviewed By: emilsjolander

Differential Revision: D7009698

fbshipit-source-id: 276fa1e5b98f05db281e101c90d6f19a1af77752
2018-02-16 06:42:02 -08:00
Daniel Büchele
1822bc5eaf Copy generated code to clipboard
Summary: Generated code modal now has a copy to clipboard button

Reviewed By: emilsjolander

Differential Revision: D7009716

fbshipit-source-id: 7a9b083d7067aa66ffa5b9d9c23741321547c4f6
2018-02-16 06:12:21 -08:00
Daniel Büchele
01ffe10c2f display NaN values as undefined
Summary: NaN values now display a placeholder saying undefined.

Reviewed By: emilsjolander

Differential Revision: D7009509

fbshipit-source-id: a3af360cc5c9d93e95a9e10368270f053a9b2c08
2018-02-16 05:51:22 -08:00
Daniel Büchele
7f99a547f5 hover on nodes
Summary: Adds a hover background color to nodes.

Reviewed By: emilsjolander

Differential Revision: D7009467

fbshipit-source-id: 1e1fb4d00086a6664ad8a53a0e8dbec075987a19
2018-02-16 05:51:22 -08:00
Daniel Büchele
0e5651fb80 Relative values in code generators
Summary: Code generators now can handle percentage and auto values as well as numeric values (DIP)

Reviewed By: emilsjolander

Differential Revision: D7009344

fbshipit-source-id: 64ddcb61a2dce01e68e38a16e4d5865d8e4c6d5b
2018-02-16 03:58:39 -08:00
Emil Sjölander
0ca44f3001 Document layout direction
Reviewed By: priteshrnandgaonkar

Differential Revision: D7000393

fbshipit-source-id: 2e5ae6a3fb69386920655bdfeee71a11f1775c2a
2018-02-16 03:49:48 -08:00
Pritesh Nandgaonkar
3f85763797 Documentation for Writing documentation
Summary: Documentation for "Writing documentation"

Reviewed By: emilsjolander

Differential Revision: D7000294

fbshipit-source-id: 633389a5e32ddd54be8f09b0945db5b9198d9552
2018-02-16 03:18:58 -08:00
Daniel Büchele
b318c4c5c9 upgrade yoga-layout
Summary:
- upgraded to yoga-layout@1.9.3
- set default values correctly
- catch errors

Reviewed By: emilsjolander

Differential Revision: D7001154

fbshipit-source-id: 49527576c61ce109ba0af0f50c981cf5c2c7d41a
2018-02-15 17:10:33 -08:00
Daniel Büchele
ae9703712a v1.9.3
Summary:
- fixes a but where `auto` was passed to properties that don't support auto as a value
- fixes errors in flow typing
- Re-adds accidentally removed scripts to package.json

Reviewed By: emilsjolander, arcanis

Differential Revision: D6999447

fbshipit-source-id: df66976c74c4af082a1ca0527e3e1ce54bdeb732
2018-02-15 09:48:39 -08:00
Emil Sjölander
d617ab6662 Tweak footer styling
Reviewed By: priteshrnandgaonkar

Differential Revision: D6999652

fbshipit-source-id: 93f4e43894388bb607112691a0b97e2e12a7df23
2018-02-15 09:12:34 -08:00
Daniel Büchele
4c3eebd3e5 Remove standalone playground
Summary: This is an older version of the standalone playground which is outdated and not used anymore

Reviewed By: emilsjolander

Differential Revision: D6998970

fbshipit-source-id: a27bee81b6f85f70c35a8d3e7ea7b06486c52626
2018-02-15 08:36:40 -08:00
Daniel Büchele
10061af491 enum title display
Summary: lower case and centerd

Reviewed By: emilsjolander

Differential Revision: D6998485

fbshipit-source-id: c06472afa4ccaa25ebf7c3c791d697b1fdc7732c
2018-02-15 08:36:40 -08:00
Daniel Büchele
91621641e6 visually center root node
Summary: root node is now centerwed between edge and editor

Reviewed By: emilsjolander

Differential Revision: D6989159

fbshipit-source-id: ce2621402d380843125fabc43452c64ea3b563dd
2018-02-15 08:36:40 -08:00
Pritesh Nandgaonkar
35c6931ade Remove unwanted footer items
Summary: Remove unwanted footer items

Reviewed By: emilsjolander

Differential Revision: D6999348

fbshipit-source-id: e1ff13b8a5a497bfc54e04294994eddef48bbf94
2018-02-15 08:13:40 -08:00
Yuichi ONO
44622912a2 Fix main size calculation from the aspect ratio
Summary:
When the following conditions are met, the main size become smaller by the margins in the main axis.
* The aspect ratio is defined
* The main size is not defined
* The cross size is defined
* The main margin is defined

This is because the main margin size is not included when calculating the main size from the aspect ratio.
Closes https://github.com/facebook/yoga/pull/715

Reviewed By: emilsjolander

Differential Revision: D6998988

Pulled By: priteshrnandgaonkar

fbshipit-source-id: f6f69c47ece17bd7c5e41517b96032bf0c149356
2018-02-15 07:40:34 -08:00
Pritesh Nandgaonkar
aac40cf89b Footer implementation
Summary: Footer Implementation

Reviewed By: emilsjolander

Differential Revision: D6998645

fbshipit-source-id: db637f2d9fe1cdbcaa8366e0cc03f2bf67e2543a
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
d4b20f5793 Documentation for absolute/relative layout
Summary: Documentation for absolute/relative layout

Reviewed By: emilsjolander

Differential Revision: D6998594

fbshipit-source-id: 25dacbb87e067ab8abd555fd24611776b0332047
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
89df2d9475 Google Analytics added
Summary: Google analytics added

Reviewed By: emilsjolander

Differential Revision: D6998583

fbshipit-source-id: 3886964407ec32454da4770b0fe80185e8e18881
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
79fa6f8d58 Documentation for min/max
Summary: Documentation for min/max

Reviewed By: emilsjolander

Differential Revision: D6998539

fbshipit-source-id: 65a0c1713fb5a01e41e0afcfbefa1b0280c82ed5
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
69242938f7 Add min/max in YogaRecord
Summary: Add min/max in YogaRecord

Reviewed By: emilsjolander

Differential Revision: D6998533

fbshipit-source-id: 4613c99bd3a4cb3b8fbe577909157b25f3bef9c7
2018-02-15 06:21:00 -08:00
Pritesh Nandgaonkar
1b66b5d941 Documentation added for width and height
Summary: Width and height documentation

Reviewed By: emilsjolander

Differential Revision: D6978015

fbshipit-source-id: f62972acaf70be2b6df5056b5deed2a893c10b4c
2018-02-15 06:21:00 -08:00
Emil Sjölander
fb30f7ddcb Responsify
Reviewed By: danielbuechele

Differential Revision: D6998697

fbshipit-source-id: ea15f1b1ce3f518c194dc66169413a92e0d870bc
2018-02-15 06:21:00 -08:00
David Vacca
747c2a4208 Make Java YogaNode cloneable
Summary:
This diff exposes the YogaNode clone operation to JNI in order to be able to clone Java YogaNode objects.

The clone method performs a shallow copy of the java YogaNode.

I made YogaNode to implement Cloneable, I know that this might not be a good idea but in this case it simplifies the cloning mechanism. I am open to suggestions.

IMPORTANT NOTES:
- The current implementation IS NOT making a deep copy of the mData instance variable.
- The mParent Java instance variable will reference the parent of the original Java YogaNode, is that ok sebmarkbage?

Reviewed By: priteshrnandgaonkar

Differential Revision: D6935971

fbshipit-source-id: a2008f1eb849b5074585b48699b7de56d5ac90d4
2018-02-14 18:12:34 -08:00
Daniel Büchele
43fda26275 add share and code buttons
Summary: Adds code and share buttons to the editor

Reviewed By: emilsjolander

Differential Revision: D6989097

fbshipit-source-id: 67478fe0810a0af43524f24458c520acf2999219
2018-02-14 11:03:59 -08:00
David Vacca
b1222bf83e Expose methods of persistent yoga for Java
Summary: This diff extends the JNI version of yoga in order to allow Java instances of the YogaConfig class to receive a callback when a Yoga node is cloned.

Reviewed By: priteshrnandgaonkar

Differential Revision: D6918605

fbshipit-source-id: e424c78680c04e21154ebe21405671c4e90f6529
2018-02-14 09:41:52 -08:00
Emil Sjölander
3ec41b656f Markdown redirect frontmatter
Reviewed By: danielbuechele

Differential Revision: D6987631

fbshipit-source-id: 8b3431fa885fb94d4a87119b5a5199db0b36b20c
2018-02-14 08:49:37 -08:00
Daniel Büchele
740ef6cd9e flexWrap, alignContent, initialPlayground
Summary: Adds `initialPlayground` to the markdown header. Adds contents fro alignContent and flexWrap.

Reviewed By: emilsjolander

Differential Revision: D6987513

fbshipit-source-id: 41de309d427a9f42e09477170fb8512ce1e7a816
2018-02-14 08:17:21 -08:00
Daniel Büchele
8c5cbf698b Inline controls for docs
Summary:
Adding inline controls in markdown using:
```
<controls prop="flexWrap"></controls>
```

Reviewed By: emilsjolander

Differential Revision: D6987150

fbshipit-source-id: 28def12df702ba5d5d5b6a83dd1cb907716d1b1c
2018-02-14 08:17:21 -08:00
Emil Sjölander
5f2cf6623f Bump size of documentation sidebar
Reviewed By: danielbuechele

Differential Revision: D6978450

fbshipit-source-id: c82da40e2ef44b360cb98e1cc0a28b516aa2e573
2018-02-13 11:43:04 -08:00
Emil Sjölander
4b7efb73d7 Change some default playground styling
Reviewed By: danielbuechele

Differential Revision: D6977989

fbshipit-source-id: 64975685490b8a2230d4effc8791c028b680d2b7
2018-02-13 11:43:04 -08:00
Emil Sjölander
a6b7e34187 Go over property descriptions and add documentation links
Reviewed By: danielbuechele

Differential Revision: D6977090

fbshipit-source-id: cc8a6acda8b9b7f007ad0a2f83249d4e6037bb0f
2018-02-13 11:43:04 -08:00
Emil Sjölander
e50308e823 Tweak styling of list and code in docs
Reviewed By: danielbuechele

Differential Revision: D6976762

fbshipit-source-id: 6decc7af180773193e3811253ada7f8d543c6cc8
2018-02-13 11:43:04 -08:00
Emil Sjölander
b6a13ce43a Mark selected page in toolbar
Reviewed By: danielbuechele

Differential Revision: D6976597

fbshipit-source-id: 280623b4dbf18eb008da846077fc8f5277eccc09
2018-02-13 11:43:03 -08:00
Daniel Büchele
96a87a811d Shorten playground URL
Summary: Shorten URL using Google's URL shortner and display URL for copying.

Reviewed By: emilsjolander

Differential Revision: D6976973

fbshipit-source-id: cc791ffbf9e01a8dc2e0a40d05bce5022a3957bc
2018-02-13 09:45:06 -08:00
Emil Sjölander
025ee03cb1 Add copywrite headers to css files
Reviewed By: danielbuechele

Differential Revision: D6976529

fbshipit-source-id: 7f0c3fdd70105cbe055fa49f10eac3bdaf84b5c2
2018-02-13 09:16:03 -08:00
Emil Sjölander
c06ee92251 Add standalone docs
Reviewed By: danielbuechele

Differential Revision: D6976384

fbshipit-source-id: 329dd6b5997ab83d408fb330421624cf85e3f09e
2018-02-13 07:42:41 -08:00
Emil Sjölander
3aca5965dc Fix sizing of playground in landing page
Reviewed By: danielbuechele

Differential Revision: D6976272

fbshipit-source-id: e9cf8582aa4f8d97190b40d5b7cf219ff1ef8ae5
2018-02-13 07:42:41 -08:00
Emil Sjölander
cac77e5ffa Add contributing docs
Reviewed By: danielbuechele

Differential Revision: D6976258

fbshipit-source-id: 71b3d0ab4a071ce0c4a9c1241cd6295aa6d52b8e
2018-02-13 07:31:58 -08:00
Emil Sjölander
49f1d7b5f6 Add external doc links for Litho, ComponentKit, and React Native
Reviewed By: danielbuechele

Differential Revision: D6976131

fbshipit-source-id: 83f5f59cb839d0c2f291621f9f88678261077082
2018-02-13 06:55:33 -08:00
Emil Sjölander
82e44dbf04 Handle external doc links
Reviewed By: danielbuechele

Differential Revision: D6976132

fbshipit-source-id: 56bd33816a312af12ba9a0f088c9f49a42ef9913
2018-02-13 06:55:33 -08:00
Emil Sjölander
9b501dd9eb Scroll doc sidebar not whole page
Reviewed By: danielbuechele

Differential Revision: D6976133

fbshipit-source-id: 7807aa4e2ab0ed013fbd1f4bbef2ee1b8098dff6
2018-02-13 06:55:33 -08:00
Emil Sjölander
8ba663f6f4 Document margins, paddings, and borders
Reviewed By: danielbuechele

Differential Revision: D6976134

fbshipit-source-id: dcf870d9a88478ed1aef68e9840e7b17467b87bb
2018-02-13 06:55:32 -08:00
Emil Sjölander
8f35484262 Document flexing
Reviewed By: danielbuechele

Differential Revision: D6976135

fbshipit-source-id: e9051b1e583d909aefe76f7aa9505467890a0d4c
2018-02-13 06:55:32 -08:00
Emil Sjölander
1e3143656d Document aspect ratio
Reviewed By: danielbuechele

Differential Revision: D6976130

fbshipit-source-id: caf3cc1d1d1c00fee03ca26966fb57d1796e1604
2018-02-13 06:55:32 -08:00
Daniel Büchele
699b1f5012 Fixing playground editing
Summary: editing numerical values didn't work. this fixes it and cleans up the API of the playground

Reviewed By: emilsjolander

Differential Revision: D6976128

fbshipit-source-id: 9b1ace9d93ba8e597bdfb4842ed6adcaf8b77fd9
2018-02-13 06:16:12 -08:00
Daniel Büchele
9c877a621e fix inserting/deleting children
Summary: Inserting or deleting nodes threw an error, due to some changes I made earlier. This fixes the error.

Reviewed By: emilsjolander

Differential Revision: D6975950

fbshipit-source-id: d04df08260ab8ab248726809329e69f4d264decd
2018-02-13 06:16:12 -08:00
Daniel Büchele
a3144150e0 fix Yoga imports for build script
Summary: The bundling of gatsby is done in node. This caused the node-libs from yoga being loaded. This directly imports the browser version.

Reviewed By: emilsjolander

Differential Revision: D6975779

fbshipit-source-id: 0257a86733c5552259b171309e59cc676786621e
2018-02-13 06:16:12 -08:00
Daniel Büchele
c830083df3 Website readme
Summary: Updating readme

Reviewed By: emilsjolander

Differential Revision: D6975778

fbshipit-source-id: c27a074c8d512e72de63ffa1d2f06f18a4f8e2c5
2018-02-13 06:16:12 -08:00
Emil Sjölander
9eb03b1bcd playground doc page first draft
Reviewed By: danielbuechele

Differential Revision: D6968725

fbshipit-source-id: 588018a347a723b32e4dcab407c4da2db0d85130
2018-02-13 04:01:04 -08:00
Emil Sjölander
7e3136c347 non-playground doc page first draft
Reviewed By: danielbuechele

Differential Revision: D6968540

fbshipit-source-id: c5d408adb1d11c429d72a0f180ce3154ae0922a6
2018-02-13 04:01:04 -08:00
Emil Sjölander
c3de8016c0 Move footer to only landing page
Reviewed By: danielbuechele

Differential Revision: D6968277

fbshipit-source-id: ec01d6e0de6a76ab9235378a1c1a29dcf7903ae3
2018-02-13 04:01:04 -08:00
Emil Sjölander
af45863f8e Docs page first draft
Reviewed By: danielbuechele

Differential Revision: D6968201

fbshipit-source-id: f08104428188b8b3225b2803c9f2165ee653a0b6
2018-02-13 04:01:04 -08:00
Emil Sjölander
08d7d1673e Add documentation placeholders
Reviewed By: danielbuechele

Differential Revision: D6968199

fbshipit-source-id: 433d81b6367d1376224e0b3516be65132c091a34
2018-02-13 04:01:03 -08:00
Emil Sjölander
e7c56ccd1e Landing page first draft
Reviewed By: danielbuechele

Differential Revision: D6964899

fbshipit-source-id: ea9fed66ba0376a5cd2efda4d631cc14e591e666
2018-02-12 10:46:04 -08:00
Emil Sjölander
de8cab8e60 Footer design
Reviewed By: danielbuechele

Differential Revision: D6964900

fbshipit-source-id: 68831f101ef2112613cd170cb90bdd9235441c9d
2018-02-12 10:46:04 -08:00
Emil Sjölander
9e0f751464 Toolbar design
Reviewed By: danielbuechele

Differential Revision: D6964901

fbshipit-source-id: c052449d0ae3da91bec64c8f9da867244022ccf1
2018-02-12 10:46:03 -08:00
Daniel Büchele
951a429ac5 Template for docs pages
Summary:
- Dynamic loading of documentation pages
- code highlighting for markdown files
- editing playground from sidebar

Reviewed By: emilsjolander

Differential Revision: D6964951

fbshipit-source-id: 1c7f36afa8d23215471d5b9a9c01bd2241c2008e
2018-02-12 10:46:03 -08:00
Daniel Büchele
e43bb9da19 website v2 skeleton
Summary:
Sets up a skeleton for the new yoga website using gatsby static site generator

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D6952326

fbshipit-source-id: 7579bc80bec21552689da5b78f3d960910ff13bb
2018-02-12 09:39:22 -08:00
Pritesh Nandgaonkar
b08bd572ef Add flag in YGConfig for running experiments
Summary: Add flag in YGConfig for running experiments

Reviewed By: emilsjolander

Differential Revision: D6948702

fbshipit-source-id: 009fe2d64b6098f8c3a0289f0e6939dea5ce0d37
2018-02-09 06:45:11 -08:00
Pritesh Nandgaonkar
402ee11273 Fix memory leak by not duplicating the YGConfig
Summary:
YGConfig isn't owned by the YGNode, and thus isn't freed when freeing the node (`YGNodeFreeRecursive`)

This fixes a memory leak caused by D6856812

Reviewed By: emilsjolander

Differential Revision: D6945022

fbshipit-source-id: 5fd3c3e2ac1cd94d459d5aa06e0daa8f107779ac
2018-02-09 05:00:13 -08:00
Pritesh Nandgaonkar
6e38a26f32 Expose a function which marks all descendants dirty
Summary: Expose a function which marks all descendants dirty

Reviewed By: emilsjolander

Differential Revision: D6911869

fbshipit-source-id: e0a3abcf5653f921297edfdca473d83b947cc627
2018-02-08 05:23:46 -08:00
Pritesh Nandgaonkar
d66239bea8 call margin method on child instead of node
Summary: While moving a function as a method in YGNode, there was an error in which I mistakenly called a method on node, whereas I had to call it on child.

Reviewed By: emilsjolander

Differential Revision: D6918367

fbshipit-source-id: cee90e015f9e45a717a7307f59fd3b9ef6f399b6
2018-02-07 17:27:22 -08:00
Pritesh Nandgaonkar
7eb8df2777 Fix screenshot test due main axis justification refactor
Summary: There was a slight error in main axis justification which caused the regression

Reviewed By: emilsjolander

Differential Revision: D6923178

fbshipit-source-id: d8f81b06d9127c75daecffb73b5e6c5abbad8ade
2018-02-07 08:53:08 -08:00
Joel Marcey
75473fd924 Create CNAME 2018-02-06 09:32:58 -08:00
Joel Marcey
c94ade8ffd Update config for yogalayout.com
Summary: Closes https://github.com/facebook/yoga/pull/710

Reviewed By: emilsjolander

Differential Revision: D6912211

Pulled By: JoelMarcey

fbshipit-source-id: 8ccadc1a4845fb8a6fdc756077bfad01f0de7aac
2018-02-06 09:31:34 -08:00
Pritesh Nandgaonkar
61afbd43c9 Moved margin axis function as a method in YGNode
Summary: Moved margin axis function as a method in YGNode

Reviewed By: emilsjolander

Differential Revision: D6900003

fbshipit-source-id: a42da3bcd3126bf8c432c6740987b5ec0b572172
2018-02-06 08:44:46 -08:00
Pritesh Nandgaonkar
64f6ea37bd Moved trailing padding and border function as a method on YGNode
Summary: Moved trailing padding and border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6899571

fbshipit-source-id: 7f686e8771d5a94aae502191516557b20c557d7c
2018-02-06 08:44:46 -08:00
Pritesh Nandgaonkar
dc0609d153 Moved out main axis justification logic to seperate function
Summary: Moved out main axis justification logic to seperate function

Reviewed By: emilsjolander

Differential Revision: D6845997

fbshipit-source-id: fdb64e00de39427ce1d66d4fbfd06c23c0d32bcf
2018-02-06 08:44:45 -08:00
Daniel Büchele
bd46344a4e Fix ComponentKit code generation
Summary: Fixes ComponentKit code generation to outpput valid code.

Reviewed By: emilsjolander

Differential Revision: D6902924

fbshipit-source-id: f03a69268d22084f30aea46297b59aec28ba68d2
2018-02-06 08:27:42 -08:00
Joel Marcey
7199902316 Delete CNAME 2018-02-06 08:16:40 -08:00
Joel Marcey
250873abf2 Create CNAME 2018-02-06 08:12:21 -08:00
Pritesh Nandgaonkar
1e775ecb83 Fixed failing snapshot test
Summary: Fixed failing snapshot test

Reviewed By: emilsjolander

Differential Revision: D6901242

fbshipit-source-id: 7391d6a34fa28e9f92f4ff834755a89dd876fdad
2018-02-06 07:23:56 -08:00
Daniel Büchele
9718c517d9 add playground
Summary:
This adds a web-based playground to try out Yoga. The playground uses yogas javascript bindings to use yoga within the browser. The layout tree can be modified and shared. Code generators for litho, ComponentKit and React Native allow the layout to be copied into any app.

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D6871601

fbshipit-source-id: 3b97c87e91d6bafe8e1c38b8b7eca8d372324c0b
2018-02-05 07:11:57 -08:00
Pritesh Nandgaonkar
afc215aa66 Made a separate function for resolving flexible length
Summary: Made a separate function for resolving flexible length

Reviewed By: emilsjolander

Differential Revision: D6834269

fbshipit-source-id: 954bc7fe8eb9256d353cdda27e5c64c076808e25
2018-02-05 06:42:52 -08:00
Pritesh Nandgaonkar
5df8157863 Seperate function for second pass
Summary: Added a separate function which does the second pass to distribute the free space amongst the views which can be flexed.

Reviewed By: emilsjolander

Differential Revision: D6833635

fbshipit-source-id: 7680a67db8bfe22f8fb86407159888882f3a3353
2018-02-05 06:42:52 -08:00
Pritesh Nandgaonkar
802fe6bb29 Replaced first pass with a function
Summary: Added a function which does the first pass to determine the free space based on flex items whose min and max constraints are triggered

Reviewed By: emilsjolander

Differential Revision: D6819719

fbshipit-source-id: e5e77c21d1dca2255433da3388887d9db3f7b642
2018-02-05 06:42:51 -08:00
Pritesh Nandgaonkar
27d2ad198e Moved out logic to calculate size consumed on a line into seperate function
Summary: Moved out logic to calculate size consumed on a line into seperate function

Reviewed By: emilsjolander

Differential Revision: D6797640

fbshipit-source-id: ad9757e7d603c0ce57f452b1e5c404037605bed9
2018-02-05 06:42:51 -08:00
Pritesh Nandgaonkar
63be3ff84c Remove the use of legacy flag and log the diff if its used
Summary: Check if the layout tree is different if we do not use legacy flags. If they are different then report to the client

Reviewed By: emilsjolander

Differential Revision: D6856812

fbshipit-source-id: e4724d80702cc75c1894e348e137b24e663573d2
2018-02-02 07:43:26 -08:00
Mark Wang
66045bd13d Use delete instead of free
Summary: Since a `YGNodeRef` is created with `new`, it needs to be deleted using `delete` instead of `free`.

Reviewed By: richardjrossiii

Differential Revision: D6866064

fbshipit-source-id: a44828cedb5045b6c97179fb30ffd8c8dafcbfbe
2018-01-31 18:12:55 -08:00
Pritesh Nandgaonkar
f5f8105b57 Made logging logic dynamic to log string length
Summary: Previously the logging logic assumed fixed number of characters in the string to be logged. With this diff the logging logic is made dynamic, catering to variable length of the string to be logged

Reviewed By: emilsjolander

Differential Revision: D6784491

fbshipit-source-id: 26e4520a84be355ff992b808297ce7a95b3d09e3
2018-01-23 06:41:41 -08:00
Pritesh Nandgaonkar
4f92ae46ef Yoga android news feed benchmark tests
Summary: Added a benchmark tests along with the usual gentest in yoga for a complex yoga android news feed view.

Reviewed By: emilsjolander

Differential Revision: D6753544

fbshipit-source-id: 23b8da9785990a86248ff4708ac61e12411eb489
2018-01-22 04:30:26 -08:00
Pascal Hartig
80f8aa3c7e Mark model fields final
Summary: These are already considered immutable, but not marked in their class.

Reviewed By: emilsjolander

Differential Revision: D6759564

fbshipit-source-id: 810dc8a9730fb330760d2aedecafcea81cf25cb1
2018-01-22 02:56:53 -08:00
Daniel Büchele
42778f687b Release version 1.9.0
Summary:
- Fixes bindings
- Fixes benchmarks and test calls
- version 1.9.0

Reviewed By: arcanis, priteshrnandgaonkar

Differential Revision: D6759438

fbshipit-source-id: 0ea58e607e0b518aaa907cbfa82d2baea7bc1ed5
2018-01-19 11:28:44 -08:00
Daniel Büchele
7b27a58b97 NPM release v1.8.1
Summary: Package is already published via NPM. This is just the version bump.

Reviewed By: emilsjolander

Differential Revision: D6750224

fbshipit-source-id: 6add1ce71714e58e4afacd095265b3e770bc558e
2018-01-19 11:28:44 -08:00
Daniel Büchele
a40ba9d350 update JavaScript bindings
Summary:
- adds flow types
- transpiles bundle using babel
- cleans and formats code

Reviewed By: emilsjolander

Differential Revision: D6748362

fbshipit-source-id: fcb5fdde73df6e0062eff1e5038bb5fe0532f997
2018-01-18 08:27:03 -08:00
Pritesh Nandgaonkar
9ecdff14fa Use vector instead of linked list
Summary: Currently in the flexbox algorithm we were using linked list for maintaining the nodes which had relative/absolute position types, this diff uses STL vector instead of linked list.

Reviewed By: emilsjolander

Differential Revision: D6722959

fbshipit-source-id: 4e81176802b9a9319bc5f385c824a06be14a83a2
2018-01-16 09:42:13 -08:00
Pritesh Nandgaonkar
288adc49c9 Fix for failing screenshot tests
Summary: Fixes failing screenshot tests

Reviewed By: emilsjolander

Differential Revision: D6726745

fbshipit-source-id: 99f91aabe2337b23953724545f97695238f2124e
2018-01-16 09:20:09 -08:00
Valentin Shergin
b8c2428b31 Exposing setDirtiedFunc as plain C function YGNodeSetDirtiedFunc
Summary:
@public
Trivial. Those lines were lost during rebasing of the original commit.

Reviewed By: priteshrnandgaonkar

Differential Revision: D6717696

fbshipit-source-id: a5dce25427c8977352b3ae7ea01e546a540e0c13
2018-01-15 15:52:29 -08:00
Pritesh Nandgaonkar
92bfcbafc0 Moved leadingpaddingnandborder function as a method on YGNode
Summary: Moved leadingpaddingnandborder function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711991

fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297
2018-01-15 10:15:14 -08:00
Pritesh Nandgaonkar
130b5beca2 Move trailing padding function as a method on YGNode
Summary: Move trailing padding function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711897

fbshipit-source-id: fa2e1a8e31242358a6e94aef51368e2c2c58b79d
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
adb2e0fdd6 Moved leading padding function as a method on YGNode
Summary: Moved leading padding function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711830

fbshipit-source-id: d2f6f55ec23b007bb51f8a91385e02236f46dc7b
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
0a04bd7f2f Resolve direction function is now as a method on YGNode
Summary: Resolve direction function is now as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711755

fbshipit-source-id: a0e80596e10f0c7fb7a31b75377da4db846c4bbb
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
9d6af5b314 Move trailing border function as a method on YGNode
Summary: Move trailing border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711666

fbshipit-source-id: fe4fdfc2db59d03beb763317e1a6f9de52f851d4
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
6efb4b90d4 Move leading border function as a method on YGNode
Summary: Move leading border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711523

fbshipit-source-id: 76e90083a9dd0728dc9557cc3b0a1f431f3afd5d
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
5806f1728c Moved YGNodeIsFlex as a method on YGNode
Summary: Moved YGNodeIsFlex as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711536

fbshipit-source-id: e60be7da55e3e8d254eb253c141d219a37a76087
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
a9dd527748 Refactored step3 of flexbox algorithm
Summary: Previously flexbasis calculation was doing more than one task of accumulating absolutelypositioned child and flexbasis calculation. So this diff refactors the logic and moves out absolutely positioned child calculation to our step 1(which is calculating the variables which are required for rest of the algorithm). This diff also moves the flexbasis logic into separate function

Reviewed By: emilsjolander

Differential Revision: D6702749

fbshipit-source-id: 15dcc94ae30ac185e4d1c7d6e3744a40cfa47317
2018-01-15 10:15:12 -08:00
Pritesh Nandgaonkar
db3d20b7b7 Refactored the flexbox step to determine available space in main and cross dim
Summary: Refactored the logic to calculate available main and cross dimensions

Reviewed By: emilsjolander

Differential Revision: D6693777

fbshipit-source-id: d6c87670e74bdc22b32916c2d77fe423d831b378
2018-01-15 05:41:56 -08:00
Semen Zhydenko
acd4e01aaf Typos in comments and log messages
Summary:
No code changes, no testing required.

alligned -> aligned
allignment -> alignment
completly -> completely
conseptually -> conceptually
decendents -> descendants
indefinetly -> indefinitely
dimention -> dimension
doesnt -> doesn't
safegaurd -> safeguard
intialization -> initialization
hierachy -> hierarchy
happend -> happened
gaurd -> guard
programatically -> programmatically
initalized -> initialized
immidiately -> immediately
occured -> occurred
unkown -> unknown
neccessary -> necessary
neccesarily -> necessarily
occuring -> occurring
comoponent -> component
propogate -> propagate
recieved -> received
referece -> reference
perfomance -> performance
recieving -> receiving
subsquently -> subsequently
scoll -> scroll
suprisingly -> surprisingly
targetting -> targeting
tranform -> transform
symetrical -> symmetrical
wtih -> with
Closes https://github.com/facebook/react-native/pull/17578

Differential Revision: D6718791

Pulled By: shergin

fbshipit-source-id: 4ab79c1131ec5971d35a0c7199eba7ec0a0918ad
2018-01-12 22:16:32 -08:00
Attila Jakabfi
b217f23ba5 Spacing
Summary: Add spacing type to Yoga Config

Differential Revision: D6683074

fbshipit-source-id: a76bc5028962d738bb931a997752f6ba194bd8ed
2018-01-12 05:13:40 -08:00
Pritesh Nandgaonkar
76875af207 Moved setPosition as a method on YGNode
Summary: Moved setPosition as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683387

fbshipit-source-id: 83f64101faa700933771c69b222056ec2a6b8d1e
2018-01-11 04:59:02 -08:00
Pritesh Nandgaonkar
f2ba14c309 Moved trailingmargin function as a method on YGNode
Summary: Moved trailingmargin function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683313

fbshipit-source-id: 5ee458c2f4698768724901df0e3f5d8805c7c8f5
2018-01-11 04:59:02 -08:00
Pritesh Nandgaonkar
a65b79a944 Moved getLeadingMargin as a function on YGNode
Summary: Moved getLeadingMargin as a function on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683270

fbshipit-source-id: a26663006419e13cb783e9849183e3c665f59b3c
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
681b580fd8 Moved getTrailingPosition function as a method on YGNode
Summary: Moved getTrailingPosition function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683205

fbshipit-source-id: d30003d90d634c644d92c833e58165b073d4d13e
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
b985b6c377 Moved is isTrailingPos defined as a method on YGNode
Summary: Moved is isTrailingPos defined as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683190

fbshipit-source-id: c37e57d02cc4475eb8181a2bb003c555bdb0aaea
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
92eda21e78 Moved isLeadingPos defined as a method on YGNode
Summary: Moved isLeadingPos defined as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6682956

fbshipit-source-id: 31c60e0eae906e1434a6969f3cd786fcaf9097a5
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
0cfdb50477 Moved YGNodeLeading position as a method on YGNode
Summary: Moved YGNodeLeading position as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6682929

fbshipit-source-id: 3607aab1544b62b1126c5d75b2f6fb8f5ca2d45f
2018-01-11 04:59:01 -08:00
Valentin Shergin
1eb9a5edd9 Tests for YGNodeSetDirtiedFunc
Summary: testallthethings

Reviewed By: gkassabli

Differential Revision: D6687460

fbshipit-source-id: bebae3604212cb10e7ac43d10cfebd4978834d69
2018-01-10 10:09:38 -08:00
Valentin Shergin
383b881748 Introducing on-dirty handler (aka YGNodeSetDirtiedFunc)
Summary:
@public
Currently, we can dirty leaf nodes with `measure` function, we also can get `dirty` status for any node, but we cannot handle a moment when this change happen. This diff introduces a new call-back-manner handler for it.
We need this to plug Yoga inside and outside other layout systems without maintaining own dirty propagation infrastructure.
Consider using Yoga for flex-box layout in React Native where we can have deeply nested layout like `<View><Text><View><Text/></View></Text></View>` where all content of all <Text> nodes are laid out using native text/inline (not flex-box!) layout system. In this case, when some change dirties some deeply nested Yoga node, we have to propagate the dirty state down to outer one. Having this handler makes possible to wire up `on-dirty` handler on the root node and `setDirtied` for the leaf node.
Removing custom dirting mechanism from React Native should drastically simplify rendering layer and bring a huge performance win.

Reviewed By: emilsjolander

Differential Revision: D6597856

fbshipit-source-id: 6588cd712f9c1dede4af32f3d326f90103e48ff0
2018-01-10 10:09:38 -08:00
Pritesh Nandgaonkar
47543c8fba Move utility functions to utils file
Summary: Move utility functions to utils file

Reviewed By: emilsjolander

Differential Revision: D6682933

fbshipit-source-id: 0fd90fdaf5ca4f9b7a11cbd15d8c54c7d0ce8a03
2018-01-10 05:03:52 -08:00
Pritesh Nandgaonkar
dc6ed89bfa Fix warnings of casting and null pointer handling
Summary: There were warnings of castings and null pointer handling in yoga.cpp. This diff fixes the warnings. The issue was brought up here https://github.com/facebook/react-native/issues/17274

Reviewed By: emilsjolander

Differential Revision: D6675111

fbshipit-source-id: 884659fabb05033b4d43d3aa6629e22481d39b7e
2018-01-09 04:27:01 -08:00
Pritesh Nandgaonkar
348dd368b5 Move YGNodeResolveFlexShrink to a method on YGNode
Summary: Move YGNodeResolveFlexShrink to a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6611418

fbshipit-source-id: 6e5ba39b555d313a967800589891027920112c15
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
40eeefd4f7 Moved YGResolveFlexGrow as a method on YGNode
Summary: Moved YGResolveFlexGrow as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6611385

fbshipit-source-id: 71660946c469fac77c5ffa0284c793e6adc9db7b
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
47892c17ce Move markDirtyInternal as a method in YGNode
Summary: Moved YGNodeMarkDirtyInternal as a method in YGNode

Reviewed By: emilsjolander

Differential Revision: D6611287

fbshipit-source-id: 54402145d51ea717553ea136be739b9880a79817
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
f2a369fb73 Move YGCloneChildrenIfNeeded as a method on YGNode
Summary:
- Removed the default() static method, instead of this, its zero argument initialiser is used
  - Moved `YGCloneChildrenIfNeeded` to `cloneChildrenIfNeeded` as a method on `YGNode`.

Reviewed By: emilsjolander

Differential Revision: D6611155

fbshipit-source-id: 463723a363e0fbd2c7686f65226eca73236bd07e
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
61dc10ef66 Optimize the performance of Origami
Summary: With this flag the the workflow successfully passed.

Reviewed By: emilsjolander

Differential Revision: D6619293

fbshipit-source-id: c1632efd97f47696b7f8bb1b3e763de92c707287
2017-12-22 06:55:20 -08:00
Pritesh Nandgaonkar
7d01f4d8b1 Do not set FB_ASSERTION_ENABLED
Summary: Currently whenever `Yoga.h` is imported by someone we set `FB_ASSERTION_ENABLED`. The use case of this flag is to use assert calls of `FBAssert.h`, since we do not use it anymore, there is no need to set this flag.

Reviewed By: emilsjolander

Differential Revision: D6611904

fbshipit-source-id: f01ac144159c1b333d8deb8cbb5ba0288e4bf7a4
2017-12-21 04:56:09 -08:00
Pritesh Nandgaonkar
c7a5e1e290 Fix typo in YogaKit's YGDimensionFlexibility
Summary: Fix typo in `YGDimensionFlexibility` enum

Reviewed By: emilsjolander

Differential Revision: D6601679

fbshipit-source-id: 3a7d98322de3383de65ff5164d4c7a632ac6916f
2017-12-20 03:11:46 -08:00
Pritesh Nandgaonkar
fbd332dee8 Make YGNode as c++ struct with properties exposed through accessors
Summary: Moved c implementation of `YGNode` to C++ struct. Not moving to C++ class as the React Classes dependent on `Yoga.h` assume it to be C. Thats why keeping `Yoga.h` C compatible. Sorry for the long diff, didn't thought that it will turn out to be this much big.Will keep an eye on number of lines next time 😉

Reviewed By: emilsjolander

Differential Revision: D6592257

fbshipit-source-id: 641e8b9462ad00731a094511f9f5608b23a6bb21
2017-12-19 11:33:07 -08:00
Pritesh Nandgaonkar
dbf6a12134 Hide init of YGLayout
Summary:
Make default init unavailable, as it will not initialise `YGNode` which is required for the setters
 and getters of YGLayout's properties to work properly. In setters and getters we call the corresponding `YGNode`'s setters and getters. Thus the following code will crash

```
let layout = YGLayout()
layout.flexDirection = .row
```

Reviewed By: emilsjolander

Differential Revision: D6597796

fbshipit-source-id: 653d275d7314bfdd7a1106884fa3fbc0a13e1be7
2017-12-19 07:48:35 -08:00
Amir Shalem
dbc47ae383 Disable assert code in release builds (define DNDEBUG)
Summary:
Disable assert code in release builds (define DNDEBUG).
This disables assertions in Facebook JNI library - which checks that our references to Yoga JNI objects are correct.
This saves CPU time, since those checks are costly.

Reviewed By: emilsjolander

Differential Revision: D6592023

fbshipit-source-id: eaf869c7990cab3a72ae2bbdc67e709153f5020c
2017-12-18 11:32:36 -08:00
Amir Shalem
f22cfd52e0 Add buck mode/opt compile file to support release compilation mode
Summary:
Currently we have `-O3` hardcoded inside our BUCK target files, this will allow us afterwards to remove that.
Follow up commit will also add `-DNDEBUG` which will disable `assert` in release builds.

Reviewed By: emilsjolander

Differential Revision: D6592024

fbshipit-source-id: f541ee8728ff44db8e31885f2085dc036a400f70
2017-12-18 11:32:36 -08:00
Jonathan Kim
2a10337344 Consolidate mobile yoga into top-level xplat
Reviewed By: emilsjolander

Differential Revision: D6494379

fbshipit-source-id: f6b78d8a1b3d4bcdeef350ad7bd097cdbe5d15b1
2017-12-13 15:08:03 -08:00
Greg McGary
836eaa62df Explicitly #define isnan __builtin_isnan for Android clang-5 to mimic gcc's default behavior
Summary:
GCC internally aliases isnan and a dozen other math.h primitives to their `__builtin_` counterparts, which compile straight to assembler. Clang does not do this, so calls to `isnan` compile to a function call. The Android libc does not define `isnan` because it assumes all application code compiled `__builtin_isnan` and has no need for the function `isnan`.

This is a temporary kludge: Starting with NDK r16, the math.h header has appropriate `#defines` to alias primitives to their `__builtin_` counterparts. Upon upgrade to NDK r16, this can be reverted.

Reviewed By: passy

Differential Revision: D6527499

fbshipit-source-id: 65d9e43c7e7d973a6c92e9863ebe469b35a24ac8
2017-12-12 16:56:48 -08:00
Taras Tsugrii
a01c7adcfb Skylarkify default_platform_defs macros.
Reviewed By: adamjernst

Differential Revision: D6527119

fbshipit-source-id: 1e31b9491d2cf501f348d544482c025096fd81b1
2017-12-09 10:28:47 -08:00
Ben Nham
5133faa1ad Revert D6155682: Use clang-5.0 -Oz
Summary:
This reverts commit 2f64e742f4dc44be171274c2ad0a41fb1e7079d7

bypass-lint

Differential Revision: D6155682

fbshipit-source-id: 9139ed14e0d24784bf25b2783e364a511173ab83
2017-12-08 09:42:21 -08:00
Emil Sjölander
6a8c2960ad New javascript release
Summary: https://www.npmjs.com/package/yoga-layout

Reviewed By: arcanis

Differential Revision: D6496634

fbshipit-source-id: 2d834edcfce6c1e3d3f481822b3ccd22b39e1a13
2017-12-07 19:02:32 -08:00
Greg McGary
0c98e89fdb Use clang-5.0 -Oz
Summary:
Use clang-5.0 -Oz as default NDK compiler for android.
It does 3 good things:
* brings us into compliance with deprecation of gcc for android NDKs since r13
* yields slightly smaller native code, on the order of many-10s-to-small-100s of KB
* slight improvement in startup performance, on the order of 10s of ms

Reviewed By: mzlee

Differential Revision: D6155682

fbshipit-source-id: 2f64e742f4dc44be171274c2ad0a41fb1e7079d7
2017-12-07 13:27:20 -08:00
Yaroslav Pavlov
5f78181911 Round size geometry for Button and RichText components.
Summary:
ComponentKit requires all size geometry provided to be rounded to pixel grid. This ensures
that layout will not truncate provided sizes.

Reviewed By: cuva

Differential Revision: D6466875

fbshipit-source-id: 62a480411e7d2354a6879917c42bbf0ee96cdadd
2017-12-06 16:27:45 -08:00
Pritesh Nandgaonkar
03dd1d23fa vector instead of YGNodeList
Summary: Replaced YGNodeList with std::vector

Reviewed By: jonathandann, emilsjolander

Differential Revision: D6442379

fbshipit-source-id: d2d48ef0676351d2eeaa2d427dcd72e082cd15a1
2017-12-05 08:28:54 -08:00
Luc Dion
91683be798 YogaKit: Changes so we are able to reset properties to their initial value
Summary:
Changes so we are able to reset properties to their initial value.
This is required to reset these properties.

Add the support of YGUnitUndefined to many properties:
* minWidth
* maxWidth
* minHeight
* maxHeight

Also, these properties must be reset to YGUnitAuto.
* width
* height
* flexBasis

This now matches completely how these properties are initialized in Yoga.cpp
Closes https://github.com/facebook/yoga/pull/672

Reviewed By: dshahidehpour

Differential Revision: D6407908

Pulled By: emilsjolander

fbshipit-source-id: ac20c7b2c06349115aea7d31240204d17e2f1b44
2017-12-04 04:26:46 -08:00
Cory Reed
109cb1a562 Fix Android comment and docblock typos
Summary:
👋 Hello! Thanks for react-native, it’s a great project.

I was digging into the Android implementation in _ReactAndroid_ and noticed a couple typos in the documentation. I went through and tried to fix all the typos I could find using [aspell](http://aspell.net).

Not applicable: these changes are only to comments, and CI should be skipped.

[ANDROID][ENHANCEMENT][*] - Correct comment and docblock typos
Closes https://github.com/facebook/react-native/pull/17049

Differential Revision: D6472182

Pulled By: shergin

fbshipit-source-id: 7e62cab118609596b483d1cf16c3abf651d6753b
2017-12-03 20:15:49 -08:00
Lukas Wöhrl
ad1240e276 Fix min/max percentage constraints on measured nodes
Summary:
Fix min/max percentage constraints on measured nodes. Currently we passed in the available size instead of the parent size.
Fixes #611
Closes https://github.com/facebook/yoga/pull/649

Reviewed By: priteshrnandgaonkar

Differential Revision: D6408019

Pulled By: emilsjolander

fbshipit-source-id: 18be5056dbc0dc179970ec231ab8b4e2cdba65c5
2017-11-30 08:02:05 -08:00
Emil Sjölander
2e468d9c8c Update watir
Summary: We were using a very out-dated version of watir which did not run with latest ruby

Reviewed By: priteshrnandgaonkar

Differential Revision: D6447029

fbshipit-source-id: ff4ccb8c96947811ff09f7e87cb504e3e7cb834e
2017-11-30 07:01:32 -08:00
Huge Rocker
6caa94b779 Fix can not find source files in CMakeLists.txt
Summary:
Because the source files are *.cpp, not *.c. This fixes building issue with gradle.
Closes https://github.com/facebook/yoga/pull/676

Reviewed By: emilsjolander

Differential Revision: D6446545

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 809229057db26665b2d97b3002ade73632dd9117
2017-11-30 07:01:31 -08:00
Lukas Wöhrl
429a7eeee3 Suppress unused warnings on YGDefaultLog
Summary:
Suppresses the unused warnings on ```YGDefaultLog```. It uses a more generic macro which simply casts the variable to ```(void)```. This is the simples approach to make mutiple different compilers happy. Fixes #650
Closes https://github.com/facebook/yoga/pull/651

Differential Revision: D6407999

Pulled By: emilsjolander

fbshipit-source-id: 19fd78dd8b84eafdbb48875dd003d506a98c4807
2017-11-28 10:26:07 -08:00
Taras Tsugrii
dec1172f38 Migrate yoga defs to Skylark syntax.
Summary: https://our.intern.facebook.com/intern/dex/buck/python-to-skylark/

Reviewed By: adamjernst

Differential Revision: D6411822

fbshipit-source-id: 2abe2c183d1b1a28349d0c7bd765754688ec4441
2017-11-27 14:00:52 -08:00
Lukas Wöhrl
afaafb4126 Measure nodes which have margin: auto and align-item: stretch
Summary:
If you have a measurable node and set ```marign-left: auto``` + ```align-item:stretch``` on it, it won't get measured and they get a width/height of ```-(nan)```. This change fixes that behaviour. Fixes #644.
Closes https://github.com/facebook/yoga/pull/645

Differential Revision: D6413512

Pulled By: emilsjolander

fbshipit-source-id: 755febeb33bb0d4520ca6b3c28d56ac333e4a14d
2017-11-27 05:36:48 -08:00
Jake Larson
e566fcca08 Fix invalid value check for entry-common.js
Summary:
`!Object.prototype.hasOwnProperty.call(methods, unit))` doesn't correctly return `true` when an unsupported value is passed into `setMaxWidth` within an Automator (macOS) javascript/cocoascript environment.

This PR fixes the issue and also adds the `value` information to the returned error to help with debugging
Closes https://github.com/facebook/yoga/pull/643

Differential Revision: D6413569

Pulled By: emilsjolander

fbshipit-source-id: a42a66710a3ca578b5c25ecef8722f9c3f082b73
2017-11-27 05:12:37 -08:00
vincentriemer
c7f7ba250c Add Config::setPointScaleFactor to JavaScript binding
Summary:
Needed for a project I'm working on to properly render on high dpi screens. I've manually tested against my project to confirm it works.
Closes https://github.com/facebook/yoga/pull/612

Differential Revision: D6413517

Pulled By: emilsjolander

fbshipit-source-id: c298d7f6b58dc45aaaede2bb995df8615911a4a9
2017-11-27 04:59:53 -08:00
Lukas Wöhrl
7e3be21811 Add justify-content: space-evenly
Summary:
Adds new ```space-evenly``` for ```justify-content```.

Also adds a typofix in one of the other justify-content tests.

Fixes #657
Closes https://github.com/facebook/yoga/pull/658

Differential Revision: D6407996

Pulled By: emilsjolander

fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
2017-11-27 03:47:23 -08:00
Lukas Wöhrl
5e39f1a57c Fix shrinking in non strech alignments while retaining legacy behaviour
Summary:
This fixes shrinking of elements which are in a non stretch alignment, but keeps the legacy stretch behaviour in place. Additionally this adds a testcase for ```useLegacyStretchBehaviour```

Fixes #633
Closes https://github.com/facebook/yoga/pull/635

Differential Revision: D6408037

Pulled By: emilsjolander

fbshipit-source-id: 377ab0308dd3a75a148a0af31ab5eb3ffb5b5d83
2017-11-27 03:14:59 -08:00
Lukas Wöhrl
5aa0f44a9b Do not mark node as dirty if, new and old values are undefined
Summary:
If we have a values already set to undefined and set it to undefined again, we invalidate the layout. This change takes this case into account and keeps the layout valid.
Fixes #630
Closes https://github.com/facebook/yoga/pull/648

Differential Revision: D6408013

Pulled By: emilsjolander

fbshipit-source-id: dc2a848d84d3de9f4650fac9e41d7c8169446406
2017-11-27 03:14:54 -08:00
Jake Teton-Landis
55c767ba7f Fix assertion preventing YGNodeLayoutGet* with YGEdgeEnd
Summary:
Expected to be able to call `YGNodeLayoutGetMargin(node, YGEdgeEnd)`, but instead, the program aborts with `"Cannot get layout properties of multi-edge shorthands"`.

This bug seems to incorrectly prevent properties from YGEdgeEnd for all Layout properties.
Closes https://github.com/facebook/yoga/pull/632

Differential Revision: D6408060

Pulled By: emilsjolander

fbshipit-source-id: 4ab3b2ffb2f1bb6fd3a27f780caf0123abcdb230
2017-11-27 03:00:05 -08:00
Taras Tsugrii
5502a97f7f Replace include_defs with load.
Summary: https://our.intern.facebook.com/intern/dex/buck/python-to-skylark/

Reviewed By: adamjernst

Differential Revision: D6411777

fbshipit-source-id: 5553d75a650d906a280a61b38492e20d7bc7081a
2017-11-26 21:30:14 -08:00
Taras Tsugrii
8ab1d81917 Do not use isdir in build files.
Summary: This leads to slow, non-reproducible builds.

Reviewed By: adamjernst

Differential Revision: D6411750

fbshipit-source-id: 566424fa813edd20813da15101e6640d6c8fff19
2017-11-26 21:05:54 -08:00
Alexander Sarkisov
942543f6a5 Add default block attribute.
Summary:
It is very inconvenient to enter block attribute name for each view in Objective-C.
Closes https://github.com/facebook/yoga/pull/618

Differential Revision: D6408138

Pulled By: emilsjolander

fbshipit-source-id: 71fe8eadda7233e5055560667d0fc3840ab7259b
2017-11-24 08:12:33 -08:00
Lukas Wöhrl
a69545a6ae Fix justify content with min/max constraint parent
Summary:
The min/max inner width shouldn't take the margins into account.
Adds a test for both cases.

Fixes #664
Closes https://github.com/facebook/yoga/pull/665

Differential Revision: D6407982

Pulled By: emilsjolander

fbshipit-source-id: ffa549a06f802263e3b8488e90756aa3f722d52d
2017-11-24 07:24:51 -08:00
Lukas Wöhrl
0b13a0c168 Fix generation of license header for java
Summary:
If you run ```enums.py``` it will revert the changes from 835b2bb . This changes the license header for java to  not be a javadocs comment.
Closes https://github.com/facebook/yoga/pull/660

Differential Revision: D6407985

Pulled By: emilsjolander

fbshipit-source-id: 49efe555fecb8d740675c6b4631dce2a64f10417
2017-11-24 06:57:23 -08:00
Yury Zholobov
d8341ca3b0 Fix horizontally to vertically in FlexDirection=Column doc
Summary: Closes https://github.com/facebook/yoga/pull/663

Differential Revision: D6407915

Pulled By: emilsjolander

fbshipit-source-id: 03e2896b9b98cf476a92e7c87fd8dc3f7cef9047
2017-11-24 06:26:37 -08:00
Pritesh Nandgaonkar
34ac314101 Refactor and move YGNodeToString implementation to different file
Summary: Refactored the `YGNodeToString` function from c to c++.

Reviewed By: emilsjolander

Differential Revision: D6397372

fbshipit-source-id: 79e701efe7f19db6dac1aea6328ebf0ac84a7ac3
2017-11-23 09:42:21 -08:00
Pritesh Nandgaonkar
02c00f2711 Change c files to cpp
Summary: Changed the extensions of c files to cpp and made the project build successfully

Reviewed By: gkassabli

Differential Revision: D6271299

fbshipit-source-id: 66c0e54ccf019d72d1fd0b4d117826e4e84fdc89
2017-11-21 10:28:51 -08:00
Flarnie Marchan
15231c3304 Add Code of Conduct
Summary:
**what is the change?:**
Adding a document linking to the Facebook Open Source Code of Conduct,
for visibility and to meet Github community standards.

**why make this change?:**
Facebook Open Source provides a Code of Conduct statement for all
projects to follow.

Exposing the COC via a separate markdown file is a standard being
promoted by Github via the Community Profile in order to meet their Open
Source Guide's recommended community standards.

As you can see, adding this file will complete [Yoga's Community Profile](https://github.com/facebook/yoga/community)
checklist and increase the visibility of our COC.

We also added a link to the COC in the CONTRIBUTING doc because folks may miss the separate CODE_OF_CONDUCT document.

**test plan:**
Viewing it on my branch -
![screen shot 2017-11-20 at 6 02 25 pm](https://user-images.githubusercontent.com/1114467/33051133-4dc293e6-ce1d-11e7-9b0a-776cad6211f5.png)
![screen shot 2017-11-20 at 6 02 33 pm](https://user-images.githubusercontent.com/1114467/33051135-4dee35fa-ce1d-11e7-9077-a2d6d6f2ed3e.png)

**issue:**
internal task t23481323
Closes https://github.com/facebook/yoga/pull/670

Reviewed By: emilsjolander

Differential Revision: D6384655

Pulled By: flarnie

fbshipit-source-id: 6c5557094719cc8f1b08deb4d477ab56603caf39
2017-11-21 05:27:53 -08:00
Pritesh Nandgaonkar
d98e5aef97 Deleted YGSetMemoryFucs as it is unused
Summary: Removed YGSetMemoryFuncs, as it is not used internally and barely externally.

Reviewed By: emilsjolander

Differential Revision: D6374147

fbshipit-source-id: 8c896dce23571268a1a52df5cc72486af9d66df7
2017-11-21 03:43:23 -08:00
Pritesh Nandgaonkar
5b0dfa471f Use internal clang format settings
Summary: Use internal linting rules instead of the custom once.

Differential Revision: D6284667

fbshipit-source-id: 65aae336f1d7f14dfefed7391b0f5b89b333495e
2017-11-20 03:17:53 -08:00
Pritesh Nandgaonkar
26481a6553 Replace printf with YGLog calls
Summary: Replace printf calls with YGLog

Reviewed By: gkassabli

Differential Revision: D6297015

fbshipit-source-id: 6a67bdf33ef121785ac14938f5d3ed6e9d6f2656
2017-11-16 05:43:23 -08:00
Pascal Hartig
64e08aa98b v1.7.1-SNAPSHOT
Summary: Back to snapshot releases.

Reviewed By: emilsjolander

Differential Revision: D6284123

fbshipit-source-id: 30ec356d0da63e7bf6c33cbc20d446aea7be5a05
2017-11-16 03:15:52 -08:00
Pascal Hartig
0c3168f150 v1.7.0
Summary: Version bumps.

Reviewed By: emilsjolander

Differential Revision: D6284124

fbshipit-source-id: 08f6116bb0237791210847976533206055376f1a
2017-11-16 03:15:52 -08:00
Pascal Hartig
40861c699e Modernize Android build system, bump dependencies
Summary:
- Build against Android SDK 26
- Upgrade to Gradle 4
- Upgrade to Android Plugin 3.0, adjust dependency management accordingly
- Upgrade Maven deployment plugin

Reviewed By: emilsjolander

Differential Revision: D6272007

fbshipit-source-id: b198b4c8e1a94e2ee031ad26193fdfdf5b52adf1
2017-11-08 09:47:26 -08:00
Daniel Tsuan
d8fee24778 Set link_whole true for YogaKit and IGListKit
Summary: For our -objc efforts we'll be excluding vendorlibs from these changes for now and then working on getting them to not have to be fully linked as a second effort. The way -objc flag works is its an all or nothing flag for the app and thus for any library we still want to link completely we'll have to add a link_whole = True to the BUCK file. (Otherwise we'll have crashes in these libraries :P).

Reviewed By: kastiglione

Differential Revision: D6252740

fbshipit-source-id: fe074977a11b70c4aa63a4c69cb7518906c98eb9
2017-11-07 14:36:48 -08:00
Richard Ross
5c617a5947 Mirror AsyncExecutor, yoga, and nanosvg to fbcode.
Summary: We'll need these libraries for rainbow, and none of them exist in fbcode.

Reviewed By: mzlee

Differential Revision: D5897801

fbshipit-source-id: c379b76fef2ab204555ceded0834efc6ba932f90
2017-11-01 16:42:21 -07:00
Chandra Patni
ff0a3f39d9 use > || YGFloatsEqual instead of >= for computing round value to pixel grid
Summary: YGRoundValueToPixelGrid does not handle float point values correctly. It causes layout bugs in arm 32 devices. The way values are rounded to pixel grid is the following: if value is close to the left pixel - discard error and set it equal to left pixel. If value is close to right pixel - set it equal to the right pixel. Otherwise if value is closer to the left - set it equal to the left, closer to the right - set it equal to the right. The problem is when values are close to the middle. Old implementation could produce either left or right boundaries. This patch moves all values that are close to the middle to right boundary. This way results are consistent.

Reviewed By: emilsjolander

Differential Revision: D6202484

fbshipit-source-id: bb80235452208caec388775574cc4f07bfd649c4
2017-11-01 15:52:49 -07:00
Georgiy Kassabli
bfb4dabf0c Fixing the edge case in Yoga with percentage absolute position and infinite constraint
Summary: Yoga has an edge case that cause layout to return NaN. This happened when we used absolute position with percentage and infinite constraint in that dimension. This diff fixes that case to default to border+padding

Reviewed By: emilsjolander

Differential Revision: D6199731

fbshipit-source-id: f40ddf00614b2f507848fb35f348a9dfef14b323
2017-11-01 06:40:10 -07:00
Pritesh Nandgaonkar
58d14ee557 Reverting the dirty child optimization
Summary: Reverting D6134754

Reviewed By: emilsjolander

Differential Revision: D6203290

fbshipit-source-id: 8e42abb70e55f0fac90faaa21ecdbe0fbb76ce6b
2017-10-31 23:23:01 -07:00
Pritesh Nandgaonkar
c5182c4bf5 Used hasDirtyChildren tag for the optimization
Summary:
More fine grained dirty marking

Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent.

This change has the potential of greatly improving performance of re-calculating a tree.

This might require adding a second dirty flag named hasDirtyDescendants ensuring that traversal still works even though a parent is not marked as dirty.

Reviewed By: emilsjolander

Differential Revision: D6134754

fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
2017-10-31 08:22:29 -07:00
Jonathan Keljo
132b016bae Automated fixups for Instagram
Summary:
Source-only ABIs are a new feature of Buck that allows massive parallelism
by generating ABI jars from just the source code (without looking at most
dependencies). Because dependencies are not available, the generator
makes assumptions about how we write Java code. This commit updates
Instagram's code to conform to those assumptions.

These changes were generated by Buck's automatic migration script.

Reviewed By: dreiss

Differential Revision: D6168048

fbshipit-source-id: 0e51319d93fd697db01ea3933f48cd06a6ffac12
2017-10-27 01:14:24 -07:00
Sebastian Markbage
4785e95a0c Persistent Yoga
Summary:
This is meant to show a possible route format for a persistent form of Yoga. Where previous layouts can remain intact while still taking advantage of incremental layout by reusing previous subtrees.

```c
YGNodeRef YGNodeClone(const YGNodeRef node);
```

The core of this functionality is a new API to clone an existing node. This makes a new detached node with all the same values as the previous one. Conceptually this makes the original node "frozen" from that point on. It's now immutable. (This is not yet enforced at runtime in this PR but something we should add.)

Since the original is frozen, we reuse the children set from the original node. Their parent pointers still point back to the original tree though.

The cloned node is still mutable. It can have its styles updated, and nodes can be inserted or deleted. If an insertion/deletion happens on a cloned node whose children were reused, it'll first shallow clone its children automatically.

As a convenience I also added an API to clear all children:

```c
void YGNodeRemoveAllChildren(const YGNodeRef node);
```

During insert/delete, or as a result of layout a set of reused children may need to be first cloned. A kind of copy-on-write. When that happens, the host may want to respond. E.g. by updating the `context` such as by cloning any wrapper objects and attaching them to the new node.

```c
typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode,
                                 YGNodeRef newNode,
                                 YGNodeRef parent,
                                 int childIndex);

void YGConfigSetNodeClonedFunc(YGConfigRef config,
                               YGNodeClonedFunc callback);
```

This PR doesn't change any existing semantics for trees that are not first cloned.

It's possible for a single node to exist in two trees at once and be used by multiple threads. Therefore it's not safe to recursively free a whole tree when you use persistence. To solve this, any user of the library has to manually manage ref counting or tracing GC. E.g. by replicating the tree structure in a wrapper.

In a follow up we could consider moving ref counting into Yoga.
Closes https://github.com/facebook/yoga/pull/636

Reviewed By: emilsjolander

Differential Revision: D5941921

Pulled By: sebmarkbage

fbshipit-source-id: c8e93421824c112d09c4773bed4e3141b6491ccf
2017-10-17 01:11:11 -07:00
Pascal Hartig
be94a5ef8d Fix NDK download in Travis
Summary:
After about 500MB, Travis seems to kill the TLS connection. Could be a traffic
limit, could be a timeout. I've only seen this for their MacOS boxes. We're now
retrying a few times with curl, which seems to work.

Reviewed By: emilsjolander

Differential Revision: D6051024

fbshipit-source-id: feb73bfb9fd81b2a8b9b4d33d4e9f230a9899a66
2017-10-13 06:56:18 -07:00
Pascal Hartig
208b70a93c Fix license check
Summary: This seems to have changed upstream.

Reviewed By: emilsjolander

Differential Revision: D6050471

fbshipit-source-id: b453831c1d5a5974572265a78da40b0612b1d1f2
2017-10-13 03:56:35 -07:00
Pascal Hartig
6c3155ae3b Download right NDK for Travis
Summary:
I'm a big dummy.

https://travis-ci.org/facebook/yoga/jobs/257605319

Reviewed By: emilsjolander

Differential Revision: D6040274

fbshipit-source-id: e73225e6e2e1e899c25326030ac522d5a7aa06a5
2017-10-12 08:41:55 -07:00
Pascal Hartig
32f071c2ad Fix NDK download
Summary: Fix NDK download for Travis.

Reviewed By: emilsjolander

Differential Revision: D6020352

fbshipit-source-id: c7523c0afb18d675fc2443e133d5ab63109fec7b
2017-10-11 08:19:51 -07:00
Pascal Hartig
fdd1dbe3a9 Update buildScript deps
Summary:
The native-dependencies plugin seems unused. Upgrade to the latest
gradle-bintray-plugin version that's supported for the current Gradle version.

I'll hold back the upgrade to Gradle 4 until the Gradle Android Plugin for the
version hits stable.

Reviewed By: IanChilds

Differential Revision: D5986549

fbshipit-source-id: d26aa19e9eba40a2b30b20d5ffa9d2b006450f95
2017-10-06 02:26:15 -07:00
Pascal Hartig
1ca5bb694d Use NDK 15c
Summary: To match internal config.

Reviewed By: emilsjolander

Differential Revision: D5986514

fbshipit-source-id: b0e7dbc060c106f17f8e1c5e54e5b951d9e3e350
2017-10-06 02:26:15 -07:00
Marko Novakovic
b4cfaa916c Un-inline-ing a method declared as export
Reviewed By: compnerd

Differential Revision: D5909847

fbshipit-source-id: 7108dd88271e640e1881b20c0cbf1ad28bbf63c9
2017-09-26 19:12:42 -07:00
Michael Lee
fc6c85996e Reformat BUCK files
Summary: Reformat BUCK files to better conform with style.

Reviewed By: zertosh

Differential Revision: D5901515

fbshipit-source-id: 93e8c56450f65b691af9017d880e6cf2a2cdb7af
2017-09-25 10:16:22 -07:00
Andrew Gallagher
969f055f47 Deprecate older API uses of prebuilt_cxx_library
Summary:
Use the `deprecated_prebuilt_cxx_library` wrapper instead of the deprecated
API of `prebuilt_cxx_library`.

Reviewed By: ttsugriy

Differential Revision: D5878523

fbshipit-source-id: 2c8c1fd1d19597ff7459bbd527c89573520db74b
2017-09-22 13:27:32 -07:00
Bin Yu
58328d01ef Add 'useYoga' property to indicate whether UIView uses Yoga for layout or not
Summary: Now developer could check whether UIView uses Yoga for layout.

Reviewed By: emilsjolander

Differential Revision: D5881242

fbshipit-source-id: 4d1cf0b489b759ff0b9c5091cc51534fd12dcf60
2017-09-21 10:18:52 -07:00
Mingwei Pan
d90914f3dc Improve formatting of YogaNode.print() on Android
Summary:
The Android logger adds newline automatically, which makes the log ugly on Android.
To avoid that, wrap the android logger, print to a memory buffer.  Call __android_log_write() when '\n' is detected.

Reviewed By: emilsjolander

Differential Revision: D5842889

fbshipit-source-id: 8ecc829dc43614934c47fd3a68317259e403325a
2017-09-21 07:41:37 -07:00
Emil Sjolander
3a0a86788e Revert D5874862: [yoga][PR] Fix shrinking in non strech alignments
Summary:
This reverts commit 1426aa6b60f6ba42c2be702e6f24cea935ab7acb

bypass-lint

Differential Revision: D5874862

fbshipit-source-id: 24517d26b18c11fb9f75c6d3b5faae360711ea9e
2017-09-21 03:41:19 -07:00
Lukas Wöhrl
a77aa9a41e Fix shrinking in non strech alignments
Summary:
This fixes shrinking of elements which are in a non stretch alignment

Fixes #633
Closes https://github.com/facebook/yoga/pull/634

Differential Revision: D5874862

Pulled By: emilsjolander

fbshipit-source-id: 1426aa6b60f6ba42c2be702e6f24cea935ab7acb
2017-09-20 13:30:39 -07:00
Shaddix
7217471427 fix build, correctly size UIScrollViews
Summary: Closes https://github.com/facebook/yoga/pull/626

Reviewed By: emilsjolander

Differential Revision: D5824425

Pulled By: splhack

fbshipit-source-id: e1a8dda5e86e2705afa7f6630a6757491a94c6d6
2017-09-19 09:41:41 -07:00
Mingwei Pan
bcc36cc1b2 Zero out all fields in YGZeroOutLayoutRecursivly using memset
Summary:
Add a new test named YGZeroOutLayoutRecursivlyTest, which verifies that padding and margin of a child node should be set to 0 when the display is set to none.
Modify YGZeroOutLayoutRecursivly function, use memset to clear the layout struct of the node.

Reviewed By: emilsjolander

Differential Revision: D5842351

fbshipit-source-id: d2c2b6f829588a200525b7ccbdb63003cb4dcc4e
2017-09-15 08:32:36 -07:00
Amir Shalem
16052085d0 Fix YogaLogger leakage when removing it from YogaConfig
Summary: -

Reviewed By: emilsjolander

Differential Revision: D5802035

fbshipit-source-id: 79c1f8c3cc5ddf3abd51206f23e076f2410cfc0c
2017-09-11 03:14:11 -07:00
Lukas Wöhrl
c20f2864ab Only add UIView nodes to Yoga where they are enabled
Summary:
Only add UIView nodes to Yoga where they are enabled.

We check for it in `isLeaf` but I think we should also check for them in the check for sub views.
Closes https://github.com/facebook/yoga/pull/609

Reviewed By: emilsjolander

Differential Revision: D5643387

Pulled By: dshahidehpour

fbshipit-source-id: a85c62b6b2e0120b2913e7f2df8b094d43ca49a6
2017-08-23 15:46:51 -07:00
Lukas Wöhrl
4185a44393 Fix const declaration mismatch and double/float mix
Summary:
This PR fixes a declaration mismatch for `YGNodeCanUseCachedMeasurement` where the last argument is declared non `const` in `.h` and `const` in `.c`.

Additionally it uses explicit `float` for fraction calculation do avoid usage of `double` assignment.
Closes https://github.com/facebook/yoga/pull/607

Differential Revision: D5677931

Pulled By: emilsjolander

fbshipit-source-id: 502da957089e4439ed956987ff8dec10bd033ba3
2017-08-23 03:02:16 -07:00
Scott Wolchok
c79c5e3c9d Make gYGNodeDefaults const
Summary: At least one compiler seems to care about it.

Reviewed By: emilsjolander

Differential Revision: D5675518

fbshipit-source-id: 72a6e208263dde0b6bb46a78fedb2796d0e0a600
2017-08-22 11:56:21 -07:00
Emil Sjolander
35a9f33abb BREAKING: Change aspect ratio behavior
Summary:
@public

== Before ==
- Aspect ratio would do its best to fit within it's parent constraints
- Aspect ratio would prioritize `alignItems: stretch` over other sizing properties.

== After ==
- Aspect ratio is allowed to make a node grow past its parent constraints. This matches many other aspects of flexbox where parent constraints are not treated as hard constraints but rather as suggestions.
- Aspect ratio only takes `alignItems: stretch` into account if no other size definition is defined. This matches the interaction of other properties with `alignItems: stretch`.

== Updating your code ==

**You probably don't need to do anything** but in case something does break in your product it should be as easy as  adding `{width: '100%', height: '100%', flexShrink: 1}` to the style declaring the `aspectRatio`.

Reviewed By: gkassabli

Differential Revision: D5639187

fbshipit-source-id: 603e8fcc3373f0b7f2461da2dad1625ab59dcb19
2017-08-21 03:12:00 -07:00
Hoa Dinh
32f128640b Revert D5643382: [yoga][PR] Fix a typo in YogaKit,
Summary:
This reverts commit 127b0c11dbfd76d298db823e65fd2f6e365642e7

bypass-lint

Differential Revision: D5643382

fbshipit-source-id: f25b04680428bcd4515c44741ed72a004be43ef1
2017-08-17 15:48:47 -07:00
Luc Dion
18d19af7ec Fix a typo in YogaKit,
Summary:
`YGDimensionFlexibilityFlexibleHeight` it was wrongly spelled `YGDimensionFlexibilityFlexibleHeigth`.

[X] Test suite passes
[X] Contributor License Agreement
Closes https://github.com/facebook/yoga/pull/605

Reviewed By: amonshiz

Differential Revision: D5643382

Pulled By: dshahidehpour

fbshipit-source-id: 127b0c11dbfd76d298db823e65fd2f6e365642e7
2017-08-17 14:42:03 -07:00
Levi McCallum
2ee2dd439f Fix link to YGLayout header in docs
Summary: Closes https://github.com/facebook/yoga/pull/595

Reviewed By: amonshiz

Differential Revision: D5643379

Pulled By: dshahidehpour

fbshipit-source-id: ae972f270ee26fe7755ba5dee4d357d150a27c2a
2017-08-17 13:56:37 -07:00
Lior Tubi
5edfb679e7 Add a java binary buck target
Summary: .

Reviewed By: amir-shalem

Differential Revision: D5619667

fbshipit-source-id: e956190be0c6a7ea573e5511231de28aab5586fe
2017-08-13 07:32:11 -07:00
Georgiy Kassabli
f45059e1e6 Fixing edge case issue in Yoga where text node was unnecessary rounded down
Summary: There was an uncovered edge case where number close to the whole was forced to round down because it was considered non-whole and had forced flooring. This diff covers that + adds a bunch of test cases to cover rounding function

Reviewed By: emilsjolander

Differential Revision: D5465632

fbshipit-source-id: 57e11092a97eba5dd76daad15fa8619535ff9c1b
2017-07-26 19:38:31 -07:00
Pascal Hartig
c9384762ee Fix NDK build, Take II
Summary:
There was one incorrect path and some caching problems. I hope this will take
care of it for good.

Reviewed By: emilsjolander

Differential Revision: D5470120

fbshipit-source-id: 17c9e783c952c92fa5c2ccfb18107a59d8a80e3d
2017-07-21 08:29:43 -07:00
Pascal Hartig
7ea50439ce Fix travis NDK setup
Summary:
Phew, this took a while. Buck had some changes in how it picks up SDK/NDK
configs.

In order to satisfy the new demands, I'm now installing the NDK manually and no
longer through the SDK manager. I'm also trying to cache as much as possible to
reduce the flakiness here.

Reviewed By: emilsjolander

Differential Revision: D5465206

fbshipit-source-id: 61a4b9006fe96fc9a99fb9d75b822589064a9d1a
2017-07-21 03:14:21 -07:00
Pascal Hartig
154e67adbc Bump to 1.6.1-SNAPSHOT
Summary:
Set to the next snapshot version so automatic snapshot publishing is reenabled.
We need those to keep in sync with the Litho snapshots.

Reviewed By: emilsjolander

Differential Revision: D5442493

fbshipit-source-id: ecb92071ec8edb9c3c6b625c08f5aad20368d0a3
2017-07-18 11:46:10 -07:00
Lukas Wöhrl
570a193b7e Update c# docs to use object initializer
Summary:
Updates the C# docs to use the object initializer instead of `Create` which doesn't exist anymore.

Fixes facebook/yoga#550.
Closes https://github.com/facebook/yoga/pull/601

Reviewed By: emilsjolander

Differential Revision: D5427217

Pulled By: splhack

fbshipit-source-id: 9a2f036335e5ab475d5c1ee8308701ccb5a3b4e4
2017-07-14 16:13:07 -07:00
Emil Sjolander
79e294c927 1.6.0 version bumps
Reviewed By: passy

Differential Revision: D5415450

fbshipit-source-id: cf3c42303c4a63adf114199618d42dabdb123c42
2017-07-13 08:27:10 -07:00
Georgiy Kassabli
5d75c7c4c8 Fixing the issue with node dimensions rounding in Yoga
Summary: Yoga had a bug in Rounding calculation that caused text nodes dimensions to be rounded up even when the dimensions didn't need rounding

Reviewed By: emilsjolander

Differential Revision: D5406211

fbshipit-source-id: df1d54ed0805dfc3abbd8f0ceae30f6d8c26d61a
2017-07-12 09:33:51 -07:00
vincentriemer
7c688cea68 Add babel processing to browser build to remove references to node builtins
Summary:
Currently the nbind asm.js output generates boilerplate code which can conditionally load node's `fs` and `path` modules. If this output is run directly in the browser there are no issues but if you run it through a bundler the build step will fail trying to resolve the node builtins.

Workarounds currently exist for bundlers like webpack (mentioned in #444) but this is not a safe assumption to make (for example such workarounds don't exist for `metro-bundler`).

I am by no means suggesting that this is the perfect solution but this might provide a stop-gap fix for people who are currently blocked by this issue (like I am).
Closes https://github.com/facebook/yoga/pull/585

Differential Revision: D5388660

Pulled By: emilsjolander

fbshipit-source-id: d3a51eb852df35e3d0610158fe7d9f5754e4e684
2017-07-10 12:00:37 -07:00
Lukas Wöhrl
7640cd667f Reset the hadOverflow flag at the beginning of the algorithm
Summary:
This fixes the case where we change the layout, so that it doesn't overflow anymore.

This also improves the readability by using `|=` instead of referencing the value twice.
Closes https://github.com/facebook/yoga/pull/587

Differential Revision: D5388657

Pulled By: emilsjolander

fbshipit-source-id: ce1b1ded1feed7314a2c16bf695f62b866c19ea0
2017-07-10 12:00:37 -07:00
Lukas Wöhrl
24e2fc95dd Fix text node rounding with fractional dimensions matching the rounding factor
Summary:
If we have a fractional measure output which matches the subpixel rounding factor, we still should round both dimension into the same direction.

Fixes facebook/yoga#580.
Closes https://github.com/facebook/yoga/pull/583

Reviewed By: marco-cova

Differential Revision: D5274212

Pulled By: emilsjolander

fbshipit-source-id: 1febf9194210437ab77f91319d10d4da9b284b79
2017-07-04 06:27:24 -07:00
Andrey Mishanin
ce3f99939f Overflow detection in Yoga
Summary:
We need to provide Yoga clients with means of detecting overflow in flexbox layout. This information can be used later to identify a non-overflowing layout variant among others.

Flexbox layout considered overflown if (this is *not* an exhaustive list):

- if any child node overflows
- [no-wrap] total flex basis of all child nodes is greater than available space in parent and there are no flexible children
- [no-wrap] after flexing there is still not enough space to layout all child nodes

Reviewed By: gkassabli

Differential Revision: D5336645

fbshipit-source-id: c4f87d1754d7bac848e8d347b31d619393b94d2c
2017-06-30 09:26:57 -07:00
Lior Tubi
11bc97b16c Don't load fb native library
Summary: We don't bundle this library with the yoga source, and it isn't needed.

Reviewed By: emilsjolander

Differential Revision: D5274172

fbshipit-source-id: fec47d2700da86498410fe445d2980f31a563551
2017-06-19 05:42:52 -07:00
Matthew Jarjoura
4804bcd594 make sure YGPointValue works in Obj-C++
Summary:
This is an easy diff to wrap YGPointValue() in an extern "C" block to make sure it compiles
when we are using inside of Objective-C++ classes.

Reviewed By: emilsjolander

Differential Revision: D5242366

fbshipit-source-id: 772aaac056b3a20041926d5f35128716848a271a
2017-06-16 11:12:31 -07:00
Lukas Wöhrl
ca2c607f90 The total flex factores need to be a minimum of 1 if any
Summary:
The only thing I found in the spec for this change is the following. Not exactly sure if this is the thing this PR is about:

> For each flex item, subtract its outer flex base size from its max-content contribution size. If that result is not zero, divide it by (if the result was positive) its **flex grow factor floored at 1** or (if the result was negative) by its scaled flex shrink factor, having **floored the flex shrink factor at 1**. This is the item’s max-content flex fraction.

But at least it seems a required change.

Fixes facebook/yoga#566
Closes https://github.com/facebook/yoga/pull/572

Differential Revision: D5264388

Pulled By: emilsjolander

fbshipit-source-id: 0004d1c3b9bad070a98cd6766c1adc06a54475f8
2017-06-16 07:46:06 -07:00
sospartan
6c67684fa6 Change android minimum SDK version to 14
Summary:
The library(yoga) has no dependency on android framework. As a matter of
fact this version can change to a lower number which will make yoga
support more old systems.

According to I/O 17, support library has change its minimum SDK version
 to 14, so I think 14 is a reasonable min support version for yoga as well.

See
https://developer.android.com/topic/libraries/support-library/revisions.html
Closes https://github.com/facebook/yoga/pull/573

Differential Revision: D5264385

Pulled By: emilsjolander

fbshipit-source-id: cb813a3b643a3f4e2034c6c0ab8b488f94d6a7d0
2017-06-16 06:43:28 -07:00
Pascal Hartig
835b2bbae8 Fix license headers
Summary:
They were set up as javadocs (double-asterisk at the start) but should be normal
block headers.

Reviewed By: IanChilds

Differential Revision: D5255424

fbshipit-source-id: 23439ac035f74f2fd1c756b8185e39199e748e33
2017-06-15 07:41:44 -07:00
Pascal Hartig
47edd2586c Bump gradle plugin version
Summary:
Same as litho, just for compat with Android Studio. Shouldn't affect the
project.

Reviewed By: emilsjolander

Differential Revision: D5217956

fbshipit-source-id: 32cfec0bf4ab4e51f5e4116149ee091cf1245e95
2017-06-10 08:28:58 -07:00
Marco Cova
ca483cae00 Rounding error in width/height fixed
Summary: If the width has an exact dimension, while the left and right edges have a decimal part, that means the decimal part is equal and we can round both down instead of rounding left down and right up. Same for top and bottom.

Reviewed By: emilsjolander

Differential Revision:
D5209073

Tags: accept2ship

fbshipit-source-id: a3a6a43767aa707ebfa5eee62a83adcdd88d7ce6
2017-06-10 05:45:35 -07:00
Lukas Wöhrl
a20bde8444 Fix absolute position if wrap-reverse and align-items: flex-end
Summary:
This is a fix on top of 56b10fc. It takes the case into account were you have `wrap-reverse` and `align-items: flex-end` set.
Closes https://github.com/facebook/yoga/pull/568

Differential Revision: D5155521

Pulled By: emilsjolander

fbshipit-source-id: 7e5fcfa2fbb48b6c6279da46cc648a071ff2b079
2017-06-01 05:41:25 -07:00
Christian Oliff
ac885626b3 Correct capitalization of JavaScript
Summary:
Correct capitalization of JavaScript
Closes https://github.com/facebook/yoga/pull/569

Differential Revision: D5155524

Pulled By: emilsjolander

fbshipit-source-id: 48d9a28a61bb96af42241aa2ed6ac3d070adeaf9
2017-05-31 10:27:00 -07:00
Emil Sjolander
976ecc6816 Version bump
Summary: Version bump

Reviewed By: passy

Differential Revision: D5155064

fbshipit-source-id: a6d896b6b8741ea947cb5cc36c2a2f9333edfb2a
2017-05-31 08:27:41 -07:00
Emil Sjolander
d2f22283bb Fix confusing variable name
Summary: Variable name suggest it does not constrain to min dimension but it did indeed. Changing that to match variable name. This required updating code to use fully constraint value again. gkassabli this seems wrong, do you know what is going on?

Reviewed By: gkassabli

Differential Revision: D5144146

fbshipit-source-id: a5d711f8ad7049b0d96ee0f0f3eef1165ab3b4e8
2017-05-29 07:57:00 -07:00
Emil Sjolander
56b10fc35b Fix absolute positioning in reverse wrapping container
Summary: aligning with odd web behaviour

Reviewed By: gkassabli

Differential Revision: D5144145

fbshipit-source-id: da6ef999ec0aabacf499017d1cfa81fc8f66e4bd
2017-05-29 07:57:00 -07:00
Eduardo Gonzalez
5a3ceffba1 Add .editorconfig
Summary:
Just add .editorconfig into yoga 😄
Closes https://github.com/facebook/yoga/pull/562

Differential Revision: D5144025

Pulled By: emilsjolander

fbshipit-source-id: 9f28caaff276b266ac2aa514097fda6972b85f7c
2017-05-27 09:12:22 -07:00
Georgiy Kassabli
b378a685a4 Changed pointScaleFactor usage to avoid accumulating error
Summary: Previously pointScaleFactor was stored as a divider that opened way to accumulating difference. For instance in ScreenScale=3, pointScaleFactor = 0.3333343 (0.000001 error). When used for width = 300 that error was multiplied by the number of times pointScale contained in width (300 *3 = 900) and we had almost 0.001 error accumulated. With this change Yoga will avoid such issue

Reviewed By: shergin

Differential Revision: D5137923

fbshipit-source-id: 652b59bc3da3f35ee93ffa3695936f623298a023
2017-05-26 10:57:12 -07:00
Pascal Hartig
fa50f048f1 Only decrypt if keys are present
Summary:
Travis doesn't set encrypted variables in pull requests (for very good reasons),
but openssl fails rather loudly if it doesn't get them. Our artifact publishing
script happily skips PRs anyway, so we don't need these variables in that case.

Reviewed By: emilsjolander

Differential Revision:
D5137092

Tags: accept2ship

fbshipit-source-id: b14d61feba0bb98a1705b2f8232f52ba59a2c734
2017-05-26 04:13:01 -07:00
Emil Sjolander
f68b50bb4b Parse YogaValue from string. inverse of toString()
Summary: Implement the inverse of toString. This allows us to parse a YogaValue from a string inputted from the user in debugging tools.

Reviewed By: kittens

Differential Revision: D5120456

fbshipit-source-id: 6ac7cff2a040778e63a953070e1bd7e768fedaa7
2017-05-24 07:56:49 -07:00
Brian Cooke
aad1c3055c Move sdks = out to YOGA_DEFS
Summary: To fix builds where `sdks =` is not supported.

Reviewed By: splhack

Differential Revision: D5113020

fbshipit-source-id: b716acd6fb88ccb55c72b24f9fcdf20a2ea3693e
2017-05-23 12:12:45 -07:00
Georgiy Kassabli
cd1dbc3f0f Fixing potential measure call with negative size value
Summary: There is a case when measure() function will be called with negative width/height because of margin/padding. This diff fixes that scenario

Reviewed By: emilsjolander

Differential Revision: D5111534

fbshipit-source-id: 99f09b85f0c6a0e5dec89a26baba8f9d560100da
2017-05-23 11:12:10 -07:00
Pascal Hartig
bf4ff0769d Use 'dumb' terminal for Gradle
Summary: This makes the output less messy.

Reviewed By: emilsjolander

Differential Revision: D5111279

fbshipit-source-id: c65c7f275e57312fb56c2edfec429cc3d2373e3f
2017-05-23 03:57:34 -07:00
Pascal Hartig
a141ebfb50 Run Android tests with Gradle
Summary:
Make sure that the gradle tests pass before publishing the snapshot. Also makes
sure that we don't break the gradle build.

Reviewed By: emilsjolander

Differential Revision: D5020044

fbshipit-source-id: dfebd829701717eac3ed078a807cd10f489f4348
2017-05-23 03:57:33 -07:00
Jernej Strasner
2fb01daf70 Expose calculateLayoutWithSize in YogaKit
Summary:
calculateLayoutWithSize: can be useful when calculating table/collection view sizes before the views are fully laid out by UIKit.
Closes https://github.com/facebook/yoga/pull/558

Differential Revision: D5104863

Pulled By: emilsjolander

fbshipit-source-id: e0e0c6d502f6745be8d84de8c1b6e24cc25a0352
2017-05-22 11:41:55 -07:00
Pascal Hartig
e9e1e084da Enable unit tests with Gradle
Summary:
This adds the same logic that we have in place with Litho for Yoga, allowing
unit tests to run with Gradle for Yoga. It'll still shell out to Buck to build
the native library, but that's hopefully only until we have found a way to reuse
the NDK build. For CI this shouldn't matter as we want to run `buck build`
anyway and the build step should be a no-op.

FB-Only:
This should unlock D5020044.

Reviewed By: emilsjolander

Differential Revision: D5104154

fbshipit-source-id: 48732fff6c1d100a155452f675de343aaf06427b
2017-05-22 10:11:49 -07:00
yihuang
629e401deb Fix right/bottom in absolute layout.
Summary:
1, Change bottom to be based� on height of parent.
2, Respect margin value when layout with right/bottom.
Closes https://github.com/facebook/yoga/pull/552

Differential Revision: D5102090

Pulled By: emilsjolander

fbshipit-source-id: dca291413ffc2027d7628f4c8b8eeeb0b4823bc2
2017-05-22 02:56:41 -07:00
Chiamaka Nwolisa
f4c2b6ae63 Fix Typo
Summary: Closes https://github.com/facebook/yoga/pull/556

Differential Revision: D5102089

Pulled By: emilsjolander

fbshipit-source-id: 340cab34189628318c08ec45fe8c50a5c1970a17
2017-05-22 02:33:05 -07:00
yihuang
4487862227 fix print edge value.
Summary: Closes https://github.com/facebook/yoga/pull/551

Differential Revision: D5069358

Pulled By: emilsjolander

fbshipit-source-id: 8a8f07043d43f9f2d846a645217a52913cffe31b
2017-05-21 07:00:25 -07:00
Brian Cooke
927eca6604 Enable YogaKit for tvOS
Summary:
This is used in a stack where I'm using YogaKit on tvOS. fb_apple_library needs `sdks = ` to get buck to do its thing for tvOS.

This seems like it should be OK since apple_library is a nop on non apple platforms (which makes sense since this is ObjC only) - I think that makes sense anyway?

Reviewed By: emilsjolander

Differential Revision: D5080261

fbshipit-source-id: f08d7e6d2599b9af25fb964ade485aef552f306b
2017-05-18 06:03:25 -07:00
Georgiy Kassabli
f2612192c5 Fixing using flex in root node
Summary: We should always try to make root node as small as possible, while previously this wasn't functioning this way

Reviewed By: emilsjolander

Differential Revision: D5071164

fbshipit-source-id: b8afef42477d0ed87d0c9fcfd26349e0a0babd6e
2017-05-17 07:28:30 -07:00
Rui Marinho
49bccf47fa Fix windows and osx builds
Summary: Closes https://github.com/facebook/yoga/pull/555

Reviewed By: emilsjolander

Differential Revision: D5071045

Pulled By: splhack

fbshipit-source-id: f9e387242055e0a4a7c330c7bf99ed4a4b4057be
2017-05-16 12:42:08 -07:00
cregnier
fa54167a20 fixes #411 - add npm config platform env var in order to set which js…
Summary:
… platform will be built
Closes https://github.com/facebook/yoga/pull/537

Differential Revision: D5069356

Pulled By: emilsjolander

fbshipit-source-id: eaa67d17fe9d5ed9d0959781ed12a238cb3d95f2
2017-05-16 10:57:03 -07:00
Rui Marinho
50feb21cb3 Centralize native dependencies build script
Summary: Closes https://github.com/facebook/yoga/pull/554

Differential Revision: D5069362

Pulled By: emilsjolander

fbshipit-source-id: 7cf65233928c11010337ee21c633173ea919cc94
2017-05-16 09:59:13 -07:00
Kazuki Sakamoto
52ce5828c9 Use buck release for csharp/build-native.sh
Summary: Closes https://github.com/facebook/yoga/pull/553

Differential Revision: D5069363

Pulled By: emilsjolander

fbshipit-source-id: 2a88f0f53147b5abf1d4eb26f05108c2c001a8f5
2017-05-16 08:11:46 -07:00
Georgiy Kassabli
9cdaedfcb5 Correct YGNodeCanUseCachedMeasurement to account for non-existent scale factor
Summary: When config was added to YGNodeCanUseCachedMeasurement we didn't account for default 0 scale factor. This diff fixes that

Reviewed By: emilsjolander

Differential Revision: D5061016

fbshipit-source-id: 907ef987bd0ead29cf02f6945a3f03d4ffb58a2e
2017-05-15 08:41:30 -07:00
Georgiy Kassabli
adad054cad Adding ability to account for rounding in YGNodeCanUseCachedMeasurement
Summary: We want to be able to use YGConfig to account for possible rounding of width/height

Reviewed By: emilsjolander

Differential Revision: D5059560

fbshipit-source-id: d729e991758a8c668a4b373105b71337961875cd
2017-05-15 06:28:39 -07:00
Emil Sjolander
b2b0c7ee37 Fix typo causing wrapped children to be sized by wrong axis margin
Summary: Fixes https://github.com/facebook/yoga/issues/548

Reviewed By: passy

Differential Revision: D5044470

fbshipit-source-id: 7d203dd48b258a5fe5c4b3c493099092a1d334db
2017-05-12 09:12:51 -07:00
Emil Sjolander
488a7c1fe0 Include margin when calculating if children overflow
Summary: Include margin when calculating if children overflow

Reviewed By: passy

Differential Revision: D5044471

fbshipit-source-id: e7c1eb694445ffb898bcf375d9deefc558c49f11
2017-05-12 09:12:51 -07:00
Emil Sjolander
85c2e406e4 Fix flex basis not accounting for max size constraint
Summary: Fix flex basis not being constraint to the max size in the main direction. Previously this caused the added test to fail due to NaN in child dimensions.

Reviewed By: gkassabli

Differential Revision: D5044314

fbshipit-source-id: d9f9db832e4943a57a89c9d162ff6077b709795a
2017-05-12 09:12:51 -07:00
Emil Sjolander
dcf57d2f7e Big refactor moving most logic into DebugComponent
Summary: This adds very little (no?) new features and mostly just refactors code to live in a singular place. Instead of users having to worry about DebugComponent as well as the DebugInfo object and attaching it correctly to a tree now user's of the DebugComponent API only need to worry about a single class, greatly simplifying its usage.

Reviewed By: passy

Differential Revision: D5027780

fbshipit-source-id: 95a95b3572747aa2088f8f9b35a160257eb59269
2017-05-12 03:57:10 -07:00
Georgiy Kassabli
3fefe9fc49 Adding node type and moving rounding dependency to rely on that type
Summary: This diff adds node type definition to Yoga and moves rounding to rely on the node type. If the node has measure function we consider that node to be text node, otherwise we have default behavior.

Reviewed By: emilsjolander

Differential Revision: D5025107

fbshipit-source-id: a8d66e2f9c5d02ab080784cc474be583a09b92e2
2017-05-11 08:15:46 -07:00
Pascal Hartig
626a05fb6f Update docs for SNAPSHOTs
Summary: Also bumped the version number for the existing dependency examples.

Reviewed By: emilsjolander

Differential Revision: D5044190

fbshipit-source-id: 4199ab114450a256efaa30a811822923beafb378
2017-05-11 05:27:02 -07:00
Pascal Hartig
ffcd2cfc8a Fix android build and enable snapshots
Summary:
Fix some long-standing issues with the android build on Travis (and elsewhere)
and enable automatic publishing of snapshots.

Reviewed By: emilsjolander

Differential Revision: D5044001

fbshipit-source-id: f00be07f33c8018573af0b98233068ebd93360b4
2017-05-11 03:47:16 -07:00
Pascal Hartig
181101c92d Bump snapshot version
Summary: Per title

Reviewed By: emilsjolander

Differential Revision: D5044000

fbshipit-source-id: f1058700daff115bdff52ff62b859b4b3f2e469e
2017-05-11 03:47:16 -07:00
Pascal Hartig
3db6804202 Fix sample app oss build
Summary: The appcompat library was way outdated and failed CI: https://travis-ci.org/facebook/yoga/builds/231065300

Reviewed By: emilsjolander

Differential Revision: D5043967

fbshipit-source-id: a5bb02110cf016972d983f511cf8c31dd9d667e1
2017-05-11 03:47:15 -07:00
Emil Sjolander
3fb135829d Release 1.5.0
Summary: Bump version and fix small issues blocking release

Reviewed By: passy

Differential Revision: D5036755

fbshipit-source-id: 65fa2cd09dad8108bdd21067fb44107b059732e8
2017-05-10 09:32:26 -07:00
Pieter De Baets
2c91e1e7d2 Mark ByteBuffer methods as const
Summary: So I can use them from JSBigString whose methods are marked const.

Reviewed By: emilsjolander

Differential Revision: D5020648

fbshipit-source-id: 6e60b80cb3d4718bab25dd6ca9627aee862117db
2017-05-10 04:26:22 -07:00
Pascal Hartig
c3982b6c1e Set up for automatic snapshot publishing
Summary:
Gets all the pieces in place to automatically publish snapshot artifacts after
successful travis build.

I'll test the actual publishing in a separate branch and then flip the switch in
a separate diff when it's ready.

Reviewed By: emilsjolander

Differential Revision: D5028239

fbshipit-source-id: c57d02a1dee41c84001bd17821b050c8c9aa4134
2017-05-09 08:52:36 -07:00
Pascal Hartig
ae33c6c19c Update Maven release scripts
Summary:
Reuse the gradle setup we've built for Litho which allows for parallel publishing to Bintray and Maven Central in addition to Sonatype Snapshots.

This appears not to break the existing jcenter deploy script which is pretty great.

Reviewed By: emilsjolander

Differential Revision: D5020576

fbshipit-source-id: 3ef163ccbfe91c6858b051d39dcf237ca388e18d
2017-05-09 03:41:51 -07:00
Pascal Hartig
bcd68b997f Add missing fbjni deps
Summary:
fbjni was previously dependency-free but now requires some annotations and
soloader. This unbreaks the gradle build.

Reviewed By: emilsjolander

Differential Revision: D5020069

fbshipit-source-id: b8bde83ce6a70b06e04491f1d70c2a6b568bc99c
2017-05-09 01:56:44 -07:00
Emil Sjolander
fcfa1b9f01 Update pod lock
Summary: run pod install

Reviewed By: gkassabli

Differential Revision: D5019525

fbshipit-source-id: 9cf5d22d8542560e377ab5c3be80ba3ea7ec3de2
2017-05-08 04:48:49 -07:00
Emil Sjolander
d9a0822517 Update formula location for android-sdk
Summary: follow brews instructions on changed location of android sdk

Reviewed By: passy

Differential Revision: D5010781

fbshipit-source-id: 8c39116c821befadb8a153870f365cd0d3a1140d
2017-05-05 10:16:08 -07:00
Emil Sjolander
097e99b699 Always use latest buck
Summary: Always use latest buck

Reviewed By: aiked

Differential Revision: D5010762

fbshipit-source-id: d0c7d36665fab0c58ea5e05d9880b849b3ccf745
2017-05-05 09:19:22 -07:00
Kazuki Sakamoto
ff7bec703b Fix build and test
Summary: Closes https://github.com/facebook/yoga/pull/543

Reviewed By: emilsjolander

Differential Revision: D4997389

Pulled By: splhack

fbshipit-source-id: b4b3aa4cba29063df93fd2a57f96031a8fa393de
2017-05-04 09:19:40 -07:00
Maël Nison
c7ab004922 Fixes Travis error reporting
Summary:
Just cherry-picked my commit from #508
Closes https://github.com/facebook/yoga/pull/542

Differential Revision: D5002335

Pulled By: emilsjolander

fbshipit-source-id: 3f61a235c41627e9cfb90dce150323f11892e65f
2017-05-04 07:45:28 -07:00
Lukas Wöhrl
91230ae177 Move YGLogger into YGConfig and associate YGNodeRef with log events
Summary:
Moves the `YGLogger` into `YGConfig` and pass the `YGNodeRef` into the logger to be able to associate the log messages and assertions with the specific node.

Tackles facebook/yoga#530 and facebook/yoga#446
Closes https://github.com/facebook/yoga/pull/531

Reviewed By: astreet

Differential Revision: D4970149

Pulled By: emilsjolander

fbshipit-source-id: b7fcdaa273143ea2fa35861620b2e4d79f04f0af
2017-05-03 09:30:25 -07:00
Aurimas
40eba60cf5 Move from ActionBarActivity to AppCompatActivity
Summary:
ActionBarActivity has been deprecated for 2+ years now.
Closes https://github.com/facebook/yoga/pull/538

Differential Revision: D4985973

Pulled By: emilsjolander

fbshipit-source-id: 09f2a8a12943c9b3ccdaee9cac684276b42ff843
2017-05-02 09:27:18 -07:00
Aurimas
fb4cfed20d Move from ActionBarActivity to AppCompatActivity
Summary:
ActionBarActivity has been deprecated for 2+ years now.
Closes https://github.com/facebook/yoga/pull/539

Differential Revision: D4985970

Pulled By: emilsjolander

fbshipit-source-id: 2e2fcc5188c08ef1cd78f7e1be71917f0395ff2c
2017-05-02 09:27:18 -07:00
Emil Sjolander
d3a9a84ac4 use java_library instead of android_library
Summary: fbjni doesn't have android deps anyways.

Reviewed By: passy

Differential Revision: D4985285

fbshipit-source-id: 95a5942d89210568b74caa9f3c976a8ae6e9601c
2017-05-02 04:17:14 -07:00
cregnier
accad5366f fixes #535 - changes unneeded js require expression to a static strin…
Summary:
fixes #535 - changes unneeded js require expression to a static string to clean up webpack warnings
Closes https://github.com/facebook/yoga/pull/536

Differential Revision: D4977993

Pulled By: emilsjolander

fbshipit-source-id: 92fe3a278391f37e44ac816d662885df6b4ea11f
2017-05-01 05:21:32 -07:00
Emil Sjolander
8eca67e257 Fix useLegacyStretchBehaviour flag by simplifying its usage
Summary: See blame revision. we are still passing all the added tests from that pull request but with much simpler logic.

Reviewed By: gkassabli

Differential Revision: D4977923

fbshipit-source-id: cb488e63c7c2e15e4c0f0133a16df36580c646fd
2017-05-01 04:32:40 -07:00
Emil Sjolander
40e1bf6ce3 Treat measured nodes size as a minimun contraint when rounding
Summary: We need to treat measurements from nodes with measure functions as minimum values as to not truncate text.

Reviewed By: shergin

Differential Revision: D4972290

fbshipit-source-id: 0a7bcc7f47b3e5acb8745da5286abcb9c4e44a38
2017-04-30 03:11:58 -07:00
David Hart
7b89a1dd48 Implemented percentage values in YogaKit
Summary:
We still need to wait for the `YGUnitPoint` PR to be merged :) But please let me know what you think. One caveat: because of a limitation of Swift, a literal value can be automatically understood as a point-based `YGValue`, but variables have to be explicitly cast. I haven't found a way around it yet:

```
view.yoga.width = 10 // value == 10, unit == YGUnitPixel

let a: CGFloat = 100
view.yoga.height = a // Compiler error
view.yoga.height = YGValue(a) // works, not great
```
Closes https://github.com/facebook/yoga/pull/390

Reviewed By: emilsjolander

Differential Revision: D4954021

Pulled By: maxoll

fbshipit-source-id: 5eff6aeb6dd969d0d5dc557b149bb5819b0e31de
2017-04-28 10:51:31 -07:00
Lukas Wöhrl
203577724e Fix sizing of non strech items
Summary:
Fixes the sizing of items so that under most scenarios it calcultes its height by it's content for non exact measurings. This introduces a new useLegacyStretchBehaviour flag on the config to opt out of this change as it is breaking.

See facebook/yoga#505
Closes https://github.com/facebook/yoga/pull/506

Reviewed By: astreet

Differential Revision: D4954016

Pulled By: emilsjolander

fbshipit-source-id: d28bd5d174cd76951fb94df85e3b0cfab7f81ff7
2017-04-28 06:27:14 -07:00
Emil Sjolander
e3dbef7cbd Revert D4957570: [yoga] Consolidate measure cache for layout nodes and leaf nodes
Summary: This reverts commit 5c5f39b67bd3f72d92b939ecee2d9a46c80b583f

Differential Revision: D4957570

fbshipit-source-id: 4d30de37c6911aac2dc1243a54914515aabfb229
2017-04-28 04:19:33 -07:00
Ivan Persidskiy
0ee3303791 Configure YogaKit with main screen scale factor
Summary:
Hi! After merging 3db38f2a80 the rounding algorithm become broken in YogaKit because it doesn't configure scale factor.
Closes https://github.com/facebook/yoga/pull/534

Differential Revision: D4969481

Pulled By: emilsjolander

fbshipit-source-id: 57ea42a3b1f37007b2392cda724d509e0b28c4cb
2017-04-28 03:12:12 -07:00
Emil Sjolander
83fddd8af6 Expose print function to java
Summary: Allow printing a node from java

Reviewed By: astreet

Differential Revision: D4962456

fbshipit-source-id: 8f62ed6724490e621fbc11573b2a9b25c56e51f1
2017-04-27 16:28:34 -07:00
Emil Sjolander
77c05b5ff6 Consolidate measure cache for layout nodes and leaf nodes
Summary: Re-use advanced changing logic of leaf nodes in layout nodes. //benchmark:benchmark nested flex test shows a ~15% improvement in layout performance!

Reviewed By: astreet

Differential Revision: D4957570

fbshipit-source-id: 5c5f39b67bd3f72d92b939ecee2d9a46c80b583f
2017-04-27 13:11:50 -07:00
Kazuki Sakamoto
7c324f058c Fix C# MeasureFunc test
Summary: Closes https://github.com/facebook/yoga/pull/533

Reviewed By: emilsjolander

Differential Revision: D4962771

Pulled By: splhack

fbshipit-source-id: 96919da73f0f35c027097259fa189b5658fb11b7
2017-04-27 09:30:20 -07:00
Emil Sjolander
3db38f2a80 Remove rounding from experimental features
Summary: Rounding has been successfully adopted by multiple products and frameworks. Time to move it out of experimental mode. Rounding can still be turned of by setting the point scale factor to 0 on the config.

Reviewed By: gkassabli

Differential Revision: D4953838

fbshipit-source-id: 3ee5f27d92f95b3ed4a01c98bc35e9157f2e91c5
2017-04-27 07:14:29 -07:00
Lukas Wöhrl
f6b17183c5 Let measure behave more like on the web
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes https://github.com/facebook/yoga/pull/499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
2017-04-27 07:14:29 -07:00
Emil Sjolander
8f9d7e243e Expose setPointScaleFactor to java
Summary: Expose setPointScaleFactor to java

Reviewed By: gkassabli

Differential Revision: D4953835

fbshipit-source-id: b1f97d9ec1bb78ccf7f53131fce87955fe66eb02
2017-04-26 12:35:00 -07:00
Cheng Zhao
fde4db9383 Add YGConfigCopy
Summary: Closes https://github.com/facebook/yoga/pull/525

Differential Revision: D4953723

Pulled By: emilsjolander

fbshipit-source-id: 1c54f40dfae5054822a440edf9d0aafb22a465d9
2017-04-26 11:57:01 -07:00
Lukas Wöhrl
3178e3bf15 Fix flex-wrap with max constraint
Summary:
Fixes `flex-wrap` with a max constraint and `justify-content`. Fixes facebook/yoga#514.
Closes https://github.com/facebook/yoga/pull/519

Differential Revision: D4953727

Pulled By: emilsjolander

fbshipit-source-id: 32dec48220be1392ea8dac5f34871d407eb8d49b
2017-04-26 11:46:23 -07:00
ChengWei
cdfd05c742 Fix the parameter error
Summary: Closes https://github.com/facebook/yoga/pull/528

Differential Revision: D4953974

Pulled By: emilsjolander

fbshipit-source-id: eda4770d4eb6cf52304d40a1b7ac17c2f0e17148
2017-04-26 11:27:52 -07:00
Emil Sjolander
76f6a54327 Update fbjni
Summary: Update yoga's copy of fbjni to include some missing java files.

Reviewed By: IanChilds

Differential Revision: D4953841

fbshipit-source-id: 74d5c617a6fcd11e82c86f03e61448b14a34b86b
2017-04-26 07:42:40 -07:00
Robert Spencer
c91e4b3566 Correct android attribute link in docs
Summary:
Addresses issue #523
Closes https://github.com/facebook/yoga/pull/529

Differential Revision: D4953973

Pulled By: emilsjolander

fbshipit-source-id: b6e64f30ad615ba65152f19e775bd6c890e6c6b6
2017-04-26 06:27:17 -07:00
Robert Spencer
e24561bcef Update Android XML attribute names in docs
Summary:
Fixes #507 .  The attribute name format got changed and the docs were left behind.
Closes https://github.com/facebook/yoga/pull/510

Differential Revision: D4953733

Pulled By: emilsjolander

fbshipit-source-id: 6eb02d6745d08fdd8cce669c691794351bd6fbc7
2017-04-26 03:12:51 -07:00
Uldéric KIBONGUI
363e941867 Fixed doc mismatch with the implementation
Summary: Closes https://github.com/facebook/yoga/pull/518

Differential Revision: D4953729

Pulled By: emilsjolander

fbshipit-source-id: 6693a0e44e8f12f07af5c3fe7c0475f8553a1df2
2017-04-26 03:12:51 -07:00
Ivan Persidskiy
3fb2c1888c Downgrade deployment target to ios 7
Summary:
Hey there, lets downgrade deployment target of YogaKit pod to iOS7. This days there is a lot of apps that still have support of ios7 (and  i'm working on one of them :)). And I didnt't find any reason why it couldn't be done.

Thanks
Closes https://github.com/facebook/yoga/pull/524

Differential Revision: D4953726

Pulled By: emilsjolander

fbshipit-source-id: 9e17a40caaa0a3ae26779c0d08acb59f71df2b23
2017-04-26 03:12:51 -07:00
Valentin Shergin
aa5b296ac7 New round-to-pixel-grid algorithm that fixes possible subpixel gaps between sibling nodes
Summary:
This diff introduces new, little bit sophisticated round-to-pixel-grid algorithm.

**Motivation:**

Previous simple and straightforward solution works in most cases but sometimes produce the not-so-great result. A while ago Nick Lockwood described this problem and proposed the solution in RN's RCTShadowView class:

For example, say you have the following structure:

  // +--------+---------+--------+
  // |        |+-------+|        |
  // |        ||       ||        |
  // |        |+-------+|        |
  // +--------+---------+--------+

Say the screen width is 320 pts so the three big views will get the following x bounds from our layout system:
{0, 106.667}, {106.667, 213.333}, {213.333, 320}
Assuming screen scale is 2, these numbers must be rounded to the nearest 0.5 to fit the pixel grid:
{0, 106.5}, {106.5, 213.5}, {213.5, 320}
You'll notice that the three widths are 106.5, 107, 106.5.

This is great for the parent views but it gets trickier when we consider rounding for the subview. When we go to round the bounds for the subview in the middle, it's relative bounds are {0, 106.667} which gets rounded to {0, 106.5}. This will cause the subview to be one pixel smaller than it should be. This is why we need to pass in the absolute position in order to do the rounding relative to the screen's grid rather than the view's grid. After passing in the absolutePosition of {106.667, y}, we do the following calculations:
absoluteLeft = round(absolutePosition.x + viewPosition.left) = round(106.667 + 0) = 106.5
absoluteRight = round(absolutePosition.x + viewPosition.left + viewSize.width) + round(106.667 + 0 + 106.667) = 213.5
width = 213.5 - 106.5 = 107

You'll notice that this is the same width we calculated for the parent view because we've taken its position into account.

I believe this is awesome. I also believe that we have to decouple this logic from RN and put it into awesome Yoga. So I did it in this diff.

**Fun fact:**
The original implementation of this algorithm in RN had (and still have) a bug, which was found by Dustin dshahidehpour and fixed in D4133643. Therefore that diff was unlanded because it broke something unrelated inside RN text engine. I will fix that problem in RN later.

**Why do we need to change test methodology?**
Because the way we receive layout metrics from Chrome browser actually directly related to rounding problem. Previously we used `offsetHeight` and `offsetWidth` properties of the DOM node, which contain naively rounded values from `computedStyle` or `getBoundingClientRect`. (Which is we are trying to fix!) So, I added the new function that computes node size using two-step-rounding approach, conceptually similar to one that implemented in Yoga. Note: Chrome browser performs rounding layout as part of rendering process and actual values that can ve computed by counting actual pixel are different from these natively rounded ones.

**Why do some tests now have different desired values?**
These changes actually prove that my approach is correct and more useful for actual view rendering goals. So, let's take a look at test with changed values `rounding_fractial_input_3`:
Previously: 64+25+24=114 (Incorrect!)
Now: 65+24+25=114 (Correct!)
Previously: 64+25+24=114 (Incorrect!)
Now: 65+24+25=114 (Correct!)

Reviewed By: emilsjolander

Differential Revision: D4941266

fbshipit-source-id: 07500f5cc93c628219500e9e07291438e9d5d36c
2017-04-25 17:43:13 -07:00
Lukas Wöhrl
f2b5d0fef7 Mark some fields as readonly and reuse index value in RemoveChild
Summary:
Mark some fields as readonly and reuse index value in RemoveChild.
Closes https://github.com/facebook/yoga/pull/516

Reviewed By: emilsjolander

Differential Revision: D4921809

Pulled By: splhack

fbshipit-source-id: 261a7910675d93be165c16ee53a83c02b15925f1
2017-04-25 11:27:55 -07:00
Lukas Wöhrl
0684795a89 Mark enum with [Flags] where they are used as flags
Summary:
Marks enum with ```[Flags]``` attribute, where they are used as flags.
Closes https://github.com/facebook/yoga/pull/515

Reviewed By: emilsjolander

Differential Revision: D4921807

Pulled By: splhack

fbshipit-source-id: f056189b76ee6e6c042417a7998bfd20a610c27f
2017-04-25 10:28:06 -07:00
Daniel Wagner-Hall
2ffc23f400 Remove project_config rules
Summary:
These only exist to support a deprecated form of project generation which is
about to be removed.

Reviewed By: marcinkosiba

Differential Revision: D4945841

fbshipit-source-id: 3d35b8f8cd902572995ee4f55f9b5930efa186ec
2017-04-25 08:04:02 -07:00
Emil Sjolander
dc4d16401f Move reset into yoga node and dont set overflow as it has no effect
Summary: We don't need to set overflow from litho any more because overflow hidden / visible no longer effects layout.

Reviewed By: marco-cova

Differential Revision: D4938759

fbshipit-source-id: 4cd6bc478dd1f56340f23e8bfe95fe7bb1b5db2d
2017-04-25 03:27:27 -07:00
Martin Kralik
849de89a58 support flexible top container
Summary:
The main container that gets called `applyLayoutPreservingOrigin:` is using its size as a fixed bounding box.
In some cases it's preferrable to let it accomodate its contents.

This diffs extends `applyLayoutPreservingOrigin:` by adding an additional parameter which can be used to sepecify whether width and/or height are fixed or flexible.

Feel free to suggest better names than `YGDimensionFlexibility` & co.
Let me know if you prefet to kill the API without flexiblity specifier - I'll codemod everything then.

Reviewed By: dshahidehpour

Differential Revision: D4929702

fbshipit-source-id: f128f244140b4a54d8ce3b3f4edddbb9756f8fdf
2017-04-23 17:26:50 -07:00
Martin Kralik
f8a2903d02 fixed invalid test
Summary: The `block` paramenter is marked as nonnull, so we can't pass `nil` directly in.

Reviewed By: dshahidehpour

Differential Revision: D4929692

fbshipit-source-id: a35ef2940d6986f4ff55444d8a99ba17eb7c677e
2017-04-22 10:02:50 -07:00
Emil Sjolander
60977de242 Manual resync of moved fbjni files 2017-04-20 12:43:17 -07:00
Georgiy Kassabli
cb612bcfbe Correcting Flex fix within Experimental feature
Summary: This diff corrects the fix to be limited only to cases when either element itself or all of it's children can't be flexed

Reviewed By: emilsjolander

Differential Revision: D4915189

fbshipit-source-id: efccee2fe39ed0f474a41dc3250d24c546f3f5d9
2017-04-19 13:27:52 -07:00
Pascal Hartig
6be1c2cdb4 Begone buckBuildAndCopy!
Summary:
I'm actually quite excited about this one!

No more buck shelling out for building the Yoga AARs/JARs via Gradle. It's now
all done via Gradle.

This commit is the only one that should actually change anything about the entry
points to the gradle builds and release process. **So if anything goes wrong
with the next release, reverting this one here should be enough!**

Reviewed By: emilsjolander

Differential Revision: D4913600

fbshipit-source-id: 4a54562ad5be69f62a7781d43fddad211f99ab25
2017-04-19 12:27:32 -07:00
Pascal Hartig
034ab0b3b1 Set up Gradle build for yogacore
Summary:
I put the CMake file in the root directory to avoid moving the actual `yoga/`
dir around, but created a directory for the Android library manifest nonsense
so it works as its own module you can depend on.

Reviewed By: emilsjolander

Differential Revision: D4913601

fbshipit-source-id: 582064264cf0b6b69c03d0e72ed9dd22d217dd16
2017-04-19 12:27:32 -07:00
Pascal Hartig
8c50347f3c Add NDK build for libfb
Summary:
This enables using gradle for building libfb using the NDK. This is 1/3 of what
we need to do. We also need to build yoga itself (which is the easiest as it's
just a static library without external dependencies) and yogajni which relies on
the other two.

Hopefully, this should also make it more obvious why the previous moves were
necessary.

Reviewed By: emilsjolander

Differential Revision: D4913360

fbshipit-source-id: 47658328532fd1ec15f10f8e31ea04691c481011
2017-04-19 12:27:32 -07:00
Pascal Hartig
9f76fb6980 Move libfb to src/main/cpp
Summary:
This way we can more easily build it with Gradle. The CMake build for this comes
with the next Diff.

Reviewed By: emilsjolander

Differential Revision: D4913361

fbshipit-source-id: b7958e204a8a4a97a1f60043788d826dd2a4c080
2017-04-19 11:42:38 -07:00
Lukas Wöhrl
8b0ff0a25c Add methods for easy adding/removing children
Summary:
Adds two methods ```AddChild``` and ```RemoveChild``` to be able to add/remove children without the need to know there position.
Closes https://github.com/facebook/yoga/pull/513

Reviewed By: emilsjolander

Differential Revision: D4914242

Pulled By: splhack

fbshipit-source-id: df187ba71a1bae0b3b0649624f3c29401d5f8804
2017-04-19 11:30:41 -07:00
Lukas Wöhrl
8891ea1a7a Rename StyleAspectRatio to AspectRatio to be more consistent
Summary:
Rename ```StyleAspectRatio``` to ```AspectRatio``` to be consistent with the other getters and setters.
Closes https://github.com/facebook/yoga/pull/512

Reviewed By: emilsjolander

Differential Revision: D4914236

Pulled By: splhack

fbshipit-source-id: 7b9ebdbf8945c4a8570c61de16d71c8d9d96bf9f
2017-04-19 11:30:41 -07:00
Lukas Wöhrl
ede2ad94bc Add YGEnums to visual studio solutions
Summary:
As stated in 152074935 by rmarinho the Visual Studio solution didn't compile as ```YGEnums.c/YGEnums.h``` hasn't been added to them. This fixes this problem.
Closes https://github.com/facebook/yoga/pull/511

Reviewed By: emilsjolander

Differential Revision: D4914234

Pulled By: splhack

fbshipit-source-id: 473b6169bfb6576ca8848d4a5079f81692766897
2017-04-19 11:30:41 -07:00
Pascal Hartig
eacf3cdbb4 Bump gradle and android dependencies
Summary:
We need to use the most recent Android SDK to leverage the cmake-based NDK build
system. Also, since everything seems to be still working - why not?

I also changed the dependency of `yoga-layout` to be the project, not the
pre-published artifact as it no longer compiled due to the changed measure API
signature. I'm not sure if there was a reason to keep the two separate.

By relying on Maven-published artifacts, we generate better POMs when publishing
and people can override dependencies and see them more easily.

A few more cleanups based on what we did with Litho.

Reviewed By: emilsjolander

Differential Revision: D4913208

fbshipit-source-id: 053deb444ce91106afb3b66c3be28d6fcbdea450
2017-04-19 10:56:48 -07:00
Pascal Hartig
3569a13b74 Make bintray parameters optional
Summary:
By declaring the properties first, before using them in the scripts, you no
longer get an exception if you fail to specify them.

You can now build artifacts or run tests without specifying your bintray
password, which is probably what you want.

Reviewed By: emilsjolander

Differential Revision: D4913103

fbshipit-source-id: 8787af8973cebb84cd59e18c63a3a9f28e0ec348
2017-04-19 10:56:48 -07:00
Pascal Hartig
b2a96ec744 Bundle gradle wrapper
Summary:
I'm trying to get an NDK build set up for Yoga and clean up some of the Gradle
things along the way.

Having a wrapper is not only the preferred way of setting up Android
repositories and more convenient than asking users to install Gradle on their
machines themselves, but also allows for version pinning, which is important
when dealing with Android plugins which usually expect one very specific version
of Gradle.

Reviewed By: emilsjolander

Differential Revision: D4913104

fbshipit-source-id: b14964025271cd16c3c5c05a2fb6dab213227346
2017-04-19 10:56:48 -07:00
Pascal Hartig
a505adb2b7 Bump Android target SDK
Summary: Can we just bump this here?

Reviewed By: emilsjolander

Differential Revision: D4905930

fbshipit-source-id: ea0bd51e32700556ecd1527d2b7fad67d4645366
2017-04-18 12:11:15 -07:00
Pascal Hartig
906b6e52f8 Bump java artifact
Summary: Distribute a new java binary after removing YogaNodeAPI

Reviewed By: lucasr

Differential Revision: D4895449

fbshipit-source-id: c911d3ab69ad01967c76527da22d7c9be7f5f049
2017-04-15 00:45:15 -07:00
George Xu
3292337754 Revert D4875343: Correct fix for flexing grandchildren
Summary: This reverts commit 634e961f9798dff43eae2c6564b28c6629b816e0

Differential Revision: D4875343

fbshipit-source-id: 2949762bf47e151c8c0ff923d501859b3e0a567a
2017-04-13 18:15:40 -07:00
Emil Sjolander
eb4af86e3c Revert D4850458: [yoga][PR] Let measure behave more like on the web
Summary: This reverts commit be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc

Differential Revision: D4850458

fbshipit-source-id: 2ecb6c8627a84b52ade968fd18331a7473369ebe
2017-04-13 15:41:55 -07:00
Emil Sjolander
1b3e971549 Remove references to CSSLayoutDEPRECATED
Summary: Remove references to CSSLayoutDEPRECATED from litho

Reviewed By: marco-cova

Differential Revision: D4859822

fbshipit-source-id: 2588c1b3334f28332ae43e6c0bdec65934ca84c4
2017-04-13 12:45:23 -07:00
Emil Sjolander
4615eee2d8 Revert D4878875: [yoga][PR] Fix sizing of non strech items
Summary: This reverts commit ab1174ac7a76dcf20aae7b29a3bc396e11077c4d

Differential Revision: D4878875

fbshipit-source-id: 8927438e7a1969deb617434369af53f71f625638
2017-04-13 10:04:15 -07:00
Lukas Wöhrl
7c57245943 Let measure behave more like on the web
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes https://github.com/facebook/yoga/pull/499

Differential Revision: D4850458

Pulled By: emilsjolander

fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
2017-04-13 08:46:20 -07:00
Georgiy Kassabli
0d100ad7e9 Correct fix for flexing grandchildren
Summary: This diff adds correct fix for non-flexible child with flexible grandchildren

Reviewed By: emilsjolander

Differential Revision: D4875343

fbshipit-source-id: 634e961f9798dff43eae2c6564b28c6629b816e0
2017-04-13 08:46:20 -07:00
Lukas Wöhrl
0235789863 Fix sizing of non strech items
Summary:
Fixes the sizing of items so that under most scenarios it calcultes its height by it's content for non exact measurings. See facebook/yoga#505
Closes https://github.com/facebook/yoga/pull/506

Differential Revision: D4878875

Pulled By: emilsjolander

fbshipit-source-id: ab1174ac7a76dcf20aae7b29a3bc396e11077c4d
2017-04-13 07:41:52 -07:00
Emil Sjolander
c080a46571 Fix some issues with the deploy script and deploy a new version for android
Summary: Fix some issues with the deploy script and deploy a new version for android

Reviewed By: passy

Differential Revision: D4876006

fbshipit-source-id: ddafb8349e1c77ab5afd9a823103fb6a1dfabb1d
2017-04-12 09:56:42 -07:00
Emil Sjolander
5f050cb590 Bump version of android stuff
Summary: Bump version of android things

Reviewed By: passy

Differential Revision: D4875213

fbshipit-source-id: 2b229a0dade521ef745852c0096545e7e9fe2c1e
2017-04-12 03:43:45 -07:00
Lukas Wöhrl
25f14a1917 Fix min constraint incorrectly reducing available space
Summary:
If a min constraint exists. It incorrectly reduces the available space by that amount. This adds a test and fix for this.
Closes https://github.com/facebook/yoga/pull/501

Differential Revision: D4867146

Pulled By: emilsjolander

fbshipit-source-id: ceafe070bfe7f501929d316656ac44c4e1753059
2017-04-11 13:11:08 -07:00
Lukas Wöhrl
e9927377b5 Fix position on root node with RTL direction
Summary:
If the root node has a position and we have a RTL layout, that position must be like LTR direction. See #477.
Closes https://github.com/facebook/yoga/pull/502

Differential Revision: D4867144

Pulled By: emilsjolander

fbshipit-source-id: b5ad3d87e7054090da12d7665a3d1abe8496a548
2017-04-11 13:11:05 -07:00
Kazuki Sakamoto
3ea76f8a9b Add YogaConfig unit tests
Summary:
- depends on #497
Closes https://github.com/facebook/yoga/pull/498

Reviewed By: emilsjolander

Differential Revision: D4796199

Pulled By: splhack

fbshipit-source-id: c63f23da11a719b36c0d49e954b29c0016cad8c7
2017-04-10 14:26:51 -07:00
Kazuki Sakamoto
8a45ed9671 Add YGConfigGetInstanceCount
Summary:
- depends on #496
- For memory leak unit test
- Expose the API for C#
Closes https://github.com/facebook/yoga/pull/497

Reviewed By: emilsjolander

Differential Revision: D4796190

Pulled By: splhack

fbshipit-source-id: 99e4e78e8dfb3d459cf6cd7103ab252c3748e5a6
2017-04-10 14:26:51 -07:00
Kazuki Sakamoto
1520749351 Update YogaConfig
Summary:
- Bugfix: Retain managed YogaConfig to prevent releasing unmanaged YogaConfig
- Use the same YogaConfig in the copy constructor
- Expose Set/GetUseWebDefaults APIs
- Split YogaConfig out from YogaNode.cs
Closes https://github.com/facebook/yoga/pull/496

Reviewed By: emilsjolander

Differential Revision: D4796178

Pulled By: splhack

fbshipit-source-id: cafabdc051ca914af547acbbf3d2246a5618e8bb
2017-04-10 11:03:43 -07:00
birfincankafein
f66f52d1ba Make YogaLayout create programmatically. Make YogaNode of YogaLayout …
Summary:
Make YogaLayout constructible programmatically.
Make YogaLayout's YogaNode accessible from outside.
Closes https://github.com/facebook/yoga/pull/436

Differential Revision: D4850451

Pulled By: emilsjolander

fbshipit-source-id: 2821a6ef4160854244c0227a3c4c96369f7b2e64
2017-04-07 02:12:25 -07:00
Christine Abernathy
49e18738c3 Remove gists and fix iOS instructions
Summary:
Remove gists in code blocks. This also made it easier to fix the iOS sample app instructions in the getting started.

>Note: I also needed to update my gems as I was having problems running `bundle install`. The errors were around installing json v1.8.3. It was resolved by creating a new Gemfile.lock.

1. Build website and check changed pages (see attached Getting Started for an example)
2. Also check how it would look for mobile site (see attached index page)

Verified that the code snippets matched previous snippets and styling acceptable.

![yoga_gs](https://cloud.githubusercontent.com/assets/691109/24681238/1601fcc8-1949-11e7-8caa-5ac78a4c9a6b.png)
![yoga_index_mobile](https://cloud.githubusercontent.com/assets/691109/24681248/1ee3ea86-1949-11e7-9677-83056f93e385.png)
Closes https://github.com/facebook/yoga/pull/500

Differential Revision: D4834356

Pulled By: emilsjolander

fbshipit-source-id: f47dca4b7518822b195f0bd5076fbf852904372b
2017-04-05 05:43:21 -07:00
Lukas Wöhrl
586b57009a Optimize log print by using html format
Summary:
See facebook/yoga#453. Optimizes the node log print by generating some enum text via ```enum.py``` and moving printing to new functions to reduce boilerplate code.

Changes the log output to format the nodes in html to be able to copy paste it  into browsers for quick debugging.

Hides all default values.
Closes https://github.com/facebook/yoga/pull/479

Reviewed By: gkassabli

Differential Revision: D4802184

Pulled By: emilsjolander

fbshipit-source-id: 143bd63cbc31fb0755d711062cb4e6a448049ba3
2017-04-03 09:41:57 -07:00
Lukas Wöhrl
5112564f08 Don't transfer layout outputs to java for unset edges
Summary:
See facebook/yoga#483. We should not transfer the layout if the layout didn't change. (using ```hasNewLayout```). This also changes that the lock on the java node is only aquired if needed, and it holds the lock only for the time the values are set and not for the time all it's children are set.
Closes https://github.com/facebook/yoga/pull/484

Reviewed By: astreet

Differential Revision: D4802966

Pulled By: emilsjolander

fbshipit-source-id: e8a8f2280ad6b25b98fc68b07eac68e0ec80fe3e
2017-04-01 04:43:09 -07:00
Lukas Wöhrl
34726a9926 Fix xmlns import for android yoga library
Summary:
Fix xmlns import for yoga library by using `apk` instead of `lib` in the comment.
Closes https://github.com/facebook/yoga/pull/495

Reviewed By: emilsjolander

Differential Revision: D4802918

Pulled By: rspencer01

fbshipit-source-id: 9cef7709606e30e8e30af6e396866ac4900168bf
2017-03-30 09:32:11 -07:00
Lukas Wöhrl
5884ab7b76 Don't transfer layout outputs to java for nodes which don't have a new layout
Summary:
As suggested in facebook/yoga#484. This is the PR which only adds the part of using a local bool field for storing the hasLayoutFlag, to be able to pass the layout only if it has really changed.
Closes https://github.com/facebook/yoga/pull/492

Reviewed By: astreet

Differential Revision: D4786961

Pulled By: emilsjolander

fbshipit-source-id: cf3d354b93f6dcc3ef817ef73a47bd29e37d1848
2017-03-29 16:44:13 -07:00
Robert Spencer
60db018ce4 Fix native build script for deployments
Summary: The native build script didn't make the directories it needed, and thus only worked if you'd run it before :O

Reviewed By: emilsjolander

Differential Revision: D4794861

fbshipit-source-id: 69764ef1ddadf63333ce5d91dfa85bc943479fef
2017-03-29 07:42:59 -07:00
Robert Spencer
6b002bad3d Version bump of java library
Summary: Version bump as we have introduced `setUseWebDefaults`.

Reviewed By: emilsjolander

Differential Revision: D4794772

fbshipit-source-id: 0a42def3bec3f4f76caf6da01e3b9ab3679ebcb0
2017-03-29 06:56:13 -07:00
Emil Sjolander
5b173c1b61 Set web defaults when resetting
Summary: Set web defaults when resetting

Reviewed By: astreet

Differential Revision: D4779742

fbshipit-source-id: 5b8c5d7bd432a12984e4ebfd3187da3d680272cd
2017-03-29 03:12:33 -07:00
Emil Sjolander
bc2fb5c7ab Expose UseWebDefaults to java
Summary: Expose UseWebDefaults to java

Reviewed By: astreet

Differential Revision: D4779743

fbshipit-source-id: 65a4184af6fb959fefff5c2014522c551ca440d5
2017-03-29 03:12:33 -07:00
Emil Sjolander
ebdf82f491 Set hasNewLayout on children when changing their layout due to display none parent
Summary: Mark nodes as having a new layout when changing display to none recursively.

Reviewed By: astreet

Differential Revision: D4786615

fbshipit-source-id: 2f3a16661d37bc37939e8e7a551445886a06524e
2017-03-28 12:43:10 -07:00
Maël Nison
36f6fa9861 Fix tests of splitted config feature
Summary:
The following PR fixes the tests used in the javascript port (it modifies gentest.rb).

These changes don't yet pass, it seems something is segfaulting somewhere. I have to check if it comes from nbind, the yoga library, or the node bridge itself. There's also some fails on the browser build, but it might be the same issue.
Closes https://github.com/facebook/yoga/pull/487

Reviewed By: emilsjolander

Differential Revision: D4778870

Pulled By: astreet

fbshipit-source-id: 936fbca564ec89738c78e50c4402c53eb6867dec
2017-03-28 10:49:46 -07:00
Kazuki Sakamoto
91a34bb875 Support IL2CPP and fix stale handle
Summary:
- Unity IL2CPP (ENABLE_IL2CPP) requires the same code path with AOT compile.
- Clean up unneeded code in YGConfigHandle.
- YogaNode.Reset makes YGNodeHandle stale. Unmanaged side was reset by YGNodeReset, but YGNodeHandle keeps to retain the old managed handle. Release it.
Closes https://github.com/facebook/yoga/pull/491

Reviewed By: astreet

Differential Revision: D4765683

Pulled By: splhack

fbshipit-source-id: 83bfe19feb0e6ec45dc504e42b0c6c34e10af8e2
2017-03-27 08:12:22 -07:00
Kazuki Sakamoto
d342fb1879 Use Assert.Throws instead of ExpectedException
Summary:
Unity 5.6 doesn't have ExpectedException attribute.
Closes https://github.com/facebook/yoga/pull/486

Reviewed By: astreet

Differential Revision: D4739149

Pulled By: splhack

fbshipit-source-id: 9cc486a094c6e159b46fa7938669fecbf523c666
2017-03-27 08:12:22 -07:00
Emil Sjolander
b283572453 Revert D4716024: [yoga] Avoid transfering cached layout information to java
Summary: This reverts commit c30763a6fc7426d653c7a6ca129615cddb4140e9

Differential Revision: D4716024

fbshipit-source-id: 7276b4bbf072aa444c5ae9fd1a3d62ea87a0cec1
2017-03-17 13:27:18 -07:00
Shoaib Meenai
62a74a5ef9 Move -fPIC into YOGA_DEFS
Summary:
Move -fPIC from BUCK to YOGA_DEFS, so that it can be overridden when
building yoga inside another build tree (since the larger build tree
may need its own configuration for -fPIC). No change when building yoga
standalone.

Reviewed By: emilsjolander

Differential Revision: D4714782

fbshipit-source-id: c706336cda72b36045e744e4fcaea4c0899bcf38
2017-03-17 10:58:42 -07:00
Emil Sjolander
a14aeb27bb Avoid transfering cached layout information to java
Summary: Don't transfer layout outputs to java if the layout was cached as this means that it has already been transfered

Reviewed By: astreet

Differential Revision: D4716024

fbshipit-source-id: c30763a6fc7426d653c7a6ca129615cddb4140e9
2017-03-17 09:14:08 -07:00
Emil Sjolander
249d010dad Invalidate layout when node is removed from tree
Summary: The layout of a node is invalid once it leaves the tree. Let's reset it for safety in case it is added to another tree.

Reviewed By: astreet

Differential Revision: D4716022

fbshipit-source-id: 399cc64a4b3f5fd3fc469ea37bdd31abe474dc6c
2017-03-17 09:14:08 -07:00
Pascal Hartig
9b13fdeae4 Add YOGA_ROOTS to permit multiple definitions
Summary:
This changes the `YOGA_ROOT` to `YOGA_ROOTS` in `YOGA_DEFS`. This allows the
inclusion of Yoga in the exported Components libraries directory and
back-references to the nested dependencies within it.

Reviewed By: rspencer01

Differential Revision: D4721745

fbshipit-source-id: 2dc9d4a730076510aed02027cb6713f6326c588d
2017-03-16 10:41:59 -07:00
Robert Spencer
794b6b35ce YogaLayout perf tests
Summary: We would like to know some numbers on benchmarking `YogaLayout` against other layouts, particularly `LinearLayout`.  This implements a `BenchmarkActivity` to fill that need.

Reviewed By: emilsjolander

Differential Revision: D4565531

fbshipit-source-id: fe1c558beb603c3116ac3d0dd6654b0376dd6b8a
2017-03-15 09:11:24 -07:00
Maxime Ollivier
dcff4d3db2 Update .travis.yml to build iOS sample project
Summary: Closes https://github.com/facebook/yoga/pull/481

Differential Revision: D4713645

Pulled By: emilsjolander

fbshipit-source-id: b51eded585b59f50471e01271aabb5672b0682b1
2017-03-15 09:11:24 -07:00
Lukas Wöhrl
b94466e502 Fix align-content: center, flex-end alignment with margin
Summary:
This fixes ```align-content: center``` and ```align-content: flex-end``` when the child exceeds the parents size. See #476. It also fixes those layouts if the child has ```margin: auto``` set.
Closes https://github.com/facebook/yoga/pull/477

Differential Revision: D4697833

Pulled By: emilsjolander

fbshipit-source-id: d081ec7ea559a5f2bd3271c3a4dc272960beddfa
2017-03-15 05:31:38 -07:00
Dustin Shahidehpour
11052053d8 Upgrade sample project to use bulk update API.
Summary: Using the newer/recommended API in the sample project. #accept2ship

Reviewed By: emilsjolander

Differential Revision: D4698936

fbshipit-source-id: 07b61df897524cd38390ba48dfa2a2e10942329b
2017-03-13 12:11:54 -07:00
Dustin Shahidehpour
6ab3984bba Update README.md
Summary: Closes https://github.com/facebook/yoga/pull/478

Differential Revision: D4698444

Pulled By: dshahidehpour

fbshipit-source-id: 4e87f8f4922ff3888f27d97063495ab2a5edd5fd
2017-03-13 09:58:09 -07:00
Maxime Ollivier
136e0c7e52 undo iOS sample project build
Summary:
Temporarily remove the iOS sample project build.
Closes https://github.com/facebook/yoga/pull/475

Differential Revision: D4689718

Pulled By: emilsjolander

fbshipit-source-id: 9249e9d03dfdb60e222f8c3c0f496ec67122ed62
2017-03-10 10:12:19 -08:00
Kazuki Sakamoto
7e2ef926ea Add Workaround #if to GC test
Summary: Closes https://github.com/facebook/yoga/pull/474

Reviewed By: emilsjolander

Differential Revision: D4687978

Pulled By: splhack

fbshipit-source-id: 5b411e94f76c9846eadd2f01f0c8fd511fd6cdbf
2017-03-10 09:42:16 -08:00
Lukas Wöhrl
061981fb23 Align resolve function names to have similiar namings
Summary:
We have some resolve functions with ```YG**Resolve``` and others named ```YGResolve**```. This changes both to be named like the later one, as I think this is the grammatically better readable one.
Closes https://github.com/facebook/yoga/pull/471

Differential Revision: D4688997

Pulled By: emilsjolander

fbshipit-source-id: 38b5f84d4d39ed3effedf08188085b9efd96b4ce
2017-03-10 06:13:06 -08:00
Maxime Ollivier
3d6fb2f2e5 Update .travis.yml to build iOS sample project
Summary: Closes https://github.com/facebook/yoga/pull/472

Differential Revision: D4688993

Pulled By: emilsjolander

fbshipit-source-id: 9b5a16866c4258245a50582aa1110d54139a7ec2
2017-03-10 05:26:00 -08:00
Kazuki Sakamoto
a8e6123d47 Allow to reset measure and baseline functions
Summary:
Once measure and baseline functions are set, C# layer never calls YGNodeSetMeasure/BaselineFunc with NULL. This diff will fix the issue.
Closes https://github.com/facebook/yoga/pull/468

Reviewed By: emilsjolander

Differential Revision: D4676753

Pulled By: splhack

fbshipit-source-id: da34de2fc28adf320a18de2addffe9671cf1ecf9
2017-03-09 08:13:28 -08:00
Lukas Wöhrl
406c8a2117 Move pointscalefactor to config
Summary:
This adds some improvements to the new ```YGConfig```, it tackles #452 and moves the scalefactor into the config.
Closes https://github.com/facebook/yoga/pull/457

Differential Revision: D4675088

Pulled By: emilsjolander

fbshipit-source-id: 99b2c734d6c5139fe1dc8bdeb014bb038f0e337d
2017-03-09 07:35:07 -08:00
Robert Spencer
0445962bd4 Use camelCase for attributes
Summary: The android standard is `prefix_camelCase` such as `layout_marginLeft`.  This changes attributes like `yg_margin_left` to `yg_marginLeft`.

Reviewed By: emilsjolander

Differential Revision: D4681514

fbshipit-source-id: 76a80c24f19f3ee52329a2a254fe1f5fbcb40b9c
2017-03-09 06:26:34 -08:00
Lukas Wöhrl
09f0c2d8ce Take margin into account on max dimension
Summary:
We need to take the margin into account if we clip on max dimension. Fixes #466.
Closes https://github.com/facebook/yoga/pull/467

Differential Revision: D4681342

Pulled By: emilsjolander

fbshipit-source-id: 56311df9864a284d553c31f1c6db382f337f1fad
2017-03-09 03:56:00 -08:00
Lukas Wöhrl
8dea884a69 Fix typo in test class to use same name as the others
Summary:
Fixes a typo in the test class to use the same name as the other tests.
Closes https://github.com/facebook/yoga/pull/469

Differential Revision: D4681340

Pulled By: emilsjolander

fbshipit-source-id: a5e60b5e2aa74dc25e677a5579bb853492708c16
2017-03-09 03:42:56 -08:00
Robert Spencer
57898762a2 Bump NDK version and build all architectures
Summary: Until now we've been building only arm-v7 and x86 libraries.  This builds 64 bit versions too, and sets up the gradle script to publish them.  We also bump up the NDK version, and increase the min API to 21, as this is the first API supporting 64 bit NDK tools.

Reviewed By: emilsjolander

Differential Revision: D4674049

fbshipit-source-id: fbc87541fcaf72b83d376646c7aab70c317125e1
2017-03-09 03:12:42 -08:00
Lukas Wöhrl
01bf8d7b6c Add unittest for percentage width inside absolute layout
Summary:
Added unittest to constraint layout of percentage width inside absolute parent. See #454.
Closes https://github.com/facebook/yoga/pull/456

Differential Revision: D4674103

Pulled By: emilsjolander

fbshipit-source-id: 569a762e5a2b4ac80cd79bfbc9abfe57ada74dc9
2017-03-08 09:26:08 -08:00
Rui Marinho
af8d55c08e Missing project, Badges, ignore test on MacOS for a green build
Summary:
For some reason this Universal.csproj wasn't pulled from rozele PR.. i added the missing files.

Added badges for build and nuget for more exposure.

Ignore a failing unit test on MacOS for a green build.
Closes https://github.com/facebook/yoga/pull/464

Reviewed By: emilsjolander

Differential Revision: D4670392

Pulled By: splhack

fbshipit-source-id: 9ea3150b92039cab87ce8696db983fdf373c5388
2017-03-08 07:58:46 -08:00
Bryan Jennings
53398b42c6 Fix broken link, rename CONTRIBUTING to CONTRIBUTING.md
Summary:
Before:
There was a broken link in ./docs/README.md
CONTRIBUTING didn't render markup on Github

After:
All links to CONTRIBUTING.md are not broken anymore
CONTRIBUTING.md renders markup on Github
Closes https://github.com/facebook/yoga/pull/458

Differential Revision: D4673746

Pulled By: emilsjolander

fbshipit-source-id: 151c1f38789a96b61dfbb544fd11996098dc456d
2017-03-08 06:41:24 -08:00
Robert Spencer
1bf142e048 Separate annotation processors and include in java as provided
Summary:
With the current setup, the final aar contains `com.facebook.proguard.annotation.DoNotStrip`.  This is not needed (it is only used for proguard), and thus should not get published.

We move proguard annotations into its own project for this, and place it into `java/proguard-annotations`. Here we adopt the gradle convention of `src/main` to make for a nice, clean (one line!) gradle script.  As a different subproject, we can include this to `:yoga` as a `provided` dependency now, which doesn't include it in the output artifact.

Reviewed By: emilsjolander

Differential Revision: D4666572

fbshipit-source-id: a0cb26cb6c264065a0bd355b7d72ba02e3759560
2017-03-08 00:12:05 -08:00
Rui Marinho
0405c4f77d Update nuget and sln
Summary:
Update nuget CI
Closes https://github.com/facebook/yoga/pull/463

Reviewed By: emilsjolander

Differential Revision: D4666500

Pulled By: splhack

fbshipit-source-id: 1d77457d59eafe6de855a27b4f8a8567cd415b7b
2017-03-07 09:11:14 -08:00
Robert Spencer
61595763b0 Use SVGs for all badges
Summary: I accidentally used pngs for the bintray badges.  This renders ugly sometimes.  This corrects that.

Reviewed By: emilsjolander

Differential Revision: D4666641

fbshipit-source-id: df53f08a77be3067804d7671d673146f208a24fd
2017-03-07 09:11:14 -08:00
Robert Spencer
f6ecc8da7b Update readme with badges and YogaLayout badges
Summary: This adds bintray badges to the readme, and creates a readme for the android code.

Reviewed By: emilsjolander

Differential Revision: D4666314

fbshipit-source-id: a2549374f3e9c39c260160d1e32fb37801ff4208
2017-03-07 06:56:26 -08:00
Robert Spencer
32792a0de5 Gradle versionbump
Summary: Version 1.3

Reviewed By: emilsjolander

Differential Revision: D4666239

fbshipit-source-id: fad4b97b9947342ac91718d4f261184e7baf334a
2017-03-07 06:56:26 -08:00
Emil Sjolander
c3d60b55bd Bump podspec version
Summary: Bump podspec version

Reviewed By: dshahidehpour

Differential Revision: D4666248

fbshipit-source-id: 924aea76db5d68acbae7048d8542cab71122cbc2
2017-03-07 06:28:47 -08:00
649 changed files with 55896 additions and 13345 deletions

View File

@@ -1,9 +1,10 @@
[cxx]
gtest_dep = //lib/gtest:gtest
[android]
target = Google Inc.:Google APIs:19
target = android-25
build_tools_version = 26.0.2
[ndk]
ndk_version = 12.1.2977051
ndk_version = 15.2.4203891
compiler = clang
app_platform = android-19
cpu_abis = armv7, x86
app_platform = android-21
cpu_abis = arm64, armv7, x86, x86_64

11
.editorconfig Normal file
View File

@@ -0,0 +1,11 @@
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

2
.gitignore vendored
View File

@@ -63,3 +63,5 @@ Carthage/Build
# Gradle
.gradle
# NDK/CMake
.externalNativeBuild

View File

@@ -5,116 +5,28 @@
# 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.
os: osx
osx_image: xcode8.2
language: cpp
compiler: clang
language: node_js
node_js:
- "8"
env:
- TARGET=c
- TARGET=java
- TARGET=net
- TARGET=ios
- TARGET=js
- TARGET=android
before_install:
- brew update > /dev/null
- brew tap facebook/fb
- brew install buck
# Java
- |
if [[ $TARGET = "java" ]]; then
brew cask install java &&
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) &&
export PATH=$JAVA_HOME/bin:$PATH
fi
# .NET
- |
if [[ $TARGET = "net" ]]; then
brew install mono
fi
# iOS
- |
if [[ $TARGET = "ios" ]]; then
brew outdated xctool || brew upgrade xctool
fi
# Emscripten (used for js tests)
# Note: cannot be ran on Linux (because it will compile Clang from its sources :|)
- |
if [[ $TARGET = "js" ]]; then
wget -O /tmp/emsdk-portable.tar.gz https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz &&
tar xf /tmp/emsdk-portable.tar.gz -C /tmp/ &&
/tmp/emsdk_portable/emsdk install latest >& /dev/null &&
/tmp/emsdk_portable/emsdk activate latest
fi
# Android
- |
if [[ $TARGET = "android" ]]; then
brew cask install java;
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);
export PATH=$JAVA_HOME/bin:$PATH;
brew install android-sdk;
export ANDROID_SDK=/usr/local/Cellar/android-sdk/24.4.1_1;
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1;
brew install lib32stdc++6 lib32z1;
echo y | $ANDROID_SDK/tools/android update sdk --filter android-19,addon-google_apis-google-19,build-tools-19.1.0 --no-ui;
echo y | $ANDROID_SDK/tools/android update sdk -u;
fi
# JavaScript
- |
if [[ $TARGET = "js" ]]; then (
cd javascript &&
npm install &&
unset CC && unset CXX && unset LINK &&
source /tmp/emsdk_portable/emsdk_env.sh &&
npm run build:browser
) fi
install:
- cd website
- yarn --ignore-scripts
- cd ..
script:
# C
- |
if [[ $TARGET = "c" ]]; then
buck test --verbose 0 //:yoga &&
buck run --verbose 0 //benchmark:benchmark &&
git checkout HEAD^ &&
buck run --verbose 0 //benchmark:benchmark
fi
- cd website
- yarn build
- cd ..
# Java
- |
if [[ $TARGET = "java" ]]; then
buck test --verbose 0 //java:java
fi
# .NET
- |
if [[ $TARGET = "net" ]]; then
sh csharp/tests/Facebook.Yoga/test_macos.sh
fi
# iOS
- |
if [[ $TARGET = "ios" ]]; then
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64
fi
# Android
- |
if [[ $TARGET = "android" ]]; then
buck build --verbose 0 //android/sample:sample
fi
# JavaScript
- |
if [[ $TARGET = "js" ]]; then (
cd javascript &&
npm run test:all &&
npm run bench
) fi
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
fqdn: yogalayout.com
local-dir: website/public
email: yogabot@fb.com
name: Yoga-bot
keep-history: true
on:
branch: master

39
BUCK
View File

@@ -1,34 +1,47 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "LIBRARY_COMPILER_FLAGS", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "yoga_dep", "cxx_library", "cxx_test")
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",
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c++1y",
]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ["-std=c++11"]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-std=c++1y",
]
cxx_library(
name = "yoga",
srcs = glob(["yoga/*.c"]),
compiler_flags = COMPILER_FLAGS,
exported_headers = subdir_glob([("", "yoga/*.h")]),
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS,
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [] if THIS_IS_FBOBJC else [
deps = [
yoga_dep("lib/fb:ndklog"),
],
)
cxx_library(
name = "yogafastmath",
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS + ["-ffast-math"],
soname = "libyogafastmathcore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
],
)

15
CMakeLists.txt Normal file
View File

@@ -0,0 +1,15 @@
#
# Copyright (c) 2014-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB yogacore_SRC yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC})
target_link_libraries(yogacore android log)

3
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,3 @@
# Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.

View File

@@ -2,6 +2,10 @@
We want to make contributing to this project as easy and transparent as
possible.
## Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
## Pull Requests
We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`.
@@ -25,9 +29,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
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
* format.sh
## License
By contributing to yoga, you agree that your contributions will be licensed
under its BSD license.
under its MIT license.

43
LICENSE
View File

@@ -1,30 +1,21 @@
BSD License
MIT License
For yoga software
Copyright (c) 2014-present, Facebook, Inc.
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 THE
AUTHORS OR COPYRIGHT HOLDERS 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.

33
PATENTS
View File

@@ -1,33 +0,0 @@
Additional Grant of Patent Rights Version 2
"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
(subject to the termination provision below) license under any Necessary
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
transfer the Software. For avoidance of doubt, no license is granted under
Facebook's rights in any patent claims that are infringed by (i) modifications
to the Software made by you or any third party or (ii) the Software in
combination with any software or other technology.
The license granted hereunder will terminate, automatically and without notice,
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.
A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.

View File

@@ -1,11 +1,4 @@
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout)
[![C Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=c&label=C)](https://travis-ci.org/facebook/yoga)
[![Java Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=java&label=Java)](https://travis-ci.org/facebook/yoga)
[![iOS Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=ios&label=iOS)](https://travis-ci.org/facebook/yoga)
[![.NET Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=net&label=.NET)](https://travis-ci.org/facebook/yoga)
[![JavaScript Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=js&label=JavaScript)](https://travis-ci.org/facebook/yoga)
[![Android Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=android&label=Android)](https://travis-ci.org/facebook/yoga)
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![bintray](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga:yoga.svg)](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [![NuGet](https://img.shields.io/nuget/v/Facebook.Yoga.svg)](https://www.nuget.org/packages/Facebook.Yoga)
## 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.
@@ -30,8 +23,26 @@ You may need to install the latest watir-webdriver gem (`gem install watir-webdr
### .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.
## Benchmarks
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. 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.
### JavaScript
Installing through NPM
```sh
npm install yoga-layout
```
By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.
```sh
npm config set yoga-layout:platform standalone
```
This will now only run the standalone webpack build upon install.
## Build Platforms
| name | description |
|----------------|-------------------------------------------------|
| all (default) | Builds all of these platforms. |
| browser | Builds asm js browser version. |
| node | Builds node js version. |
| standalone | Runs webpack. |
| none | Does nothing. You can use the prepackaged libs. |

View File

@@ -1,42 +0,0 @@
YOGA_ROOT = '//...'
JAVA_TARGET = '//java:java'
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'
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
ANDROID_TARGET = '//android:android'
ANDROID_JAVA_TARGET = '//android/src/main/java/com/facebook/yoga/android:android'
ANDROID_RES_TARGET = '//android:res'
ANDROID_SAMPLE_JAVA_TARGET = '//android/sample/java/com/facebook/samples/yoga:yoga'
ANDROID_SAMPLE_RES_TARGET = '//android/sample:res'
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
with allow_unsafe_import():
import os.path
def isdir(filename):
return os.path.isdir(filename)

View File

@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '1.2.0'
spec.license = { :type => 'BSD', :file => "LICENSE" }
spec.version = '1.7.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/'
@@ -11,7 +11,7 @@ Pod::Spec.new do |spec|
spec.authors = 'Facebook'
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => '1.2.0',
:tag => '1.7.0',
}
spec.module_name = 'yoga'
@@ -21,8 +21,8 @@ Pod::Spec.new do |spec|
'-fexceptions',
'-Wall',
'-Werror',
'-std=c11',
'-std=c++1y',
'-fPIC'
]
spec.source_files = 'yoga/**/*.{c,h}'
spec.source_files = 'yoga/**/*.{c,h,cpp}'
end

View File

@@ -1,7 +1,7 @@
podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit'
spec.version = '1.2.0'
spec.license = { :type => 'BSD', :file => "LICENSE" }
spec.version = '1.7.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
@@ -11,15 +11,15 @@ podspec = Pod::Spec.new do |spec|
spec.authors = 'Facebook'
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => '1.2.0',
:tag => '1.7.0',
}
spec.platform = :ios
spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.2'
spec.source_files = 'YogaKit/Source/*.{h,m}'
spec.dependency 'Yoga', '~> 1.7'
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
end

View File

@@ -1,11 +1,9 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "yoga_dep", "apple_library", "apple_test")
COMPILER_FLAGS = [
"-fobjc-arc",
@@ -30,12 +28,21 @@ COMPILER_FLAGS = [
apple_library(
name = "YogaKit",
srcs = glob(["Source/**/*.m"]),
header_namespace = "",
exported_headers = subdir_glob(
[
("", "Source/**/*.h"),
("Source", "**/*.h"),
],
prefix = "YogaKit",
),
compiler_flags = COMPILER_FLAGS,
exported_headers = glob(["Source/**/*.h"]),
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
],
header_path_prefix = "",
link_whole = True,
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),

View File

@@ -1,46 +0,0 @@
# CHANGELOG
The changelog for `YogaKit`.
1.2.0 (**upcoming release**)
-----
### Breaking Changes
- `applyLayout()` has now been changed to `applyLayout(preservingOrigin:)`.
- Computed properties are no longer reflected in getter's of the affected properties.
```swift
// OLD
view.yoga.margin = 10
view.yoga.marginTop // 10
view.yoga.marginLeft // 10
// NEW
view.yoga.margin = 10
view.yoga.marginTop // 0
view.yoga.marginLeft // 0
```
### Enhancements
- Pixel Rounding now uses `roundf()` instead of `round()`.
- There is now a method that allows "bulk" updates to YGLayout.
```objc
[view configureLayoutWithBlock:^(YGLayout *layout) {
layout.isEnabled = YES;
layout.width = 50;
layout.height = 50;
}];
```
```swift
view.configureLayout { (layout) in
layout.isEnabled = true
layout.width = 50
layout.height = 50
}
```
- Added new `isDirty` property, and make `markDirty` a little more performant.

View File

@@ -8,7 +8,7 @@
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
```
pod 'YogaKit', '~> 1.1'
pod 'YogaKit', '~> 1.7'
```
## Getting Started
@@ -19,4 +19,4 @@ We also have a sample project. To try it out, clone this repo and open `YogaKitS
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
See the [CONTRIBUTING](https://github.com/facebook/yoga/blob/master/CONTRIBUTING) file for how to help out.
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout.h"
@@ -12,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
typedef void (^YGLayoutConfigurationBlock)(YGLayout *);
typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
@interface UIView (Yoga)
@@ -20,6 +18,10 @@ typedef void (^YGLayoutConfigurationBlock)(YGLayout *);
The YGLayout that is attached to this view. It is lazily created.
*/
@property (nonatomic, readonly, strong) YGLayout *yoga;
/**
Indicates whether or not Yoga is enabled
*/
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
/**
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "UIView+Yoga.h"
@@ -26,6 +24,11 @@ static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
return yoga;
}
- (BOOL)isYogaEnabled
{
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
}
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
{
if (block != nil) {

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout.h"

View File

@@ -1,19 +1,41 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <yoga/YGEnums.h>
#import <yoga/Yoga.h>
#import <yoga/YGMacros.h>
YG_EXTERN_C_BEGIN
extern YGValue YGPointValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
extern YGValue YGPercentValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
YG_EXTERN_C_END
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
YGDimensionFlexibilityFlexibleHeight = 1 << 1,
};
@interface YGLayout : NSObject
/**
The property that decides if we should include this view when calculating layout. Defaults to YES.
Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
- (instancetype)init
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
The property that decides if we should include this view when calculating
layout. Defaults to YES.
*/
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
@@ -36,34 +58,34 @@
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) CGFloat flexBasis;
@property (nonatomic, readwrite, assign) YGValue flexBasis;
@property (nonatomic, readwrite, assign) CGFloat left;
@property (nonatomic, readwrite, assign) CGFloat top;
@property (nonatomic, readwrite, assign) CGFloat right;
@property (nonatomic, readwrite, assign) CGFloat bottom;
@property (nonatomic, readwrite, assign) CGFloat start;
@property (nonatomic, readwrite, assign) CGFloat end;
@property (nonatomic, readwrite, assign) YGValue left;
@property (nonatomic, readwrite, assign) YGValue top;
@property (nonatomic, readwrite, assign) YGValue right;
@property (nonatomic, readwrite, assign) YGValue bottom;
@property (nonatomic, readwrite, assign) YGValue start;
@property (nonatomic, readwrite, assign) YGValue end;
@property (nonatomic, readwrite, assign) CGFloat marginLeft;
@property (nonatomic, readwrite, assign) CGFloat marginTop;
@property (nonatomic, readwrite, assign) CGFloat marginRight;
@property (nonatomic, readwrite, assign) CGFloat marginBottom;
@property (nonatomic, readwrite, assign) CGFloat marginStart;
@property (nonatomic, readwrite, assign) CGFloat marginEnd;
@property (nonatomic, readwrite, assign) CGFloat marginHorizontal;
@property (nonatomic, readwrite, assign) CGFloat marginVertical;
@property (nonatomic, readwrite, assign) CGFloat margin;
@property (nonatomic, readwrite, assign) YGValue marginLeft;
@property (nonatomic, readwrite, assign) YGValue marginTop;
@property (nonatomic, readwrite, assign) YGValue marginRight;
@property (nonatomic, readwrite, assign) YGValue marginBottom;
@property (nonatomic, readwrite, assign) YGValue marginStart;
@property (nonatomic, readwrite, assign) YGValue marginEnd;
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
@property (nonatomic, readwrite, assign) YGValue marginVertical;
@property (nonatomic, readwrite, assign) YGValue margin;
@property (nonatomic, readwrite, assign) CGFloat paddingLeft;
@property (nonatomic, readwrite, assign) CGFloat paddingTop;
@property (nonatomic, readwrite, assign) CGFloat paddingRight;
@property (nonatomic, readwrite, assign) CGFloat paddingBottom;
@property (nonatomic, readwrite, assign) CGFloat paddingStart;
@property (nonatomic, readwrite, assign) CGFloat paddingEnd;
@property (nonatomic, readwrite, assign) CGFloat paddingHorizontal;
@property (nonatomic, readwrite, assign) CGFloat paddingVertical;
@property (nonatomic, readwrite, assign) CGFloat padding;
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
@property (nonatomic, readwrite, assign) YGValue paddingTop;
@property (nonatomic, readwrite, assign) YGValue paddingRight;
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
@property (nonatomic, readwrite, assign) YGValue paddingStart;
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
@property (nonatomic, readwrite, assign) YGValue padding;
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
@@ -73,12 +95,12 @@
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
@property (nonatomic, readwrite, assign) CGFloat width;
@property (nonatomic, readwrite, assign) CGFloat height;
@property (nonatomic, readwrite, assign) CGFloat minWidth;
@property (nonatomic, readwrite, assign) CGFloat minHeight;
@property (nonatomic, readwrite, assign) CGFloat maxWidth;
@property (nonatomic, readwrite, assign) CGFloat maxHeight;
@property (nonatomic, readwrite, assign) YGValue width;
@property (nonatomic, readwrite, assign) YGValue height;
@property (nonatomic, readwrite, assign) YGValue minWidth;
@property (nonatomic, readwrite, assign) YGValue minHeight;
@property (nonatomic, readwrite, assign) YGValue maxWidth;
@property (nonatomic, readwrite, assign) YGValue maxHeight;
// Yoga specific properties, not compatible with flexbox specification
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
@@ -95,12 +117,26 @@
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
If the origin is not preserved, the root view's layout results will applied from {0,0}.
*/
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
/**
Returns the size of the view if no constraints were given. This could equivalent to calling [self
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
/**
Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension.
*/
- (CGSize)calculateLayoutWithSize:(CGSize)size
NS_SWIFT_NAME(calculateLayout(with:));
/**
Returns the number of children that are using Flexbox.
*/

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout+Private.h"
@@ -21,26 +19,56 @@
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
}
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (CGFloat)lowercased_name \
{ \
YGValue value = YGNodeStyleGet##capitalized_name(self.node); \
if (value.unit == YGUnitPoint) { \
return value.value; \
} else { \
return YGUndefined; \
} \
} \
\
- (void)set##capitalized_name:(CGFloat)lowercased_name \
{ \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
- (CGFloat)lowercased_name \
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##property(self.node, edge); \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
case YGUnitAuto: \
YGNodeStyleSet##capitalized_name##Auto(self.node); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##property(self.node, edge); \
}
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
@@ -49,42 +77,53 @@
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
}
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGE_PROPERTY_GETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (CGFloat)objc_lowercased_name \
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
{ \
YGValue value = YGNodeStyleGet##c_name(self.node, edge); \
if (value.unit == YGUnitPoint) { \
return value.value; \
} else { \
return YGUndefined; \
switch (objc_lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \
{ \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \
}
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
YGValue YGPointValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPoint };
}
YGValue YGPercentValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPercent };
}
static YGConfigRef globalConfig;
@interface YGLayout ()
@@ -103,6 +142,7 @@ static YGConfigRef globalConfig;
{
globalConfig = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
}
- (instancetype)initWithView:(UIView*)view
@@ -189,7 +229,7 @@ YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_VALUE_PROPERTY(flexBasis, FlexBasis)
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft)
YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop)
@@ -208,8 +248,8 @@ YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
YG_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll)
YG_VALUE_PROPERTY(width, Width)
YG_VALUE_PROPERTY(height, Height)
YG_AUTO_VALUE_PROPERTY(width, Width)
YG_AUTO_VALUE_PROPERTY(height, Height)
YG_VALUE_PROPERTY(minWidth, MinWidth)
YG_VALUE_PROPERTY(minHeight, MinHeight)
YG_VALUE_PROPERTY(maxWidth, MaxWidth)
@@ -235,6 +275,20 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
{
CGSize size = self.view.bounds.size;
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
size.width = YGUndefined;
}
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeight) {
size.height = YGUndefined;
}
[self calculateLayoutWithSize:size];
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (CGSize)intrinsicSize
{
const CGSize constrainedSize = {
@@ -244,8 +298,6 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
return [self calculateLayoutWithSize:constrainedSize];
}
#pragma mark - Private
- (CGSize)calculateLayoutWithSize:(CGSize)size
{
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
@@ -266,6 +318,8 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
};
}
#pragma mark - Private
static YGSize YGMeasureView(
YGNodeRef node,
float width,
@@ -334,7 +388,7 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) {
if (subview.yoga.isIncludedInLayout) {
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
[subviewsToInclude addObject:subview];
}
}

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
postfix operator %
extension Int {
public static postfix func %(value: Int) -> YGValue {
return YGValue(value: Float(value), unit: .percent)
}
}
extension Float {
public static postfix func %(value: Float) -> YGValue {
return YGValue(value: value, unit: .percent)
}
}
extension CGFloat {
public static postfix func %(value: CGFloat) -> YGValue {
return YGValue(value: Float(value), unit: .percent)
}
}
extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
public init(integerLiteral value: Int) {
self = YGValue(value: Float(value), unit: .point)
}
public init(floatLiteral value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: CGFloat) {
self = YGValue(value: Float(value), unit: .point)
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <XCTest/XCTest.h>
@@ -21,7 +19,8 @@
- (void)testConfigureLayoutIsNoOpWithNilBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertNoThrow([view configureLayoutWithBlock:nil]);
id block = nil;
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
}
- (void)testConfigureLayoutBlockWorksWithValidBlock
@@ -30,11 +29,11 @@
[view configureLayoutWithBlock:^(YGLayout *layout){
XCTAssertNotNil(layout);
layout.isEnabled = YES;
layout.width = 25;
layout.width = YGPointValue(25);
}];
XCTAssertTrue(view.yoga.isEnabled);
XCTAssertEqual(view.yoga.width, 25);
XCTAssertEqual(view.yoga.width.value, 25);
}
- (void)testNodesAreDeallocedWithSingleView
@@ -43,7 +42,7 @@
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.flexBasis = 1;
view.yoga.flexBasis = YGPointValue(1);
layoutRef = view.yoga;
XCTAssertNotNil(layoutRef);
@@ -62,11 +61,11 @@
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
topLayout = view.yoga;
topLayout.flexBasis = 1;
topLayout.flexBasis = YGPointValue(1);
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
subviewLayout = subview.yoga;
subviewLayout.flexBasis = 1;
subviewLayout.flexBasis = YGPointValue(1);
view = nil;
}
@@ -112,9 +111,9 @@
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
textBadgeView.yoga.isEnabled = YES;
textBadgeView.yoga.margin = 0;
textBadgeView.yoga.width = 10;
textBadgeView.yoga.height = 10;
textBadgeView.yoga.margin = YGPointValue(0);
textBadgeView.yoga.width = YGPointValue(10);
textBadgeView.yoga.height = YGPointValue(10);
[container addSubview:textBadgeView];
const CGSize textBadgeViewSize = textBadgeView.yoga.intrinsicSize;
@@ -135,14 +134,14 @@
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.isEnabled = YES;
view.yoga.flexBasis = 0;
view.yoga.flexBasis = YGPointValue(0);
view.yoga.flexGrow = 1;
[container addSubview:view];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
view2.yoga.isEnabled = YES;
view2.yoga.marginTop = 25;
view2.yoga.flexBasis = 0;
view2.yoga.marginTop = YGPointValue(25);
view2.yoga.flexBasis = YGPointValue(0);
view2.yoga.flexGrow = 1;
[container addSubview:view2];
@@ -153,6 +152,59 @@
XCTAssertEqual(25, view2.frame.origin.y);
}
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(200, container.frame.size.height);
}
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(200, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth |
YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
@@ -388,12 +440,12 @@
XCTAssertTrue(view.yoga.isLeaf);
view.yoga.isEnabled = YES;
view.yoga.width = 50.0;
view.yoga.width = YGPointValue(50);
XCTAssertTrue(view.yoga.isLeaf);
UIView *const subview = view.subviews[0];
subview.yoga.isEnabled = YES;
subview.yoga.width = 50.0;
subview.yoga.width = YGPointValue(50);
XCTAssertFalse(view.yoga.isLeaf);
}
@@ -405,14 +457,14 @@
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.width = 100;
subview1.yoga.width = YGPointValue(100);
subview1.yoga.flexGrow = 1;
subview1.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.width = 150;
subview2.yoga.width = YGPointValue(150);
subview2.yoga.flexGrow = 1;
subview2.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview2];
@@ -473,155 +525,195 @@
[container.yoga applyLayoutPreservingOrigin:YES];
}
- (void)testPointPercent
{
XCTAssertEqual(YGPointValue(1).value, 1);
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
XCTAssertEqual(YGPercentValue(2).value, 2);
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
}
- (void)testPositionalPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.left = 1;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.left, 1);
view.yoga.left = YGPointValue(1);
XCTAssertEqual(view.yoga.left.value, 1);
XCTAssertEqual(view.yoga.left.unit, YGUnitPoint);
view.yoga.left = YGPercentValue(2);
XCTAssertEqual(view.yoga.left.value, 2);
XCTAssertEqual(view.yoga.left.unit, YGUnitPercent);
view.yoga.right = 2;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.right, 2);
view.yoga.right = YGPointValue(3);
XCTAssertEqual(view.yoga.right.value, 3);
XCTAssertEqual(view.yoga.right.unit, YGUnitPoint);
view.yoga.right = YGPercentValue(4);
XCTAssertEqual(view.yoga.right.value, 4);
XCTAssertEqual(view.yoga.right.unit, YGUnitPercent);
view.yoga.top = 3;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.top, 3);
view.yoga.top = YGPointValue(5);
XCTAssertEqual(view.yoga.top.value, 5);
XCTAssertEqual(view.yoga.top.unit, YGUnitPoint);
view.yoga.top = YGPercentValue(6);
XCTAssertEqual(view.yoga.top.value, 6);
XCTAssertEqual(view.yoga.top.unit, YGUnitPercent);
view.yoga.bottom = 4;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.bottom, 4);
view.yoga.bottom = YGPointValue(7);
XCTAssertEqual(view.yoga.bottom.value, 7);
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPoint);
view.yoga.bottom = YGPercentValue(8);
XCTAssertEqual(view.yoga.bottom.value, 8);
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPercent);
view.yoga.start = 5;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.start, 5);
view.yoga.start = YGPointValue(9);
XCTAssertEqual(view.yoga.start.value, 9);
XCTAssertEqual(view.yoga.start.unit, YGUnitPoint);
view.yoga.start = YGPercentValue(10);
XCTAssertEqual(view.yoga.start.value, 10);
XCTAssertEqual(view.yoga.start.unit, YGUnitPercent);
view.yoga.end = 6;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.end, 6);
view.yoga.end = YGPointValue(11);
XCTAssertEqual(view.yoga.end.value, 11);
XCTAssertEqual(view.yoga.end.unit, YGUnitPoint);
view.yoga.end = YGPercentValue(12);
XCTAssertEqual(view.yoga.end.value, 12);
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
}
- (void)testMarginPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.margin = 1;
XCTAssertEqual(view.yoga.margin, 1);
XCTAssertTrue(isnan(view.yoga.marginLeft));
XCTAssertTrue(isnan(view.yoga.marginRight));
XCTAssertTrue(isnan(view.yoga.marginStart));
XCTAssertTrue(isnan(view.yoga.marginEnd));
XCTAssertTrue(isnan(view.yoga.marginTop));
XCTAssertTrue(isnan(view.yoga.marginBottom));
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
XCTAssertTrue(isnan(view.yoga.marginVertical));
view.yoga.margin = YGPointValue(1);
XCTAssertEqual(view.yoga.margin.value, 1);
XCTAssertEqual(view.yoga.margin.unit, YGUnitPoint);
view.yoga.margin = YGPercentValue(2);
XCTAssertEqual(view.yoga.margin.value, 2);
XCTAssertEqual(view.yoga.margin.unit, YGUnitPercent);
view.yoga.marginHorizontal = 2;
XCTAssertEqual(view.yoga.marginHorizontal, 2);
XCTAssertTrue(isnan(view.yoga.marginLeft));
XCTAssertTrue(isnan(view.yoga.marginRight));
XCTAssertTrue(isnan(view.yoga.marginStart));
XCTAssertTrue(isnan(view.yoga.marginEnd));
view.yoga.marginHorizontal = YGPointValue(3);
XCTAssertEqual(view.yoga.marginHorizontal.value, 3);
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPoint);
view.yoga.marginHorizontal = YGPercentValue(4);
XCTAssertEqual(view.yoga.marginHorizontal.value, 4);
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPercent);
view.yoga.marginVertical = 3;
XCTAssertEqual(view.yoga.marginVertical, 3);
XCTAssertTrue(isnan(view.yoga.marginTop));
XCTAssertTrue(isnan(view.yoga.marginBottom));
view.yoga.marginVertical = YGPointValue(5);
XCTAssertEqual(view.yoga.marginVertical.value, 5);
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPoint);
view.yoga.marginVertical = YGPercentValue(6);
XCTAssertEqual(view.yoga.marginVertical.value, 6);
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPercent);
view.yoga.marginLeft = 4;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginLeft, 4);
view.yoga.marginLeft = YGPointValue(7);
XCTAssertEqual(view.yoga.marginLeft.value, 7);
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPoint);
view.yoga.marginLeft = YGPercentValue(8);
XCTAssertEqual(view.yoga.marginLeft.value, 8);
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPercent);
view.yoga.marginRight = 5;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginRight, 5);
view.yoga.marginRight = YGPointValue(9);
XCTAssertEqual(view.yoga.marginRight.value, 9);
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPoint);
view.yoga.marginRight = YGPercentValue(10);
XCTAssertEqual(view.yoga.marginRight.value, 10);
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPercent);
view.yoga.marginTop = 6;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginTop, 6);
view.yoga.marginTop = YGPointValue(11);
XCTAssertEqual(view.yoga.marginTop.value, 11);
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPoint);
view.yoga.marginTop = YGPercentValue(12);
XCTAssertEqual(view.yoga.marginTop.value, 12);
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPercent);
view.yoga.marginBottom = 7;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginBottom, 7);
view.yoga.marginBottom = YGPointValue(13);
XCTAssertEqual(view.yoga.marginBottom.value, 13);
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPoint);
view.yoga.marginBottom = YGPercentValue(14);
XCTAssertEqual(view.yoga.marginBottom.value, 14);
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPercent);
view.yoga.marginStart = 8;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginStart, 8);
view.yoga.marginStart = YGPointValue(15);
XCTAssertEqual(view.yoga.marginStart.value, 15);
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPoint);
view.yoga.marginStart = YGPercentValue(16);
XCTAssertEqual(view.yoga.marginStart.value, 16);
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPercent);
view.yoga.marginEnd = 9;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.marginEnd, 9);
view.yoga.marginEnd = YGPointValue(17);
XCTAssertEqual(view.yoga.marginEnd.value, 17);
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPoint);
view.yoga.marginEnd = YGPercentValue(18);
XCTAssertEqual(view.yoga.marginEnd.value, 18);
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
}
- (void)testPaddingPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.padding = 1;
XCTAssertEqual(view.yoga.padding, 1);
XCTAssertTrue(isnan(view.yoga.paddingLeft));
XCTAssertTrue(isnan(view.yoga.paddingRight));
XCTAssertTrue(isnan(view.yoga.paddingStart));
XCTAssertTrue(isnan(view.yoga.paddingEnd));
XCTAssertTrue(isnan(view.yoga.paddingTop));
XCTAssertTrue(isnan(view.yoga.paddingBottom));
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
XCTAssertTrue(isnan(view.yoga.paddingVertical));
view.yoga.padding = YGPointValue(1);
XCTAssertEqual(view.yoga.padding.value, 1);
XCTAssertEqual(view.yoga.padding.unit, YGUnitPoint);
view.yoga.padding = YGPercentValue(2);
XCTAssertEqual(view.yoga.padding.value, 2);
XCTAssertEqual(view.yoga.padding.unit, YGUnitPercent);
view.yoga.paddingHorizontal = 2;
XCTAssertEqual(view.yoga.paddingHorizontal, 2);
XCTAssertTrue(isnan(view.yoga.paddingLeft));
XCTAssertTrue(isnan(view.yoga.paddingRight));
XCTAssertTrue(isnan(view.yoga.paddingStart));
XCTAssertTrue(isnan(view.yoga.paddingEnd));
view.yoga.paddingHorizontal = YGPointValue(3);
XCTAssertEqual(view.yoga.paddingHorizontal.value, 3);
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPoint);
view.yoga.paddingHorizontal = YGPercentValue(4);
XCTAssertEqual(view.yoga.paddingHorizontal.value, 4);
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPercent);
view.yoga.paddingVertical = 3;
XCTAssertEqual(view.yoga.paddingVertical, 3);
XCTAssertTrue(isnan(view.yoga.paddingTop));
XCTAssertTrue(isnan(view.yoga.paddingBottom));
view.yoga.paddingVertical = YGPointValue(5);
XCTAssertEqual(view.yoga.paddingVertical.value, 5);
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPoint);
view.yoga.paddingVertical = YGPercentValue(6);
XCTAssertEqual(view.yoga.paddingVertical.value, 6);
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPercent);
view.yoga.paddingLeft = 4;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingLeft, 4);
view.yoga.paddingLeft = YGPointValue(7);
XCTAssertEqual(view.yoga.paddingLeft.value, 7);
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPoint);
view.yoga.paddingLeft = YGPercentValue(8);
XCTAssertEqual(view.yoga.paddingLeft.value, 8);
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPercent);
view.yoga.paddingRight = 5;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingRight, 5);
view.yoga.paddingRight = YGPointValue(9);
XCTAssertEqual(view.yoga.paddingRight.value, 9);
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPoint);
view.yoga.paddingRight = YGPercentValue(10);
XCTAssertEqual(view.yoga.paddingRight.value, 10);
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPercent);
view.yoga.paddingTop = 6;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingTop, 6);
view.yoga.paddingTop = YGPointValue(11);
XCTAssertEqual(view.yoga.paddingTop.value, 11);
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPoint);
view.yoga.paddingTop = YGPercentValue(12);
XCTAssertEqual(view.yoga.paddingTop.value, 12);
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPercent);
view.yoga.paddingBottom = 7;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingBottom, 7);
view.yoga.paddingBottom = YGPointValue(13);
XCTAssertEqual(view.yoga.paddingBottom.value, 13);
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPoint);
view.yoga.paddingBottom = YGPercentValue(14);
XCTAssertEqual(view.yoga.paddingBottom.value, 14);
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPercent);
view.yoga.paddingStart = 8;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingStart, 8);
view.yoga.paddingStart = YGPointValue(15);
XCTAssertEqual(view.yoga.paddingStart.value, 15);
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPoint);
view.yoga.paddingStart = YGPercentValue(16);
XCTAssertEqual(view.yoga.paddingStart.value, 16);
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPercent);
view.yoga.paddingEnd = 9;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
XCTAssertEqual(view.yoga.paddingEnd, 9);
view.yoga.paddingEnd = YGPointValue(17);
XCTAssertEqual(view.yoga.paddingEnd.value, 17);
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPoint);
view.yoga.paddingEnd = YGPercentValue(18);
XCTAssertEqual(view.yoga.paddingEnd.value, 18);
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
}
- (void)testBorderWidthPropertiesWork
@@ -630,12 +722,6 @@
view.yoga.borderWidth = 1;
XCTAssertEqual(view.yoga.borderWidth, 1);
XCTAssertTrue(isnan(view.yoga.borderLeftWidth));
XCTAssertTrue(isnan(view.yoga.borderRightWidth));
XCTAssertTrue(isnan(view.yoga.borderStartWidth));
XCTAssertTrue(isnan(view.yoga.borderEndWidth));
XCTAssertTrue(isnan(view.yoga.borderTopWidth));
XCTAssertTrue(isnan(view.yoga.borderBottomWidth));
view.yoga.borderLeftWidth = 2;
XCTAssertEqual(view.yoga.borderLeftWidth, 2);

View File

@@ -4,9 +4,9 @@ PODS:
- IGListKit/Default (2.1.0):
- IGListKit/Diffing
- IGListKit/Diffing (2.1.0)
- Yoga (1.2.0)
- YogaKit (1.2.0):
- Yoga (~> 1.2)
- Yoga (1.7.0)
- YogaKit (1.7.0):
- Yoga (~> 1.7)
DEPENDENCIES:
- IGListKit (~> 2.1.0)
@@ -14,13 +14,13 @@ DEPENDENCIES:
EXTERNAL SOURCES:
YogaKit:
:path: "../../YogaKit.podspec"
:path: ../../YogaKit.podspec
SPEC CHECKSUMS:
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
Yoga: 20fc010c282cc5f3c27ce512de1329cd1e72b077
YogaKit: 72d5c8a806dc5cf2aa50c93a6dd88913cdbec6fe
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
YogaKit: 31576530e8fcae3175469719ec3212397403330b
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
COCOAPODS: 1.2.0
COCOAPODS: 1.1.1

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
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>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "638A944E1E215CC800A726AD"
BuildableName = "YogaKitSampleTests.xctest"
BlueprintName = "YogaKitSampleTests"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</TestableReference>
</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>

View File

@@ -12,6 +12,11 @@ import YogaKit
struct DemoItem {
let name: String
root.backgroundColor = .red
root.yoga.isEnabled = true
root.yoga.width = YGValue(self.view.bounds.size.width)
root.yoga.height = YGValue(self.view.bounds.size.height)
root.yoga.alignItems = .center
}
final class SwiftViewController: UIViewController, IGListAdapterDataSource {

View File

@@ -17,16 +17,16 @@
UIView *root = self.view;
root.backgroundColor = [UIColor redColor];
root.yoga.isEnabled = YES;
root.yoga.width = self.view.bounds.size.width;
root.yoga.height = self.view.bounds.size.height;
root.yoga.width = YGPointValue(self.view.bounds.size.width);
root.yoga.height = YGPointValue(self.view.bounds.size.height);
root.yoga.alignItems = YGAlignCenter;
root.yoga.justifyContent = YGJustifyCenter;
UIView *child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
child1.yoga.isEnabled = YES;
child1.yoga.width = 100;
child1.yoga.height = 100;
child1.yoga.width = YGPointValue(100);
child1.yoga.height = YGPointValue(100);
UIView *child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];

View File

@@ -15,32 +15,38 @@ final class BasicViewController: UIViewController {
let root = self.view!
root.backgroundColor = .white
root.yoga.isEnabled = true
root.yoga.width = containerSize.width
root.yoga.height = containerSize.height
root.yoga.alignItems = .center
root.yoga.justifyContent = .center
root.configureLayout { (layout) in
layout.isEnabled = true
layout.width = YGValue(containerSize.width)
layout.height = YGValue(containerSize.height)
layout.alignItems = .center
layout.justifyContent = .center
}
let child1 = UIView()
child1.backgroundColor = .blue
child1.yoga.isEnabled = true
child1.yoga.width = 100
child1.yoga.height = 10
child1.yoga.marginBottom = 25
child1.configureLayout { (layout) in
layout.isEnabled = true
layout.width = 100
layout.height = 10
layout.marginBottom = 25
}
root.addSubview(child1)
let child2 = UIView()
child2.yoga.isEnabled = true
child2.yoga.alignSelf = .flexEnd
let child2 = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
child2.backgroundColor = .green
child2.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
child2.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexEnd
}
root.addSubview(child2)
let child3 = UIView()
child3.yoga.isEnabled = true
child3.yoga.alignSelf = .flexStart
let child3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
child3.backgroundColor = .yellow
child3.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
child3.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexStart
}
root.addSubview(child3)
root.yoga.applyLayout(preservingOrigin: true)

View File

@@ -17,40 +17,50 @@ final class LayoutInclusionViewController: UIViewController {
override func viewDidLoad() {
let root = self.view!
root.backgroundColor = .white
root.yoga.isEnabled = true
root.yoga.flexDirection = .column
root.yoga.justifyContent = .spaceAround
root.configureLayout { (layout) in
layout.isEnabled = true
layout.flexDirection = .column
layout.justifyContent = .spaceAround
}
contentView.backgroundColor = .clear
contentView.layer.borderColor = UIColor.lightGray.cgColor
contentView.layer.borderWidth = 1.0
contentView.yoga.isEnabled = true
contentView.yoga.height = 300
contentView.yoga.width = self.view.bounds.size.width
contentView.yoga.flexDirection = .row
contentView.yoga.justifyContent = .center
contentView.yoga.paddingHorizontal = 25
contentView.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 300
layout.width = YGValue(self.view.bounds.size.width)
layout.flexDirection = .row
layout.justifyContent = .center
layout.paddingHorizontal = 25
}
self.view.addSubview(contentView)
let redView = UIView(frame: .zero)
redView.backgroundColor = .red
redView.yoga.isEnabled = true
redView.yoga.flexGrow = 1
redView.yoga.flexShrink = 1
redView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexGrow = 1
layout.flexShrink = 1
}
contentView.addSubview(redView)
disappearingView.backgroundColor = .blue
disappearingView.yoga.isEnabled = true
disappearingView.yoga.flexGrow = 1
disappearingView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexGrow = 1
}
contentView.addSubview(disappearingView)
button.setTitle("Add Blue View", for: UIControlState.selected)
button.setTitle("Remove Blue View", for: UIControlState.normal)
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
button.yoga.isEnabled = true
button.yoga.height = 300
button.yoga.width = 300
button.yoga.alignSelf = .center
button.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 300
layout.width = 300
layout.alignSelf = .center
}
root.addSubview(button)
root.yoga.applyLayout(preservingOrigin: false)

View File

@@ -15,9 +15,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
contentView.yoga.isEnabled = true
contentView.yoga.flexDirection = .column
contentView.yoga.justifyContent = .flexEnd
contentView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexDirection = .column
layout.justifyContent = .flexEnd
}
label.textAlignment = .center
label.numberOfLines = 1
@@ -26,9 +28,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
let border = UIView(frame: .zero)
border.backgroundColor = .lightGray
border.yoga.isEnabled = true
border.yoga.height = 0.5
border.yoga.marginHorizontal = 25
border.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 0.5
layout.marginHorizontal = 25
}
contentView.addSubview(border)
}

View File

@@ -1,11 +1,9 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "android_aar", "android_resource")
android_aar(
name = "android",
@@ -30,7 +28,3 @@ android_resource(
"PUBLIC",
],
)
project_config(
src_target = ":android",
)

21
android/README.md Normal file
View File

@@ -0,0 +1,21 @@
# YogaLayout [![Platform](https://img.shields.io/badge/platforms-Android-orange.svg)](https://facebook.github.io/yoga/docs/api/android/) [![Languages](https://img.shields.io/badge/languages-Java-orange.svg)](https://facebook.github.io/yoga/docs/api/android/) [![Download](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga.android:yoga-layout.svg)](https://bintray.com/facebook/maven/com.facebook.yoga.android%3Ayoga-layout/_latestVersion)
## Installation
YogaLayout is available via jcenter:
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
## Getting Started
Check out the docs [here](https://facebook.github.io/yoga/docs/api/android/).
We also have a sample project. To try it, clone the repo and run (with a device attached)
buck install -r android/sample
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of YogaKit daily, so we're always testing the latest changes.
See the CONTRIBUTING file for how to help out.

View File

@@ -1,31 +1,28 @@
apply plugin: "com.jfrog.bintray"
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
version = '1.2.0'
group = 'com.facebook.yoga.android'
version = VERSION_NAME
group = GROUP
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
targetCompatibility rootProject.targetCompatibilityVersion
sourceCompatibility rootProject.sourceCompatibilityVersion
}
}
dependencies {
compile 'com.facebook.yoga:yoga:1.2.0'
api project(':yoga')
}
task sourcesJar(type: Jar) {
@@ -45,8 +42,4 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
ext {
bintrayName = "com.facebook.yoga.android:yoga-layout"
}
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
apply from: rootProject.file('gradle/release.gradle')

View File

@@ -0,0 +1,5 @@
GROUP=com.facebook.yoga.android
POM_NAME=YogaLayout
POM_DESCRIPTION=YogaLayout
POM_ARTIFACT_ID=yoga-layout
POM_PACKAGING=aar

View File

@@ -22,6 +22,8 @@
android:targetSdkVersion="19"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
@@ -42,6 +44,11 @@
</activity>
<activity
android:name=".BenchmarkActivity"
android:exported="false"
/>
</application>
</manifest>

View File

@@ -4,7 +4,7 @@
# This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_RES_TARGET", "android_binary", "android_resource")
android_binary(
name = "sample",
@@ -33,7 +33,3 @@ keystore(
properties = "debug.keystore.properties",
store = "debug.keystore",
)
project_config(
src_target = ":sample",
)

View File

@@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "android_library")
android_library(
name = "yoga",

View File

@@ -0,0 +1,113 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Menu;
import android.support.v7.app.ActionBar;
import com.facebook.samples.yoga.R;
import com.facebook.yoga.android.YogaViewLayoutFactory;
public class BenchmarkActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
super.onCreate(savedInstanceState);
setContentView(R.layout.benchmark_select_layout);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
};
actionBar.addTab(
actionBar.newTab()
.setText("Inflate")
.setTabListener(tabListener));
actionBar.addTab(
actionBar.newTab()
.setText("Measure")
.setTabListener(tabListener));
actionBar.addTab(
actionBar.newTab()
.setText("Layout")
.setTabListener(tabListener));
viewPager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// When swiping between pages, select the
// corresponding tab.
actionBar.setSelectedNavigationItem(position);
}
});
viewPager.setOffscreenPageLimit(3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_bar_benchmark, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// There is only one option
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
this.finish();
return true;
}
public static class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
switch (i) {
case 0:
return new BenchmarkInflate();
case 1:
return new BenchmarkMeasure();
default:
return new BenchmarkLayout();
}
}
@Override
public int getCount() {
return 3;
}
}
}

View File

@@ -0,0 +1,193 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.Math;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.text.DateFormat;
import java.util.Date;
import android.content.Context;
import android.util.Log;
import android.os.Environment;
import static java.util.Collections.sort;
public class BenchmarkAggregator {
private final int GRAPH_WIDTH = 30;
private final int GRAPH_HEIGHT = 6;
private List<Long> times;
private boolean tracing;
private long lastTraceStart;
private boolean statsFresh;
private long mean;
private long variance;
private long stddev;
private long min;
private long max;
private long p10;
private long p50;
private long p90;
private String name;
public BenchmarkAggregator(String name) {
times = new ArrayList<>();
tracing = false;
this.name = name;
}
public void startTrace() {
if (tracing) {
throw new RuntimeException("Cannot start trace while running previous one");
}
tracing = true;
lastTraceStart = System.nanoTime();
}
public void endTrace() {
if (!tracing) {
throw new RuntimeException("Cannot stop trace if none are running!");
}
times.add(System.nanoTime() - lastTraceStart);
tracing = false;
statsFresh = false;
}
private void computeStats() {
if (statsFresh) {
return;
}
sort(times);
min = Long.MAX_VALUE;
max = -1;
mean = 0;
for (long f: times) {
mean += f;
if (f < min) {
min = f;
}
if (f > max) {
max = f;
}
}
mean /= times.size();
variance = 0;
for (long f: times) {
variance += (f-mean)*(f-mean);
}
variance /= times.size();
stddev = (long) Math.sqrt((double) variance);
p10 = times.get(times.size()*10/100);
p50 = times.get(times.size()*50/100);
p90 = times.get(times.size()*90/100);
statsFresh = true;
}
public String toString() {
computeStats();
return String.format(
"%s:\n" +
"| %d samples\n" +
"| Mean %.3f\u00B1%.3fms\n" + // plusminus
"| Min %.3fms ; Max %.3fms\n" +
"| p10 %.3fms ; p50 %.3fms ; p90 %.3fms\n" +
"%s",
name,
times.size(),
mean/10e6,
stddev/10e6,
min/10e6,
max/10e6,
p10/10e6,
p50/10e6,
p90/10e6,
makeGraph());
}
private String makeGraph() {
char canvas[][] = new char[GRAPH_HEIGHT][GRAPH_WIDTH];
for (int i = 0; i < GRAPH_HEIGHT; i++)
for (int j = 0; j < GRAPH_WIDTH; j++)
canvas[i][j] = ' ';
long bucketSize = (p90 - p10) / GRAPH_WIDTH+1;
int bucketCount[] = new int[GRAPH_WIDTH];
for (long time : times) {
if (time<p90 && time>p10) {
bucketCount[(int) ((time - p10) / bucketSize)]++;
}
}
int maxBucket = 0;
for (int i = 0; i < GRAPH_WIDTH; i++)
if (bucketCount[i] > maxBucket) {
maxBucket = bucketCount[i];
}
for (int i = 0; i < GRAPH_HEIGHT; i++)
for (int j = 0; j < GRAPH_WIDTH; j++)
if (i < bucketCount[j] * GRAPH_HEIGHT / maxBucket) {
canvas[i][j] = 'Z';
}
String graph = new String();
for (int i = 0; i < GRAPH_HEIGHT; i++)
{
int percentage = 100 * (GRAPH_HEIGHT - i - 1) * maxBucket / (times.size() * GRAPH_HEIGHT);
graph += String.format("| %2d%% ", percentage);
for (int j = 0; j < GRAPH_WIDTH; j++)
graph += canvas[GRAPH_HEIGHT-1-i][j];
graph += '\n';
}
graph += "| p10";
for (int i = 0; i < GRAPH_WIDTH-6; i++)
graph += " ";
graph += "p90\n";
return graph;
}
/**
* Dumps the collected times to a file on the device. This allows us to grab the raw data
* and perform more in-depth analysis.
*/
public void dump(Context context) {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Log.e("YogaLayoutBenchmark","No external file storage");
return;
}
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String filename = format.format(new Date()) + "_" + name.replace(' ','_');
File file = new File(context.getExternalFilesDir(
Environment.DIRECTORY_DOCUMENTS), filename);
try {
PrintWriter printWriter = new PrintWriter(file);
for (long l : times) {
printWriter.println(l);
}
printWriter.close();
Log.i("YogaLayoutBenchmark","Benchmark data saved in "+file.getPath());
} catch (java.io.IOException e) {
Log.e("YogaLayoutBenchmark", "Could not save benchmark data", e);
}
}
}

View File

@@ -0,0 +1,110 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import java.util.Random;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView;
import com.facebook.samples.yoga.R;
import com.facebook.yoga.android.YogaLayout;
public class BenchmarkFragment extends Fragment implements AdapterView.OnItemSelectedListener {
private LayoutInflater mInflater;
protected com.facebook.yoga.android.YogaLayout rootLayout;
protected int yogaLayout;
protected int linearLayout;
static final Random random = new Random();
static void randomizeText(View root) {
if (root instanceof TextView) {
((TextView) root).setText("" + random.nextInt(1000));
((TextView) root).setTextSize(10 + random.nextInt(20));
ViewParent parent = root.getParent();
if (parent instanceof YogaLayout) {
((YogaLayout) parent).invalidate(root);
}
} else if (root instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) root).getChildCount(); i++) {
randomizeText(((ViewGroup) root).getChildAt(i));
}
}
}
public BenchmarkFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
mInflater = inflater;
rootLayout = (YogaLayout) inflater.inflate(
R.layout.benchmark_fragment,
container,
false);
Spinner benchmarkSelect = (Spinner) rootLayout.findViewById(R.id.benchmarkSelect);
String[] items = new String[]{"Basic", "Typical", "Nested"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
benchmarkSelect.setAdapter(adapter);
benchmarkSelect.setOnItemSelectedListener(this);
return rootLayout;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
switch (pos) {
case 0:
yogaLayout = R.layout.benchmark_layout_1;
linearLayout = R.layout.benchmark_layout_1_linear;
break;
case 1:
yogaLayout = R.layout.benchmark_layout_2;
linearLayout = R.layout.benchmark_layout_2_linear;
break;
case 2:
default:
yogaLayout = R.layout.benchmark_layout_3;
linearLayout = R.layout.benchmark_layout_3_linear;
break;
}
updatePreview();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
yogaLayout = R.layout.benchmark_layout_1;
linearLayout = R.layout.benchmark_layout_1_linear;
updatePreview();
}
private void updatePreview() {
LinearLayout previewLayout = (LinearLayout) rootLayout.findViewById(R.id.preview);
View v = mInflater.inflate(yogaLayout, rootLayout, false);
v.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
previewLayout.removeAllViews();
previewLayout.addView(v);
}
}

View File

@@ -0,0 +1,65 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
import android.view.ViewGroup;
import android.util.Log;
import com.facebook.samples.yoga.R;
public class BenchmarkInflate extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
final int ITERATIONS = 500;
inflater.inflate(yogaLayout, null);
inflater.inflate(linearLayout, null);
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Inflate");
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Inflate");
for (int i = 0; i < ITERATIONS; i++) {
yogaInflationAggregator.startTrace();
inflater.inflate(yogaLayout, null);
yogaInflationAggregator.endTrace();
linearInflationAggregator.startTrace();
inflater.inflate(linearLayout, null);
linearInflationAggregator.endTrace();
}
textView.setText(
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
rootLayout.invalidate();
}
}

View File

@@ -0,0 +1,74 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.facebook.samples.yoga.R;
import java.util.Random;
public class BenchmarkLayout extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
Random random = new Random();
final int ITERATIONS = 500;
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Layout");
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Layout");
View yogaView = inflater.inflate(yogaLayout, null);
View linearView = inflater.inflate(linearLayout, null);
for (int i = 0; i < ITERATIONS; i++) {
randomizeText(yogaView);
randomizeText(linearView);
yogaView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
linearView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
yogaInflationAggregator.startTrace();
yogaView.layout(0, 0, yogaView.getMeasuredWidth(), yogaView.getMeasuredHeight());
yogaInflationAggregator.endTrace();
linearInflationAggregator.startTrace();
linearView.layout(0, 0, linearView.getMeasuredWidth(), linearView.getMeasuredHeight());
linearInflationAggregator.endTrace();
}
textView.setText(
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
}
}

View File

@@ -0,0 +1,75 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.facebook.samples.yoga.R;
import java.util.Random;
public class BenchmarkMeasure extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
Random random = new Random();
final int ITERATIONS = 500;
BenchmarkAggregator yogaMeasureAggregator = new BenchmarkAggregator("Yoga Measure");
BenchmarkAggregator linearMeasureAggregator = new BenchmarkAggregator("Linear Measure");
View yogaView = inflater.inflate(yogaLayout, null);
View linearView = inflater.inflate(linearLayout, null);
for (int i = 0; i < ITERATIONS; i++) {
randomizeText(yogaView);
randomizeText(linearView);
yogaMeasureAggregator.startTrace();
yogaView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
yogaMeasureAggregator.endTrace();
linearMeasureAggregator.startTrace();
linearView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
linearMeasureAggregator.endTrace();
}
textView.setText(
yogaMeasureAggregator.toString()+
"\n"+
linearMeasureAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaMeasureAggregator.toString()+
"\n"+
linearMeasureAggregator.toString());
yogaMeasureAggregator.dump(getActivity());
linearMeasureAggregator.dump(getActivity());
}
}

View File

@@ -8,9 +8,13 @@
package com.facebook.samples.yoga;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Menu;
import com.facebook.samples.yoga.R;
import com.facebook.soloader.SoLoader;
@@ -21,7 +25,7 @@ import com.facebook.yoga.android.YogaViewLayoutFactory;
* {@code main_layout.xml}) that shows off the awesome functionality of the Yoga layout engine
* as well as some optimisations on layout systems that it facilitates.
*/
public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -31,4 +35,20 @@ public class MainActivity extends ActionBarActivity {
setContentView(R.layout.main_layout);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_bar_home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// There is only one option
Intent intent = new Intent(this, BenchmarkActivity.class);
startActivity(intent);
this.finish();
return true;
}
}

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:id="@+id/rt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
yoga:yg_flexDirection="column"
>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_height="50dp"
>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Run benchmark"
yoga:yg_flex="1"
/>
<Spinner
android:id="@+id/benchmarkSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
/>
</VirtualYogaLayout>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10sp"
android:fontFamily="monospace"
yoga:yg_flex="1"
/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
/>
</YogaLayout>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="60dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/yoga_blue"
yoga:yg_flex="0"
yoga:yg_marginAll="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_2_text"
yoga:yg_flex="1"
yoga:yg_marginHorizontal="5dp"
/>
</YogaLayout>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="5dp"
android:src="@drawable/ic_launcher"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="@string/child_2_text"
/>
</LinearLayout>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="60dp"
yoga:yg_flexDirection="column"
yoga:yg_alignItems="stretch"
>
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_flex="1"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:height="40dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="stretch"
>
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginAll="10dp"
yoga:yg_aspectRatio="1"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:height="40dp"
yoga:yg_flexDirection="column"
yoga:yg_alignItems="stretch"
yoga:yg_flex="1"
yoga:yg_justifyContent="space_around"
>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:height="8dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="stretch"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
yoga:yg_flex="1"
/>
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_aspectRatio="1"
/>
</VirtualYogaLayout>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:height="8dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="stretch"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
yoga:yg_flex="1"
/>
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_aspectRatio="1"
/>
</VirtualYogaLayout>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:height="8dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="stretch"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
yoga:yg_flex="1"
/>
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_aspectRatio="1"
/>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</YogaLayout>

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:background="@color/yoga_blue"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
>
<View
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_launcher"
android:background="@color/yoga_blue"
android:layout_margin="10dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="1"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:orientation="horizontal"
android:layout_marginTop="4dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
android:layout_weight="1"
/>
<View
android:layout_width="8dp"
android:layout_height="8dp"
android:src="@drawable/ic_launcher"
android:background="@color/yoga_blue"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:orientation="horizontal"
android:layout_marginTop="4dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
android:layout_weight="1"
/>
<View
android:layout_width="8dp"
android:layout_height="8dp"
android:src="@drawable/ic_launcher"
android:background="@color/yoga_blue"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:orientation="horizontal"
android:layout_marginTop="4dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textSize="5sp"
android:layout_weight="1"
/>
<View
android:layout_width="8dp"
android:layout_height="8dp"
android:src="@drawable/ic_launcher"
android:background="@color/yoga_blue"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_alignItems="center"
yoga:yg_flexDirection="row"
yoga:yg_justifyContent="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="column"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="column"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="column"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_blue"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/yoga_grey"
yoga:yg_marginLeft="10dp"
/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_flex="1"
>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</VirtualYogaLayout>
</YogaLayout>

View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

View File

@@ -18,10 +18,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:yg_margin_horizontal="10dp"
yoga:yg_margin_top="5dp"
yoga:yg_flex_direction="row"
yoga:yg_align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
@@ -35,17 +35,17 @@
android:text="@string/child_1_text"
android:textColor="@color/children_text"
yoga:yg_flex="1"
yoga:yg_margin_start="8dp"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:yg_margin_horizontal="10dp"
yoga:yg_margin_top="5dp"
yoga:yg_flex_direction="row"
yoga:yg_align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
@@ -59,17 +59,17 @@
android:text="@string/child_2_text"
android:textColor="@color/children_text"
yoga:yg_flex="1"
yoga:yg_margin_start="8dp"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:yg_margin_horizontal="10dp"
yoga:yg_margin_top="5dp"
yoga:yg_flex_direction="row"
yoga:yg_align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
@@ -83,17 +83,17 @@
android:text="@string/child_3_text"
android:textColor="@color/children_text"
yoga:yg_flex="1"
yoga:yg_margin_start="8dp"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:yg_margin_horizontal="10dp"
yoga:yg_margin_top="5dp"
yoga:yg_flex_direction="row"
yoga:yg_align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
@@ -107,17 +107,17 @@
android:text="@string/child_4_text"
android:textColor="@color/children_text"
yoga:yg_flex="1"
yoga:yg_margin_start="8dp"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:yg_margin_horizontal="10dp"
yoga:yg_margin_top="5dp"
yoga:yg_flex_direction="row"
yoga:yg_align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
@@ -131,7 +131,7 @@
android:text="@string/child_5_text"
android:textColor="@color/children_text"
yoga:yg_flex="1"
yoga:yg_margin_start="10dp"
yoga:yg_marginStart="10dp"
/>
</YogaLayout>
</YogaLayout>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/action_home"
android:title="Home"
android:showAsAction="always"
/>
</menu>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/action_benchmark"
android:title="Benchmark"
android:showAsAction="always"
/>
</menu>

View File

@@ -2,11 +2,9 @@
<!--
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.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

View File

@@ -1,11 +1,9 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "android_library")
android_library(
name = "android",

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.android;

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.android;
@@ -23,6 +21,7 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.util.Log;
import com.facebook.yoga.android.R;
import com.facebook.yoga.YogaAlign;
@@ -36,7 +35,7 @@ import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaNodeAPI;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaOverflow;
import com.facebook.yoga.YogaPositionType;
import com.facebook.yoga.YogaWrap;
@@ -51,7 +50,7 @@ import com.facebook.yoga.YogaWrap;
* <pre>{@code
* <YogaLayout
* xmlns:android="http://schemas.android.com/apk/res/android"
* xmlns:yoga="http://schemas.android.com/lib/com.facebook.yoga.android"
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
* android:layout_width="match_parent"
* android:layout_height="match_parent"
* yoga:flex_direction="row"
@@ -90,15 +89,20 @@ public class YogaLayout extends ViewGroup {
mYogaNode.setData(this);
mYogaNode.setMeasureFunction(new ViewMeasureFunction());
final LayoutParams layoutParams = new LayoutParams(context, attrs);
LayoutParams layoutParams = null;
if (attrs != null) {
layoutParams = new LayoutParams(context, attrs);
} else {
layoutParams = (LayoutParams) generateDefaultLayoutParams();
}
applyLayoutParams(layoutParams, mYogaNode, this);
}
YogaNode getYogaNode() {
public YogaNode getYogaNode() {
return mYogaNode;
}
YogaNode getYogaNodeForView(View view) {
public YogaNode getYogaNodeForView(View view) {
return mYogaNodes.get(view);
}
@@ -153,7 +157,11 @@ public class YogaLayout extends ViewGroup {
if (child instanceof YogaLayout) {
childNode = ((YogaLayout) child).getYogaNode();
} else {
childNode = new YogaNode();
if(mYogaNodes.containsKey(child)) {
childNode = mYogaNodes.get(child);
} else {
childNode = new YogaNode();
}
childNode.setData(child);
childNode.setMeasureFunction(new ViewMeasureFunction());
@@ -278,6 +286,7 @@ public class YogaLayout extends ViewGroup {
private void applyLayoutRecursive(YogaNode node, float xOffset, float yOffset) {
View view = (View) node.getData();
if (view != null && view != this) {
if (view.getVisibility() == GONE) {
return;
@@ -360,7 +369,6 @@ public class YogaLayout extends ViewGroup {
if (widthMode == MeasureSpec.AT_MOST) {
mYogaNode.setMaxWidth(widthSize);
}
mYogaNode.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
}
@@ -403,31 +411,31 @@ public class YogaLayout extends ViewGroup {
final int attribute = layoutParameters.numericAttributes.keyAt(i);
final float value = layoutParameters.numericAttributes.valueAt(i);
if (attribute == R.styleable.yoga_yg_align_content) {
if (attribute == R.styleable.yoga_yg_alignContent) {
node.setAlignContent(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_align_items) {
} else if (attribute == R.styleable.yoga_yg_alignItems) {
node.setAlignItems(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_align_self) {
} else if (attribute == R.styleable.yoga_yg_alignSelf) {
node.setAlignSelf(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_aspect_ratio) {
} else if (attribute == R.styleable.yoga_yg_aspectRatio) {
node.setAspectRatio(value);
} else if (attribute == R.styleable.yoga_yg_border_left) {
} else if (attribute == R.styleable.yoga_yg_borderLeft) {
node.setBorder(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_yg_border_top) {
} else if (attribute == R.styleable.yoga_yg_borderTop) {
node.setBorder(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_yg_border_right) {
} else if (attribute == R.styleable.yoga_yg_borderRight) {
node.setBorder(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_yg_border_bottom) {
} else if (attribute == R.styleable.yoga_yg_borderBottom) {
node.setBorder(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_yg_border_start) {
} else if (attribute == R.styleable.yoga_yg_borderStart) {
node.setBorder(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_yg_border_end) {
} else if (attribute == R.styleable.yoga_yg_borderEnd) {
node.setBorder(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_yg_border_horizontal) {
} else if (attribute == R.styleable.yoga_yg_borderHorizontal) {
node.setBorder(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_yg_border_vertical) {
} else if (attribute == R.styleable.yoga_yg_borderVertical) {
node.setBorder(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_yg_border_all) {
} else if (attribute == R.styleable.yoga_yg_borderAll) {
node.setBorder(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_yg_direction) {
node.setDirection(YogaDirection.fromInt(Math.round(value)));
@@ -435,83 +443,83 @@ public class YogaLayout extends ViewGroup {
node.setDisplay(YogaDisplay.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_flex) {
node.setFlex(value);
} else if (attribute == R.styleable.yoga_yg_flex_basis) {
} else if (attribute == R.styleable.yoga_yg_flexBasis) {
node.setFlexBasis(value);
} else if (attribute == R.styleable.yoga_yg_flex_direction) {
} else if (attribute == R.styleable.yoga_yg_flexDirection) {
node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_flex_grow) {
} else if (attribute == R.styleable.yoga_yg_flexGrow) {
node.setFlexGrow(value);
} else if (attribute == R.styleable.yoga_yg_flex_shrink) {
} else if (attribute == R.styleable.yoga_yg_flexShrink) {
node.setFlexShrink(value);
} else if (attribute == R.styleable.yoga_yg_height) {
node.setHeight(value);
} else if (attribute == R.styleable.yoga_yg_margin_left) {
} else if (attribute == R.styleable.yoga_yg_marginLeft) {
node.setMargin(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_yg_justify_content) {
} else if (attribute == R.styleable.yoga_yg_justifyContent) {
node.setJustifyContent(YogaJustify.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_margin_top) {
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMargin(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_yg_margin_right) {
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMargin(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMargin(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_yg_margin_start) {
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMargin(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_yg_margin_end) {
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMargin(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMargin(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMargin(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_yg_margin_all) {
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMargin(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_yg_max_height) {
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
node.setMaxHeight(value);
} else if (attribute == R.styleable.yoga_yg_max_width) {
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
node.setMaxWidth(value);
} else if (attribute == R.styleable.yoga_yg_min_height) {
} else if (attribute == R.styleable.yoga_yg_minHeight) {
node.setMinHeight(value);
} else if (attribute == R.styleable.yoga_yg_min_width) {
} else if (attribute == R.styleable.yoga_yg_minWidth) {
node.setMinWidth(value);
} else if (attribute == R.styleable.yoga_yg_overflow) {
node.setOverflow(YogaOverflow.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_padding_left) {
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
node.setPadding(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_yg_padding_top) {
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
node.setPadding(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_yg_padding_right) {
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
node.setPadding(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_yg_padding_bottom) {
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
node.setPadding(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_yg_padding_start) {
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
node.setPadding(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_yg_padding_end) {
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
node.setPadding(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_yg_padding_horizontal) {
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
node.setPadding(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_yg_padding_vertical) {
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
node.setPadding(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_yg_padding_all) {
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
node.setPadding(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_yg_position_left) {
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
node.setPosition(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_yg_position_top) {
} else if (attribute == R.styleable.yoga_yg_positionTop) {
node.setPosition(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_yg_position_right) {
} else if (attribute == R.styleable.yoga_yg_positionRight) {
node.setPosition(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_yg_position_bottom) {
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
node.setPosition(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_yg_position_start) {
} else if (attribute == R.styleable.yoga_yg_positionStart) {
node.setPosition(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_yg_position_end) {
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
node.setPosition(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_yg_position_horizontal) {
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
node.setPosition(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_yg_position_vertical) {
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
node.setPosition(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_yg_position_all) {
} else if (attribute == R.styleable.yoga_yg_positionAll) {
node.setPosition(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_yg_position_type) {
} else if (attribute == R.styleable.yoga_yg_positionType) {
node.setPositionType(YogaPositionType.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_width) {
node.setWidth(value);
@@ -525,23 +533,23 @@ public class YogaLayout extends ViewGroup {
final String value = layoutParameters.stringAttributes.valueAt(i);
if (value.equals("auto")) {
if (attribute == R.styleable.yoga_yg_margin_left) {
if (attribute == R.styleable.yoga_yg_marginLeft) {
node.setMarginAuto(YogaEdge.LEFT);
} else if (attribute == R.styleable.yoga_yg_margin_top) {
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMarginAuto(YogaEdge.TOP);
} else if (attribute == R.styleable.yoga_yg_margin_right) {
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMarginAuto(YogaEdge.RIGHT);
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMarginAuto(YogaEdge.BOTTOM);
} else if (attribute == R.styleable.yoga_yg_margin_start) {
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMarginAuto(YogaEdge.START);
} else if (attribute == R.styleable.yoga_yg_margin_end) {
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMarginAuto(YogaEdge.END);
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMarginAuto(YogaEdge.HORIZONTAL);
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMarginAuto(YogaEdge.VERTICAL);
} else if (attribute == R.styleable.yoga_yg_margin_all) {
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMarginAuto(YogaEdge.ALL);
}
}
@@ -549,71 +557,71 @@ public class YogaLayout extends ViewGroup {
if (value.endsWith("%")) {
final float numericValue = Float.parseFloat(value.substring(0, value.length()-1));
if (attribute == R.styleable.yoga_yg_flex_basis) {
if (attribute == R.styleable.yoga_yg_flexBasis) {
node.setFlexBasisPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_height) {
node.setHeightPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_left) {
} else if (attribute == R.styleable.yoga_yg_marginLeft) {
node.setMarginPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_top) {
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMarginPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_right) {
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMarginPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMarginPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_start) {
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMarginPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_end) {
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMarginPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMarginPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMarginPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_margin_all) {
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMarginPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_max_height) {
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
node.setMaxHeightPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_max_width) {
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
node.setMaxWidthPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_min_height) {
} else if (attribute == R.styleable.yoga_yg_minHeight) {
node.setMinHeightPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_min_width) {
} else if (attribute == R.styleable.yoga_yg_minWidth) {
node.setMinWidthPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_left) {
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
node.setPaddingPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_top) {
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
node.setPaddingPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_right) {
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
node.setPaddingPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_bottom) {
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
node.setPaddingPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_start) {
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
node.setPaddingPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_end) {
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
node.setPaddingPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_horizontal) {
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
node.setPaddingPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_vertical) {
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
node.setPaddingPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_padding_all) {
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
node.setPaddingPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_left) {
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
node.setPositionPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_top) {
} else if (attribute == R.styleable.yoga_yg_positionTop) {
node.setPositionPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_right) {
} else if (attribute == R.styleable.yoga_yg_positionRight) {
node.setPositionPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_bottom) {
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
node.setPositionPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_start) {
} else if (attribute == R.styleable.yoga_yg_positionStart) {
node.setPositionPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_end) {
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
node.setPositionPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_horizontal) {
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
node.setPositionPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_vertical) {
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
node.setPositionPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_position_all) {
} else if (attribute == R.styleable.yoga_yg_positionAll) {
node.setPositionPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_width) {
node.setWidthPercent(numericValue);
@@ -779,7 +787,7 @@ public class YogaLayout extends ViewGroup {
* @return A measurement output ({@code YogaMeasureOutput}) for the node
*/
public long measure(
YogaNodeAPI node,
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.android;

View File

@@ -2,17 +2,15 @@
<!--
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.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<resources>
<declare-styleable name="yoga">
<attr name="yg_align_content" format="enum">
<attr name="yg_alignContent" format="enum">
<enum name="auto" value="0"/>
<enum name="flex_start" value="1"/>
<enum name="center" value="2"/>
@@ -21,7 +19,7 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="yg_align_items" format="enum">
<attr name="yg_alignItems" format="enum">
<enum name="auto" value="0"/>
<enum name="flex_start" value="1"/>
<enum name="center" value="2"/>
@@ -30,7 +28,7 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="yg_align_self" format="enum">
<attr name="yg_alignSelf" format="enum">
<enum name="auto" value="0"/>
<enum name="flex_start" value="1"/>
<enum name="center" value="2"/>
@@ -39,17 +37,17 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="yg_aspect_ratio" format="float"/>
<attr name="yg_aspectRatio" format="float"/>
<attr name="yg_border_left" format="dimension"/>
<attr name="yg_border_top" format="dimension"/>
<attr name="yg_border_right" format="dimension"/>
<attr name="yg_border_bottom" format="dimension"/>
<attr name="yg_border_start" format="dimension"/>
<attr name="yg_border_end" format="dimension"/>
<attr name="yg_border_horizontal" format="dimension"/>
<attr name="yg_border_vertical" format="dimension"/>
<attr name="yg_border_all" format="dimension"/>
<attr name="yg_borderLeft" format="dimension"/>
<attr name="yg_borderTop" format="dimension"/>
<attr name="yg_borderRight" format="dimension"/>
<attr name="yg_borderBottom" format="dimension"/>
<attr name="yg_borderStart" format="dimension"/>
<attr name="yg_borderEnd" format="dimension"/>
<attr name="yg_borderHorizontal" format="dimension"/>
<attr name="yg_borderVertical" format="dimension"/>
<attr name="yg_borderAll" format="dimension"/>
<attr name="yg_direction" format="enum">
<enum name="inherit" value="0"/>
@@ -64,22 +62,22 @@
<attr name="yg_flex" format="float"/>
<attr name="yg_flex_basis" format="float|string"/>
<attr name="yg_flexBasis" format="float|string"/>
<attr name="yg_flex_direction" format="enum">
<attr name="yg_flexDirection" format="enum">
<enum name="column" value="0"/>
<enum name="column_reverse" value="1"/>
<enum name="row" value="2"/>
<enum name="row_reverse" value="3"/>
</attr>
<attr name="yg_flex_grow" format="float"/>
<attr name="yg_flexGrow" format="float"/>
<attr name="yg_flex_shrink" format="float"/>
<attr name="yg_flexShrink" format="float"/>
<attr name="yg_height" format="dimension|string"/>
<attr name="yg_justify_content" format="enum">
<attr name="yg_justifyContent" format="enum">
<enum name="flex_start" value="0"/>
<enum name="center" value="1"/>
<enum name="flex_end" value="2"/>
@@ -87,23 +85,23 @@
<enum name="space_around" value="4"/>
</attr>
<attr name="yg_margin_left" format="dimension|string"/>
<attr name="yg_margin_top" format="dimension|string"/>
<attr name="yg_margin_right" format="dimension|string"/>
<attr name="yg_margin_bottom" format="dimension|string"/>
<attr name="yg_margin_start" format="dimension|string"/>
<attr name="yg_margin_end" format="dimension|string"/>
<attr name="yg_margin_horizontal" format="dimension|string"/>
<attr name="yg_margin_vertical" format="dimension|string"/>
<attr name="yg_margin_all" format="dimension|string"/>
<attr name="yg_marginLeft" format="dimension|string"/>
<attr name="yg_marginTop" format="dimension|string"/>
<attr name="yg_marginRight" format="dimension|string"/>
<attr name="yg_marginBottom" format="dimension|string"/>
<attr name="yg_marginStart" format="dimension|string"/>
<attr name="yg_marginEnd" format="dimension|string"/>
<attr name="yg_marginHorizontal" format="dimension|string"/>
<attr name="yg_marginVertical" format="dimension|string"/>
<attr name="yg_marginAll" format="dimension|string"/>
<attr name="yg_max_height" format="dimension|string"/>
<attr name="yg_maxHeight" format="dimension|string"/>
<attr name="yg_max_width" format="dimension|string"/>
<attr name="yg_maxWidth" format="dimension|string"/>
<attr name="yg_min_height" format="dimension|string"/>
<attr name="yg_minHeight" format="dimension|string"/>
<attr name="yg_min_width" format="dimension|string"/>
<attr name="yg_minWidth" format="dimension|string"/>
<attr name="yg_overflow" format="enum">
<enum name="visible" value="0"/>
@@ -111,27 +109,27 @@
<enum name="scroll" value="2"/>
</attr>
<attr name="yg_padding_left" format="dimension|string"/>
<attr name="yg_padding_top" format="dimension|string"/>
<attr name="yg_padding_right" format="dimension|string"/>
<attr name="yg_padding_bottom" format="dimension|string"/>
<attr name="yg_padding_start" format="dimension|string"/>
<attr name="yg_padding_end" format="dimension|string"/>
<attr name="yg_padding_horizontal" format="dimension|string"/>
<attr name="yg_padding_vertical" format="dimension|string"/>
<attr name="yg_padding_all" format="dimension|string"/>
<attr name="yg_paddingLeft" format="dimension|string"/>
<attr name="yg_paddingTop" format="dimension|string"/>
<attr name="yg_paddingRight" format="dimension|string"/>
<attr name="yg_paddingBottom" format="dimension|string"/>
<attr name="yg_paddingStart" format="dimension|string"/>
<attr name="yg_paddingEnd" format="dimension|string"/>
<attr name="yg_paddingHorizontal" format="dimension|string"/>
<attr name="yg_paddingVertical" format="dimension|string"/>
<attr name="yg_paddingAll" format="dimension|string"/>
<attr name="yg_position_left" format="dimension|string"/>
<attr name="yg_position_top" format="dimension|string"/>
<attr name="yg_position_right" format="dimension|string"/>
<attr name="yg_position_bottom" format="dimension|string"/>
<attr name="yg_position_start" format="dimension|string"/>
<attr name="yg_position_end" format="dimension|string"/>
<attr name="yg_position_horizontal" format="dimension|string"/>
<attr name="yg_position_vertical" format="dimension|string"/>
<attr name="yg_position_all" format="dimension|string"/>
<attr name="yg_positionLeft" format="dimension|string"/>
<attr name="yg_positionTop" format="dimension|string"/>
<attr name="yg_positionRight" format="dimension|string"/>
<attr name="yg_positionBottom" format="dimension|string"/>
<attr name="yg_positionStart" format="dimension|string"/>
<attr name="yg_positionEnd" format="dimension|string"/>
<attr name="yg_positionHorizontal" format="dimension|string"/>
<attr name="yg_positionVertical" format="dimension|string"/>
<attr name="yg_positionAll" format="dimension|string"/>
<attr name="yg_position_type" format="enum">
<attr name="yg_positionType" format="enum">
<enum name="relative" value="0"/>
<enum name="absolute" value="1"/>
</attr>

View File

@@ -1,15 +1,15 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "yoga_dep")
cxx_binary(
name = "benchmark",
srcs = glob(["*.c"]),
headers = subdir_glob([("", "*.h")]),
header_namespace = "",
compiler_flags = [
"-fno-omit-frame-pointer",
"-fexceptions",
@@ -18,8 +18,6 @@ cxx_binary(
"-O3",
"-std=c11",
],
header_namespace = "",
headers = subdir_glob([("", "*.h")]),
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "YGBenchmark.h"

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once

View File

@@ -3,12 +3,12 @@
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -18,15 +18,45 @@ buildscript {
allprojects {
repositories {
jcenter()
flatDir {
dirs "${rootDir}/lib/jsr-305"
dirs "${rootDir}/lib/soloader"
dirs "${rootDir}/lib/appcompat"
dirs "${rootDir}/lib/android-support"
}
}
}
ext {
minSdkVersion = 14
targetSdkVersion = 25
compileSdkVersion = 26
buildToolsVersion = '26.0.2'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
}
// If you have an idea on how to avoid this, please get in touch or
// answer https://stackoverflow.com/questions/43867014/how-to-use-the-gradle-ndk-build-to-compile-for-the-host-machine.
task copyNativeLibs(type: Copy, dependsOn: ':buckBuildNative') {
from "${rootDir}/buck-out/gen/java/tests#default,shared-library-symlink-tree/"
include '*.so'
include '*.dylib'
into "$buildDir/jniLibs"
}
task buckBuildNative(type: Exec) {
workingDir rootDir
environment BUCKVERSION: 'last'
commandLine 'buck', 'build', '//java/...'
}
allprojects {
afterEvaluate {
tasks.withType(Test) {
dependsOn copyNativeLibs
def libDir = "${rootDir}/build/jniLibs"
systemProperty 'java.library.path', libDir
environment 'LD_LIBRARY_PATH', libDir
environment 'DYLD_LIBRARY_PATH', libDir
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

3
csharp/.gitignore vendored
View File

@@ -267,3 +267,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# local buck build
lib/

View File

@@ -267,3 +267,6 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# local buck build
lib/

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System.Reflection;

View File

@@ -4,17 +4,17 @@
<BuildDependsOn>NativeLibraryARMV7;NativeLibraryX86;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="NativeLibraryARMV7" Outputs="$(ProjectDir)/lib/armeabi-v7a/libyoga.so">
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../Mac/buck-build.sh //csharp:yoganet#android-armv7,shared" />
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../build-native.sh" />
<Copy SourceFiles="$(ProjectDir)../../../buck-out/gen/csharp/yoganet#android-armv7,shared/libyoga.so" DestinationFiles="$(ProjectDir)/lib/armeabi-v7a/libyoga.so" SkipUnchangedFiles="true" />
</Target>
<!--
<Target Name="NativeLibraryARM64" Outputs="$(ProjectDir)/lib/arm64-v8a/libyoga.so">
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../Mac/buck-build.sh //csharp:yoganet#android-arm64,shared" />
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../build-native.sh" />
<Copy SourceFiles="$(ProjectDir)../../../buck-out/gen/csharp/yoganet#android-arm64,shared/libyoga.so" DestinationFiles="$(ProjectDir)/lib/arm64-v8/libyoga.so" SkipUnchangedFiles="true" />
</Target>
-->
<Target Name="NativeLibraryX86" Outputs="$(ProjectDir)/lib/x86/libyoga.so">
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../Mac/buck-build.sh //csharp:yoganet#android-x86,shared" />
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)../../build-native.sh" />
<Copy SourceFiles="$(ProjectDir)../../../buck-out/gen/csharp/yoganet#android-x86,shared/libyoga.so" DestinationFiles="$(ProjectDir)/lib/x86/libyoga.so" SkipUnchangedFiles="true" />
</Target>
</Project>

View File

@@ -1,11 +1,9 @@
# 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.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
include_defs("//YOGA_DEFS")
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "yoga_dep", "cxx_library", "is_apple_platform")
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
@@ -34,10 +32,10 @@ cxx_library(
deps = [yoga_dep(":yoga")],
)
if isdir('/Applications/Xcode.app'):
if is_apple_platform():
yoganet_ios_srcs = []
for arch in [
'iphonesimulator-x86_64', 'iphonesimulator-i386', 'iphoneos-arm64', 'iphoneos-armv7'
'iphonesimulator-x86_64', 'iphoneos-arm64'
]:
name = 'yoganet-' + arch
yoganet_ios_srcs.append(':' + name)
@@ -65,8 +63,7 @@ if isdir('/Applications/Xcode.app'):
genrule(
name = 'yoganet-macosx',
srcs = [
yoga_dep(yoganet_macosx_target % 'x86_64'),
yoga_dep(yoganet_macosx_target % 'i386'),
yoga_dep(yoganet_macosx_target % 'x86_64')
],
out = 'libyoga.dylib',
cmd = 'lipo $SRCS -create -output $OUT',

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -10,11 +10,15 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BaselineFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Logger.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MeasureFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MeasureOutput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YGConfigHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YGNodeHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaConfig.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaDimension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaDirection.cs" />

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
{
public delegate void Logger(
YogaConfig config,
YogaNode node,
YogaLogLevel level,
string message);
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
@@ -26,96 +24,9 @@ namespace Facebook.Yoga
private const string DllName = "yoga";
#endif
internal class YGNodeHandle : SafeHandle
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
private GCHandle _managed;
#endif
private YGNodeHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
if (_managed.IsAllocated)
{
_managed.Free();
}
#endif
Native.YGNodeFree(this.handle);
GC.KeepAlive(this);
return true;
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
public void SetContext(YogaNode node)
{
if (!_managed.IsAllocated)
{
_managed = GCHandle.Alloc(node, GCHandleType.Weak);
Native.YGNodeSetContext(this.handle, GCHandle.ToIntPtr(_managed));
}
}
public static YogaNode GetManaged(IntPtr ygNodePtr)
{
var node =
GCHandle.FromIntPtr(Native.YGNodeGetContext(ygNodePtr)).Target as YogaNode;
if (node == null)
{
throw new InvalidOperationException("YogaNode is already deallocated");
}
return node;
}
#endif
}
internal class YGConfigHandle : SafeHandle
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
private GCHandle _managed;
#endif
private YGConfigHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
if (_managed.IsAllocated)
{
_managed.Free();
}
#endif
Native.YGConfigFree(this.handle);
GC.KeepAlive(this);
return true;
}
}
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGInteropSetLogger(
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger logger);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGNodeHandle YGNodeNew();
@@ -129,6 +40,9 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeReset(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGConfigHandle YGConfigGetDefault();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGConfigHandle YGConfigNew();
@@ -138,6 +52,9 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGConfigGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetExperimentalFeatureEnabled(
YGConfigHandle config,
@@ -149,6 +66,19 @@ namespace Facebook.Yoga
YGConfigHandle config,
YogaExperimentalFeature feature);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetUseWebDefaults(
YGConfigHandle config,
bool useWebDefaults);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config,
float pixelsInPoint);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeInsertChild(
YGNodeHandle node,
@@ -429,15 +359,19 @@ namespace Facebook.Yoga
#endregion
#region IOS
#region Context
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr YGNodeGetContext(IntPtr node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetContext(IntPtr node, IntPtr managed);
#endif
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr YGConfigGetContext(IntPtr config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetContext(IntPtr config, IntPtr managed);
#endregion
}

View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
internal class YGConfigHandle : SafeHandle
{
internal static readonly YGConfigHandle Default = Native.YGConfigGetDefault();
private GCHandle _managedConfigHandle;
private YGConfigHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
if (this.handle != Default.handle)
{
ReleaseManaged();
if (!IsInvalid)
{
Native.YGConfigFree(this.handle);
}
}
GC.KeepAlive(this);
return true;
}
public void SetContext(YogaConfig config)
{
if (!_managedConfigHandle.IsAllocated)
{
#if UNITY_5_4_OR_NEWER
// Weak causes 'GCHandle value belongs to a different domain' error
_managedConfigHandle = GCHandle.Alloc(config);
#else
_managedConfigHandle = GCHandle.Alloc(config, GCHandleType.Weak);
#endif
var managedConfigPtr = GCHandle.ToIntPtr(_managedConfigHandle);
Native.YGConfigSetContext(this.handle, managedConfigPtr);
}
}
private void ReleaseManaged()
{
if (_managedConfigHandle.IsAllocated)
{
_managedConfigHandle.Free();
}
}
public static YogaConfig GetManaged(IntPtr unmanagedConfigPtr)
{
if (unmanagedConfigPtr != IntPtr.Zero)
{
var managedConfigPtr = Native.YGConfigGetContext(unmanagedConfigPtr);
var config = GCHandle.FromIntPtr(managedConfigPtr).Target as YogaConfig;
if (config == null)
{
throw new InvalidOperationException("YogaConfig is already deallocated");
}
return config;
}
return null;
}
}
}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
internal class YGNodeHandle : SafeHandle
{
private GCHandle _managedNodeHandle;
private YGNodeHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
ReleaseManaged();
if (!IsInvalid)
{
Native.YGNodeFree(this.handle);
GC.KeepAlive(this);
}
return true;
}
public void SetContext(YogaNode node)
{
if (!_managedNodeHandle.IsAllocated)
{
#if UNITY_5_4_OR_NEWER
// Weak causes 'GCHandle value belongs to a different domain' error
_managedNodeHandle = GCHandle.Alloc(node);
#else
_managedNodeHandle = GCHandle.Alloc(node, GCHandleType.Weak);
#endif
var managedNodePtr = GCHandle.ToIntPtr(_managedNodeHandle);
Native.YGNodeSetContext(this.handle, managedNodePtr);
}
}
public void ReleaseManaged()
{
if (_managedNodeHandle.IsAllocated)
{
_managedNodeHandle.Free();
}
}
public static YogaNode GetManaged(IntPtr unmanagedNodePtr)
{
if (unmanagedNodePtr != IntPtr.Zero)
{
var managedNodePtr = Native.YGNodeGetContext(unmanagedNodePtr);
var node = GCHandle.FromIntPtr(managedNodePtr).Target as YogaNode;
if (node == null)
{
throw new InvalidOperationException("YogaNode is already deallocated");
}
return node;
}
return null;
}
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
@@ -13,5 +11,5 @@ using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate float YogaBaselineFunc(IntPtr node, float width, float height);
public delegate float YogaBaselineFunc(IntPtr unmanagedNodePtr, float width, float height);
}

View File

@@ -0,0 +1,138 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Runtime.InteropServices;
#if __IOS__
using ObjCRuntime;
#endif
#if ENABLE_IL2CPP
using AOT;
#endif
namespace Facebook.Yoga
{
public class YogaConfig
{
internal static readonly YogaConfig Default = new YogaConfig(YGConfigHandle.Default);
private static YogaLogger _managedLogger;
private YGConfigHandle _ygConfig;
private Logger _logger;
private YogaConfig(YGConfigHandle ygConfig)
{
_ygConfig = ygConfig;
if (_ygConfig.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
_ygConfig.SetContext(this);
if (_ygConfig == YGConfigHandle.Default)
{
_managedLogger = LoggerInternal;
Native.YGInteropSetLogger(_managedLogger);
}
}
public YogaConfig()
: this(Native.YGConfigNew())
{
}
internal YGConfigHandle Handle
{
get {
return _ygConfig;
}
}
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaLogger))]
#endif
private static void LoggerInternal(
IntPtr unmanagedConfigPtr,
IntPtr unmanagedNodePtr,
YogaLogLevel level,
string message)
{
var config = YGConfigHandle.GetManaged(unmanagedConfigPtr);
if (config == null || config._logger == null)
{
// Default logger
System.Diagnostics.Debug.WriteLine(message);
}
else
{
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
config._logger(config, node, level, message);
}
if (level == YogaLogLevel.Error || level == YogaLogLevel.Fatal)
{
throw new InvalidOperationException(message);
}
}
public Logger Logger
{
get {
return _logger;
}
set {
_logger = value;
}
}
public void SetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled)
{
Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled);
}
public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
{
return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature);
}
public bool UseWebDefaults
{
get
{
return Native.YGConfigGetUseWebDefaults(_ygConfig);
}
set
{
Native.YGConfigSetUseWebDefaults(_ygConfig, value);
}
}
public float PointScaleFactor
{
set
{
Native.YGConfigSetPointScaleFactor(_ygConfig, value);
}
}
public static int GetInstanceCount()
{
return Native.YGConfigGetInstanceCount();
}
public static void SetDefaultLogger(Logger logger)
{
Default.Logger = logger;
}
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,18 +1,14 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
{
public enum YogaExperimentalFeature
{
Rounding,
WebFlexBasis,
MinFlexFix,
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
@@ -16,5 +14,6 @@ namespace Facebook.Yoga
FlexEnd,
SpaceBetween,
SpaceAround,
SpaceEvenly,
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
@@ -16,5 +14,6 @@ namespace Facebook.Yoga
Info,
Debug,
Verbose,
Fatal,
}
}

View File

@@ -1,54 +1,19 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Runtime.InteropServices;
#if __IOS__
using ObjCRuntime;
#endif
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 = LoggerInternal;
public static Func Logger = null;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
[MonoPInvokeCallback(typeof(Func))]
#endif
public static void LoggerInternal(YogaLogLevel level, string message)
{
if (Logger != null)
{
Logger(level, message);
}
if (level == YogaLogLevel.Error)
{
throw new InvalidOperationException(message);
}
}
public static void Initialize()
{
if (!_initialized)
{
Native.YGInteropSetLogger(_managedLogger);
_initialized = true;
}
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void YogaLogger(
IntPtr unmanagedConfigPtr,
IntPtr unmanagedNotePtr,
YogaLogLevel level,
string message);
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
@@ -14,7 +12,7 @@ namespace Facebook.Yoga
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate YogaSize YogaMeasureFunc(
IntPtr node,
IntPtr unmanagedNodePtr,
float width,
YogaMeasureMode widthMode,
float height,

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,100 +1,51 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
using System.Runtime.InteropServices;
#endif
#if __IOS__
using ObjCRuntime;
#endif
#if ENABLE_IL2CPP
using AOT;
#endif
namespace Facebook.Yoga
{
public class YogaConfig
{
private Native.YGConfigHandle _ygConfig;
public YogaConfig()
{
_ygConfig = Native.YGConfigNew();
if (_ygConfig.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
}
internal Native.YGConfigHandle Handle {
get {
return _ygConfig;
}
}
public void SetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled)
{
Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled);
}
public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
{
return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature);
}
}
public partial class YogaNode : IEnumerable<YogaNode>
{
private Native.YGNodeHandle _ygNode;
private readonly YGNodeHandle _ygNode;
private readonly YogaConfig _config;
private WeakReference _parent;
private List<YogaNode> _children;
private MeasureFunction _measureFunction;
private BaselineFunction _baselineFunction;
private object _data;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
private static YogaMeasureFunc _managedMeasure = MeasureInternalIOS;
private static YogaBaselineFunc _managedBaseline = BaselineInternalIOS;
#else
private YogaMeasureFunc _managedMeasure;
private YogaBaselineFunc _managedBaseline;
#endif
private object _data;
public YogaNode()
public YogaNode(YogaConfig config = null)
{
YogaLogger.Initialize();
_ygNode = Native.YGNodeNew();
_config = config == null ? YogaConfig.Default : config;
_ygNode = Native.YGNodeNewWithConfig(_config.Handle);
if (_ygNode.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
}
public YogaNode(YogaConfig config)
{
YogaLogger.Initialize();
_ygNode = Native.YGNodeNewWithConfig(config.Handle);
if (_ygNode.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
_ygNode.SetContext(this);
}
public YogaNode(YogaNode srcNode)
: this()
: this(srcNode._config)
{
CopyStyle(srcNode);
}
@@ -105,7 +56,9 @@ namespace Facebook.Yoga
_baselineFunction = null;
_data = null;
_ygNode.ReleaseManaged();
Native.YGNodeReset(_ygNode);
_ygNode.SetContext(this);
}
public bool IsDirty
@@ -466,7 +419,7 @@ namespace Facebook.Yoga
}
}
public float StyleAspectRatio
public float AspectRatio
{
get
{
@@ -595,6 +548,20 @@ namespace Facebook.Yoga
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
}
public void AddChild(YogaNode child)
{
Insert(Count, child);
}
public void RemoveChild(YogaNode child)
{
int index = IndexOf(child);
if (index >= 0)
{
RemoveAt(index);
}
}
public void Clear()
{
if (_children != null)
@@ -614,99 +581,71 @@ namespace Facebook.Yoga
public void SetMeasureFunction(MeasureFunction measureFunction)
{
_measureFunction = measureFunction;
if (measureFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
_ygNode.SetContext(this);
#else
_managedMeasure = MeasureInternal;
#endif
}
_managedMeasure = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
}
public void SetBaselineFunction(BaselineFunction baselineFunction)
{
_baselineFunction = baselineFunction;
if (baselineFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
_ygNode.SetContext(this);
#else
_managedBaseline = BaselineInternal;
#endif
}
_managedBaseline =
baselineFunction != null ? BaselineInternal : (YogaBaselineFunc)null;
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
}
public void CalculateLayout()
public void CalculateLayout(
float width = YogaConstants.Undefined,
float height = YogaConstants.Undefined)
{
Native.YGNodeCalculateLayout(
_ygNode,
YogaConstants.Undefined,
YogaConstants.Undefined,
width,
height,
Native.YGNodeStyleGetDirection(_ygNode));
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
private static YogaSize MeasureInternalIOS(
IntPtr ygNodePtr,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode)
{
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
return node.MeasureInternal(IntPtr.Zero, width, widthMode, height, heightMode);
}
#endif
private YogaSize MeasureInternal(
IntPtr node,
private static YogaSize MeasureInternal(
IntPtr unmanagedNodePtr,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode)
{
if (_measureFunction == null)
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
if (node == null || node._measureFunction == null)
{
throw new InvalidOperationException("Measure function is not defined.");
}
return _measureFunction(this, width, widthMode, height, heightMode);
return node._measureFunction(node, width, widthMode, height, heightMode);
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
private static float BaselineInternalIOS(
IntPtr ygNodePtr,
#endif
private static float BaselineInternal(
IntPtr unmanagedNodePtr,
float width,
float height)
{
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
return node.BaselineInternal(IntPtr.Zero, width, height);
}
#endif
private float BaselineInternal(IntPtr node, float width, float height)
{
if (_baselineFunction == null)
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
if (node == null || node._baselineFunction == null)
{
throw new InvalidOperationException("Baseline function is not defined.");
}
return _baselineFunction(this, width, height);
return node._baselineFunction(node, width, height);
}
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);};
Logger orig = _config.Logger;
_config.Logger = (config, node, level, message) => {sb.Append(message);};
Native.YGNodePrint(_ygNode, options);
YogaLogger.Logger = orig;
_config.Logger = orig;
return sb.ToString();
}

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
{
public enum YogaNodeType
{
Default,
Text,
}
}

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga

View File

@@ -1,14 +1,13 @@
/**
* 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.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Facebook.Yoga
{
[System.Flags]
public enum YogaPrintOptions
{
Layout = 1,

Some files were not shown because too many files have changed in this diff Show More