Compare commits

...

110 Commits
1.2.0 ... 1.4.1

Author SHA1 Message Date
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
Robert Spencer
17be6718ee Nicer formatting of gists in docs
Summary: The gists in the docs have large margins to fit with the front page.  This diff specialises that margin setting and sets it to something smaller for other gists.

Reviewed By: emilsjolander

Differential Revision: D4666016

fbshipit-source-id: 5121849a153e78d523b33e10b96641426e794f8d
2017-03-07 05:26:24 -08:00
Robert Spencer
abf912b729 Gradle version bump and POM details
Summary: This improves the quality of the published POM files, adding dependencies and marking the object as an 'aar'.  It also bumps the version to 1.2.0 for JCenter.

Reviewed By: emilsjolander

Differential Revision: D4620150

fbshipit-source-id: 968f1cea21af4b2f19aeff3f32ad575b185fa1bb
2017-03-07 03:56:46 -08:00
Eric Rozell
5bc0197c78 Workaround for P/Invoke AccessViolationException
Summary:
The issue is on ARM builds for Windows UWP. For the C# P/Invoke API wrapper, any native method that returns the YogaValue struct throws the AccessViolationException. The issue is not with structs in general, as returning the YogaSize / YGSize struct works fine. The issue seems to be limited to structs that have an enum member.

I tried a number of things to resolve the issue without changing the underlying native API for Windows. I read the ARM documentation and saw reference to variable enum sizes based on the number of enum members, so I tried to use a number of different UnmanagedType values in a [MarsalAs()] attribute on the enum member of the C# struct declaration.

What ultimately worked was to return a pointer to the location of the struct, and use the System.Runtime.InteropServices.PtrToStructure API to read the struct data from that pointer. I added a few new macros that will return the struct address on Windows only, other builds are not affected.

Note, I have not tested the impact of this ch
Closes https://github.com/facebook/yoga/pull/459

Reviewed By: emilsjolander

Differential Revision: D4652278

Pulled By: splhack

fbshipit-source-id: bf7ada4da1781e3f813b3ba331974b7bded476d9
2017-03-06 11:42:40 -08:00
Lukas Wöhrl
62f47190fb Added bool config to YGConfig to configure using web defaults
Summary:
Added bool config to YGConfig to configure using web defaults. See #445.
Closes https://github.com/facebook/yoga/pull/449

Reviewed By: astreet

Differential Revision: D4642272

Pulled By: emilsjolander

fbshipit-source-id: 4f35bd17b7f764f42295052a4a8b4ae46c192d7e
2017-03-03 10:55:59 -08:00
Lukas Wöhrl
a706f4c97c Mark all children as dirty if display changes
Summary:
If we set ```display:none``` all children are set with layout sizes/values of 0. We need do mark all those children as dirty to force a relayout if we toggle the display on a higher parent node. This fixes #443
Closes https://github.com/facebook/yoga/pull/448

Reviewed By: astreet

Differential Revision: D4642273

Pulled By: emilsjolander

fbshipit-source-id: dfdb920e2049952bd6c7f48cfa53b1448e1f3e8f
2017-03-03 10:45:19 -08:00
Lukas Wöhrl
feb365a77b Explicitly set new experimental and a small other improvement
Summary:
This sets the new ```YGExperimentalFeatureMinFlexFix``` explicitly to false in the config.

It also a changes a stretch reason to reflect that it is the strech in a multiline.
Closes https://github.com/facebook/yoga/pull/447

Reviewed By: astreet

Differential Revision: D4642275

Pulled By: emilsjolander

fbshipit-source-id: 26777db7008ff6ee86da72ca9ea19e979b916cc9
2017-03-03 10:26:41 -08:00
Lukas Wöhrl
b2a4e67fee Use floats to prevent double calculation + float casting on scale
Summary:
Use ```float``` for calculation, as we would calculate with ```double``` and cast to float afterwards otherwise. So this removes the warning.
Closes https://github.com/facebook/yoga/pull/450

Reviewed By: astreet

Differential Revision: D4642267

Pulled By: emilsjolander

fbshipit-source-id: 184ef24474f2b8a42654a71a8e98839296648b2b
2017-03-03 10:26:40 -08:00
Emil Sjolander
e7d2792009 Add another nested percentage test
Summary: Add test covering a nested percentage container inside of a unconstraint container. This is something we ran into recently and want to make sure to cover in tests.

Reviewed By: astreet

Differential Revision: D4637519

fbshipit-source-id: a8fe3c7702c2ea0ad954cce80fbdf953bb23c997
2017-03-03 10:26:40 -08:00
Emil Sjolander
0fde1424f0 re-generate tests. Something was missed when rebasing
Summary: Some of the tests were not generated correctly. most likely due to a rebase.

Reviewed By: astreet

Differential Revision: D4637539

fbshipit-source-id: 196478d7e5197519af9ab05e5134e6fb7d22b992
2017-03-03 10:26:40 -08:00
Robert Spencer
29fd447f0c Margin percent values should be floats
Summary: Percentages should be floats

Reviewed By: emilsjolander

Differential Revision: D4642511

fbshipit-source-id: f1ef78259cf967acec9b82d77e43d7b9ad263e5b
2017-03-03 06:48:10 -08:00
Robert Spencer
7047d96087 Add yg prefix to attributes
Summary: To avoid clashes in the `app:` namespace, we prefix all yoga attributes with `yg_`.

Reviewed By: emilsjolander

Differential Revision: D4643080

fbshipit-source-id: 3e9265fd57e56a1df2f687a5d17c5bc66b8befa3
2017-03-03 00:41:04 -08:00
Robert Spencer
6336e641f4 Add ability to invalidate views
Summary: When some drawing attributes of a view changes how it measures, we need to be able to relayout it correctly.  This adds method `invalidate(View)` to `YogaLayout` which will flag the corresponding node as dirty and requiring layout again.

Reviewed By: emilsjolander

Differential Revision: D4634563

fbshipit-source-id: af7f47dce00a31414d0987a58307c5d44c1bcf20
2017-03-02 02:58:52 -08:00
Scott Wolchok
ecabe757a2 BUCK file renaming round 2 (13/13)
Summary: Ran the autoformat linter on our BUCK files.

Reviewed By: dinhviethoa

Differential Revision: D4641344

fbshipit-source-id: 25b42543ddf5cc60c72e4228cec1c5175f60eaca
2017-03-01 20:42:23 -08:00
Lukas Wöhrl
37c48257ae Move configuration to new YGConfig and pass them down to CalculateLayout
Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .

Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.

New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432

Reviewed By: astreet

Differential Revision: D4611359

Pulled By: emilsjolander

fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
2017-03-01 09:27:53 -08:00
Emil Sjolander
8668e43f6d Fix margin auto for start and end values
Summary: Margin auto was not handling start/end margins correctly

Reviewed By: astreet

Differential Revision: D4627339

fbshipit-source-id: eebf64e79a34331e79cffcfa3662d4938fbd6c13
2017-03-01 09:27:52 -08:00
Emil Sjolander
785713c9c0 default root node to size of parent contraints
Summary: This is a follow up on a recent change which made the constraints passed into conculateLayout describe the parent constraints and not the root node constraints. This broke some assumptions and was not very inuitive if no size was set on the root. Therefor this diff ensure that if the root node does not have any size set then it will adopt the size of the parent constraints.

Reviewed By: dshahidehpour

Differential Revision: D4634616

fbshipit-source-id: 089eb4313c5bb810a6ff56f158cd19cec71808ec
2017-03-01 07:11:25 -08:00
Robert Spencer
b523402eda Update NDK version to 12
Summary: This diff updates the NDK version from 10 to 12

Reviewed By: emilsjolander

Differential Revision: D4634938

fbshipit-source-id: 6a9cbc48dbcbda4674d6460120c7a0d8abd626ab
2017-03-01 06:27:17 -08:00
Emil Sjolander
3790635af1 Re-generate wrap tests
Summary: Seems someone forgot to run the generation script

Reviewed By: astreet

Differential Revision: D4627337

fbshipit-source-id: 17dd1e1fed938a049ae820a9a4ac913667073d09
2017-03-01 06:27:16 -08:00
Robert Spencer
b940fadb7e Add android bindings to margin:auto
Summary: [This commit](1146013e9e) (or diff D4501142) adds an `auto` option for margins.  This diff allows you to leverage that in android via attribute `yoga:margin_all="auto"` (and as expected for the other edges).

Reviewed By: emilsjolander

Differential Revision: D4634684

fbshipit-source-id: 158f70ec975b5bb3a666e590b76eb52daeb38f49
2017-03-01 05:57:03 -08:00
Georgiy Kassabli
3ef2970032 Yoga test failure for flexing with min stack dimension
Summary: Test fails when we have flexible child and min/max layout dimension. Yoga should flex the child to minimal size, while in reality Yoga flexes it to maximal size

Reviewed By: emilsjolander

Differential Revision: D4558653

fbshipit-source-id: 06b38d7ed43aee063cc881f38b84558641f043f3
2017-02-28 16:28:54 -08:00
Robert Spencer
4372aa16d3 Enable RTL on sample app
Summary: The manifest didn't acknowledge that the sample app supports RTL.  Thus `TextView`s didn't render properly.

Reviewed By: emilsjolander

Differential Revision: D4628867

fbshipit-source-id: 72e57f48f7d68a8d2d6dd091b44b9452a3fe281a
2017-02-28 12:27:15 -08:00
Lukas Wöhrl
3346f9511a Change flex getters to return the set values
Summary:
Changed the flex getters to return the values they were actually set. See #421 .
Closes https://github.com/facebook/yoga/pull/431

Reviewed By: astreet

Differential Revision: D4604744

Pulled By: emilsjolander

fbshipit-source-id: 02d79100ef22be866db1c3bd9d53e4447186811f
2017-02-28 09:26:32 -08:00
Emil Sjolander
1cd7363bea Pass the parent size to YGNodeCalculateLayout instead of the node size
Summary: The size of the node is already set on the node however there was no way to set the size of the parent to the root so that the root could use percentages. This change fixes this by making the width and height passed to calculate layout be the width and height of the hypothetical parent.

Reviewed By: astreet

Differential Revision: D4611417

fbshipit-source-id: 2fb0eedffa17f0ec89b601722a1717a72e216b9e
2017-02-28 08:11:58 -08:00
Lukas Wöhrl
17e3dca9f9 Fix percentage in flexing parent
Summary:
If we don't measure exactly, percentage values aren't exactly either. Fix for #414.
Closes https://github.com/facebook/yoga/pull/416
Closes https://github.com/facebook/yoga/pull/414

Reviewed By: astreet

Differential Revision: D4604729

Pulled By: emilsjolander

fbshipit-source-id: 66880230073209cbe89668b838c2a82e7f9b34df
2017-02-28 07:12:05 -08:00
Robert Spencer
533f560ce0 Android bindings for display property
Summary: Diff D4501141 added display attributes for Yoga.  This exposes them in the android library.

Reviewed By: emilsjolander

Differential Revision: D4605574

fbshipit-source-id: dbad3d6fe924682c6b81f65bbba9727085de2d81
2017-02-28 00:26:27 -08:00
Robert Spencer
6a60d4893e Add travis_wait to installing Android SDK in travis builds
Summary: The android sdk and api installation seems to be timing out on Travis.  This should extend the 10 minute limit to 20 minutes.  Hopefully this will be enough to download it all.  If not, we must just extend the timeout.

Reviewed By: emilsjolander

Differential Revision: D4588245

fbshipit-source-id: fef25c54b081ba4d96d1e0435c6c1f643ff49b66
2017-02-28 00:26:27 -08:00
Emil Sjolander
51dd082682 bump javascript version
Summary: https://www.npmjs.com/package/yoga-layout

Reviewed By: arcanis

Differential Revision: D4611991

fbshipit-source-id: 4f75a85f8664e6d5bec609f6feb668a59f0fdde8
2017-02-27 01:13:08 -08:00
Michael Bolin
47d8d9d22b Apply auto-formatter for BUCK files in fbandroid.
Summary:
For more background, see:

https://fb.facebook.com/groups/303159406399348/permalink/1334977403217538/
https://fburl.com/auto-format-build-files
D4527873

fbshipit-source-id: 278ce6f67f5df830b2218e3aca69be103d3c56a6
2017-02-24 21:44:02 -08:00
Dustin Shahidehpour
d6d4dcb141 Update YogaKitSample Podfile.lock
Summary: #accept2ship

Reviewed By: amonshiz

Differential Revision: D4614473

fbshipit-source-id: d46fc54c53280fca1607dc75b59e730f340eb4e7
2017-02-24 14:26:55 -08:00
Georgiy Kassabli
37ec1774a7 Add rounding to the pixel grid to Yoga
Summary: This diff adds rounding to the pixel grid feature to Yoga and appropriate property

Reviewed By: emilsjolander

Differential Revision: D4565980

fbshipit-source-id: 9700f6d6ed147f82b19f230fbff2e9ccbd625b25
2017-02-24 09:57:00 -08:00
birfincankafein
3ad4d7dd6e Solve build target error while building Android with Buck.
Summary:
SoLoader library targets Android API 21 but main manifest targets 19. This will block buck android build.
Closes https://github.com/facebook/yoga/pull/437

Reviewed By: astreet

Differential Revision: D4611364

Pulled By: emilsjolander

fbshipit-source-id: 113bcfce751e98b8a42e46e0101b6a4b1327b9c3
2017-02-24 03:26:46 -08:00
Emil Sjolander
e596091fa2 Bump podspec versions
Summary: podspec version bump

Reviewed By: dshahidehpour

Differential Revision: D4606652

fbshipit-source-id: a9a7d4512f174182301a0b7ac2ae13303b659a3f
2017-02-23 11:57:06 -08:00
292 changed files with 16873 additions and 5254 deletions

View File

@@ -1,9 +1,9 @@
[cxx]
gtest_dep = //lib/gtest:gtest
[android]
target = Google Inc.:Google APIs:19
target = android-23
[ndk]
ndk_version = r10e
ndk_version = 13.1.3345770
compiler = clang
app_platform = android-19
cpu_abis = armv7, x86
app_platform = android-21
cpu_abis = arm64, armv7, x86, x86_64

2
.gitignore vendored
View File

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

View File

@@ -40,7 +40,11 @@ before_install:
# iOS
- |
if [[ $TARGET = "ios" ]]; then
brew outdated xctool || brew upgrade xctool
brew outdated xctool || brew upgrade xctool;
gem install xcpretty --no-document --quiet;
gem install cocoapods --pre --no-document --quiet;
pod repo update --silent;
pod install --project-directory=YogaKit/YogaKitSample/;
fi
# Emscripten (used for js tests)
@@ -56,13 +60,15 @@ before_install:
# 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/opt/android-sdk &&
export ANDROID_HOME=/usr/local/opt/android-sdk
$ANDROID_SDK/tools/android update sdk --filter android-19,addon-google_apis-google-19
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
@@ -100,7 +106,9 @@ script:
# iOS
- |
if [[ $TARGET = "ios" ]]; then
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 &&
set -o pipefail &&
xcodebuild build -workspace YogaKit/YogaKitSample/YogaKitSample.xcworkspace -scheme YogaKitSample -sdk iphonesimulator | xcpretty -c
fi
# Android

53
BUCK
View File

@@ -5,38 +5,41 @@
# 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')
include_defs("//YOGA_DEFS")
GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests
'-Wno-inconsistent-missing-override',
# gmock does not mark mocked methods as override, ignore the warnings in tests
"-Wno-inconsistent-missing-override",
]
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC']
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11']
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c11",
]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ["-std=c++11"]
cxx_library(
name = 'yoga',
soname = 'libyogacore.$(ext)',
srcs = glob(['yoga/*.c']),
tests=[':YogaTests'],
exported_headers = subdir_glob([('', 'yoga/*.h')]),
header_namespace = '',
compiler_flags = COMPILER_FLAGS,
deps = [] if THIS_IS_FBOBJC else [
yoga_dep('lib/fb:ndklog'),
],
visibility = ['PUBLIC'],
name = "yoga",
srcs = glob(["yoga/*.c"]),
compiler_flags = COMPILER_FLAGS,
exported_headers = subdir_glob([("", "yoga/*.h")]),
header_namespace = "",
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [] if THIS_IS_FBOBJC else [
yoga_dep("lib/fb:ndklog"),
],
)
cxx_test(
name = 'YogaTests',
contacts = ['emilsj@fb.com'],
srcs = glob(['tests/*.cpp']),
compiler_flags = TEST_COMPILER_FLAGS,
deps = [
':yoga',
GTEST_TARGET,
],
visibility = ['PUBLIC'],
name = "YogaTests",
srcs = glob(["tests/*.cpp"]),
compiler_flags = TEST_COMPILER_FLAGS,
contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"],
deps = [
":yoga",
GTEST_TARGET,
],
)

17
CMakeLists.txt Normal file
View File

@@ -0,0 +1,17 @@
#
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
#
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB yogacore_SRC yoga/*.c)
add_library(yogacore STATIC ${yogacore_SRC})
target_link_libraries(yogacore android log)

View File

@@ -1,4 +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)
# 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)
[![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)
@@ -7,6 +7,9 @@
[![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)
[![Visual Studio Team services](https://img.shields.io/vso/build/rumar/fe6d27b5-e424-4f61-b8f6-e2ec2f8755fb/1.svg?label=vsts-windows)]()
[![Visual Studio Team services](https://img.shields.io/vso/build/rumar/fe6d27b5-e424-4f61-b8f6-e2ec2f8755fb/2.svg?label=vsts-osx)]()
## 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.

View File

@@ -1,10 +1,10 @@
YOGA_ROOT = '//...'
YOGA_ROOTS = ['//...']
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'
PROGRUARD_ANNOTATIONS_TARGET = '//java/proguard-annotations/src/main/java/com/facebook/proguard/annotations:annotations'
SOLOADER_TARGET = '//lib/soloader:soloader'
GTEST_TARGET = '//lib/gtest:gtest'
JNI_TARGET = '//lib/jni:jni'
@@ -33,6 +33,10 @@ BASE_COMPILER_FLAGS = [
'-O3',
]
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
'-fPIC',
]
def yoga_dep(dep):
return '//' + dep

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '1.1.0'
spec.version = '1.3.0'
spec.license = { :type => 'BSD', :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 => 'v2017.02.07.00',
:tag => '1.3.0',
}
spec.module_name = 'yoga'

View File

@@ -1,6 +1,6 @@
podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit'
spec.version = '1.1.0'
spec.version = '1.3.0'
spec.license = { :type => 'BSD', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
@@ -11,14 +11,14 @@ podspec = Pod::Spec.new do |spec|
spec.authors = 'Facebook'
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => 'v2017.02.07.00',
:tag => '1.3.0',
}
spec.platform = :ios
spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.1'
spec.dependency 'Yoga', '~> 1.3'
spec.source_files = 'YogaKit/Source/*.{h,m}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'

View File

@@ -5,54 +5,54 @@
# 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')
include_defs("//YOGA_DEFS")
COMPILER_FLAGS = [
'-fobjc-arc',
'-Wconditional-uninitialized',
'-Wdangling-else',
'-Wdeprecated-declarations',
'-Wimplicit-retain-self',
'-Wincomplete-implementation',
'-Wobjc-method-access',
'-Wobjc-missing-super-calls',
'-Wmismatched-return-types',
'-Wreturn-type',
'-Wno-global-constructors',
'-Wno-shadow',
'-Wunused-const-variable',
'-Wunused-function',
'-Wunused-property-ivar',
'-Wunused-result',
'-Wunused-value',
"-fobjc-arc",
"-Wconditional-uninitialized",
"-Wdangling-else",
"-Wdeprecated-declarations",
"-Wimplicit-retain-self",
"-Wincomplete-implementation",
"-Wobjc-method-access",
"-Wobjc-missing-super-calls",
"-Wmismatched-return-types",
"-Wreturn-type",
"-Wno-global-constructors",
"-Wno-shadow",
"-Wunused-const-variable",
"-Wunused-function",
"-Wunused-property-ivar",
"-Wunused-result",
"-Wunused-value",
]
apple_library(
name = 'YogaKit',
compiler_flags = COMPILER_FLAGS,
srcs = glob(['Source/**/*.m']),
exported_headers = glob(['Source/**/*.h']),
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
],
deps = [
yoga_dep(':yoga'),
],
visibility = ['PUBLIC'],
name = "YogaKit",
srcs = glob(["Source/**/*.m"]),
compiler_flags = COMPILER_FLAGS,
exported_headers = glob(["Source/**/*.h"]),
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
],
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),
],
)
apple_test(
name = 'YogaKitTests',
compiler_flags = COMPILER_FLAGS,
info_plist = 'Tests/Info.plist',
srcs = glob(['Tests/**/*.m']),
frameworks = [
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
],
deps = [
':YogaKit',
],
visibility = ['PUBLIC'],
name = "YogaKitTests",
srcs = glob(["Tests/**/*.m"]),
compiler_flags = COMPILER_FLAGS,
frameworks = [
"$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework",
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
],
info_plist = "Tests/Info.plist",
visibility = ["PUBLIC"],
deps = [
":YogaKit",
],
)

View File

@@ -8,7 +8,7 @@
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
```
pod 'YogaKit', '~> 1.1'
pod 'YogaKit', '~> 1.3'
```
## 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

@@ -10,6 +10,11 @@
#import <UIKit/UIKit.h>
#import <yoga/YGEnums.h>
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
YGDimensionFlexibilityFlexibleHeigth = 1 << 1,
};
@interface YGLayout : NSObject
/**
@@ -95,6 +100,13 @@
- (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)];

View File

@@ -85,6 +85,8 @@ YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
static YGConfigRef globalConfig;
@interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view;
@@ -99,14 +101,15 @@ YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEd
+ (void)initialize
{
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
globalConfig = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
}
- (instancetype)initWithView:(UIView*)view
{
if (self = [super init]) {
_view = view;
_node = YGNodeNew();
_node = YGNodeNewWithConfig(globalConfig);
YGNodeSetContext(_node, (__bridge void *) view);
_isEnabled = NO;
_isIncludedInLayout = YES;
@@ -232,6 +235,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 & YGDimensionFlexibilityFlexibleHeigth) {
size.height = YGUndefined;
}
[self calculateLayoutWithSize:size];
YGApplyLayoutToViewHierarchy(self.view, NO);
}
- (CGSize)intrinsicSize
{
const CGSize constrainedSize = {

View File

@@ -21,7 +21,8 @@
- (void)testConfigureLayoutIsNoOpWithNilBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertNoThrow([view configureLayoutWithBlock:nil]);
id block = nil;
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
}
- (void)testConfigureLayoutBlockWorksWithValidBlock
@@ -153,6 +154,54 @@
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 = 100;
view.yoga.height = 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 = 100;
view.yoga.height = 100;
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleHeigth];
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 = 100;
view.yoga.height = 100;
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth | YGDimensionFlexibilityFlexibleHeigth];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];

View File

@@ -4,9 +4,9 @@ PODS:
- IGListKit/Default (2.1.0):
- IGListKit/Diffing
- IGListKit/Diffing (2.1.0)
- Yoga (1.1.0)
- YogaKit (1.1.0):
- Yoga (~> 1.1)
- Yoga (1.3.0)
- YogaKit (1.3.0):
- Yoga (~> 1.3)
DEPENDENCIES:
- IGListKit (~> 2.1.0)
@@ -14,12 +14,12 @@ DEPENDENCIES:
EXTERNAL SOURCES:
YogaKit:
:path: ../../YogaKit.podspec
:path: "../../YogaKit.podspec"
SPEC CHECKSUMS:
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
Yoga: 0bf083b7c485b20598020dbedcea869cbe53071e
YogaKit: 80df90de9ef2900baa111f2c93476a6f9e921385
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
YogaKit: cddeccc6a8d2aff563e4c738d3bddb290a6de4cb
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404

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

@@ -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 = containerSize.width
layout.height = 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 = 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

@@ -5,32 +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.
include_defs('//YOGA_DEFS')
include_defs("//YOGA_DEFS")
android_aar(
name = 'android',
manifest_skeleton = 'src/main/AndroidManifest.xml',
deps = [
ANDROID_JAVA_TARGET,
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
PROGRUARD_ANNOTATIONS_TARGET,
],
visibility = [
'PUBLIC',
],
name = "android",
manifest_skeleton = "src/main/AndroidManifest.xml",
visibility = [
"PUBLIC",
],
deps = [
ANDROID_JAVA_TARGET,
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
PROGRUARD_ANNOTATIONS_TARGET,
],
)
android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.facebook.yoga.android',
visibility = [
'PUBLIC',
],
)
project_config(
src_target = ':android',
name = "res",
package = "com.facebook.yoga.android",
res = "src/main/res",
visibility = [
"PUBLIC",
],
)

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,33 +1,23 @@
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.0.0'
version = '1.4.1'
group = 'com.facebook.yoga.android'
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
}
sourceSets.main {
jni.srcDirs = [] // disalbe NDK auto build (not sure why this is necessary)
// The alternative, fat-aar does an equivalent thing to this hack
// seehttps://github.com/adwiv/android-fat-aar/blob/master/fat-aar.gradle#L307
jniLibs.srcDirs = ['build/intermediates/exploded-aar/com.facebook.yoga/yoga/1.0.0/jni']
targetCompatibility rootProject.targetCompatibilityVersion
sourceCompatibility rootProject.sourceCompatibilityVersion
}
}
@@ -53,7 +43,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
}
ext {
bintrayName = "com.facebook.yoga.android:yoga-layout"
bintrayName = 'com.facebook.yoga.android:yoga-layout'
}
apply from: rootProject.file('gradle/android-jcenter-install.gradle')

View File

@@ -22,11 +22,14 @@
android:targetSdkVersion="19"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="false"
android:theme="@style/NoTitleBarWhiteBG"
android:supportsRtl="true"
>
<activity
@@ -41,6 +44,11 @@
</activity>
<activity
android:name=".BenchmarkActivity"
android:exported="false"
/>
</application>
</manifest>

View File

@@ -4,36 +4,32 @@
# 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')
include_defs("//YOGA_DEFS")
android_binary(
name = 'sample',
manifest = 'AndroidManifest.xml',
keystore = ':debug_keystore',
deps = [
ANDROID_SAMPLE_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
],
name = "sample",
keystore = ":debug_keystore",
manifest = "AndroidManifest.xml",
deps = [
ANDROID_SAMPLE_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
],
)
android_resource(
name = 'res',
res = 'res',
package = 'com.facebook.samples.yoga',
deps = [
ANDROID_RES_TARGET,
],
visibility = [
'PUBLIC',
],
name = "res",
package = "com.facebook.samples.yoga",
res = "res",
visibility = [
"PUBLIC",
],
deps = [
ANDROID_RES_TARGET,
],
)
keystore(
name='debug_keystore',
store='debug.keystore',
properties='debug.keystore.properties',
)
project_config(
src_target = ':sample',
name = "debug_keystore",
properties = "debug.keystore.properties",
store = "debug.keystore",
)

View File

@@ -5,19 +5,19 @@
# 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')
include_defs("//YOGA_DEFS")
android_library(
name = 'yoga',
srcs = glob(['**/*.java']),
deps = [
ANDROID_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
ANDROID_SUPPORT_TARGET,
APPCOMPAT_TARGET,
SOLOADER_TARGET,
],
visibility = [
'PUBLIC',
]
name = "yoga",
srcs = glob(["**/*.java"]),
visibility = [
"PUBLIC",
],
deps = [
ANDROID_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
ANDROID_SUPPORT_TARGET,
APPCOMPAT_TARGET,
SOLOADER_TARGET,
],
)

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.ActionBarActivity;
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 ActionBarActivity {
@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.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;
@@ -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

@@ -10,7 +10,7 @@
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
xmlns:yoga="http://schemas.android.com/apk/res/com.facebook.samples.yoga"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
@@ -18,120 +18,120 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="8dp"
yoga:yg_flex="1"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_2_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="8dp"
yoga:yg_flex="1"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_3_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="8dp"
yoga:yg_flex="1"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_4_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="8dp"
yoga:yg_flex="1"
yoga:yg_marginStart="8dp"
/>
</YogaLayout>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
yoga:yg_marginHorizontal="10dp"
yoga:yg_marginTop="5dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_5_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="10dp"
yoga:yg_flex="1"
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

@@ -17,7 +17,7 @@
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19"
android:targetSdkVersion="21"
/>
<application/>

View File

@@ -5,19 +5,19 @@
# 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')
include_defs("//YOGA_DEFS")
android_library(
name = 'android',
srcs = glob(['**/*.java']),
deps = [
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
JSR_305_TARGET,
SOLOADER_TARGET,
],
visibility = [
'PUBLIC',
]
name = "android",
srcs = glob(["**/*.java"]),
visibility = [
"PUBLIC",
],
deps = [
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
JSR_305_TARGET,
SOLOADER_TARGET,
],
)

View File

@@ -14,7 +14,6 @@ import java.util.Map;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -24,11 +23,13 @@ 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;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaDirection;
import com.facebook.yoga.YogaDisplay;
import com.facebook.yoga.YogaEdge;
import com.facebook.yoga.YogaFlexDirection;
import com.facebook.yoga.YogaJustify;
@@ -36,7 +37,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 +52,7 @@ import com.facebook.yoga.YogaWrap;
* <pre>{@code
* <YogaLayout
* xmlns:android="http://schemas.android.com/apk/res/android"
* xmlns:yoga="http://schemas.android.com/apk/res-auto"
* 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 +91,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);
}
@@ -106,7 +112,7 @@ public class YogaLayout extends ViewGroup {
* Adds a child view with the specified layout parameters.
*
* In the typical View is added, this constructs a {@code YogaNode} for this child and applies all
* the {@code yoga:*} attributes. The Toga node is added to the Yoga tree and the child is added
* the {@code yoga:*} attributes. The Yoga node is added to the Yoga tree and the child is added
* to this ViewGroup.
*
* If the child is a {@link YogaLayout} itself, we do not construct a new Yoga node for that
@@ -153,7 +159,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());
@@ -231,6 +241,28 @@ public class YogaLayout extends ViewGroup {
super.removeAllViewsInLayout();
}
/**
* Marks a particular view as "dirty" and to be relaid out. If the view is not a child of this
* {@link YogaLayout}, the entire tree is traversed to find it.
*
* @param view the view to mark as dirty
*/
public void invalidate(View view) {
if (mYogaNodes.containsKey(view)) {
mYogaNodes.get(view).dirty();
return;
}
final int childCount = mYogaNode.getChildCount();
for (int i = 0; i < childCount; i++) {
final YogaNode yogaNode = mYogaNode.getChildAt(i);
if (yogaNode.getData() instanceof YogaLayout) {
((YogaLayout) yogaNode.getData()).invalidate(view);
}
}
invalidate();
}
private void removeViewFromYogaTree(View view, boolean inLayout) {
final YogaNode node = mYogaNodes.get(view);
if (node == null) {
@@ -256,6 +288,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;
@@ -293,9 +326,7 @@ public class YogaLayout extends ViewGroup {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// Either we are a root of a tree, or this function is called by our parent's onLayout, in which
// case our r-l and b-t are the size of our node.
if (!(getParent() instanceof YogaLayout) &&
Math.round(mYogaNode.getLayoutHeight()) != b-t &&
Math.round(mYogaNode.getLayoutWidth()) != r-l) {
if (!(getParent() instanceof YogaLayout)) {
createLayout(
MeasureSpec.makeMeasureSpec(r - l, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(b - t, MeasureSpec.EXACTLY));
@@ -340,7 +371,6 @@ public class YogaLayout extends ViewGroup {
if (widthMode == MeasureSpec.AT_MOST) {
mYogaNode.setMaxWidth(widthSize);
}
mYogaNode.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
}
@@ -379,192 +409,227 @@ public class YogaLayout extends ViewGroup {
}
}
for (int i = 0; i < layoutParameters.attributes.size(); i++) {
final int attribute = layoutParameters.attributes.keyAt(i);
final float value = layoutParameters.attributes.valueAt(i);
for (int i = 0; i < layoutParameters.numericAttributes.size(); i++) {
final int attribute = layoutParameters.numericAttributes.keyAt(i);
final float value = layoutParameters.numericAttributes.valueAt(i);
if (attribute == R.styleable.yoga_align_content) {
if (attribute == R.styleable.yoga_yg_alignContent) {
node.setAlignContent(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_align_items) {
} else if (attribute == R.styleable.yoga_yg_alignItems) {
node.setAlignItems(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_align_self) {
} else if (attribute == R.styleable.yoga_yg_alignSelf) {
node.setAlignSelf(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_aspect_ratio) {
} else if (attribute == R.styleable.yoga_yg_aspectRatio) {
node.setAspectRatio(value);
} else if (attribute == R.styleable.yoga_border_left) {
} else if (attribute == R.styleable.yoga_yg_borderLeft) {
node.setBorder(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_border_top) {
} else if (attribute == R.styleable.yoga_yg_borderTop) {
node.setBorder(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_border_right) {
} else if (attribute == R.styleable.yoga_yg_borderRight) {
node.setBorder(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_border_bottom) {
} else if (attribute == R.styleable.yoga_yg_borderBottom) {
node.setBorder(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_border_start) {
} else if (attribute == R.styleable.yoga_yg_borderStart) {
node.setBorder(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_border_end) {
} else if (attribute == R.styleable.yoga_yg_borderEnd) {
node.setBorder(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_border_horizontal) {
} else if (attribute == R.styleable.yoga_yg_borderHorizontal) {
node.setBorder(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_border_vertical) {
} else if (attribute == R.styleable.yoga_yg_borderVertical) {
node.setBorder(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_border_all) {
} else if (attribute == R.styleable.yoga_yg_borderAll) {
node.setBorder(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_direction) {
} else if (attribute == R.styleable.yoga_yg_direction) {
node.setDirection(YogaDirection.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_flex) {
} else if (attribute == R.styleable.yoga_yg_display) {
node.setDisplay(YogaDisplay.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_yg_flex) {
node.setFlex(value);
} else if (attribute == R.styleable.yoga_flex_basis) {
} else if (attribute == R.styleable.yoga_yg_flexBasis) {
node.setFlexBasis(value);
} else if (attribute == R.styleable.yoga_flex_basis_percent) {
node.setFlexBasisPercent(value);
} else if (attribute == R.styleable.yoga_flex_direction) {
} else if (attribute == R.styleable.yoga_yg_flexDirection) {
node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_flex_grow) {
} else if (attribute == R.styleable.yoga_yg_flexGrow) {
node.setFlexGrow(value);
} else if (attribute == R.styleable.yoga_flex_shrink) {
} else if (attribute == R.styleable.yoga_yg_flexShrink) {
node.setFlexShrink(value);
} else if (attribute == R.styleable.yoga_height) {
} else if (attribute == R.styleable.yoga_yg_height) {
node.setHeight(value);
} else if (attribute == R.styleable.yoga_height_percent) {
node.setHeightPercent(value);
} else if (attribute == R.styleable.yoga_margin_left) {
} else if (attribute == R.styleable.yoga_yg_marginLeft) {
node.setMargin(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_justify_content) {
} else if (attribute == R.styleable.yoga_yg_justifyContent) {
node.setJustifyContent(YogaJustify.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_margin_top) {
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMargin(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_margin_right) {
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMargin(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_margin_bottom) {
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMargin(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_margin_start) {
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMargin(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_margin_end) {
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMargin(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_margin_horizontal) {
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMargin(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_margin_vertical) {
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMargin(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_margin_all) {
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMargin(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_margin_percent_left) {
node.setMarginPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_margin_percent_top) {
node.setMarginPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_margin_percent_right) {
node.setMarginPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_margin_percent_bottom) {
node.setMarginPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_margin_percent_start) {
node.setMarginPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_margin_percent_end) {
node.setMarginPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_margin_percent_horizontal) {
node.setMarginPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_margin_percent_vertical) {
node.setMarginPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_margin_percent_all) {
node.setMarginPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_max_height) {
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
node.setMaxHeight(value);
} else if (attribute == R.styleable.yoga_max_height_percent) {
node.setMaxHeightPercent(value);
} else if (attribute == R.styleable.yoga_max_width) {
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
node.setMaxWidth(value);
} else if (attribute == R.styleable.yoga_max_width_percent) {
node.setMaxWidthPercent(value);
} else if (attribute == R.styleable.yoga_min_height) {
} else if (attribute == R.styleable.yoga_yg_minHeight) {
node.setMinHeight(value);
} else if (attribute == R.styleable.yoga_min_height_percent) {
node.setMinHeightPercent(value);
} else if (attribute == R.styleable.yoga_min_width) {
} else if (attribute == R.styleable.yoga_yg_minWidth) {
node.setMinWidth(value);
} else if (attribute == R.styleable.yoga_min_width_percent) {
node.setMinWidthPercent(value);
} else if (attribute == R.styleable.yoga_overflow) {
} else if (attribute == R.styleable.yoga_yg_overflow) {
node.setOverflow(YogaOverflow.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_padding_left) {
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
node.setPadding(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_padding_top) {
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
node.setPadding(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_padding_right) {
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
node.setPadding(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_padding_bottom) {
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
node.setPadding(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_padding_start) {
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
node.setPadding(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_padding_end) {
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
node.setPadding(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_padding_horizontal) {
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
node.setPadding(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_padding_vertical) {
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
node.setPadding(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_padding_all) {
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
node.setPadding(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_padding_percent_left) {
node.setPaddingPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_padding_percent_top) {
node.setPaddingPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_padding_percent_right) {
node.setPaddingPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_padding_percent_bottom) {
node.setPaddingPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_padding_percent_start) {
node.setPaddingPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_padding_percent_end) {
node.setPaddingPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_padding_percent_horizontal) {
node.setPaddingPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_padding_percent_vertical) {
node.setPaddingPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_padding_percent_all) {
node.setPaddingPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_left) {
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
node.setPosition(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_position_top) {
} else if (attribute == R.styleable.yoga_yg_positionTop) {
node.setPosition(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_position_right) {
} else if (attribute == R.styleable.yoga_yg_positionRight) {
node.setPosition(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_position_bottom) {
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
node.setPosition(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_position_start) {
} else if (attribute == R.styleable.yoga_yg_positionStart) {
node.setPosition(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_position_end) {
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
node.setPosition(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_position_horizontal) {
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
node.setPosition(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_position_vertical) {
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
node.setPosition(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_position_all) {
} else if (attribute == R.styleable.yoga_yg_positionAll) {
node.setPosition(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_percent_left) {
node.setPositionPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_position_percent_top) {
node.setPositionPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_position_percent_right) {
node.setPositionPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_position_percent_bottom) {
node.setPositionPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_position_percent_start) {
node.setPositionPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_position_percent_end) {
node.setPositionPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_position_percent_horizontal) {
node.setPositionPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_position_percent_vertical) {
node.setPositionPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_position_percent_all) {
node.setPositionPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_type) {
} else if (attribute == R.styleable.yoga_yg_positionType) {
node.setPositionType(YogaPositionType.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_width) {
} else if (attribute == R.styleable.yoga_yg_width) {
node.setWidth(value);
} else if (attribute == R.styleable.yoga_width_percent) {
node.setWidthPercent(value);
} else if (attribute == R.styleable.yoga_wrap) {
} else if (attribute == R.styleable.yoga_yg_wrap) {
node.setWrap(YogaWrap.fromInt(Math.round(value)));
}
}
for (int i = 0; i < layoutParameters.stringAttributes.size(); i++) {
final int attribute = layoutParameters.stringAttributes.keyAt(i);
final String value = layoutParameters.stringAttributes.valueAt(i);
if (value.equals("auto")) {
if (attribute == R.styleable.yoga_yg_marginLeft) {
node.setMarginAuto(YogaEdge.LEFT);
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMarginAuto(YogaEdge.TOP);
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMarginAuto(YogaEdge.RIGHT);
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMarginAuto(YogaEdge.BOTTOM);
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMarginAuto(YogaEdge.START);
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMarginAuto(YogaEdge.END);
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMarginAuto(YogaEdge.HORIZONTAL);
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMarginAuto(YogaEdge.VERTICAL);
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMarginAuto(YogaEdge.ALL);
}
}
if (value.endsWith("%")) {
final float numericValue = Float.parseFloat(value.substring(0, value.length()-1));
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_marginLeft) {
node.setMarginPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginTop) {
node.setMarginPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginRight) {
node.setMarginPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
node.setMarginPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginStart) {
node.setMarginPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
node.setMarginPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
node.setMarginPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
node.setMarginPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_marginAll) {
node.setMarginPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
node.setMaxHeightPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
node.setMaxWidthPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_minHeight) {
node.setMinHeightPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_minWidth) {
node.setMinWidthPercent(numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
node.setPaddingPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
node.setPaddingPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
node.setPaddingPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
node.setPaddingPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
node.setPaddingPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
node.setPaddingPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
node.setPaddingPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
node.setPaddingPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
node.setPaddingPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
node.setPositionPercent(YogaEdge.LEFT, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionTop) {
node.setPositionPercent(YogaEdge.TOP, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionRight) {
node.setPositionPercent(YogaEdge.RIGHT, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
node.setPositionPercent(YogaEdge.BOTTOM, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionStart) {
node.setPositionPercent(YogaEdge.START, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
node.setPositionPercent(YogaEdge.END, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
node.setPositionPercent(YogaEdge.HORIZONTAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
node.setPositionPercent(YogaEdge.VERTICAL, numericValue);
} else if (attribute == R.styleable.yoga_yg_positionAll) {
node.setPositionPercent(YogaEdge.ALL, numericValue);
} else if (attribute == R.styleable.yoga_yg_width) {
node.setWidthPercent(numericValue);
}
}
}
}
@Override
@@ -594,18 +659,25 @@ public class YogaLayout extends ViewGroup {
*
* <p>
* This is actually mostly a wrapper around a {@code SparseArray} that holds a mapping between
* styleable id's ({@code R.styleable.yoga_*}) and the float of their values. In cases where the
* value is an enum or an integer, they should first be cast to int (with rounding) before using.
* styleable id's ({@code R.styleable.yoga_yg_*}) and the float of their values. In cases where
* the value is an enum or an integer, they should first be cast to int (with rounding) before
* using.
*/
public static class LayoutParams extends ViewGroup.LayoutParams {
/**
* A mapping from attribute keys ({@code R.styleable.yoga_*}) to the float of their values.
* A mapping from attribute keys ({@code R.styleable.yoga_yg_*}) to the float of their values.
* For attributes like position_percent_left (float), this is the native type. For attributes
* like align_self (enums), the integer enum value is cast (rounding is used on the other side
* to prevent precision errors). Dimension attributes are stored as float pixels.
*/
SparseArray<Float> attributes;
SparseArray<Float> numericAttributes;
/**
* A mapping from attribute keys ({@code R.styleable.yoga_yg_*}) with string values to those
* strings. This is used for values such as "auto".
*/
SparseArray<String> stringAttributes;
/**
* Constructs a set of layout params from a source set. In the case that the source set is
@@ -617,16 +689,18 @@ public class YogaLayout extends ViewGroup {
public LayoutParams(ViewGroup.LayoutParams source) {
super(source);
if (source instanceof LayoutParams) {
attributes = ((LayoutParams) source).attributes.clone();
numericAttributes = ((LayoutParams) source).numericAttributes.clone();
stringAttributes = ((LayoutParams) source).stringAttributes.clone();
} else {
attributes = new SparseArray<>();
numericAttributes = new SparseArray<>();
stringAttributes = new SparseArray<>();
// Negative values include MATCH_PARENT and WRAP_CONTENT
if (source.width >= 0) {
attributes.put(R.styleable.yoga_width, (float) width);
numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
}
if (source.height >= 0) {
attributes.put(R.styleable.yoga_height, (float) height);
numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
}
}
}
@@ -645,13 +719,14 @@ public class YogaLayout extends ViewGroup {
*/
public LayoutParams(int width, int height) {
super(width, height);
attributes = new SparseArray<>();
numericAttributes = new SparseArray<>();
stringAttributes = new SparseArray<>();
// Negative values include MATCH_PARENT and WRAP_CONTENT
if (width >= 0) {
attributes.put(R.styleable.yoga_width, (float) width);
numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
}
if (height >= 0) {
attributes.put(R.styleable.yoga_height, (float) height);
numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
}
}
@@ -664,15 +739,16 @@ public class YogaLayout extends ViewGroup {
*/
public LayoutParams(Context context, AttributeSet attrs) {
super(context, attrs);
attributes = new SparseArray<>();
numericAttributes = new SparseArray<>();
stringAttributes = new SparseArray<>();
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.yoga);
// Negative values include MATCH_PARENT and WRAP_CONTENT
if (width >= 0) {
attributes.put(R.styleable.yoga_width, (float) width);
numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
}
if (height >= 0) {
attributes.put(R.styleable.yoga_height, (float) height);
numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
}
final int attributeCount = a.getIndexCount();
@@ -682,11 +758,13 @@ public class YogaLayout extends ViewGroup {
a.getValue(attribute, val);
if (val.type == TypedValue.TYPE_DIMENSION) {
attributes.put(
numericAttributes.put(
attribute,
(float) a.getDimensionPixelSize(attribute, 0));
} else if (val.type == TypedValue.TYPE_STRING) {
stringAttributes.put(attribute, a.getString(attribute));
} else {
attributes.put(attribute, a.getFloat(attribute, 0));
numericAttributes.put(attribute, a.getFloat(attribute, 0));
}
}
a.recycle();
@@ -711,7 +789,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

@@ -12,7 +12,7 @@
<resources>
<declare-styleable name="yoga">
<attr name="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 +21,7 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="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 +30,7 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="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,46 +39,47 @@
<enum name="baseline" value="5"/>
</attr>
<attr name="aspect_ratio" format="float"/>
<attr name="yg_aspectRatio" format="float"/>
<attr name="border_left" format="dimension"/>
<attr name="border_top" format="dimension"/>
<attr name="border_right" format="dimension"/>
<attr name="border_bottom" format="dimension"/>
<attr name="border_start" format="dimension"/>
<attr name="border_end" format="dimension"/>
<attr name="border_horizontal" format="dimension"/>
<attr name="border_vertical" format="dimension"/>
<attr name="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="direction" format="enum">
<attr name="yg_direction" format="enum">
<enum name="inherit" value="0"/>
<enum name="ltr" value="1"/>
<enum name="rtl" value="2"/>
</attr>
<attr name="flex" format="float"/>
<attr name="yg_display" format="enum">
<enum name="flex" value="0"/>
<enum name="none" value="1"/>
</attr>
<attr name="flex_basis" format="float"/>
<attr name="yg_flex" format="float"/>
<attr name="flex_basis_percent" format="float"/>
<attr name="yg_flexBasis" format="float|string"/>
<attr name="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="flex_grow" format="float"/>
<attr name="yg_flexGrow" format="float"/>
<attr name="flex_shrink" format="float"/>
<attr name="yg_flexShrink" format="float"/>
<attr name="height" format="dimension"/>
<attr name="yg_height" format="dimension|string"/>
<attr name="height_percent" format="float"/>
<attr name="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"/>
@@ -86,98 +87,58 @@
<enum name="space_around" value="4"/>
</attr>
<attr name="margin_left" format="dimension"/>
<attr name="margin_top" format="dimension"/>
<attr name="margin_right" format="dimension"/>
<attr name="margin_bottom" format="dimension"/>
<attr name="margin_start" format="dimension"/>
<attr name="margin_end" format="dimension"/>
<attr name="margin_horizontal" format="dimension"/>
<attr name="margin_vertical" format="dimension"/>
<attr name="margin_all" format="dimension"/>
<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="margin_percent_left" format="dimension"/>
<attr name="margin_percent_top" format="dimension"/>
<attr name="margin_percent_right" format="dimension"/>
<attr name="margin_percent_bottom" format="dimension"/>
<attr name="margin_percent_start" format="dimension"/>
<attr name="margin_percent_end" format="dimension"/>
<attr name="margin_percent_horizontal" format="dimension"/>
<attr name="margin_percent_vertical" format="dimension"/>
<attr name="margin_percent_all" format="dimension"/>
<attr name="yg_maxHeight" format="dimension|string"/>
<attr name="max_height" format="dimension"/>
<attr name="yg_maxWidth" format="dimension|string"/>
<attr name="max_height_percent" format="float"/>
<attr name="yg_minHeight" format="dimension|string"/>
<attr name="max_width" format="dimension"/>
<attr name="yg_minWidth" format="dimension|string"/>
<attr name="max_width_percent" format="float"/>
<attr name="min_height" format="dimension"/>
<attr name="min_height_percent" format="float"/>
<attr name="min_width" format="dimension"/>
<attr name="min_width_percent" format="float"/>
<attr name="overflow" format="enum">
<attr name="yg_overflow" format="enum">
<enum name="visible" value="0"/>
<enum name="hidden" value="1"/>
<enum name="scroll" value="2"/>
</attr>
<attr name="padding_left" format="dimension"/>
<attr name="padding_top" format="dimension"/>
<attr name="padding_right" format="dimension"/>
<attr name="padding_bottom" format="dimension"/>
<attr name="padding_start" format="dimension"/>
<attr name="padding_end" format="dimension"/>
<attr name="padding_horizontal" format="dimension"/>
<attr name="padding_vertical" format="dimension"/>
<attr name="padding_all" format="dimension"/>
<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="padding_percent_left" format="float"/>
<attr name="padding_percent_top" format="float"/>
<attr name="padding_percent_right" format="float"/>
<attr name="padding_percent_bottom" format="float"/>
<attr name="padding_percent_start" format="float"/>
<attr name="padding_percent_end" format="float"/>
<attr name="padding_percent_horizontal" format="float"/>
<attr name="padding_percent_vertical" format="float"/>
<attr name="padding_percent_all" format="float"/>
<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="position_left" format="dimension"/>
<attr name="position_top" format="dimension"/>
<attr name="position_right" format="dimension"/>
<attr name="position_bottom" format="dimension"/>
<attr name="position_start" format="dimension"/>
<attr name="position_end" format="dimension"/>
<attr name="position_horizontal" format="dimension"/>
<attr name="position_vertical" format="dimension"/>
<attr name="position_all" format="dimension"/>
<attr name="position_percent_left" format="float"/>
<attr name="position_percent_top" format="float"/>
<attr name="position_percent_right" format="float"/>
<attr name="position_percent_bottom" format="float"/>
<attr name="position_percent_start" format="float"/>
<attr name="position_percent_end" format="float"/>
<attr name="position_percent_horizontal" format="float"/>
<attr name="position_percent_vertical" format="float"/>
<attr name="position_percent_all" format="float"/>
<attr name="position_type" format="enum">
<attr name="yg_positionType" format="enum">
<enum name="relative" value="0"/>
<enum name="absolute" value="1"/>
</attr>
<attr name="width" format="dimension"/>
<attr name="yg_width" format="dimension|string"/>
<attr name="width_percent" format="float"/>
<attr name="wrap" format="enum">
<attr name="yg_wrap" format="enum">
<enum name="no_wrap" value="0"/>
<enum name="wrap" value="1"/>
</attr>

View File

@@ -5,23 +5,23 @@
# 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')
include_defs("//YOGA_DEFS")
cxx_binary(
name = 'benchmark',
srcs = glob(['*.c']),
headers = subdir_glob([('', '*.h')]),
header_namespace = '',
compiler_flags = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
'-std=c11',
],
deps = [
yoga_dep(':yoga'),
],
visibility = ['PUBLIC'],
name = "benchmark",
srcs = glob(["*.c"]),
compiler_flags = [
"-fno-omit-frame-pointer",
"-fexceptions",
"-Wall",
"-Werror",
"-O3",
"-std=c11",
],
header_namespace = "",
headers = subdir_glob([("", "*.h")]),
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),
],
)

View File

@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.3.1'
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'
@@ -17,15 +17,19 @@ buildscript {
allprojects {
repositories {
flatDir {
dirs "${rootDir}/lib/jsr-305"
dirs "${rootDir}/lib/soloader"
dirs "${rootDir}/lib/appcompat"
dirs "${rootDir}/lib/android-support"
}
jcenter()
}
}
ext {
minSdkVersion = 15
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = '25.0.2'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -5,33 +5,33 @@
# 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')
include_defs("//YOGA_DEFS")
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
csharp_library(
name = 'yogalibnet46',
dll_name = 'Facebook.Yoga.dll',
framework_ver = 'net46',
srcs = glob(['**/*.cs']),
name = "yogalibnet46",
srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll",
framework_ver = "net46",
)
csharp_library(
name = 'yogalibnet45',
dll_name = 'Facebook.Yoga.dll',
framework_ver = 'net45',
srcs = glob(['**/*.cs']),
name = "yogalibnet45",
srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll",
framework_ver = "net45",
)
cxx_library(
name = 'yoganet',
soname = 'libyoga.$(ext)',
srcs = glob(['Yoga/YGInterop.cpp']),
compiler_flags = COMPILER_FLAGS,
link_style = 'static',
link_whole = True,
deps = [yoga_dep(':yoga')],
visibility = ['PUBLIC'],
name = "yoganet",
srcs = glob(["Yoga/YGInterop.cpp"]),
compiler_flags = COMPILER_FLAGS,
link_style = "static",
link_whole = True,
soname = "libyoga.$(ext)",
visibility = ["PUBLIC"],
deps = [yoga_dep(":yoga")],
)
if isdir('/Applications/Xcode.app'):

View File

@@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Native.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

@@ -12,6 +12,12 @@ using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
#if WINDOWS_UWP_ARM
using YogaValueType = IntPtr;
#else
using YogaValueType = YogaValue;
#endif
internal static class Native
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
@@ -22,7 +28,7 @@ namespace Facebook.Yoga
internal class YGNodeHandle : SafeHandle
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
private GCHandle _managed;
#endif
@@ -40,27 +46,37 @@ namespace Facebook.Yoga
protected override bool ReleaseHandle()
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
if (_managed.IsAllocated)
{
_managed.Free();
}
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
ReleaseManaged();
#endif
Native.YGNodeFree(this.handle);
GC.KeepAlive(this);
return true;
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
public void SetContext(YogaNode node)
{
if (!_managed.IsAllocated)
{
#if ENABLE_IL2CPP
// Weak causes 'GCHandle value belongs to a different domain' error
_managed = GCHandle.Alloc(node);
#else
_managed = GCHandle.Alloc(node, GCHandleType.Weak);
#endif
Native.YGNodeSetContext(this.handle, GCHandle.ToIntPtr(_managed));
}
}
public void ReleaseManaged()
{
if (_managed.IsAllocated)
{
_managed.Free();
}
}
public static YogaNode GetManaged(IntPtr ygNodePtr)
{
var node =
@@ -75,6 +91,28 @@ namespace Facebook.Yoga
#endif
}
internal class YGConfigHandle : SafeHandle
{
private YGConfigHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
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);
@@ -82,24 +120,51 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGNodeHandle YGNodeNew();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGNodeHandle YGNodeNewWithConfig(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeFree(IntPtr node);
[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 YGConfigNew();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigFree(IntPtr node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGSetExperimentalFeatureEnabled(
public static extern int YGConfigGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetExperimentalFeatureEnabled(
YGConfigHandle config,
YogaExperimentalFeature feature,
bool enabled);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGIsExperimentalFeatureEnabled(
public static extern bool YGConfigIsExperimentalFeatureEnabled(
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,
@@ -129,7 +194,7 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode);
#region YG_NODE_PROPERTY
#region YG_NODE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetMeasureFunc(
@@ -150,9 +215,9 @@ namespace Facebook.Yoga
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node);
#endregion
#endregion
#region YG_NODE_STYLE_PROPERTY
#region YG_NODE_STYLE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction);
@@ -239,7 +304,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
@@ -251,19 +316,19 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
@@ -272,7 +337,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
@@ -281,7 +346,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
@@ -290,7 +355,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
@@ -299,7 +364,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -307,9 +372,9 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
#endregion
#endregion
#region YG_NODE_STYLE_EDGE_PROPERTY
#region YG_NODE_STYLE_EDGE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
@@ -318,7 +383,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
@@ -330,7 +395,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
@@ -339,7 +404,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
@@ -347,9 +412,9 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge);
#endregion
#endregion
#region YG_NODE_LAYOUT_PROPERTY
#region YG_NODE_LAYOUT_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetLeft(YGNodeHandle node);
@@ -378,11 +443,11 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node);
#endregion
#endregion
#region IOS
#region AOT
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr YGNodeGetContext(IntPtr node);
@@ -390,6 +455,6 @@ namespace Facebook.Yoga
public static extern void YGNodeSetContext(IntPtr node, IntPtr managed);
#endif
#endregion
#endregion
}
}

View File

@@ -0,0 +1,72 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
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 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();
}
}
}

View File

@@ -13,5 +13,6 @@ namespace Facebook.Yoga
{
Rounding,
WebFlexBasis,
MinFlexFix,
}
}

View File

@@ -13,6 +13,9 @@ using System.Runtime.InteropServices;
#if __IOS__
using ObjCRuntime;
#endif
#if ENABLE_IL2CPP
using AOT;
#endif
namespace Facebook.Yoga
{
@@ -26,7 +29,7 @@ namespace Facebook.Yoga
public static Func Logger = null;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(Func))]
#endif
public static void LoggerInternal(YogaLogLevel level, string message)

View File

@@ -7,8 +7,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
namespace Facebook.Yoga
{
public partial class YogaNode
@@ -17,7 +15,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
}
set
@@ -30,7 +28,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
}
set
@@ -43,7 +41,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
}
set
@@ -56,7 +54,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
}
set
@@ -69,7 +67,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
}
set
@@ -82,7 +80,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
}
set
@@ -107,7 +105,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
}
set
@@ -120,7 +118,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
}
set
@@ -133,7 +131,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
}
set
@@ -146,7 +144,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
}
set
@@ -159,7 +157,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
}
set
@@ -172,7 +170,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
}
set
@@ -185,7 +183,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
}
set
@@ -198,7 +196,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
}
set
@@ -211,7 +209,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
}
set
@@ -240,7 +238,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
}
set
@@ -253,7 +251,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
}
set
@@ -266,7 +264,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
}
set
@@ -279,7 +277,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
}
set
@@ -292,7 +290,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
}
set
@@ -305,7 +303,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
}
set
@@ -318,7 +316,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
}
set
@@ -331,7 +329,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
}
set
@@ -344,7 +342,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
}
set

View File

@@ -12,26 +12,30 @@ using System.Collections;
using System.Collections.Generic;
using System.Text;
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
using System.Runtime.InteropServices;
#endif
#if __IOS__
using ObjCRuntime;
#endif
#if ENABLE_IL2CPP
using AOT;
#endif
namespace Facebook.Yoga
{
public partial class YogaNode : IEnumerable<YogaNode>
{
private Native.YGNodeHandle _ygNode;
private readonly Native.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;
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
private static YogaMeasureFunc _managedMeasure;
private static YogaBaselineFunc _managedBaseline;
#else
private YogaMeasureFunc _managedMeasure;
private YogaBaselineFunc _managedBaseline;
@@ -48,8 +52,27 @@ namespace Facebook.Yoga
}
}
public YogaNode(YogaConfig config)
{
YogaLogger.Initialize();
if (config != null)
{
_config = config;
_ygNode = Native.YGNodeNewWithConfig(_config.Handle);
}
else
{
_ygNode = Native.YGNodeNew();
}
if (_ygNode.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
}
public YogaNode(YogaNode srcNode)
: this()
: this(srcNode._config)
{
CopyStyle(srcNode);
}
@@ -61,6 +84,9 @@ namespace Facebook.Yoga
_data = null;
Native.YGNodeReset(_ygNode);
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_ygNode.ReleaseManaged();
#endif
}
public bool IsDirty
@@ -273,7 +299,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetFlexBasis(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode));
}
set
@@ -297,7 +323,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetWidth(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode));
}
set
@@ -321,7 +347,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetHeight(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode));
}
set
@@ -345,7 +371,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMaxWidth(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode));
}
set
@@ -365,7 +391,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMaxHeight(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode));
}
set
@@ -385,7 +411,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMinWidth(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode));
}
set
@@ -405,7 +431,7 @@ namespace Facebook.Yoga
{
get
{
return Native.YGNodeStyleGetMinHeight(_ygNode);
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode));
}
set
@@ -421,7 +447,7 @@ namespace Facebook.Yoga
}
}
public float StyleAspectRatio
public float AspectRatio
{
get
{
@@ -550,6 +576,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)
@@ -571,12 +611,17 @@ namespace Facebook.Yoga
_measureFunction = measureFunction;
if (measureFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_managedMeasure = MeasureInternalAOT;
_ygNode.SetContext(this);
#else
_managedMeasure = MeasureInternal;
#endif
}
else
{
_managedMeasure = null;
}
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
}
@@ -585,12 +630,17 @@ namespace Facebook.Yoga
_baselineFunction = baselineFunction;
if (baselineFunction != null)
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
_managedBaseline = BaselineInternalAOT;
_ygNode.SetContext(this);
#else
_managedBaseline = BaselineInternal;
#endif
}
else
{
_managedBaseline = null;
}
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
}
@@ -603,9 +653,9 @@ namespace Facebook.Yoga
Native.YGNodeStyleGetDirection(_ygNode));
}
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
private static YogaSize MeasureInternalIOS(
private static YogaSize MeasureInternalAOT(
IntPtr ygNodePtr,
float width,
YogaMeasureMode widthMode,
@@ -632,9 +682,9 @@ namespace Facebook.Yoga
return _measureFunction(this, 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(
private static float BaselineInternalAOT(
IntPtr ygNodePtr,
float width,
float height)
@@ -681,17 +731,5 @@ namespace Facebook.Yoga
{
return Native.YGNodeGetInstanceCount();
}
public static void SetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled)
{
Native.YGSetExperimentalFeatureEnabled(feature, enabled);
}
public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
{
return Native.YGIsExperimentalFeatureEnabled(feature);
}
}
}

View File

@@ -9,6 +9,7 @@
namespace Facebook.Yoga
{
[System.Flags]
public enum YogaPrintOptions
{
Layout = 1,

View File

@@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
@@ -92,5 +93,17 @@ namespace Facebook.Yoga
{
return Point(pointValue);
}
#if WINDOWS_UWP_ARM
internal static YogaValue MarshalValue(IntPtr ptr)
{
return Marshal.PtrToStructure<YogaValue>(ptr);
}
#else
internal static YogaValue MarshalValue(YogaValue value)
{
return value;
}
#endif
}
}

View File

@@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5289E508
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native", "Native", "{51A8E803-C084-431F-9130-F277481C2BB2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NETStandard", "NETStandard", "{DCF7899B-A487-49C0-BCDE-DC088B6750C2}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{1048DB7D-9B95-48CA-B43E-D9C35AB1DCD4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga.uwp", "..\Yoga\Yoga.Universal.vcxproj", "{2EACF721-73B5-46AE-9775-4A8674D05A9C}"
EndProject
@@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{39A2FF
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared", "..\Facebook.Yoga\Facebook.Yoga.Shared.shproj", "{91C42D32-291D-4B72-90B4-551663D60B8B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga", "Facebook.Yoga\Facebook.Yoga.csproj", "{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal", "Facebook.Yoga.Universal\Facebook.Yoga.Universal.csproj", "{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}"
ProjectSection(ProjectDependencies) = postProject
{2EACF721-73B5-46AE-9775-4A8674D05A9C} = {2EACF721-73B5-46AE-9775-4A8674D05A9C}
EndProjectSection
@@ -26,7 +26,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tes
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}*SharedItemsImports = 4
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{d6477ad6-9edd-4eba-8c60-cd31f77c52c6}*SharedItemsImports = 4
..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{4edc82d9-a201-4831-8fe0-98f468f8e4ae}*SharedItemsImports = 13
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
EndGlobalSection
@@ -55,22 +55,21 @@ Global
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x64.Build.0 = Release|x64
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x86.ActiveCfg = Release|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x86.Build.0 = Release|Win32
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|ARM.ActiveCfg = Debug|ARM
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|ARM.Build.0 = Debug|ARM
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x64.ActiveCfg = Debug|x64
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x64.Build.0 = Debug|x64
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x86.ActiveCfg = Debug|x86
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Debug|x86.Build.0 = Debug|x86
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|Any CPU.Build.0 = Release|Any CPU
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|ARM.ActiveCfg = Release|ARM
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|ARM.Build.0 = Release|ARM
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x64.ActiveCfg = Release|x64
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x64.Build.0 = Release|x64
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.ActiveCfg = Release|x86
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.Build.0 = Release|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.ActiveCfg = Debug|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.Build.0 = Debug|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.ActiveCfg = Debug|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.Build.0 = Debug|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.ActiveCfg = Debug|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.Build.0 = Debug|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.Build.0 = Release|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.ActiveCfg = Release|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.Build.0 = Release|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.ActiveCfg = Release|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.Build.0 = Release|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.ActiveCfg = Release|x86
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|Any CPU.ActiveCfg = Debug|x86
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|ARM.ActiveCfg = Debug|ARM
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Debug|ARM.Build.0 = Debug|ARM
@@ -98,7 +97,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{2EACF721-73B5-46AE-9775-4A8674D05A9C} = {51A8E803-C084-431F-9130-F277481C2BB2}
{91C42D32-291D-4B72-90B4-551663D60B8B} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC}
{3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD} = {DCF7899B-A487-49C0-BCDE-DC088B6750C2}
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6} = {1048DB7D-9B95-48CA-B43E-D9C35AB1DCD4}
{4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC}
{0C76D2FE-6767-44FE-B03D-21B2076BAA73} = {5289E508-8386-45A1-A12B-258A5899CD45}
EndGlobalSection

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Facebook.Yoga</RootNamespace>
<AssemblyName>Facebook.Yoga</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;WINDOWS_UWP_ARM</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP;WINDOWS_UWP_ARM</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\..\Facebook.Yoga\Facebook.Yoga.Shared.projitems" Label="Shared" />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,16 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}

View File

@@ -29,11 +29,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Desktop.Tests
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0C76D2FE-6767-44FE-B03D-21B2076BAA73}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{6669329B-017F-45B3-8611-53AFD065E45C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal", "Facebook.Yoga.Universal\Facebook.Yoga.Universal.csproj", "{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}*SharedItemsImports = 4
..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{4edc82d9-a201-4831-8fe0-98f468f8e4ae}*SharedItemsImports = 13
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{d6477ad6-9edd-4eba-8c60-cd31f77c52c6}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -118,6 +123,22 @@ Global
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|ARM.ActiveCfg = Release|ARM
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x64.ActiveCfg = Release|x64
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x86.ActiveCfg = Release|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.ActiveCfg = Debug|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.Build.0 = Debug|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.ActiveCfg = Debug|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.Build.0 = Debug|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.ActiveCfg = Debug|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.Build.0 = Debug|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.Build.0 = Release|Any CPU
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.ActiveCfg = Release|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.Build.0 = Release|ARM
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.ActiveCfg = Release|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.Build.0 = Release|x64
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.ActiveCfg = Release|x86
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -130,5 +151,6 @@ Global
{4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC}
{AC23F444-5545-4196-8B9F-5C1F6B3E7FB3} = {5289E508-8386-45A1-A12B-258A5899CD45}
{0C76D2FE-6767-44FE-B03D-21B2076BAA73} = {5289E508-8386-45A1-A12B-258A5899CD45}
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6} = {6669329B-017F-45B3-8611-53AFD065E45C}
EndGlobalSection
EndGlobal

View File

@@ -159,7 +159,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINARMDLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
@@ -210,7 +210,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINARMDLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAsWinRT>false</CompileAsWinRT>
@@ -243,6 +243,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\yoga\Yoga.h" />
<ClInclude Include="..\..\yoga\YGEnums.c" />
<ClInclude Include="..\..\yoga\YGMacros.h" />
<ClInclude Include="..\..\yoga\YGNodeList.h" />
<ClInclude Include="resource.h" />
@@ -252,6 +253,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\yoga\Yoga.c" />
<ClCompile Include="..\..\yoga\YGEnums.c" />
<ClCompile Include="..\..\yoga\YGNodeList.c" />
<ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp">

View File

@@ -228,6 +228,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\yoga\Yoga.h" />
<ClInclude Include="..\..\yoga\YGEnums.h" />
<ClInclude Include="..\..\yoga\YGMacros.h" />
<ClInclude Include="..\..\yoga\YGNodeList.h" />
<ClInclude Include="resource.h" />
@@ -237,6 +238,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\yoga\Yoga.c" />
<ClCompile Include="..\..\yoga\YGEnums.c" />
<ClCompile Include="..\..\yoga\YGNodeList.c" />
<ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp">

View File

@@ -1,4 +1,5 @@
#!/bin/sh
echo $ANDROID_SDK
if buck --version >/dev/null 2>&1; then true; else
echo "Building Buck!"
mkdir lib

View File

@@ -12,10 +12,6 @@
<description>A subset of CSS's flexbox layout algorithm and box model.</description>
<copyright>Copyright 2016 Facebook</copyright>
<tags>flexbox flex-box css layout css-layout yoga facebook native</tags>
<dependencies>
<group targetFramework=".NETStandard1.1" />
<group targetFramework="uap10.0" />
</dependencies>
</metadata>
<files>
<!-- build -->
@@ -28,7 +24,7 @@
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\netstandard"/>
<!-- UAP -->
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\uap10.0"/>
<file src="..\yoga_universal\bin\Release\Facebook.Yoga.dll" target="lib\uap10.0"/>
<!-- net45 -->
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\net45" />
@@ -44,24 +40,24 @@
<file src="..\yoga_android\bin\Release\Facebook.Yoga.dll" target="lib\MonoAndroid" />
<!-- runtimes -->
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win10-x86\lib\netstandard"/>
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win10-x86\lib\netstandard"/>
<file src="..\yoga_universal\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win10-x86\lib\netstandard1.0"/>
<file src="..\yoga_universal\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win10-x86\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win10-x64\lib\netstandard"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win10-x64\lib\netstandard"/>
<file src="..\yoga_universal\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win10-x64\lib\netstandard1.0"/>
<file src="..\yoga_universal\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win10-x64\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win10-arm\lib\netstandard"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win10-arm\lib\netstandard"/>
<file src="..\yoga_universal\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win10-arm\lib\netstandard1.0"/>
<file src="..\yoga_universal\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win10-arm\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win-x86\lib\netstandard"/>
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win-x86\lib\netstandard"/>
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win-x86\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win-x86\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win-x64\lib\netstandard"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win-x64\lib\netstandard"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win-x64\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win-x64\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win8-arm\lib\netstandard"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win8-arm\lib\netstandard"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win8-arm\lib\netstandard1.0"/>
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win8-arm\lib\netstandard1.0"/>
<!-- Native -->

View File

@@ -22,6 +22,7 @@
<Compile Include="$(MSBuildThisFileDirectory)YGMinMaxDimensionTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YGPaddingTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YGRoundingTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaConfigTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeSpacingTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeTest.cs" />
</ItemGroup>

View File

@@ -20,11 +20,13 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_width_height_start_top()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Start = 10;
root_child0.Top = 10;
@@ -61,11 +63,13 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_width_height_end_bottom()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.End = 10;
root_child0.Bottom = 10;
@@ -102,11 +106,13 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_start_top_end_bottom()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Start = 10;
root_child0.Top = 10;
@@ -143,11 +149,13 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_width_height_start_top_end_bottom()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Start = 10;
root_child0.Top = 10;
@@ -186,19 +194,21 @@ namespace Facebook.Yoga
[Test]
public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Overflow = YogaOverflow.Hidden;
root.Width = 50;
root.Height = 50;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Start = 0;
root_child0.Top = 0;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 100;
root_child0_child0.Height = 100;
root_child0.Insert(0, root_child0_child0);
@@ -242,7 +252,9 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_within_border()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.MarginLeft = 10;
root.MarginTop = 10;
root.MarginRight = 10;
@@ -258,7 +270,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Left = 0;
root_child0.Top = 0;
@@ -266,7 +278,7 @@ namespace Facebook.Yoga
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.PositionType = YogaPositionType.Absolute;
root_child1.Right = 0;
root_child1.Bottom = 0;
@@ -313,14 +325,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 60;
root_child0.Height = 40;
@@ -355,14 +369,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.FlexEnd;
root.AlignItems = YogaAlign.FlexEnd;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 60;
root_child0.Height = 40;
@@ -397,13 +413,15 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_justify_content_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 60;
root_child0.Height = 40;
@@ -438,13 +456,15 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 60;
root_child0.Height = 40;
@@ -479,12 +499,14 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_center_on_child_only()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.Center;
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 60;
@@ -520,14 +542,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_center_and_top_position()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Top = 10;
root_child0.Width = 60;
@@ -563,14 +587,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_center_and_bottom_position()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Bottom = 10;
root_child0.Width = 60;
@@ -606,14 +632,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_center_and_left_position()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Left = 5;
root_child0.Width = 60;
@@ -649,14 +677,16 @@ namespace Facebook.Yoga
[Test]
public void Test_absolute_layout_align_items_and_justify_content_center_and_right_position()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.FlexGrow = 1;
root.Width = 110;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Right = 5;
root_child0.Width = 60;
@@ -689,5 +719,31 @@ namespace Facebook.Yoga
Assert.AreEqual(40f, root_child0.LayoutHeight);
}
[Test]
public void Test_position_root_with_rtl_should_position_withoutdirection()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Left = 72;
root.Width = 52;
root.Height = 52;
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(72f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(72f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
}
}
}

View File

@@ -20,33 +20,35 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap;
root.Width = 130;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
@@ -120,30 +122,32 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_flex_start_without_height_on_children()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -216,36 +220,38 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_flex_start_with_flex()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 120;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 0.Percent();
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 0.Percent();
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.FlexGrow = 1;
root_child3.FlexShrink = 1;
root_child3.FlexBasis = 0.Percent();
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -318,33 +324,35 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
@@ -418,29 +426,31 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -513,34 +523,36 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_spacebetween()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.SpaceBetween;
root.Wrap = YogaWrap.Wrap;
root.Width = 130;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
@@ -614,34 +626,36 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_spacearound()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.SpaceAround;
root.Wrap = YogaWrap.Wrap;
root.Width = 140;
root.Height = 120;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 10;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 10;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root_child4.Height = 10;
root.Insert(4, root_child4);
@@ -715,30 +729,32 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -811,36 +827,38 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_children()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0_child0.FlexBasis = 0.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -923,36 +941,38 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_flex()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexShrink = 1;
root_child1.FlexBasis = 0.Percent();
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.FlexGrow = 1;
root_child3.FlexShrink = 1;
root_child3.FlexBasis = 0.Percent();
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1025,35 +1045,37 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_flex_no_shrink()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexShrink = 1;
root_child1.FlexBasis = 0.Percent();
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.FlexGrow = 1;
root_child3.FlexBasis = 0.Percent();
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1126,18 +1148,20 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_margin()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.MarginLeft = 10;
root_child1.MarginTop = 10;
root_child1.MarginRight = 10;
@@ -1145,11 +1169,11 @@ namespace Facebook.Yoga
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.MarginLeft = 10;
root_child3.MarginTop = 10;
root_child3.MarginRight = 10;
@@ -1157,7 +1181,7 @@ namespace Facebook.Yoga
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1230,18 +1254,20 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_padding()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.PaddingLeft = 10;
root_child1.PaddingTop = 10;
root_child1.PaddingRight = 10;
@@ -1249,11 +1275,11 @@ namespace Facebook.Yoga
root_child1.Width = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.PaddingLeft = 10;
root_child3.PaddingTop = 10;
root_child3.PaddingRight = 10;
@@ -1261,7 +1287,7 @@ namespace Facebook.Yoga
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1334,18 +1360,20 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_single_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -1388,31 +1416,33 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_fixed_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 60;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1485,31 +1515,33 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_max_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.MaxHeight = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1582,31 +1614,33 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_row_with_min_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.MinHeight = 80;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1679,38 +1713,40 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 150;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0_child0.FlexBasis = 0.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexShrink = 1;
root_child1.FlexBasis = 0.Percent();
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 50;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Height = 50;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Height = 50;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -1793,10 +1829,12 @@ namespace Facebook.Yoga
[Test]
public void Test_align_content_stretch_is_not_overriding_align_items()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignContent = YogaAlign.Stretch;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.AlignContent = YogaAlign.Stretch;
root_child0.AlignItems = YogaAlign.Center;
@@ -1804,7 +1842,7 @@ namespace Facebook.Yoga
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.AlignContent = YogaAlign.Stretch;
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;

View File

@@ -20,11 +20,13 @@ namespace Facebook.Yoga
[Test]
public void Test_align_items_stretch()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -57,12 +59,14 @@ namespace Facebook.Yoga
[Test]
public void Test_align_items_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -96,12 +100,14 @@ namespace Facebook.Yoga
[Test]
public void Test_align_items_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -135,12 +141,14 @@ namespace Facebook.Yoga
[Test]
public void Test_align_items_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexEnd;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -174,18 +182,20 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
@@ -229,23 +239,25 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
@@ -299,40 +311,42 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_multiline()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexDirection = YogaFlexDirection.Row;
root_child1.Wrap = YogaWrap.Wrap;
root_child1.Width = 50;
root_child1.Height = 25;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 25;
root_child1_child0.Height = 20;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = new YogaNode();
YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.Width = 25;
root_child1_child1.Height = 10;
root_child1.Insert(1, root_child1_child1);
YogaNode root_child1_child2 = new YogaNode();
YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.Width = 25;
root_child1_child2.Height = 20;
root_child1.Insert(2, root_child1_child2);
YogaNode root_child1_child3 = new YogaNode();
YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.Width = 25;
root_child1_child3.Height = 10;
root_child1.Insert(3, root_child1_child3);
@@ -416,41 +430,43 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_multiline_override()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexDirection = YogaFlexDirection.Row;
root_child1.Wrap = YogaWrap.Wrap;
root_child1.Width = 50;
root_child1.Height = 25;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 25;
root_child1_child0.Height = 20;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = new YogaNode();
YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.AlignSelf = YogaAlign.Baseline;
root_child1_child1.Width = 25;
root_child1_child1.Height = 10;
root_child1.Insert(1, root_child1_child1);
YogaNode root_child1_child2 = new YogaNode();
YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.Width = 25;
root_child1_child2.Height = 20;
root_child1.Insert(2, root_child1_child2);
YogaNode root_child1_child3 = new YogaNode();
YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.AlignSelf = YogaAlign.Baseline;
root_child1_child3.Width = 25;
root_child1_child3.Height = 10;
@@ -535,40 +551,42 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_multiline_no_override_on_secondline()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexDirection = YogaFlexDirection.Row;
root_child1.Wrap = YogaWrap.Wrap;
root_child1.Width = 50;
root_child1.Height = 25;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 25;
root_child1_child0.Height = 20;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = new YogaNode();
YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.Width = 25;
root_child1_child1.Height = 10;
root_child1.Insert(1, root_child1_child1);
YogaNode root_child1_child2 = new YogaNode();
YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.Width = 25;
root_child1_child2.Height = 20;
root_child1.Insert(2, root_child1_child2);
YogaNode root_child1_child3 = new YogaNode();
YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.AlignSelf = YogaAlign.Baseline;
root_child1_child3.Width = 25;
root_child1_child3.Height = 10;
@@ -653,24 +671,26 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_top()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Top = 10;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
@@ -724,24 +744,26 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_top2()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Top = 5;
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
@@ -795,28 +817,30 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_double_nested_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 50;
root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 15;
root_child1.Insert(0, root_child1_child0);
@@ -880,17 +904,19 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
@@ -934,13 +960,15 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_margin()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = 5;
root_child0.MarginTop = 5;
root_child0.MarginRight = 5;
@@ -949,12 +977,12 @@ namespace Facebook.Yoga
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.MarginLeft = 1;
root_child1_child0.MarginTop = 1;
root_child1_child0.MarginRight = 1;
@@ -1012,7 +1040,9 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_child_padding()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.PaddingLeft = 5;
@@ -1022,12 +1052,12 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.PaddingLeft = 5;
root_child1.PaddingTop = 5;
root_child1.PaddingRight = 5;
@@ -1036,7 +1066,7 @@ namespace Facebook.Yoga
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
@@ -1090,39 +1120,41 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_multiline()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 20;
root.Insert(2, root_child2);
YogaNode root_child2_child0 = new YogaNode();
YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.Width = 50;
root_child2_child0.Height = 10;
root_child2.Insert(0, root_child2_child0);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 50;
root.Insert(3, root_child3);
@@ -1206,38 +1238,40 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_multiline_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Baseline;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 20;
root_child1_child0.Height = 20;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 40;
root_child2.Height = 70;
root.Insert(2, root_child2);
YogaNode root_child2_child0 = new YogaNode();
YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.Width = 10;
root_child2_child0.Height = 10;
root_child2.Insert(0, root_child2_child0);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 20;
root.Insert(3, root_child3);
@@ -1321,38 +1355,40 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_multiline_column2()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Baseline;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 20;
root_child1_child0.Height = 20;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 40;
root_child2.Height = 70;
root.Insert(2, root_child2);
YogaNode root_child2_child0 = new YogaNode();
YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.Width = 10;
root_child2_child0.Height = 10;
root_child2.Insert(0, root_child2_child0);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 20;
root.Insert(3, root_child3);
@@ -1436,39 +1472,41 @@ namespace Facebook.Yoga
[Test]
public void Test_align_baseline_multiline_row_and_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 20;
root.Insert(2, root_child2);
YogaNode root_child2_child0 = new YogaNode();
YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.Width = 50;
root_child2_child0.Height = 10;
root_child2.Insert(0, root_child2_child0);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 50;
root_child3.Height = 20;
root.Insert(3, root_child3);
@@ -1549,5 +1587,233 @@ namespace Facebook.Yoga
Assert.AreEqual(20f, root_child3.LayoutHeight);
}
[Test]
public void Test_align_items_center_child_with_margin_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignItems = YogaAlign.Center;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.MarginLeft = 10;
root_child0_child0.MarginRight = 10;
root_child0_child0.Width = 52;
root_child0_child0.Height = 52;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
}
[Test]
public void Test_align_items_flex_end_child_with_margin_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignItems = YogaAlign.FlexEnd;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.MarginLeft = 10;
root_child0_child0.MarginRight = 10;
root_child0_child0.Width = 52;
root_child0_child0.Height = 52;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
}
[Test]
public void Test_align_items_center_child_without_margin_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignItems = YogaAlign.Center;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 72;
root_child0_child0.Height = 72;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
}
[Test]
public void Test_align_items_flex_end_child_without_margin_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignItems = YogaAlign.FlexEnd;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 72;
root_child0_child0.Height = 72;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-10f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
}
}
}

View File

@@ -20,11 +20,13 @@ namespace Facebook.Yoga
[Test]
public void Test_align_self_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.Center;
root_child0.Width = 10;
root_child0.Height = 10;
@@ -59,11 +61,13 @@ namespace Facebook.Yoga
[Test]
public void Test_align_self_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10;
root_child0.Height = 10;
@@ -98,11 +102,13 @@ namespace Facebook.Yoga
[Test]
public void Test_align_self_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.FlexStart;
root_child0.Width = 10;
root_child0.Height = 10;
@@ -137,12 +143,14 @@ namespace Facebook.Yoga
[Test]
public void Test_align_self_flex_end_override_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10;
root_child0.Height = 10;
@@ -177,24 +185,26 @@ namespace Facebook.Yoga
[Test]
public void Test_align_self_baseline()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.AlignSelf = YogaAlign.Baseline;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.AlignSelf = YogaAlign.Baseline;
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);

View File

@@ -20,7 +20,9 @@ namespace Facebook.Yoga
[Test]
public void Test_border_no_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
@@ -45,13 +47,15 @@ namespace Facebook.Yoga
[Test]
public void Test_border_container_match_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -85,7 +89,9 @@ namespace Facebook.Yoga
[Test]
public void Test_border_flex_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
@@ -93,7 +99,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.Width = 10;
root.Insert(0, root_child0);
@@ -127,7 +133,9 @@ namespace Facebook.Yoga
[Test]
public void Test_border_stretch_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
@@ -135,7 +143,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -168,7 +176,9 @@ namespace Facebook.Yoga
[Test]
public void Test_border_center_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.BorderStartWidth = 10;
@@ -177,7 +187,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);

View File

@@ -20,9 +20,11 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root_child0 = new YogaNode();
YogaNode root = new YogaNode(config);
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
@@ -56,12 +58,14 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_grandchild()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root_child0 = new YogaNode();
YogaNode root = new YogaNode(config);
YogaNode root_child0 = new YogaNode(config);
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 100;
root_child0_child0.Height = 100;
root_child0.Insert(0, root_child0_child0);

View File

@@ -20,16 +20,18 @@ namespace Facebook.Yoga
[Test]
public void Test_display_none()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Display = YogaDisplay.None;
root.Insert(1, root_child1);
@@ -73,16 +75,18 @@ namespace Facebook.Yoga
[Test]
public void Test_display_none_fixed_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 20;
root_child1.Height = 20;
root_child1.Display = YogaDisplay.None;
@@ -127,12 +131,14 @@ namespace Facebook.Yoga
[Test]
public void Test_display_none_with_margin()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = 10;
root_child0.MarginTop = 10;
root_child0.MarginRight = 10;
@@ -142,7 +148,7 @@ namespace Facebook.Yoga
root_child0.Display = YogaDisplay.None;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -185,25 +191,27 @@ namespace Facebook.Yoga
[Test]
public void Test_display_none_with_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 0.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexShrink = 1;
root_child1.FlexBasis = 0.Percent();
root_child1.Display = YogaDisplay.None;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.FlexGrow = 1;
root_child1_child0.FlexShrink = 1;
root_child1_child0.FlexBasis = 0.Percent();
@@ -212,7 +220,7 @@ namespace Facebook.Yoga
root_child1_child0.MinHeight = 0;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.FlexShrink = 1;
root_child2.FlexBasis = 0.Percent();
@@ -277,16 +285,18 @@ namespace Facebook.Yoga
[Test]
public void Test_display_none_with_position()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Top = 10;
root_child1.Display = YogaDisplay.None;

View File

@@ -20,18 +20,20 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_column_no_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -84,19 +86,21 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_row_no_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -149,19 +153,21 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -214,20 +220,22 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -280,20 +288,22 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_column_reverse()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.ColumnReverse;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -346,20 +356,22 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_direction_row_reverse()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.RowReverse;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;

View File

@@ -20,16 +20,18 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_basis_flex_grow_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -72,17 +74,19 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_basis_flex_grow_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -125,16 +129,18 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_basis_flex_shrink_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexBasis = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -177,17 +183,19 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_basis_flex_shrink_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexBasis = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -230,21 +238,23 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_shrink_to_zero()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Height = 75;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexShrink = 1;
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
@@ -298,22 +308,24 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_basis_overrides_main_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -367,14 +379,16 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_shrink_at_most()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0.Insert(0, root_child0_child0);

View File

@@ -20,26 +20,28 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Wrap = YogaWrap.Wrap;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 30;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 30;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
@@ -103,27 +105,29 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 30;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 30;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
@@ -187,28 +191,30 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_row_align_items_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
@@ -272,28 +278,30 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_row_align_items_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 30;
root.Insert(3, root_child3);
@@ -357,18 +365,20 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_wrap_children_with_min_main_overriding_flex_basis()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexBasis = 50;
root_child0.MinWidth = 55;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexBasis = 50;
root_child1.MinWidth = 55;
root_child1.Height = 50;
@@ -413,24 +423,26 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_wrap_wrap_to_child_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root_child0 = new YogaNode();
YogaNode root = new YogaNode(config);
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.AlignItems = YogaAlign.FlexStart;
root_child0.Wrap = YogaWrap.Wrap;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 100;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode();
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.Width = 100;
root_child0_child0_child0.Height = 100;
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 100;
root_child1.Height = 100;
root.Insert(1, root_child1);
@@ -494,17 +506,19 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_wrap_align_stretch_fits_one_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap;
root.Width = 150;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -547,32 +561,34 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_row_align_content_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -646,33 +662,35 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_row_align_content_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Center;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -746,32 +764,34 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_row_single_line_different_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 300;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -845,33 +865,35 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_row_align_content_stretch()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -945,33 +967,35 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_row_align_content_space_around()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.SpaceAround;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -1045,33 +1069,35 @@ namespace Facebook.Yoga
[Test]
public void Test_wrap_reverse_column_fixed_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Wrap = YogaWrap.WrapReverse;
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 30;
root_child1.Height = 20;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 30;
root_child2.Height = 30;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.Width = 30;
root_child3.Height = 40;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.Width = 30;
root_child4.Height = 50;
root.Insert(4, root_child4);
@@ -1145,22 +1171,24 @@ namespace Facebook.Yoga
[Test]
public void Test_wrapped_row_within_align_items_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.Wrap = YogaWrap.Wrap;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 150;
root_child0_child0.Height = 80;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.Width = 80;
root_child0_child1.Height = 80;
root_child0.Insert(1, root_child0_child1);
@@ -1212,24 +1240,26 @@ namespace Facebook.Yoga
}
[Test]
public void Test_wrapped_row_within_align_items_center2()
public void Test_wrapped_row_within_align_items_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexStart;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.Wrap = YogaWrap.Wrap;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 150;
root_child0_child0.Height = 80;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.Width = 80;
root_child0_child1.Height = 80;
root_child0.Insert(1, root_child0_child1);
@@ -1281,24 +1311,26 @@ namespace Facebook.Yoga
}
[Test]
public void Test_wrapped_row_within_align_items_center3()
public void Test_wrapped_row_within_align_items_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexEnd;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.Wrap = YogaWrap.Wrap;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 150;
root_child0_child0.Height = 80;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.Width = 80;
root_child0_child1.Height = 80;
root_child0.Insert(1, root_child0_child1);

View File

@@ -20,20 +20,22 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_row_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -86,21 +88,23 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_row_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -153,21 +157,23 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_row_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.Center;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -220,21 +226,23 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_row_space_between()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -287,21 +295,23 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_row_space_around()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -354,18 +364,20 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_column_flex_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -418,20 +430,22 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_column_flex_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -484,20 +498,22 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_column_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -550,20 +566,22 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_column_space_between()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -616,20 +634,22 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_column_space_around()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102;
root.Height = 102;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;

View File

@@ -20,12 +20,14 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_start()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginStart = 10;
root_child0.Width = 10;
root.Insert(0, root_child0);
@@ -59,11 +61,13 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_top()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -97,13 +101,15 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginEnd = 10;
root_child0.Width = 10;
root.Insert(0, root_child0);
@@ -137,12 +143,14 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_bottom()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginBottom = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -176,12 +184,14 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_and_flex_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginStart = 10;
root_child0.MarginEnd = 10;
@@ -216,11 +226,13 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_and_flex_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginTop = 10;
root_child0.MarginBottom = 10;
@@ -255,12 +267,14 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_and_stretch_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginTop = 10;
root_child0.MarginBottom = 10;
@@ -295,11 +309,13 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_and_stretch_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginStart = 10;
root_child0.MarginEnd = 10;
@@ -334,17 +350,19 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_with_sibling_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginEnd = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -387,16 +405,18 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_with_sibling_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginBottom = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -439,18 +459,20 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_bottom()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginBottom = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -494,18 +516,20 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_top()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -549,19 +573,21 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_bottom_and_top()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = YogaValue.Auto();
root_child0.MarginBottom = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -605,19 +631,21 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_bottom_and_top_justify_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = YogaValue.Auto();
root_child0.MarginBottom = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -661,24 +689,26 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_mutiple_children_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.MarginTop = YogaValue.Auto();
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
@@ -732,25 +762,27 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_mutiple_children_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.MarginRight = YogaValue.Auto();
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
@@ -804,20 +836,22 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_left_and_right_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -861,18 +895,136 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_left_and_right()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(75f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(75f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(150f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_margin_auto_start_and_end_column()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginStart = YogaValue.Auto();
root_child0.MarginEnd = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(75f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(150f, root_child1.LayoutX);
Assert.AreEqual(75f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(75f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(75f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_margin_auto_start_and_end()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginStart = YogaValue.Auto();
root_child0.MarginEnd = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -916,19 +1068,21 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_left_and_right_column_and_center()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -972,18 +1126,20 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_left()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -1027,18 +1183,20 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_right()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -1082,19 +1240,21 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_left_and_right_strech()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -1138,18 +1298,20 @@ namespace Facebook.Yoga
[Test]
public void Test_margin_auto_top_and_bottom_strech()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = YogaValue.Auto();
root_child0.MarginBottom = YogaValue.Auto();
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
@@ -1190,5 +1352,260 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_margin_should_not_be_part_of_max_height()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 250;
root.Height = 250;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginTop = 20;
root_child0.Width = 100;
root_child0.Height = 100;
root_child0.MaxHeight = 100;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(250f, root.LayoutWidth);
Assert.AreEqual(250f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(250f, root.LayoutWidth);
Assert.AreEqual(250f, root.LayoutHeight);
Assert.AreEqual(150f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
}
[Test]
public void Test_margin_should_not_be_part_of_max_width()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 250;
root.Height = 250;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = 20;
root_child0.Width = 100;
root_child0.MaxWidth = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(250f, root.LayoutWidth);
Assert.AreEqual(250f, root.LayoutHeight);
Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(250f, root.LayoutWidth);
Assert.AreEqual(250f, root.LayoutHeight);
Assert.AreEqual(150f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
}
[Test]
public void Test_margin_auto_left_right_child_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 72;
root_child0.Height = 72;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-20f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
}
[Test]
public void Test_margin_auto_left_child_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.Width = 72;
root_child0.Height = 72;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-20f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
}
[Test]
public void Test_margin_fix_left_auto_right_child_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = 10;
root_child0.MarginRight = YogaValue.Auto();
root_child0.Width = 72;
root_child0.Height = 72;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-20f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
}
[Test]
public void Test_margin_auto_left_fix_right_child_bigger_than_parent()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 52;
root.Height = 52;
YogaNode root_child0 = new YogaNode(config);
root_child0.MarginLeft = YogaValue.Auto();
root_child0.MarginRight = 10;
root_child0.Width = 72;
root_child0.Height = 72;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(52f, root.LayoutWidth);
Assert.AreEqual(52f, root.LayoutHeight);
Assert.AreEqual(-30f, root_child0.LayoutX);
Assert.AreEqual(-10f, root_child0.LayoutY);
Assert.AreEqual(72f, root_child0.LayoutWidth);
Assert.AreEqual(72f, root_child0.LayoutHeight);
}
}
}

View File

@@ -20,11 +20,13 @@ namespace Facebook.Yoga
[Test]
public void Test_max_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MaxWidth = 50;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -58,12 +60,14 @@ namespace Facebook.Yoga
[Test]
public void Test_max_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.MaxHeight = 50;
root.Insert(0, root_child0);
@@ -97,16 +101,18 @@ namespace Facebook.Yoga
[Test]
public void Test_min_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MinHeight = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -149,17 +155,19 @@ namespace Facebook.Yoga
[Test]
public void Test_min_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MinWidth = 60;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -202,13 +210,15 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_min_max()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.Width = 100;
root.MinHeight = 100;
root.MaxHeight = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 60;
root_child0.Height = 60;
root.Insert(0, root_child0);
@@ -242,13 +252,15 @@ namespace Facebook.Yoga
[Test]
public void Test_align_items_min_max()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.Center;
root.MinWidth = 100;
root.MaxWidth = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 60;
root_child0.Height = 60;
root.Insert(0, root_child0);
@@ -282,22 +294,24 @@ namespace Facebook.Yoga
[Test]
public void Test_justify_content_overflow_min_max()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.MinHeight = 100;
root.MaxHeight = 110;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 50;
root_child2.Height = 50;
root.Insert(2, root_child2);
@@ -348,19 +362,227 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child2.LayoutHeight);
}
[Test]
public void Test_flex_grow_to_min()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
YogaNode root = new YogaNode(config);
root.Width = 100;
root.MinHeight = 100;
root.MaxHeight = 500;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexShrink = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_flex_grow_in_at_most_container()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(0f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(0f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
}
[Test]
public void Test_flex_grow_child()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 0;
root_child0.Height = 100;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_constrained_min_max_column()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.MinHeight = 100;
root.MaxHeight = 200;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_max_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0);
@@ -404,16 +626,18 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_within_constrained_max_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 300;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0);
@@ -457,16 +681,18 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_within_constrained_min_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.MinWidth = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Width = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -509,14 +735,16 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_within_constrained_min_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.MinHeight = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -559,21 +787,23 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_within_constrained_max_row()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexShrink = 1;
root_child0_child0.FlexBasis = 100;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.Width = 50;
root_child0.Insert(1, root_child0_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -626,16 +856,18 @@ namespace Facebook.Yoga
[Test]
public void Test_flex_grow_within_constrained_max_column()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.MaxHeight = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.Height = 50;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
@@ -678,7 +910,9 @@ namespace Facebook.Yoga
[Test]
public void Test_min_width_overrides_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 50;
root.MinWidth = 100;
root.StyleDirection = YogaDirection.LTR;
@@ -701,7 +935,9 @@ namespace Facebook.Yoga
[Test]
public void Test_max_width_overrides_width()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.MaxWidth = 100;
root.StyleDirection = YogaDirection.LTR;
@@ -724,7 +960,9 @@ namespace Facebook.Yoga
[Test]
public void Test_min_height_overrides_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Height = 50;
root.MinHeight = 100;
root.StyleDirection = YogaDirection.LTR;
@@ -747,7 +985,9 @@ namespace Facebook.Yoga
[Test]
public void Test_max_height_overrides_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Height = 200;
root.MaxHeight = 100;
root.StyleDirection = YogaDirection.LTR;
@@ -770,12 +1010,14 @@ namespace Facebook.Yoga
[Test]
public void Test_min_max_percent_no_width_height()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.MinWidth = 10.Percent();
root_child0.MaxWidth = 10.Percent();
root_child0.MinHeight = 10.Percent();

View File

@@ -20,7 +20,9 @@ namespace Facebook.Yoga
[Test]
public void Test_padding_no_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
@@ -45,13 +47,15 @@ namespace Facebook.Yoga
[Test]
public void Test_padding_container_match_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -85,7 +89,9 @@ namespace Facebook.Yoga
[Test]
public void Test_padding_flex_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
@@ -93,7 +99,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.Width = 10;
root.Insert(0, root_child0);
@@ -127,7 +133,9 @@ namespace Facebook.Yoga
[Test]
public void Test_padding_stretch_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
@@ -135,7 +143,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -168,7 +176,9 @@ namespace Facebook.Yoga
[Test]
public void Test_padding_center_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.PaddingStart = 10;
@@ -177,7 +187,7 @@ namespace Facebook.Yoga
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -211,13 +221,15 @@ namespace Facebook.Yoga
[Test]
public void Test_child_with_padding_align_end()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.FlexEnd;
root.AlignItems = YogaAlign.FlexEnd;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PaddingLeft = 20;
root_child0.PaddingTop = 20;
root_child0.PaddingRight = 20;

View File

@@ -20,14 +20,15 @@ namespace Facebook.Yoga
[Test]
public void Test_percentage_width_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 30.Percent();
root_child0.Height = 30.Percent();
root.Insert(0, root_child0);
@@ -56,21 +57,20 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_left_top()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 400;
root.Height = 400;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Left = 10.Percent();
root_child0.Top = 20.Percent();
root_child0.Width = 45.Percent();
@@ -101,21 +101,20 @@ namespace Facebook.Yoga
Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(180f, root_child0.LayoutWidth);
Assert.AreEqual(220f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_bottom_right()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Right = 20.Percent();
root_child0.Bottom = 10.Percent();
root_child0.Width = 55.Percent();
@@ -146,26 +145,25 @@ namespace Facebook.Yoga
Assert.AreEqual(-50f, root_child0.LayoutY);
Assert.AreEqual(275f, root_child0.LayoutWidth);
Assert.AreEqual(75f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
@@ -204,25 +202,24 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(75f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
@@ -261,25 +258,24 @@ namespace Facebook.Yoga
Assert.AreEqual(125f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(75f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MinHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 2;
root_child1.MinHeight = 10.Percent();
root.Insert(1, root_child1);
@@ -318,27 +314,26 @@ namespace Facebook.Yoga
Assert.AreEqual(140f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(60f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
@@ -378,26 +373,25 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(148f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
@@ -437,27 +431,26 @@ namespace Facebook.Yoga
Assert.AreEqual(120f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxWidth = 20.Percent();
@@ -497,26 +490,25 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MaxWidth = 20.Percent();
@@ -556,27 +548,26 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MinWidth = 20.Percent();
@@ -616,26 +607,25 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(80f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
@@ -675,20 +665,19 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MarginLeft = 5;
@@ -702,7 +691,7 @@ namespace Facebook.Yoga
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.MarginLeft = 5;
root_child0_child0.MarginTop = 5;
root_child0_child0.MarginRight = 5;
@@ -714,7 +703,7 @@ namespace Facebook.Yoga
root_child0_child0.Width = 50.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode();
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.MarginLeft = 5.Percent();
root_child0_child0_child0.MarginTop = 5.Percent();
root_child0_child0_child0.MarginRight = 5.Percent();
@@ -726,7 +715,7 @@ namespace Facebook.Yoga
root_child0_child0_child0.Width = 45.Percent();
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
@@ -786,20 +775,19 @@ namespace Facebook.Yoga
Assert.AreEqual(58f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(142f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_margin_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MarginLeft = 10.Percent();
root_child0.MarginTop = 10.Percent();
@@ -807,7 +795,7 @@ namespace Facebook.Yoga
root_child0.MarginBottom = 10.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
@@ -846,20 +834,19 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_padding_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.PaddingLeft = 10.Percent();
root_child0.PaddingTop = 10.Percent();
@@ -867,7 +854,7 @@ namespace Facebook.Yoga
root_child0.PaddingBottom = 10.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
@@ -906,20 +893,19 @@ namespace Facebook.Yoga
Assert.AreEqual(20f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_absolute_position()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 200;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Left = 30.Percent();
root_child0.Top = 10.Percent();
@@ -951,16 +937,16 @@ namespace Facebook.Yoga
Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_width_height_undefined_parent_size()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root_child0 = new YogaNode();
YogaNode root = new YogaNode(config);
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 50.Percent();
root_child0.Height = 50.Percent();
root.Insert(0, root_child0);
@@ -991,5 +977,245 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0.LayoutHeight);
}
[Test]
public void Test_percent_within_flex_grow()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 350;
root.Height = 100;
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.Width = 100.Percent();
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode(config);
root_child2.Width = 100;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(350f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(100f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(150f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(150f, root_child1_child0.LayoutWidth);
Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
Assert.AreEqual(250f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(350f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(250f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(100f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(150f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(150f, root_child1_child0.LayoutWidth);
Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
}
[Test]
public void Test_percentage_container_in_wrapping_container()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode(config);
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexDirection = YogaFlexDirection.Row;
root_child0_child0.JustifyContent = YogaJustify.Center;
root_child0_child0.Width = 100.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.Width = 50;
root_child0_child0_child0.Height = 50;
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child0_child0_child1 = new YogaNode(config);
root_child0_child0_child1.Width = 50;
root_child0_child0_child1.Height = 50;
root_child0_child0.Insert(1, root_child0_child0_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(75f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(50f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(50f, root_child0_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child1.LayoutY);
Assert.AreEqual(50f, root_child0_child0_child1.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(75f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
Assert.AreEqual(50f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(50f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child1.LayoutY);
Assert.AreEqual(50f, root_child0_child0_child1.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
}
[Test]
public void Test_percent_absolute_position()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 60;
root.Height = 50;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Left = 50.Percent();
root_child0.Width = 100.Percent();
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 100.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.Width = 100.Percent();
root_child0.Insert(1, root_child0_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(60f, root.LayoutWidth);
Assert.AreEqual(50f, root.LayoutHeight);
Assert.AreEqual(30f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
Assert.AreEqual(60f, root_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child1.LayoutY);
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(60f, root.LayoutWidth);
Assert.AreEqual(50f, root.LayoutHeight);
Assert.AreEqual(30f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
Assert.AreEqual(-60f, root_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child1.LayoutY);
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
}
}
}

View File

@@ -20,22 +20,23 @@ namespace Facebook.Yoga
[Test]
public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -83,37 +84,36 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(33f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 113;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode();
YogaNode root_child3 = new YogaNode(config);
root_child3.FlexGrow = 1;
root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode();
YogaNode root_child4 = new YogaNode(config);
root_child4.FlexGrow = 1;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
@@ -181,30 +181,29 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child4.LayoutY);
Assert.AreEqual(23f, root_child4.LayoutWidth);
Assert.AreEqual(100f, root_child4.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_flex_shrink_row()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 101;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexBasis = 25;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexBasis = 25;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
@@ -252,31 +251,30 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(25f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_overrides_main_size()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 113;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -325,31 +323,30 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_total_fractial()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 87.4f;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 0.7f;
root_child0.FlexBasis = 50.3f;
root_child0.Height = 20.3f;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1.6f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1.1f;
root_child2.Height = 10.7f;
root.Insert(2, root_child2);
@@ -398,45 +395,44 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_total_fractial_nested()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 87.4f;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 0.7f;
root_child0.FlexBasis = 50.3f;
root_child0.Height = 20.3f;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0.3f;
root_child0_child0.Bottom = 13.3f;
root_child0_child0.Height = 9.9f;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.FlexGrow = 4;
root_child0_child1.FlexBasis = 0.3f;
root_child0_child1.Top = 13.3f;
root_child0_child1.Height = 1.1f;
root_child0.Insert(1, root_child0_child1);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1.6f;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1.1f;
root_child2.Height = 10.7f;
root.Insert(2, root_child2);
@@ -505,31 +501,30 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_1()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -578,31 +573,30 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_2()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 113.6f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -651,32 +645,31 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(25f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_3()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Top = 0.3f;
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -691,17 +684,17 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(65f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(24f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
Assert.AreEqual(25f, root_child2.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
@@ -714,43 +707,42 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(65f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(24f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
Assert.AreEqual(25f, root_child2.LayoutHeight);
}
[Test]
public void Test_rounding_fractial_input_4()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
YogaNode root = new YogaNode(config);
root.Top = 0.7f;
root.Width = 100;
root.Height = 113.4f;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50;
root_child0.Height = 20;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode();
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
@@ -799,8 +791,309 @@ namespace Facebook.Yoga
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
}
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
[Test]
public void Test_rounding_inner_node_controversy_horizontal()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 320;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.Height = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 10;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.FlexGrow = 1;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(320f, root.LayoutWidth);
Assert.AreEqual(10f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(107f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(107f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(106f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(106f, root_child1_child0.LayoutWidth);
Assert.AreEqual(10f, root_child1_child0.LayoutHeight);
Assert.AreEqual(213f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(107f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(320f, root.LayoutWidth);
Assert.AreEqual(10f, root.LayoutHeight);
Assert.AreEqual(213f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(107f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(107f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(106f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(106f, root_child1_child0.LayoutWidth);
Assert.AreEqual(10f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(107f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
}
[Test]
public void Test_rounding_inner_node_controversy_vertical()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(config);
root.Height = 320;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.Width = 10;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Width = 10;
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.FlexGrow = 1;
root_child1_child0.Width = 10;
root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Width = 10;
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(10f, root.LayoutWidth);
Assert.AreEqual(320f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(107f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(107f, root_child1.LayoutY);
Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(106f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
Assert.AreEqual(106f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(213f, root_child2.LayoutY);
Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(107f, root_child2.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(10f, root.LayoutWidth);
Assert.AreEqual(320f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(107f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(107f, root_child1.LayoutY);
Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(106f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
Assert.AreEqual(106f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(213f, root_child2.LayoutY);
Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(107f, root_child2.LayoutHeight);
}
[Test]
public void Test_rounding_inner_node_controversy_combined()
{
YogaConfig config = new YogaConfig();
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 640;
root.Height = 320;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.Height = 100.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.Height = 100.Percent();
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.FlexGrow = 1;
root_child1_child0.Width = 100.Percent();
root_child1.Insert(0, root_child1_child0);
YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.FlexGrow = 1;
root_child1_child1.Width = 100.Percent();
root_child1.Insert(1, root_child1_child1);
YogaNode root_child1_child1_child0 = new YogaNode(config);
root_child1_child1_child0.FlexGrow = 1;
root_child1_child1_child0.Width = 100.Percent();
root_child1_child1.Insert(0, root_child1_child1_child0);
YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.FlexGrow = 1;
root_child1_child2.Width = 100.Percent();
root_child1.Insert(2, root_child1_child2);
YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.Height = 100.Percent();
root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(640f, root.LayoutWidth);
Assert.AreEqual(320f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(213f, root_child0.LayoutWidth);
Assert.AreEqual(320f, root_child0.LayoutHeight);
Assert.AreEqual(213f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(214f, root_child1.LayoutWidth);
Assert.AreEqual(320f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(214f, root_child1_child0.LayoutWidth);
Assert.AreEqual(107f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1_child1.LayoutX);
Assert.AreEqual(107f, root_child1_child1.LayoutY);
Assert.AreEqual(214f, root_child1_child1.LayoutWidth);
Assert.AreEqual(106f, root_child1_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child1_child0.LayoutY);
Assert.AreEqual(214f, root_child1_child1_child0.LayoutWidth);
Assert.AreEqual(106f, root_child1_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1_child2.LayoutX);
Assert.AreEqual(213f, root_child1_child2.LayoutY);
Assert.AreEqual(214f, root_child1_child2.LayoutWidth);
Assert.AreEqual(107f, root_child1_child2.LayoutHeight);
Assert.AreEqual(427f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(213f, root_child2.LayoutWidth);
Assert.AreEqual(320f, root_child2.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(640f, root.LayoutWidth);
Assert.AreEqual(320f, root.LayoutHeight);
Assert.AreEqual(427f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(213f, root_child0.LayoutWidth);
Assert.AreEqual(320f, root_child0.LayoutHeight);
Assert.AreEqual(213f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(214f, root_child1.LayoutWidth);
Assert.AreEqual(320f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child0.LayoutY);
Assert.AreEqual(214f, root_child1_child0.LayoutWidth);
Assert.AreEqual(107f, root_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1_child1.LayoutX);
Assert.AreEqual(107f, root_child1_child1.LayoutY);
Assert.AreEqual(214f, root_child1_child1.LayoutWidth);
Assert.AreEqual(106f, root_child1_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child1_child1_child0.LayoutY);
Assert.AreEqual(214f, root_child1_child1_child0.LayoutWidth);
Assert.AreEqual(106f, root_child1_child1_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1_child2.LayoutX);
Assert.AreEqual(213f, root_child1_child2.LayoutY);
Assert.AreEqual(214f, root_child1_child2.LayoutWidth);
Assert.AreEqual(107f, root_child1_child2.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(213f, root_child2.LayoutWidth);
Assert.AreEqual(320f, root_child2.LayoutHeight);
}
}

View File

@@ -20,14 +20,16 @@ namespace Facebook.Yoga
[Test]
public void Test_nested_overflowing_child()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 200;
root_child0_child0.Height = 200;
root_child0.Insert(0, root_child0_child0);
@@ -71,16 +73,18 @@ namespace Facebook.Yoga
[Test]
public void Test_nested_overflowing_child_in_constraint_parent()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 200;
root_child0_child0.Height = 200;
root_child0.Insert(0, root_child0_child0);
@@ -124,15 +128,17 @@ namespace Facebook.Yoga
[Test]
public void Test_parent_wrap_child_size_overflowing_parent()
{
YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
YogaNode root_child0 = new YogaNode(config);
root_child0.Width = 100;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.Width = 100;
root_child0_child0.Height = 200;
root_child0.Insert(0, root_child0_child0);

View File

@@ -0,0 +1,136 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using NUnit.Framework;
using System;
/**
* Tests for {@link YogaConfig}.
*/
namespace Facebook.Yoga
{
[TestFixture]
public class YogaConfigTest
{
[Test]
public void TestUseWebDefaults()
{
YogaNode node0 = new YogaNode(new YogaConfig{UseWebDefaults = true});
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
node0.Reset();
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
YogaConfig config = new YogaConfig();
config.UseWebDefaults = true;
YogaNode node1 = new YogaNode(config);
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
node1.Reset();
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
}
[Test]
public void TestDefaultConfig()
{
YogaNode node0 = new YogaNode();
Assert.AreEqual(YogaFlexDirection.Column, node0.FlexDirection);
YogaNode node1 = new YogaNode(new YogaConfig());
Assert.AreEqual(YogaFlexDirection.Column, node1.FlexDirection);
}
[Test]
public void TestCopyConstructor()
{
YogaNode srcNode = new YogaNode(new YogaConfig{UseWebDefaults = true});
YogaNode node0 = new YogaNode(srcNode);
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
node0.FlexDirection = YogaFlexDirection.Column;
Assert.AreEqual(YogaFlexDirection.Column, node0.FlexDirection);
node0.Reset();
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
YogaNode node1 = new YogaNode(srcNode)
{
FlexDirection = YogaFlexDirection.Column
};
Assert.AreEqual(YogaFlexDirection.Column, node1.FlexDirection);
node1.Reset();
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
}
public static void ForceGC()
{
YogaNodeTest.ForceGC();
}
[Test]
public void TestDestructor()
{
ForceGC();
int instanceCount = YogaConfig.GetInstanceCount();
TestDestructorForGC(instanceCount);
ForceGC();
Assert.AreEqual(instanceCount, YogaConfig.GetInstanceCount());
}
private void TestDestructorForGC(int instanceCount)
{
YogaConfig config = new YogaConfig();
Assert.IsNotNull(config);
Assert.AreEqual(instanceCount + 1, YogaConfig.GetInstanceCount());
config = null;
}
[Test]
public void TestRetainConfig()
{
ForceGC();
int nodeInstanceCount = YogaNode.GetInstanceCount();
int configInstanceCount = YogaConfig.GetInstanceCount();
TestRetainConfigForGC(nodeInstanceCount, configInstanceCount);
ForceGC();
Assert.AreEqual(nodeInstanceCount, YogaNode.GetInstanceCount());
Assert.AreEqual(configInstanceCount, YogaConfig.GetInstanceCount());
}
private void TestRetainConfigForGC(int nodeInstanceCount, int configInstanceCount)
{
ForceGC();
Assert.AreEqual(nodeInstanceCount, YogaNode.GetInstanceCount());
Assert.AreEqual(configInstanceCount, YogaConfig.GetInstanceCount());
YogaNode node = TestRetainConfigForGC2(nodeInstanceCount, configInstanceCount);
ForceGC();
Assert.IsNotNull(node);
Assert.AreEqual(configInstanceCount + 1, YogaConfig.GetInstanceCount());
Assert.AreEqual(nodeInstanceCount + 1, YogaNode.GetInstanceCount());
node = null;
}
private YogaNode TestRetainConfigForGC2(int nodeInstanceCount, int configInstanceCount)
{
YogaConfig config = new YogaConfig();
Assert.IsNotNull(config);
Assert.AreEqual(configInstanceCount + 1, YogaConfig.GetInstanceCount());
YogaNode node = new YogaNode(config);
Assert.IsNotNull(node);
Assert.AreEqual(nodeInstanceCount + 1, YogaNode.GetInstanceCount());
config = null;
return node;
}
}
}

View File

@@ -73,25 +73,22 @@ namespace Facebook.Yoga
}
[Test]
[ExpectedException("System.NullReferenceException")]
public void TestRemoveAtFromEmpty()
{
YogaNode parent = new YogaNode();
parent.RemoveAt(0);
Assert.Throws<NullReferenceException>(() => parent.RemoveAt(0));
}
[Test]
[ExpectedException("System.ArgumentOutOfRangeException")]
public void TestRemoveAtOutOfRange()
{
YogaNode parent = new YogaNode();
YogaNode child = new YogaNode();
parent.Insert(0, child);
parent.RemoveAt(1);
Assert.Throws<ArgumentOutOfRangeException>(() => parent.RemoveAt(1));
}
[Test]
[ExpectedException("System.InvalidOperationException")]
public void TestCannotAddChildToMultipleParents()
{
YogaNode parent1 = new YogaNode();
@@ -99,7 +96,7 @@ namespace Facebook.Yoga
YogaNode child = new YogaNode();
parent1.Insert(0, child);
parent2.Insert(0, child);
Assert.Throws<InvalidOperationException>(() => parent2.Insert(0, child));
}
[Test]
@@ -113,23 +110,21 @@ namespace Facebook.Yoga
}
[Test]
[ExpectedException("System.InvalidOperationException")]
public void TestResetParent()
{
YogaNode parent = new YogaNode();
YogaNode child = new YogaNode();
parent.Insert(0, child);
parent.Reset();
Assert.Throws<InvalidOperationException>(() => parent.Reset());
}
[Test]
[ExpectedException("System.InvalidOperationException")]
public void TestResetChild()
{
YogaNode parent = new YogaNode();
YogaNode child = new YogaNode();
parent.Insert(0, child);
child.Reset();
Assert.Throws<InvalidOperationException>(() => child.Reset());
}
[Test]
@@ -174,7 +169,6 @@ namespace Facebook.Yoga
}
[Test]
[ExpectedException("System.InvalidOperationException")]
public void TestChildWithMeasureFunc()
{
YogaNode node = new YogaNode();
@@ -182,19 +176,20 @@ namespace Facebook.Yoga
return MeasureOutput.Make(100, 150);
});
YogaNode child = new YogaNode();
node.Insert(0, child);
Assert.Throws<InvalidOperationException>(() => node.Insert(0, child));
}
[Test]
[ExpectedException("System.InvalidOperationException")]
public void TestMeasureFuncWithChild()
{
YogaNode node = new YogaNode();
YogaNode child = new YogaNode();
node.Insert(0, child);
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
return MeasureOutput.Make(100, 150);
});
Assert.Throws<InvalidOperationException>(() =>
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
return MeasureOutput.Make(100, 150);
})
);
}
[Test]
@@ -260,7 +255,7 @@ namespace Facebook.Yoga
parent.Insert(0, child0);
parent.Insert(0, child1);
parent.CalculateLayout();
Assert.AreEqual("{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 100pt, height: 120pt, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 35pt, height: 45pt, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 30pt, height: 40pt, },\n]},\n", parent.Print());
Assert.AreEqual("<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" >\n <div layout=\"width: 35; height: 45; top: 0; left: 0;\" style=\"width: 35px; height: 45px; \" ></div>\n <div layout=\"width: 30; height: 40; top: 45; left: 0;\" style=\"width: 30px; height: 40px; \" ></div>\n</div>", parent.Print());
}
[Test]
@@ -306,7 +301,7 @@ namespace Facebook.Yoga
Assert.AreEqual(90.Pt(), node4.MaxHeight);
}
private void ForceGC()
public static void ForceGC()
{
GC.Collect(GC.MaxGeneration);
GC.WaitForPendingFinalizers();
@@ -365,6 +360,7 @@ namespace Facebook.Yoga
child = null;
}
#if YOGA_ENABLE_GC_TEST
[Test]
public void TestParentDestructor()
{
@@ -386,6 +382,7 @@ namespace Facebook.Yoga
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
parent.Insert(0, child);
}
#endif
[Test]
public void TestClearWithChildDestructor()

View File

@@ -11,14 +11,14 @@ GEM
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
coffee-script-source (1.12.2)
colorator (1.1.0)
ethon (0.9.1)
ethon (0.10.1)
ffi (>= 1.3.0)
execjs (2.7.0)
faraday (0.9.2)
faraday (0.12.0.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.14)
ffi (1.9.18)
forwardable-extended (2.6.0)
gemoji (2.1.0)
github-pages (104)
@@ -51,10 +51,10 @@ GEM
octokit (~> 4.0)
public_suffix (~> 1.4)
typhoeus (~> 0.7)
html-pipeline (2.4.2)
html-pipeline (2.5.0)
activesupport (>= 2)
nokogiri (>= 1.4)
i18n (0.7.0)
i18n (0.8.1)
jekyll (3.3.0)
addressable (~> 2.4)
colorator (~> 1.0)
@@ -98,7 +98,7 @@ GEM
gemoji (~> 2.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0)
json (1.8.3)
json (1.8.6)
kramdown (1.11.1)
liquid (3.0.6)
listen (3.0.6)
@@ -107,33 +107,33 @@ GEM
mercenary (0.3.6)
mini_portile2 (2.1.0)
minima (2.0.0)
minitest (5.9.1)
minitest (5.10.1)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.6.8.1)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
octokit (4.4.1)
sawyer (~> 0.7.0, >= 0.5.3)
octokit (4.6.2)
sawyer (~> 0.8.0, >= 0.5.3)
pathutil (0.14.0)
forwardable-extended (~> 2.6)
public_suffix (1.5.3)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.22)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
sass (3.4.23)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.5)
thread_safe (0.3.6)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.2)
tzinfo (1.2.3)
thread_safe (~> 0.1)
unicode-display_width (1.1.1)
unicode-display_width (1.1.3)
PLATFORMS
ruby
@@ -142,4 +142,4 @@ DEPENDENCIES
github-pages (~> 104)
BUNDLED WITH
1.13.1
1.14.6

View File

@@ -4,7 +4,7 @@ This directory will contain the user, feature and API documentation for Yoga. Th
### Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to add or modify content.
See [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) for details on how to add or modify content.
### Run the Site Locally

View File

@@ -5,12 +5,58 @@ layout: docs
permalink: /docs/api/android/
---
There is an easy interface to Yoga called `YogaLayout`. This is a view group that lays out its children using Yoga. We recommend looking at the sample app for details on its usage. However, as an overview you can simply define XML layouts such as
To include the java bindings and `.so` libraries, add to your build:
<script src="https://gist.github.com/rspencer01/c1964b98f0c60de7c49683a049ed0640.js"></script>
```java
compile 'com.facebook.yoga:yoga:1.2.0'
```
There is an easy interface to Yoga called `YogaLayout`. This is a view group that lays out its children using Yoga. We recommend looking at the sample app for details on its usage. However, as an overview you can simply define XML layouts such as:
```xml
<?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="match_parent"
yoga:align_items="stretch"
>
<YogaLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp"
yoga:margin_top="5dp"
yoga:flex_direction="row"
yoga:align_items="center"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"
yoga:flex="0"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
android:textColor="@color/children_text"
yoga:flex="1"
yoga:margin_start="8dp"
/>
</YogaLayout>
</YogaLayout>
```
Note that there are some caveats, such as requiring the custom `YogaLayoutViewFactory` in order to have tags `YogaLayout` instead of `com.facebook.samples.yoga.YogaLayout`.
To include this in your project, add to your build:
```java
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
```
## layout\_width and layout\_height
If either are set to an actual size (in px or dp etc) then this is taken as a default for `yoga:height` or `yoga:width`. Otherwise they are ignored.
@@ -26,3 +72,13 @@ RTL locales are supported by default. That is, unless you explicitly set the `y
## Attributes
The list of all attributes can be found in [attrs.xml](https://github.com/facebook/yoga/blob/master/android/sample/res/com/facebook/samples/yoga/res/values/attrs.xml), but logically map from the Yoga properties.
## Auto margins
You can specify `margin_left="auto"` (or `margin_right` etc.) for auto values. This is in addition to the dimensions you can speicfy, such as `margin_left="20dp"`.
## Invalidation (_temporary_)
If you change any attribute of a view that will change its measure size, you must invalidate it. Do this by calling `YogaLayout#invalidate(View)` on any `YogaLayout` further up the tree. Obviously it is most efficient to call it on the view's parent (if it is a `YogaLayout`, but in case this is impractical, you can call it on the root of the tree.
This is a temporary solution. Ideally, the view should invalidate itself whenever an attribute (text, font etc.) that will alter its size changes. This will be automatic once we find a good way to hook into the Android invalidation system.

View File

@@ -10,7 +10,12 @@ permalink: /docs/api/c/
The following functions control the lifecycle of a `YGNodeRef`.
<script src="https://gist.github.com/emilsjolander/99e454d04df4765147f407bde131feca.js"></script>
```c
YGNodeRef YGNodeNew();
void YGNodeReset(YGNodeRef node);
void YGNodeFree(YGNodeRef node);
void YGNodeFreeRecursive(YGNodeRef node);
```
- `YGNodeReset` will reset a node to its initial state so it can be re-used without needing to re-allocate a new node.
- `YGNodeFreeRecursive` is mostly used for testing and will free not only the node itself but also its children.
@@ -19,19 +24,167 @@ The following functions control the lifecycle of a `YGNodeRef`.
The following functions help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/7e162314294087bb78817c064d345afb.js"></script>
```c
void YGNodeInsertChild(YGNodeRef node, YGNodeRef child, uint32_t index);
void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child);
YGNodeRef YGNodeGetChild(YGNodeRef node, uint32_t index);
uint32_t YGNodeChildCount(YGNodeRef node);
```
### Style getters & setters
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/74913a3326d952ff5a65dabe5ce4baf8.js"></script>
```c
typedef enum YGDirection {
YGDirectionInherit,
YGDirectionLTR,
YGDirectionRTL,
} YGDirection;
void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction);
YGDirection YGNodeStyleGetDirection(YGNodeRef node);
typedef enum YGFlexDirection {
YGFlexDirectionColumn,
YGFlexDirectionColumnReverse,
YGFlexDirectionRow,
YGFlexDirectionRowReverse,
} YGFlexDirection;
void YGNodeStyleSetFlexDirection(YGNodeRef node,
YGFlexDirection flexDirection);
YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeRef node);
typedef enum YGJustify {
YGJustifyFlexStart,
YGJustifyCenter,
YGJustifyFlexEnd,
YGJustifySpaceBetween,
YGJustifySpaceAround,
} YGJustify;
void YGNodeStyleSetJustifyContent(YGNodeRef node,
YGJustify justifyContent);
YGJustify YGNodeStyleGetJustifyContent(YGNodeRef node);
typedef enum YGAlign {
YGAlignAuto,
YGAlignFlexStart,
YGAlignCenter,
YGAlignFlexEnd,
YGAlignStretch,
} YGAlign;
void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent);
YGAlign YGNodeStyleGetAlignContent(YGNodeRef node);
void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems);
YGAlign YGNodeStyleGetAlignItems(YGNodeRef node);
void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf);
YGAlign YGNodeStyleGetAlignSelf(YGNodeRef node);
typedef enum YGPositionType {
YGPositionTypeRelative,
YGPositionTypeAbsolute,
} YGPositionType;
void YGNodeStyleSetPositionType(YGNodeRef node,
YGPositionType positionType);
YGPositionType YGNodeStyleGetPositionType(YGNodeRef node);
typedef enum YGWrap {
YGWrapNoWrap,
YGWrapWrap,
} YGWrap;
void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap);
YGWrap YGNodeStyleGetFlexWrap(YGNodeRef node);
typedef enum YGOverflow {
YGOverflowVisible,
YGOverflowHidden,
YGOverflowScroll,
} YGOverflow;
void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow);
YGOverflow YGNodeStyleGetOverflow(YGNodeRef node);
void YGNodeStyleSetFlex(YGNodeRef node, float flex);
void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow);
float YGNodeStyleGetFlexGrow(YGNodeRef node);
void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink);
float YGNodeStyleGetFlexShrink(YGNodeRef node);
void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
float YGNodeStyleGetFlexBasis(YGNodeRef node);
typedef enum YGEdge {
YGEdgeLeft,
YGEdgeTop,
YGEdgeRight,
YGEdgeBottom,
YGEdgeStart,
YGEdgeEnd,
YGEdgeHorizontal,
YGEdgeVertical,
YGEdgeAll,
} YGEdge;
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
float YGNodeStyleGetPosition(YGNodeRef node, YGEdge edge);
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
float YGNodeStyleGetMargin(YGNodeRef node, YGEdge edge);
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float padding);
float YGNodeStyleGetPadding(YGNodeRef node, YGEdge edge);
void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
float YGNodeStyleGetBorder(YGNodeRef node, YGEdge edge);
void YGNodeStyleSetWidth(YGNodeRef node, float width);
float YGNodeStyleGetWidth(YGNodeRef node);
void YGNodeStyleSetHeight(YGNodeRef node, float height);
float YGNodeStyleGetHeight(YGNodeRef node);
void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
float YGNodeStyleGetMinWidth(YGNodeRef node);
void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
float YGNodeStyleGetMinHeight(YGNodeRef node);
void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
float YGNodeStyleGetMaxWidth(YGNodeRef node);
void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
float YGNodeStyleGetMaxHeight(YGNodeRef node);
void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
float YGNodeStyleGetAspectRatio(YGNodeRef node);
```
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `YGNodeCalculateLayout` with the desired width and height or `YGUndefined` to perform the layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/7c7c9c61b69daff5b925719065fb0dc9.js"></script>
```c
void YGNodeCalculateLayout(YGNodeRef node,
float availableWidth,
float availableHeight,
YGDirection parentDirection);
float YGNodeLayoutGetLeft(YGNodeRef node);
float YGNodeLayoutGetTop(YGNodeRef node);
float YGNodeLayoutGetRight(YGNodeRef node);
float YGNodeLayoutGetBottom(YGNodeRef node);
float YGNodeLayoutGetWidth(YGNodeRef node);
float YGNodeLayoutGetHeight(YGNodeRef node);
YGDirection YGNodeLayoutGetDirection(YGNodeRef node);
```
### Custom measurements
@@ -41,34 +194,103 @@ Certain nodes need the ability to measure themselves, the most common example is
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/73f9118d8bd27f9cb3744c08f1e53a32.js"></script>
```c
typedef enum YGMeasureMode {
YGMeasureModeUndefined,
YGMeasureModeExactly,
YGMeasureModeAtMost,
} YGMeasureMode;
typedef struct YGSize {
float width;
float height;
} YGSize;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc);
YGMeasureFunc YGNodeGetMeasureFunc(YGNodeRef node);
void YGNodeMarkDirty(YGNodeRef node);
bool YGNodeIsDirty(YGNodeRef node);
```
### Context
Context is important when integrating Yoga into another layout system. Context allows you to associate another object with a `YGNodeRef`. This context can then be retrieved from a `YGNodeRef` when for example its measure function is called. This is what enables Yoga to rely on the Android and iOS system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/c3d23a1b880d59627e959f3447a9511b.js"></script>
```c
void YGNodeSetContext(YGNodeRef node, void *context);
void *YGNodeGetContext(YGNodeRef node);
```
### Logging
Yoga will by default log to stdout and stderr. You may however customize this to instead log to your own logger.
<script src="https://gist.github.com/emilsjolander/b538718ffd7a55efc80845468e0f063e.js"></script>
```c
typedef enum YGLogLevel {
YGLogLevelError,
YGLogLevelWarn,
YGLogLevelInfo,
YGLogLevelDebug,
YGLogLevelVerbose,
} YGLogLevel;
typedef int (*YGLogger)(YGLogLevel level, char *format, va_list args);
void YGSetLogger(YGLogger logger);
void YGLog(YGLogLevel level, char *message, ...);
```
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/002516a55e10947e4bdcf5484eee8745.js"></script>
```c
typedef enum YGExperimentalFeature {
// Current experiments
} YGExperimentalFeature;
void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature,
bool enabled);
bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
```
### Custom allocators
You may want to swap out the allocator used in Yoga. These functions allow that.
<script src="https://gist.github.com/emilsjolander/f45053d4f09a9faaf94a8fc071f0224f.js"></script>
```c
typedef void *(*YGMalloc)(size_t size);
typedef void *(*YGCalloc)(size_t count, size_t size);
typedef void *(*YGRealloc)(void *ptr, size_t size);
typedef void (*YGFree)(void *ptr);
void YGSetMemoryFuncs(YGMalloc cssMalloc,
YGCalloc cssCalloc,
YGRealloc cssRealloc,
YGFree cssFree);
```
### Printing
Yoga has some hooks to print debug information while calculating layout. With the printing APIs you can add additional information to a node when it is printed.
<script src="https://gist.github.com/emilsjolander/c9fbaba914d699ecc91841f4f5515f20.js"></script>
```c
typedef enum YGPrintOptions {
YGPrintOptionsLayout = 1,
YGPrintOptionsStyle = 2,
YGPrintOptionsChildren = 4,
} YGPrintOptions;
typedef void (*YGPrintFunc)(YGNodeRef node);
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node);
void YGNodePrint(YGNodeRef node, YGPrintOptions options);
```

View File

@@ -10,25 +10,176 @@ permalink: /docs/api/csharp/
Create a `YogaNode` via its default constructor or the static `Create()` builder method and use `Reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
<script src="https://gist.github.com/emilsjolander/ce73212ee5fdb543d463822c3dd172b4.js"></script>
```csharp
YogaNode();
void Reset();
static YogaNode Create(
YogaDirection? styleDirection = null,
YogaFlexDirection? flexDirection = null,
YogaJustify? justifyContent = null,
YogaAlign? alignContent = null,
YogaAlign? alignItems = null,
YogaAlign? alignSelf = null,
YogaPositionType? positionType = null,
YogaWrap? wrap = null,
YogaOverflow? overflow = null,
float? flex = null,
float? flexGrow = null,
float? flexShrink = null,
float? flexBasis = null,
Spacing position = null,
Spacing margin = null,
Spacing padding = null,
Spacing border = null,
float? Width = null,
float? Height = null,
float? MaxWidth = null,
float? MaxHeight = null,
float? MinWidth = null,
float? MinHeight = null);
```
### Children
The following methods help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/2b0ea738d3c24644fa98910b276620e4.js"></script>
```csharp
int Count { get };
YogaNode this[int index] { get };
void Insert(int index, YogaNode node);
void RemoveAt(int index);
void Clear();
int IndexOf(YogaNode node);
```
### Style getters & setters
The large part of Yoga's API consists of properties, setters, and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/a84208768e0006b8421a322c40f98539.js"></script>
```csharp
enum YogaDirection
{
Inherit,
LTR,
RTL,
}
YogaDirection StyleDirection {get, set};
enum YogaFlexDirection
{
Column,
ColumnReverse,
Row,
RowReverse,
}
YogaFlexDirection FlexDirection {get, set};
enum YogaJustify
{
FlexStart,
Center,
FlexEnd,
SpaceBetween,
SpaceAround,
}
YogaJustify JustifyContent {get, set};
enum YogaAlign
{
Auto,
FlexStart,
Center,
FlexEnd,
Stretch,
}
YogaAlign AlignItems {get, set};
YogaAlign AlignSelf {get, set};
YogaAlign AlignContent {get, set};
enum YogaPositionType
{
Relative,
Absolute,
}
YogaPositionType PositionType {get, set};
enum YogaWrap
{
NoWrap,
Wrap,
}
YogaWrap Wrap {get, set};
enum YogaOverflow
{
Visible,
Hidden,
Scroll,
}
YogaOverflow Overflow {get, set};
float Flex {set};
float FlexGrow {get, set};
float FlexShrink {get, set};
float FlexBasis {get, set};
enum YogaEdge
{
Left,
Top,
Right,
Bottom,
Start,
End,
Horizontal,
Vertical,
All,
}
float GetMargin(YogaEdge edge);
void SetMargin(YogaEdge edge, float margin);
float GetPadding(YogaEdge edge);
void SetPadding(YogaEdge edge, float padding);
float GetBorder(YogaEdge edge);
void SetBorder(YogaEdge edge, float border);
float GetPosition(YogaEdge edge);
void SetPosition(YogaEdge edge, float position);
float Width {get, set};
float Height {get, set};
float MaxWidth {get, set};
float MinWidth {get, set};
float MaxHeight {get, set};
float MinHeight {get, set};
float AspectRatio {get, set};
```
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `CalculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/b50acf9fc0877affeb0fc3e55b5c6b4c.js"></script>
```csharp
void CalculateLayout();
float LayoutX {get};
float LayoutY {get};
float LayoutWidth {get};
float LayoutHeight {get};
YogaDirection LayoutDirection {get};
```
### Custom measurements
@@ -38,16 +189,53 @@ Certain nodes need to ability to measure themselves, the most common example is
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/57178307f515e5ea1ccfbedc05df429b.js"></script>
```csharp
enum YogaMeasureMode
{
Undefined,
Exactly,
AtMost,
}
public delegate long MeasureFunction(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
class MeasureOutput
{
public static long Make(int width, int height);
}
void SetMeasureFunction(MeasureFunction measureFunction);
bool IsMeasureDefined();
bool IsDirty {get};
void MarkDirty();
```
### Data
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/c099f826623d70fd6bf7dece14e76700.js"></script>
```csharp
object Data {get, set}
```
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>
```csharp
enum YogaExperimentalFeature {
// Current experiments
}
static void setExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
boolean enabled);
static boolean isExperimentalFeatureEnabled(
YogaExperimentalFeature feature);
```

View File

@@ -10,25 +10,166 @@ permalink: /docs/api/java/
Create a `YogaNode` via its default constructor and use `reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
<script src="https://gist.github.com/emilsjolander/8775de8c778eb99a05a38e8257f0b4a7.js"></script>
```java
YogaNode();
void reset();
```
### Children
The following methods help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/5d1c64d8d3be7f7942435c4f5bec45a5.js"></script>
```java
int getChildCount();
YogaNodeType getChildAt(int i);
void addChildAt(YogaNodeType child, int i);
YogaNodeType removeChildAt(int i);
YogaNodeType getParent();
int indexOf(YogaNodeType child);
```
### Style getters & setters
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/f94ca2aa69441a3060a7c9f5126f202f.js"></script>
```java
enum YogaDirection {
INHERIT,
LTR,
RTL
}
YogaDirection getStyleDirection();
void setDirection(YogaDirection direction);
enum YogaFlexDirection {
COLUMN,
COLUMN_REVERSE,
ROW,
ROW_REVERSE
}
YogaFlexDirection getFlexDirection();
void setFlexDirection(YogaFlexDirection flexDirection);
enum YogaJustify {
FLEX_START,
CENTER,
FLEX_END,
SPACE_BETWEEN,
SPACE_AROUND
}
YogaJustify getJustifyContent();
void setJustifyContent(YogaJustify justifyContent);
enum YogaAlign {
AUTO,
FLEX_START,
CENTER,
FLEX_END,
STRETCH
}
YogaAlign getAlignItems();
void setAlignItems(YogaAlign alignItems);
YogaAlign getAlignSelf();
void setAlignSelf(YogaAlign alignSelf);
YogaAlign getAlignContent();
void setAlignContent(YogaAlign alignContent);
enum YogaPositionType {
RELATIVE,
ABSOLUTE
}
YogaPositionType getPositionType();
void setPositionType(YogaPositionType positionType);
enum YogaWrap {
NO_WRAP,
WRAP
}
void setWrap(YogaWrap flexWrap);
enum YogaOverflow {
VISIBLE,
HIDDEN,
SCROLL
}
YogaOverflow getOverflow();
void setOverflow(YogaOverflow overflow);
void setFlex(float flex);
float getFlexGrow();
void setFlexGrow(float flexGrow);
float getFlexShrink();
void setFlexShrink(float flexShrink);
float getFlexBasis();
void setFlexBasis(float flexBasis);
enum YogaEdge {
LEFT,
TOP,
RIGHT,
BOTTOM,
START,
END,
HORIZONTAL,
VERTICAL,
ALL
}
float getMargin(YogaEdge edge);
void setMargin(YogaEdge edge, float margin);
float getPadding(YogaEdge edge);
void setPadding(YogaEdge edge, float padding);
float getBorder(YogaEdge edge);
void setBorder(YogaEdge edge, float border);
float getPosition(YogaEdge edge);
void setPosition(YogaEdge edge, float position);
float getWidth();
void setWidth(float width);
float getHeight();
void setHeight(float height);
float getMaxWidth();
void setMaxWidth(float maxWidth);
float getMinWidth();
void setMinWidth(float minWidth);
float getMaxHeight();
void setMaxHeight(float maxHeight);
float getMinHeight();
void setMinHeight(float minHeight);
float getAspectRatio();
void setAspectRatio(float aspectRatio);
```
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `calculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/613a80ae11abce423a4806521e1e315b.js"></script>
```java
void calculateLayout();
float getLayoutX();
float getLayoutY();
float getLayoutWidth();
float getLayoutHeight();
YogaDirection getLayoutDirection();
```
### Custom measurements
@@ -38,22 +179,74 @@ Certain nodes need to ability to measure themselves, the most common example is
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/70fd958b87647abbba604956709a9026.js"></script>
```java
enum YogaMeasureMode {
UNDEFINED,
EXACTLY,
AT_MOST
}
interface YogaMeasureFunction {
long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}
class YogaMeasureOutput {
static long make(int width, int height);
}
void setMeasureFunction(YogaMeasureFunction measureFunction);
boolean isMeasureDefined();
boolean isDirty();
void dirty();
```
### Data
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/3f10f3fa91120960b71783780f528973.js"></script>
```java
void setData(Object data);
Object getData();
```
### Logging
Yoga will by default log to stdout and stderr (or logcat on Android). You may however customize this to instead log to your own logger.
<script src="https://gist.github.com/emilsjolander/6d012f5d48be0e98b7f9c2225c358f6e.js"></script>
```java
enum YogaLogLevel {
ERROR,
WARN,
INFO,
DEBUG,
VERBOSE
}
interface YogaLogger {
void log(YogaLogLevel level, String message);
}
void setLogger(YogaLogger logger);
```
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>
```java
enum YogaExperimentalFeature {
// Current experiments
}
static void setExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
boolean enabled);
static boolean isExperimentalFeatureEnabled(
YogaExperimentalFeature feature);
```

View File

@@ -19,13 +19,22 @@ For now we recommend including Yoga as a [git submodule](https://git-scm.com/doc
Yoga ships with an [iOS example](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample). To get it running:
<script src="https://gist.github.com/emilsjolander/903b16185b24c957acc4cd250c6e73d9.js"></script>
```sh
$ git clone https://github.com/facebook/yoga.git
$ cd open yoga/YogaKit/YogaKitSample/
$ pod install
$ open YogaKitSample.xcworkspace
```
#### Android
Yoga ships with an [Android example too](https://github.com/facebook/yoga/tree/master/android/sample). To get it running on an attached device (or emulator):
<script src="https://gist.github.com/rspencer01/a512f7cd24055c948675be15d48eba78.js"></script>
```sh
$ git clone https://github.com/facebook/yoga.git
$ cd yoga
$ buck install -r android/sample
```
Actually, this is more than just an example, and more a layout system for Android using Yoga in general (see `YogaLayout`). For more information see the [Android API section](/yoga/docs/api/android).
@@ -35,4 +44,15 @@ Yoga uses [Buck](https://buckbuild.com/) as its build system. Buck is not requir
If you are using Buck all you need to do is reference the language bindings you want to use in your `BUCK` file.
<script src="https://gist.github.com/emilsjolander/895b4ec79425882b8d4676b6545d6943.js"></script>
```sh
deps = [
# C
'//path/to/submodule/yoga:yoga',
# Java
'//path/to/submodule/yoga/java:jni',
# Objective-C
'//path/to/submodule/yoga/YogaKit:YogaKit',
]
```

View File

@@ -15,7 +15,23 @@ Yoga aims to be compatible with Flexbox according to the [w3 specification](http
Yoga has chosen to change the default values of some properties to better fit mobile layout use cases. The following CSS block describes the differences in default values from the [Flexbox w3 specification](https://www.w3.org/TR/css3-flexbox).
<script src="https://gist.github.com/emilsjolander/f9b3981cab44c51afa9ac446b8fdb60c.js"></script>
```css
div {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
border-width: 0px;
margin: 0px;
padding: 0px;
min-width: 0px;
}
```
We have set up a [JSFiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) so you can see these default values in action.

View File

@@ -1,15 +1,15 @@
.rougeHighlight { background-color: $code-bg; color: #93a1a1 }
.rougeHighlight { background-color: $code-bg; color: #000 }
.rougeHighlight .c { color: #586e75 } /* Comment */
.rougeHighlight .err { color: #93a1a1 } /* Error */
.rougeHighlight .g { color: #93a1a1 } /* Generic */
.rougeHighlight .k { color: #859900 } /* Keyword */
.rougeHighlight .l { color: #93a1a1 } /* Literal */
.rougeHighlight .n { color: #93a1a1 } /* Name */
.rougeHighlight .n { color: #795da3 } /* Name */
.rougeHighlight .o { color: #859900 } /* Operator */
.rougeHighlight .x { color: #cb4b16 } /* Other */
.rougeHighlight .p { color: #93a1a1 } /* Punctuation */
.rougeHighlight .p { color: #000000 } /* Punctuation */
.rougeHighlight .cm { color: #586e75 } /* Comment.Multiline */
.rougeHighlight .cp { color: #859900 } /* Comment.Preproc */
.rougeHighlight .c1 { color: #72c02c; } /* Comment.Single */
@@ -20,7 +20,7 @@
.rougeHighlight .gh { color: #cb4b16 } /* Generic.Heading */
.rougeHighlight .gi { color: #859900 } /* Generic.Inserted */
.rougeHighlight .go { color: #93a1a1 } /* Generic.Output */
.rougeHighlight .gp { color: #93a1a1 } /* Generic.Prompt */
.rougeHighlight .gp { color: #000000 } /* Generic.Prompt */
.rougeHighlight .gs { color: #93a1a1; font-weight: bold } /* Generic.Strong */
.rougeHighlight .gu { color: #cb4b16 } /* Generic.Subheading */
.rougeHighlight .gt { color: #93a1a1 } /* Generic.Traceback */
@@ -41,11 +41,11 @@
.rougeHighlight .ni { color: #cb4b16 } /* Name.Entity */
.rougeHighlight .ne { color: #cb4b16 } /* Name.Exception */
.rougeHighlight .nf { color: #268bd2 } /* Name.Function */
.rougeHighlight .nl { color: #93a1a1 } /* Name.Label */
.rougeHighlight .nl { color: #0086b3 } /* Name.Label */
.rougeHighlight .nn { color: #93a1a1 } /* Name.Namespace */
.rougeHighlight .nx { color: #93a1a1 } /* Name.Other */
.rougeHighlight .py { color: #93a1a1 } /* Name.Property */
.rougeHighlight .nt { color: #268bd2 } /* Name.Tag */
.rougeHighlight .nt { color: #63a35c } /* Name.Tag */
.rougeHighlight .nv { color: #268bd2 } /* Name.Variable */
.rougeHighlight .ow { color: #859900 } /* Operator.Word */
.rougeHighlight .w { color: #93a1a1 } /* Text.Whitespace */
@@ -72,11 +72,12 @@
.highlighter-rouge {
color: darken(#72c02c, 8%);
font: 800 12px/1.5em Hack, monospace;
font: 500 12px/1.8em "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
max-width: 100%;
.rougeHighlight {
border-radius: 3px;
border: 1px solid #ccc;
margin: 20px 0;
padding: 0px;
overflow-x: scroll;
@@ -97,8 +98,9 @@
flex: 1 1;
&.gutter {
border-right: 1px solid lighten($code-bg, 10%);
color: lighten($code-bg, 15%);
border-right: 1px solid darken($code-bg, 10%);
color: darken($code-bg, 25%);
margin-left: 10px;
margin-right: 10px;
max-width: 40px;
padding-right: 10px;

View File

@@ -29,6 +29,12 @@
}
.gist {
margin: 5px;
margin-left: 0px;
margin-right: 0px;
}
.gistsample > .gist {
width: 600px;
margin: 50px;
margin-left: 0px;

View File

@@ -86,7 +86,7 @@ $sidenav-overlay: lighten($sidenav, 10%);
$sidenav-active: darken($sidenav, 10%);
{% endif %}
$code-bg: #002b36;
$code-bg: #ffffff;
$header-height: 34px;

View File

@@ -13,8 +13,28 @@ id: home
<div class="yoga" style="background-color: #303846; flex-grow: 1; height: 25px; align-self: center;"></div>
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/emilsjolander/40685eadad702e0227374f3e33daaa12.js"></script>
<div class="blockContent">
<div markdown="1" style="width: 700px; max-width: 100%;">
```c
YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 500);
YGNodeStyleSetHeight(root, 120);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetPadding(root, YGEdgeAll, 20);
YGNodeRef image = YGNodeNew();
YGNodeStyleSetWidth(image, 80);
YGNodeStyleSetMargin(image, YGEdgeEnd, 20);
YGNodeRef text = YGNodeNew();
YGNodeStyleSetHeight(text, 25);
YGNodeStyleSetAlignSelf(text, YGAlignCenter);
YGNodeStyleSetFlexGrow(text, 1);
YGNodeInsertChild(root, image, 0);
YGNodeInsertChild(root, text, 1);
```
</div>
</div>
</div>
</div>
@@ -28,8 +48,28 @@ id: home
<div class="yoga" style="background-color: #303846; height: 25px; width: 100px;"></div>
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/dshahidehpour/a426c443a1e02c5432b22b09c457ede0.js"></script>
<div class="blockContent">
<div markdown="1" style="width: 700px; max-width: 100%;">
```objc
UIView *root = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 300)];
[root configureLayoutWithBlock:^void(YGLayout *layout) {
layout.isEnabled = YES;
layout.alignItems = YGAlignCenter;
layout.justifyContent = YGJustifyContentCenter;
layout.padding = 20.0f;
}];
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
[image configureLayoutWithBlock:^void(YGLayout *layout) {
layout.isEnabled = YES;
layout.marginBottom = 20.0f;
}];
[root addSubview:image];
UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 25, 100)];
[root addSubview:text];
```
</div>
</div>
</div>
</div>
@@ -43,8 +83,31 @@ id: home
<div class="yoga" style="background-color: #97dccf; width: 50px; height: 50px; position: absolute; right: 20px; top: 20px;"></div>
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/emilsjolander/f7b9b5dc2b97577bab2f1e6e1bf80b62.js"></script>
<div class="blockContent">
<div markdown="1" style="width: 700px; max-width: 100%;">
```java
YogaNode root = new YogaNode();
root.setWidth(500);
root.setHeight(300);
root.setAlignItems(CENTER);
root.setJustifyContent(CENTER);
root.setPadding(ALL, 20);
YogaNode text = new YogaNode();
text.setWidth(200);
text.setHeight(25);
YogaNode image = new YogaNode();
image.setWidth(50);
image.setHeight(50);
image.setPositionType(ABSOLUTE);
image.setPosition(END, 20);
image.setPosition(TOP, 20);
root.addChildAt(text, 0);
root.addChildAt(image, 1);
```
</div>
</div>
</div>
</div>
@@ -58,8 +121,26 @@ id: home
<div class="yoga" style="background-color: #303846; margin: 20px; height: 25px; width: 300px;"></div>
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/emilsjolander/29b91608b66d56d3df81f53101ad9d8b.js"></script>
<div class="blockContent">
<div markdown="1" style="width: 700px; max-width: 100%;">
```csharp
YogaNode root = YogaNode.Create(
width: 500,
height: 300,
);
YogaNode image = YogaNode.Create(flexGrow: 1);
YogaNode text = YogaNode.Create(
width: 300,
height: 25,
margin: new Spacing(left: 20, top: 20, right: 20, bottom: 20),
);
root.Insert(image, 0);
root.Insert(text, 1);
```
</div>
</div>
</div>
</div>
@@ -76,8 +157,35 @@ id: home
</div>
</div>
</div>
<div class="blockContent gistsample">
<script src="https://gist.github.com/rspencer01/0b3e467a58ab56a23f60579ea193189f.js"></script>
<div class="blockContent">
<div markdown="1" style="width: 700px; max-width: 100%;">
```xml
<YogaLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
yoga:justify_content="stretch">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:flex="1"/>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:padding_all="20px"
yoga:flex_direction="row"
yoga:align_items="center">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:flex="1"
yoga:margin_start="20px"/>
</VirtualYogaLayout>
</YogaLayout>
```
</div>
</div>
</div>
</div>

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