Compare commits
1 Commits
v1.19.0
...
yxping/mas
Author | SHA1 | Date | |
---|---|---|---|
|
8bea26d0a0 |
@@ -1,56 +0,0 @@
|
|||||||
Language: Cpp
|
|
||||||
AccessModifierOffset: -2
|
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
|
||||||
AlignConsecutiveAssignments: false
|
|
||||||
AlignConsecutiveDeclarations: false
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AlignOperands: false
|
|
||||||
AlignTrailingComments: false
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
|
||||||
AllowShortBlocksOnASingleLine: false
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AllowShortLoopsOnASingleLine: true
|
|
||||||
AlwaysBreakAfterReturnType: None
|
|
||||||
AlwaysBreakBeforeMultilineStrings: true
|
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: false
|
|
||||||
BreakBeforeBinaryOperators: false
|
|
||||||
BreakBeforeBraces: Attach
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakConstructorInitializers: BeforeColon
|
|
||||||
BreakInheritanceList: BeforeColon
|
|
||||||
BreakStringLiterals: true
|
|
||||||
ColumnLimit: 80
|
|
||||||
CompactNamespaces: false
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
FixNamespaceComments: true
|
|
||||||
IndentCaseLabels: true
|
|
||||||
IndentPPDirectives: None
|
|
||||||
IndentWidth: 2
|
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: None
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 2000
|
|
||||||
PointerAlignment: Left
|
|
||||||
ReflowComments: true
|
|
||||||
SortIncludes: false
|
|
||||||
SortUsingDeclarations: true
|
|
||||||
SpaceAfterCStyleCast: true
|
|
||||||
SpaceAfterTemplateKeyword: true
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
|
||||||
SpaceBeforeCpp11BracedList: false
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
|
||||||
SpaceBeforeInheritanceColon: true
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
|
||||||
SpaceInEmptyParentheses: false
|
|
||||||
SpacesBeforeTrailingComments: 1
|
|
||||||
Standard: Cpp11
|
|
||||||
UseTab: Never
|
|
@@ -1 +0,0 @@
|
|||||||
^lib/.*
|
|
58
.github/workflows/ci.yml
vendored
58
.github/workflows/ci.yml
vendored
@@ -1,58 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
website:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: 8.x
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install --frozen-lockfile --ignore-scripts
|
|
||||||
working-directory: website
|
|
||||||
- name: Build
|
|
||||||
run: yarn build
|
|
||||||
working-directory: website
|
|
||||||
- name: Deploy
|
|
||||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
publish_branch: gh-pages
|
|
||||||
publish_dir: website/public
|
|
||||||
cname: yogalayout.com
|
|
||||||
keep_files: true
|
|
||||||
user_name: 'Yoga-bot'
|
|
||||||
user_email: 'yogabot@fb.com'
|
|
||||||
android:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: set up JDK 1.8
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 1.8
|
|
||||||
- name: Install NDK 21
|
|
||||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then
|
|
||||||
openssl aes-256-cbc -K ${{ secrets.encrypted_d27e803291ff_key }} -iv {{ secrets.encrypted_d27e803291ff_iv }} -in scripts/setup-keys.enc -d >> gradle.properties;
|
|
||||||
fi
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y ninja-build
|
|
||||||
pushd $HOME
|
|
||||||
git clone --depth 1 https://github.com/facebook/buck.git
|
|
||||||
cd buck
|
|
||||||
ant
|
|
||||||
popd
|
|
||||||
echo "$HOME/buck/bin" >> $GITHUB_PATH
|
|
||||||
export PATH=$PATH:$HOME/buck/bin/
|
|
||||||
buck --version
|
|
||||||
- name: Build
|
|
||||||
# TODO: Run the tests here again. They're currently crashing the JVM in GitHub Actions for some reason.
|
|
||||||
run: ./gradlew :yoga-layout:assembleDebug && scripts/publish-snapshot.sh
|
|
32
.github/workflows/release.yml
vendored
32
.github/workflows/release.yml
vendored
@@ -1,32 +0,0 @@
|
|||||||
name: Publish
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- created
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: set up JDK 1.8
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 1.8
|
|
||||||
- name: Install dependencies
|
|
||||||
run: source scripts/android-setup.sh && installAndroidSDK
|
|
||||||
- name: Write GPG Sec Ring
|
|
||||||
run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg
|
|
||||||
- name: Update gradle.properties
|
|
||||||
run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties
|
|
||||||
- name: Upload Android Archives
|
|
||||||
run: ./gradlew :yoga:assembleRelease publish --info
|
|
||||||
- name: Release and close
|
|
||||||
run: ./gradlew closeAndReleaseRepository
|
|
||||||
- name: Clean secrets
|
|
||||||
if: always()
|
|
||||||
run: rm /tmp/secring.gpg
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,9 +6,6 @@
|
|||||||
/.buckd
|
/.buckd
|
||||||
/gentest/test.html
|
/gentest/test.html
|
||||||
.buckversion
|
.buckversion
|
||||||
.cxx
|
|
||||||
.idea
|
|
||||||
/local.properties
|
|
||||||
|
|
||||||
# Jekyll
|
# Jekyll
|
||||||
/.sass-cache/
|
/.sass-cache/
|
||||||
|
1
.swift-version
Normal file
1
.swift-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0
|
25
.travis.yml
Normal file
25
.travis.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "8"
|
||||||
|
|
||||||
|
install:
|
||||||
|
- cd website
|
||||||
|
- yarn --ignore-scripts
|
||||||
|
- cd ..
|
||||||
|
|
||||||
|
script:
|
||||||
|
- cd website
|
||||||
|
- yarn build
|
||||||
|
- cd ..
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: pages
|
||||||
|
skip-cleanup: true
|
||||||
|
github-token: $GITHUB_TOKEN
|
||||||
|
fqdn: yogalayout.com
|
||||||
|
local-dir: website/public
|
||||||
|
email: yogabot@fb.com
|
||||||
|
name: Yoga-bot
|
||||||
|
keep-history: true
|
||||||
|
on:
|
||||||
|
branch: master
|
72
BUCK
72
BUCK
@@ -1,83 +1,59 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep", "yoga_prebuilt_cxx_library")
|
|
||||||
|
load("//:yoga_defs.bzl", "LIBRARY_COMPILER_FLAGS", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "yoga_dep", "cxx_library", "cxx_test")
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
GMOCK_OVERRIDE_FLAGS = [
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||||
"-Wno-inconsistent-missing-override",
|
"-Wno-inconsistent-missing-override",
|
||||||
]
|
]
|
||||||
|
|
||||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
|
||||||
"-DDEBUG",
|
"-std=c++1y",
|
||||||
"-DYG_ENABLE_EVENTS",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
yoga_prebuilt_cxx_library(
|
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
||||||
name = "ndklog",
|
"-std=c++1y",
|
||||||
exported_platform_linker_flags = [
|
]
|
||||||
(
|
|
||||||
"^android.*",
|
|
||||||
["-llog"],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
header_only = True,
|
|
||||||
visibility = YOGA_ROOTS,
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_cxx_library(
|
cxx_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
srcs = glob(["yoga/*.cpp"]),
|
||||||
compiler_flags = LIBRARY_COMPILER_FLAGS,
|
header_namespace = "",
|
||||||
public_include_directories = ["."],
|
exported_headers = subdir_glob([("", "yoga/*.h")]),
|
||||||
raw_headers = glob(["yoga/**/*.h"]),
|
compiler_flags = COMPILER_FLAGS,
|
||||||
soname = "libyogacore.$(ext)",
|
soname = "libyogacore.$(ext)",
|
||||||
tests = [":YogaTests"],
|
tests = [":YogaTests"],
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":ndklog",
|
yoga_dep("lib/fb:ndklog"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_cxx_library(
|
cxx_library(
|
||||||
name = "yoga-static",
|
name = "yogafastmath",
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
srcs = glob(["yoga/*.cpp"]),
|
||||||
compiler_flags = LIBRARY_COMPILER_FLAGS,
|
header_namespace = "",
|
||||||
preferred_linkage = "static",
|
exported_headers = subdir_glob([("", "yoga/*.h")]),
|
||||||
public_include_directories = ["."],
|
compiler_flags = COMPILER_FLAGS + ["-ffast-math"],
|
||||||
raw_headers = glob(["yoga/**/*.h"]),
|
soname = "libyogafastmathcore.$(ext)",
|
||||||
tests = [":YogaTests"],
|
tests = [":YogaTests"],
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":ndklog",
|
yoga_dep("lib/fb:ndklog"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_cxx_library(
|
cxx_test(
|
||||||
name = "yogaForDebug",
|
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
|
||||||
public_include_directories = ["."],
|
|
||||||
raw_headers = glob(["yoga/**/*.h"]),
|
|
||||||
soname = "libyogacore.$(ext)",
|
|
||||||
tests = [":YogaTests"],
|
|
||||||
visibility = ["PUBLIC"],
|
|
||||||
deps = [
|
|
||||||
":yoga",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
yoga_cxx_test(
|
|
||||||
name = "YogaTests",
|
name = "YogaTests",
|
||||||
srcs = glob(["tests/*.cpp"]),
|
srcs = glob(["tests/*.cpp"]),
|
||||||
headers = subdir_glob([("", "yoga/**/*.h")]),
|
|
||||||
compiler_flags = TEST_COMPILER_FLAGS,
|
compiler_flags = TEST_COMPILER_FLAGS,
|
||||||
contacts = ["emilsj@fb.com"],
|
contacts = ["emilsj@fb.com"],
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":yogaForDebug",
|
":yoga",
|
||||||
yoga_dep("testutil:testutil"),
|
|
||||||
GTEST_TARGET,
|
GTEST_TARGET,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -1,24 +1,15 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
#
|
||||||
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
add_compile_options(
|
file(GLOB yogacore_SRC yoga/*.cpp)
|
||||||
-fno-omit-frame-pointer
|
|
||||||
-fexceptions
|
|
||||||
-fvisibility=hidden
|
|
||||||
-ffunction-sections
|
|
||||||
-fdata-sections
|
|
||||||
-Wall
|
|
||||||
-std=c++11)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
|
|
||||||
add_library(yogacore STATIC ${yogacore_SRC})
|
add_library(yogacore STATIC ${yogacore_SRC})
|
||||||
|
|
||||||
target_include_directories(yogacore PUBLIC .)
|
|
||||||
target_link_libraries(yogacore android log)
|
target_link_libraries(yogacore android log)
|
||||||
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
|
|
||||||
|
@@ -1,77 +1,3 @@
|
|||||||
# Code of Conduct
|
# Code of Conduct
|
||||||
|
|
||||||
## Our Pledge
|
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
|
||||||
contributors and maintainers pledge to make participation in our project and
|
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
||||||
level of experience, education, socio-economic status, nationality, personal
|
|
||||||
appearance, race, religion, or sexual identity and orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
|
||||||
include:
|
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
|
||||||
* Being respectful of differing viewpoints and experiences
|
|
||||||
* Gracefully accepting constructive criticism
|
|
||||||
* Focusing on what is best for the community
|
|
||||||
* Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
||||||
advances
|
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or electronic
|
|
||||||
address, without explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
|
||||||
response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies within all project spaces, and it also applies when
|
|
||||||
an individual is representing the project or its community in public spaces.
|
|
||||||
Examples of representing a project or community include using an official
|
|
||||||
project e-mail address, posting via an official social media account, or acting
|
|
||||||
as an appointed representative at an online or offline event. Representation of
|
|
||||||
a project may be further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported by contacting the project team at <opensource-conduct@fb.com>. All
|
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
|
||||||
members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
||||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see
|
|
||||||
https://www.contributor-covenant.org/faq
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ possible.
|
|||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
|
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
|
||||||
|
|
||||||
## Pull Requests
|
## Pull Requests
|
||||||
We actively welcome your pull requests.
|
We actively welcome your pull requests.
|
||||||
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) Facebook, Inc. and its affiliates.
|
Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
30
README.md
30
README.md
@@ -1,14 +1,14 @@
|
|||||||
# Yoga [](http://cocoapods.org/pods/YogaKit) [](https://www.npmjs.com/package/yoga-layout) [](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [](https://www.nuget.org/packages/Facebook.Yoga)
|
# Yoga [](http://cocoapods.org/pods/YogaKit) [](https://www.npmjs.com/package/yoga-layout) [](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [](https://www.nuget.org/packages/Facebook.Yoga)
|
||||||
|
|
||||||
## Building
|
## 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.
|
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.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
|
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
|
||||||
|
|
||||||
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
|
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
|
||||||
|
|
||||||
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
|
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
|
||||||
@@ -46,29 +46,3 @@ This will now only run the standalone webpack build upon install.
|
|||||||
| node | Builds node js version. |
|
| node | Builds node js version. |
|
||||||
| standalone | Runs webpack. |
|
| standalone | Runs webpack. |
|
||||||
| none | Does nothing. You can use the prepackaged libs. |
|
| none | Does nothing. You can use the prepackaged libs. |
|
||||||
|
|
||||||
## Maintainer Release Guide
|
|
||||||
|
|
||||||
To publish a new release, follow these steps:
|
|
||||||
|
|
||||||
1. Ensure you have your GPG key set up and your [OSS Sonatype](https://oss.sonatype.org/) credentials handy.
|
|
||||||
2. Add the follow entries to either your local `gradle.properties` (don't forget to revert) or your global `~/.gradle/gradle.properties`:
|
|
||||||
|
|
||||||
```
|
|
||||||
# You get these from https://oss.sonatype.org/#profile;User%20Token
|
|
||||||
mavenCentralRepositoryUsername=<username>
|
|
||||||
mavenCentralRepositoryPassword=<password>
|
|
||||||
|
|
||||||
# You can get the keyId (in GPG 1.4 format) by running `gpg1 --list-keys`.
|
|
||||||
signing.secretKeyRingFile=</path/to/secring.gpg>
|
|
||||||
signing.keyId=<key_id>
|
|
||||||
signing.password=<key_password>
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Change the `VERSION_NAME` in `gradle.properties` to a non-SNAPSHOT release.
|
|
||||||
4. Commit and land the version change.
|
|
||||||
5. Run `./gradlew publishToMaven`.
|
|
||||||
6. Run `./gradlew closeAndReleaseRepository`.
|
|
||||||
7. Change the `VERSION_NAME` in `gradle.properties` back to a new SNAPSHOT release.
|
|
||||||
8. Commit and land the version change.
|
|
||||||
9. Celebrate! You've made a release!
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
16
Yoga.podspec
16
Yoga.podspec
@@ -1,11 +1,6 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '1.14.0'
|
spec.version = '1.8.0'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://yogalayout.com/'
|
spec.homepage = 'https://yogalayout.com/'
|
||||||
spec.documentation_url = 'https://yogalayout.com/docs'
|
spec.documentation_url = 'https://yogalayout.com/docs'
|
||||||
@@ -16,14 +11,11 @@ Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => spec.version.to_s,
|
:tag => '1.8.0',
|
||||||
}
|
}
|
||||||
spec.platforms = { :ios => "8.0", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
|
spec.osx.deployment_target = '10.13'
|
||||||
spec.module_name = 'yoga'
|
spec.module_name = 'yoga'
|
||||||
spec.requires_arc = false
|
spec.requires_arc = false
|
||||||
spec.pod_target_xcconfig = {
|
|
||||||
'DEFINES_MODULE' => 'YES'
|
|
||||||
}
|
|
||||||
spec.compiler_flags = [
|
spec.compiler_flags = [
|
||||||
'-fno-omit-frame-pointer',
|
'-fno-omit-frame-pointer',
|
||||||
'-fexceptions',
|
'-fexceptions',
|
||||||
@@ -33,6 +25,6 @@ Pod::Spec.new do |spec|
|
|||||||
'-fPIC'
|
'-fPIC'
|
||||||
]
|
]
|
||||||
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
spec.source_files = 'yoga/**/*.{c,h,cpp}'
|
||||||
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGNode,YGStyle,YGValue}.h'
|
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros}.h'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Workspace
|
|
||||||
version = "1.0">
|
|
||||||
<FileRef
|
|
||||||
location = "group:YogaDev/YogaDev.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
<FileRef
|
|
||||||
location = "group:ReactYoga.xcodeproj">
|
|
||||||
</FileRef>
|
|
||||||
</Workspace>
|
|
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>IDEDidComputeMac32BitWarning</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
@@ -1,350 +0,0 @@
|
|||||||
// !$*UTF8*$!
|
|
||||||
{
|
|
||||||
archiveVersion = 1;
|
|
||||||
classes = {
|
|
||||||
};
|
|
||||||
objectVersion = 50;
|
|
||||||
objects = {
|
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
|
||||||
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F892249476700CBB1EC /* YGMarker.cpp */; };
|
|
||||||
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F8B2249476700CBB1EC /* YGValue.cpp */; };
|
|
||||||
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F902249476700CBB1EC /* YGLayout.cpp */; };
|
|
||||||
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */; };
|
|
||||||
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F992249476800CBB1EC /* YGStyle.cpp */; };
|
|
||||||
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9A2249476800CBB1EC /* log.cpp */; };
|
|
||||||
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9B2249476800CBB1EC /* YGNode.cpp */; };
|
|
||||||
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9C2249476800CBB1EC /* Yoga.cpp */; };
|
|
||||||
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9D2249476800CBB1EC /* Utils.cpp */; };
|
|
||||||
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */; };
|
|
||||||
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7FA32249476800CBB1EC /* YGConfig.cpp */; };
|
|
||||||
/* End PBXBuildFile section */
|
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
|
||||||
6D4C7F76224945B200CBB1EC /* CopyFiles */ = {
|
|
||||||
isa = PBXCopyFilesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
dstPath = "include/$(PRODUCT_NAME)";
|
|
||||||
dstSubfolderSpec = 16;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
|
||||||
6D4C7F78224945B200CBB1EC /* libYogaDev.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libYogaDev.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
6D4C7F892249476700CBB1EC /* YGMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGMarker.cpp; path = ../yoga/YGMarker.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8A2249476700CBB1EC /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../yoga/Utils.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGValue.cpp; path = ../yoga/YGValue.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8C2249476700CBB1EC /* instrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instrumentation.h; path = ../yoga/instrumentation.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8D2249476700CBB1EC /* YGStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGStyle.h; path = ../yoga/YGStyle.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNodePrint.h; path = ../yoga/YGNodePrint.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F8F2249476700CBB1EC /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMarker.h; path = ../yoga/YGMarker.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F902249476700CBB1EC /* YGLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGLayout.cpp; path = ../yoga/YGLayout.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F912249476700CBB1EC /* YGEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGEnums.h; path = ../yoga/YGEnums.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNodePrint.cpp; path = ../yoga/YGNodePrint.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F932249476700CBB1EC /* YGMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMacros.h; path = ../yoga/YGMacros.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F942249476700CBB1EC /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = log.h; path = ../yoga/log.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGFloatOptional.h; path = ../yoga/YGFloatOptional.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F962249476800CBB1EC /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNode.h; path = ../yoga/YGNode.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F972249476800CBB1EC /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGLayout.h; path = ../yoga/YGLayout.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F982249476800CBB1EC /* CompactValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactValue.h; path = ../yoga/CompactValue.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7F992249476800CBB1EC /* YGStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGStyle.cpp; path = ../yoga/YGStyle.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9A2249476800CBB1EC /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = log.cpp; path = ../yoga/log.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNode.cpp; path = ../yoga/YGNode.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Yoga.cpp; path = ../yoga/Yoga.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9D2249476800CBB1EC /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Utils.cpp; path = ../yoga/Utils.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGEnums.cpp; path = ../yoga/YGEnums.cpp; sourceTree = "<group>"; };
|
|
||||||
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Yoga-internal.h"; path = "../yoga/Yoga-internal.h"; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA02249476800CBB1EC /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGValue.h; path = ../yoga/YGValue.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA12249476800CBB1EC /* Yoga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yoga.h; path = ../yoga/Yoga.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA22249476800CBB1EC /* YGConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGConfig.h; path = ../yoga/YGConfig.h; sourceTree = "<group>"; };
|
|
||||||
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGConfig.cpp; path = ../yoga/YGConfig.cpp; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
|
||||||
6D4C7F75224945B200CBB1EC /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXFrameworksBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
|
||||||
6D4C7F6F224945B200CBB1EC = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
6D4C7F982249476800CBB1EC /* CompactValue.h */,
|
|
||||||
6D4C7F8C2249476700CBB1EC /* instrumentation.h */,
|
|
||||||
6D4C7F9A2249476800CBB1EC /* log.cpp */,
|
|
||||||
6D4C7F942249476700CBB1EC /* log.h */,
|
|
||||||
6D4C7F9D2249476800CBB1EC /* Utils.cpp */,
|
|
||||||
6D4C7F8A2249476700CBB1EC /* Utils.h */,
|
|
||||||
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */,
|
|
||||||
6D4C7FA22249476800CBB1EC /* YGConfig.h */,
|
|
||||||
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */,
|
|
||||||
6D4C7F912249476700CBB1EC /* YGEnums.h */,
|
|
||||||
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */,
|
|
||||||
6D4C7F902249476700CBB1EC /* YGLayout.cpp */,
|
|
||||||
6D4C7F972249476800CBB1EC /* YGLayout.h */,
|
|
||||||
6D4C7F932249476700CBB1EC /* YGMacros.h */,
|
|
||||||
6D4C7F892249476700CBB1EC /* YGMarker.cpp */,
|
|
||||||
6D4C7F8F2249476700CBB1EC /* YGMarker.h */,
|
|
||||||
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */,
|
|
||||||
6D4C7F962249476800CBB1EC /* YGNode.h */,
|
|
||||||
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */,
|
|
||||||
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */,
|
|
||||||
6D4C7F992249476800CBB1EC /* YGStyle.cpp */,
|
|
||||||
6D4C7F8D2249476700CBB1EC /* YGStyle.h */,
|
|
||||||
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */,
|
|
||||||
6D4C7FA02249476800CBB1EC /* YGValue.h */,
|
|
||||||
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */,
|
|
||||||
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */,
|
|
||||||
6D4C7FA12249476800CBB1EC /* Yoga.h */,
|
|
||||||
6D4C7F79224945B200CBB1EC /* Products */,
|
|
||||||
);
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
6D4C7F79224945B200CBB1EC /* Products */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
6D4C7F78224945B200CBB1EC /* libYogaDev.a */,
|
|
||||||
);
|
|
||||||
name = Products;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXGroup section */
|
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
|
||||||
6D4C7F77224945B200CBB1EC /* YogaDev */ = {
|
|
||||||
isa = PBXNativeTarget;
|
|
||||||
buildConfigurationList = 6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */;
|
|
||||||
buildPhases = (
|
|
||||||
6D4C7F74224945B200CBB1EC /* Sources */,
|
|
||||||
6D4C7F75224945B200CBB1EC /* Frameworks */,
|
|
||||||
6D4C7F76224945B200CBB1EC /* CopyFiles */,
|
|
||||||
);
|
|
||||||
buildRules = (
|
|
||||||
);
|
|
||||||
dependencies = (
|
|
||||||
);
|
|
||||||
name = YogaDev;
|
|
||||||
productName = YogaDev;
|
|
||||||
productReference = 6D4C7F78224945B200CBB1EC /* libYogaDev.a */;
|
|
||||||
productType = "com.apple.product-type.library.static";
|
|
||||||
};
|
|
||||||
/* End PBXNativeTarget section */
|
|
||||||
|
|
||||||
/* Begin PBXProject section */
|
|
||||||
6D4C7F70224945B200CBB1EC /* Project object */ = {
|
|
||||||
isa = PBXProject;
|
|
||||||
attributes = {
|
|
||||||
LastUpgradeCheck = 1010;
|
|
||||||
ORGANIZATIONNAME = "Will Wilson";
|
|
||||||
TargetAttributes = {
|
|
||||||
6D4C7F77224945B200CBB1EC = {
|
|
||||||
CreatedOnToolsVersion = 10.1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
buildConfigurationList = 6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */;
|
|
||||||
compatibilityVersion = "Xcode 9.3";
|
|
||||||
developmentRegion = en;
|
|
||||||
hasScannedForEncodings = 0;
|
|
||||||
knownRegions = (
|
|
||||||
en,
|
|
||||||
);
|
|
||||||
mainGroup = 6D4C7F6F224945B200CBB1EC;
|
|
||||||
productRefGroup = 6D4C7F79224945B200CBB1EC /* Products */;
|
|
||||||
projectDirPath = "";
|
|
||||||
projectRoot = "";
|
|
||||||
targets = (
|
|
||||||
6D4C7F77224945B200CBB1EC /* YogaDev */,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
/* End PBXProject section */
|
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
|
||||||
6D4C7F74224945B200CBB1EC /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */,
|
|
||||||
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */,
|
|
||||||
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */,
|
|
||||||
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */,
|
|
||||||
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */,
|
|
||||||
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */,
|
|
||||||
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */,
|
|
||||||
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */,
|
|
||||||
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */,
|
|
||||||
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */,
|
|
||||||
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXSourcesBuildPhase section */
|
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
|
||||||
6D4C7F7F224945B200CBB1EC /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
|
||||||
CLANG_ENABLE_MODULES = YES;
|
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_COMMA = YES;
|
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
||||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
||||||
COPY_PHASE_STRIP = NO;
|
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
ENABLE_TESTABILITY = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
||||||
"DEBUG=1",
|
|
||||||
"$(inherited)",
|
|
||||||
);
|
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
|
||||||
MTL_FAST_MATH = YES;
|
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
|
||||||
SDKROOT = iphoneos;
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
6D4C7F80224945B200CBB1EC /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
|
||||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
|
||||||
CLANG_ENABLE_MODULES = YES;
|
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_COMMA = YES;
|
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
|
||||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
||||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
|
||||||
COPY_PHASE_STRIP = NO;
|
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
|
||||||
MTL_FAST_MATH = YES;
|
|
||||||
SDKROOT = iphoneos;
|
|
||||||
VALIDATE_PRODUCT = YES;
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
6D4C7F82224945B200CBB1EC /* Debug */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
|
||||||
};
|
|
||||||
name = Debug;
|
|
||||||
};
|
|
||||||
6D4C7F83224945B200CBB1EC /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
buildSettings = {
|
|
||||||
CODE_SIGN_STYLE = Automatic;
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
|
||||||
};
|
|
||||||
name = Release;
|
|
||||||
};
|
|
||||||
/* End XCBuildConfiguration section */
|
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
|
||||||
6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
6D4C7F7F224945B200CBB1EC /* Debug */,
|
|
||||||
6D4C7F80224945B200CBB1EC /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */ = {
|
|
||||||
isa = XCConfigurationList;
|
|
||||||
buildConfigurations = (
|
|
||||||
6D4C7F82224945B200CBB1EC /* Debug */,
|
|
||||||
6D4C7F83224945B200CBB1EC /* Release */,
|
|
||||||
);
|
|
||||||
defaultConfigurationIsVisible = 0;
|
|
||||||
defaultConfigurationName = Release;
|
|
||||||
};
|
|
||||||
/* End XCConfigurationList section */
|
|
||||||
};
|
|
||||||
rootObject = 6D4C7F70224945B200CBB1EC /* Project object */;
|
|
||||||
}
|
|
@@ -1,14 +1,9 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
podspec = Pod::Spec.new do |spec|
|
podspec = Pod::Spec.new do |spec|
|
||||||
spec.name = 'YogaKit'
|
spec.name = 'YogaKit'
|
||||||
spec.version = '1.18.1'
|
spec.version = '1.7.0'
|
||||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
||||||
|
|
||||||
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
||||||
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
|
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
|
||||||
@@ -16,22 +11,17 @@ podspec = Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => "1.18.0",
|
:tag => '1.7.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.platform = :ios
|
spec.platform = :ios
|
||||||
spec.ios.deployment_target = '8.0'
|
spec.ios.deployment_target = '8.0'
|
||||||
spec.ios.frameworks = 'UIKit'
|
spec.ios.frameworks = 'UIKit'
|
||||||
spec.module_name = 'YogaKit'
|
|
||||||
spec.dependency 'Yoga', '~> 1.14'
|
spec.dependency 'Yoga', '~> 1.7'
|
||||||
# Fixes the bug related the xcode 11 not able to find swift related frameworks.
|
|
||||||
# https://github.com/Carthage/Carthage/issues/2825
|
|
||||||
# https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21
|
|
||||||
spec.pod_target_xcconfig = {"LD_VERIFY_BITCODE": "NO"}
|
|
||||||
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
||||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||||
spec.swift_version = '5.1'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/facebook/yoga/pull/366
|
# See https://github.com/facebook/yoga/pull/366
|
||||||
|
12
YogaKit/BUCK
12
YogaKit/BUCK
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
|
|
||||||
|
load("//:yoga_defs.bzl", "yoga_dep", "apple_library", "apple_test")
|
||||||
|
|
||||||
COMPILER_FLAGS = [
|
COMPILER_FLAGS = [
|
||||||
"-fobjc-arc",
|
"-fobjc-arc",
|
||||||
@@ -24,7 +25,7 @@ COMPILER_FLAGS = [
|
|||||||
"-Wunused-value",
|
"-Wunused-value",
|
||||||
]
|
]
|
||||||
|
|
||||||
yoga_apple_library(
|
apple_library(
|
||||||
name = "YogaKit",
|
name = "YogaKit",
|
||||||
srcs = glob(["Source/**/*.m"]),
|
srcs = glob(["Source/**/*.m"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
@@ -37,21 +38,18 @@ yoga_apple_library(
|
|||||||
),
|
),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
frameworks = [
|
frameworks = [
|
||||||
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
|
|
||||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||||
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
|
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
|
||||||
],
|
],
|
||||||
header_path_prefix = "",
|
header_path_prefix = "",
|
||||||
link_whole = True,
|
link_whole = True,
|
||||||
modular = True,
|
|
||||||
module_name = "YogaKit",
|
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
yoga_dep(":yoga"),
|
yoga_dep(":yoga"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_apple_test(
|
apple_test(
|
||||||
name = "YogaKitTests",
|
name = "YogaKitTests",
|
||||||
srcs = glob(["Tests/**/*.m"]),
|
srcs = glob(["Tests/**/*.m"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
|
@@ -1,33 +1,32 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "YGLayout.h"
|
#import "YGLayout.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef void (^YGLayoutConfigurationBlock)(YGLayout* layout);
|
typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
|
||||||
|
|
||||||
@interface UIView (Yoga)
|
@interface UIView (Yoga)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The YGLayout that is attached to this view. It is lazily created.
|
The YGLayout that is attached to this view. It is lazily created.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, strong) YGLayout* yoga;
|
@property (nonatomic, readonly, strong) YGLayout *yoga;
|
||||||
/**
|
/**
|
||||||
Indicates whether or not Yoga is enabled
|
Indicates whether or not Yoga is enabled
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) BOOL isYogaEnabled;
|
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
In ObjC land, every time you access `view.yoga.*` you are adding another
|
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`
|
||||||
`objc_msgSend` to your code. If you plan on making multiple changes to
|
to your code. If you plan on making multiple changes to YGLayout, it's more performant
|
||||||
YGLayout, it's more performant to use this method, which uses a single
|
to use this method, which uses a single objc_msgSend call.
|
||||||
objc_msgSend call.
|
|
||||||
*/
|
*/
|
||||||
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
||||||
NS_SWIFT_NAME(configureLayout(block:));
|
NS_SWIFT_NAME(configureLayout(block:));
|
||||||
|
@@ -1,34 +1,36 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <objc/runtime.h>
|
|
||||||
#import "UIView+Yoga.h"
|
#import "UIView+Yoga.h"
|
||||||
#import "YGLayout+Private.h"
|
#import "YGLayout+Private.h"
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
static const void* kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
||||||
|
|
||||||
@implementation UIView (YogaKit)
|
@implementation UIView (YogaKit)
|
||||||
|
|
||||||
- (YGLayout*)yoga {
|
- (YGLayout *)yoga
|
||||||
YGLayout* yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
{
|
||||||
|
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
||||||
if (!yoga) {
|
if (!yoga) {
|
||||||
yoga = [[YGLayout alloc] initWithView:self];
|
yoga = [[YGLayout alloc] initWithView:self];
|
||||||
objc_setAssociatedObject(
|
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return yoga;
|
return yoga;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isYogaEnabled {
|
- (BOOL)isYogaEnabled
|
||||||
|
{
|
||||||
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
|
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block {
|
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
|
||||||
|
{
|
||||||
if (block != nil) {
|
if (block != nil) {
|
||||||
block(self.yoga);
|
block(self.yoga);
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <yoga/Yoga.h>
|
|
||||||
#import "YGLayout.h"
|
#import "YGLayout.h"
|
||||||
|
#import <yoga/Yoga.h>
|
||||||
|
|
||||||
@interface YGLayout ()
|
@interface YGLayout ()
|
||||||
|
|
||||||
@property(nonatomic, assign, readonly) YGNodeRef node;
|
@property (nonatomic, assign, readonly) YGNodeRef node;
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView*)view;
|
- (instancetype)initWithView:(UIView *)view;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -7,15 +7,15 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <yoga/YGEnums.h>
|
#import <yoga/YGEnums.h>
|
||||||
#import <yoga/YGMacros.h>
|
|
||||||
#import <yoga/Yoga.h>
|
#import <yoga/Yoga.h>
|
||||||
|
#import <yoga/YGMacros.h>
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
extern YGValue YGPointValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
extern YGValue YGPointValue(CGFloat value)
|
||||||
"Use the swift Int and FloatingPoint extensions instead");
|
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
||||||
extern YGValue YGPercentValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
|
extern YGValue YGPercentValue(CGFloat value)
|
||||||
"Use the swift Int and FloatingPoint extensions instead");
|
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
||||||
@@ -33,118 +33,106 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
|||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
__attribute__((unavailable("you are not meant to initialise YGLayout")));
|
__attribute__((unavailable("you are not meant to initialise YGLayout")));
|
||||||
|
|
||||||
/**
|
|
||||||
Make default init unavailable, as it will not initialise YGNode which is
|
|
||||||
required for the setters and getters of YGLayout's properties to work properly.
|
|
||||||
*/
|
|
||||||
+ (instancetype)new
|
|
||||||
__attribute__((unavailable("you are not meant to initialise YGLayout")));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The property that decides if we should include this view when calculating
|
The property that decides if we should include this view when calculating
|
||||||
layout. Defaults to YES.
|
layout. Defaults to YES.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readwrite, assign, setter=setIncludedInLayout:)
|
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
|
||||||
BOOL isIncludedInLayout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The property that decides during layout/sizing whether or not styling
|
The property that decides during layout/sizing whether or not styling properties should be applied.
|
||||||
properties should be applied. Defaults to NO.
|
Defaults to NO.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) YGDirection direction;
|
@property (nonatomic, readwrite, assign) YGDirection direction;
|
||||||
@property(nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
|
||||||
@property(nonatomic, readwrite, assign) YGJustify justifyContent;
|
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
|
||||||
@property(nonatomic, readwrite, assign) YGAlign alignContent;
|
@property (nonatomic, readwrite, assign) YGAlign alignContent;
|
||||||
@property(nonatomic, readwrite, assign) YGAlign alignItems;
|
@property (nonatomic, readwrite, assign) YGAlign alignItems;
|
||||||
@property(nonatomic, readwrite, assign) YGAlign alignSelf;
|
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
|
||||||
@property(nonatomic, readwrite, assign) YGPositionType position;
|
@property (nonatomic, readwrite, assign) YGPositionType position;
|
||||||
@property(nonatomic, readwrite, assign) YGWrap flexWrap;
|
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
|
||||||
@property(nonatomic, readwrite, assign) YGOverflow overflow;
|
@property (nonatomic, readwrite, assign) YGOverflow overflow;
|
||||||
@property(nonatomic, readwrite, assign) YGDisplay display;
|
@property (nonatomic, readwrite, assign) YGDisplay display;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) CGFloat flex;
|
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat flexGrow;
|
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat flexShrink;
|
@property (nonatomic, readwrite, assign) YGValue flexBasis;
|
||||||
@property(nonatomic, readwrite, assign) YGValue flexBasis;
|
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) YGValue left;
|
@property (nonatomic, readwrite, assign) YGValue left;
|
||||||
@property(nonatomic, readwrite, assign) YGValue top;
|
@property (nonatomic, readwrite, assign) YGValue top;
|
||||||
@property(nonatomic, readwrite, assign) YGValue right;
|
@property (nonatomic, readwrite, assign) YGValue right;
|
||||||
@property(nonatomic, readwrite, assign) YGValue bottom;
|
@property (nonatomic, readwrite, assign) YGValue bottom;
|
||||||
@property(nonatomic, readwrite, assign) YGValue start;
|
@property (nonatomic, readwrite, assign) YGValue start;
|
||||||
@property(nonatomic, readwrite, assign) YGValue end;
|
@property (nonatomic, readwrite, assign) YGValue end;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginLeft;
|
@property (nonatomic, readwrite, assign) YGValue marginLeft;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginTop;
|
@property (nonatomic, readwrite, assign) YGValue marginTop;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginRight;
|
@property (nonatomic, readwrite, assign) YGValue marginRight;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginBottom;
|
@property (nonatomic, readwrite, assign) YGValue marginBottom;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginStart;
|
@property (nonatomic, readwrite, assign) YGValue marginStart;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginEnd;
|
@property (nonatomic, readwrite, assign) YGValue marginEnd;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginHorizontal;
|
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
|
||||||
@property(nonatomic, readwrite, assign) YGValue marginVertical;
|
@property (nonatomic, readwrite, assign) YGValue marginVertical;
|
||||||
@property(nonatomic, readwrite, assign) YGValue margin;
|
@property (nonatomic, readwrite, assign) YGValue margin;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingLeft;
|
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingTop;
|
@property (nonatomic, readwrite, assign) YGValue paddingTop;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingRight;
|
@property (nonatomic, readwrite, assign) YGValue paddingRight;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingBottom;
|
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingStart;
|
@property (nonatomic, readwrite, assign) YGValue paddingStart;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingEnd;
|
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
||||||
@property(nonatomic, readwrite, assign) YGValue paddingVertical;
|
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
|
||||||
@property(nonatomic, readwrite, assign) YGValue padding;
|
@property (nonatomic, readwrite, assign) YGValue padding;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
||||||
@property(nonatomic, readwrite, assign) CGFloat borderWidth;
|
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
|
||||||
|
|
||||||
@property(nonatomic, readwrite, assign) YGValue width;
|
@property (nonatomic, readwrite, assign) YGValue width;
|
||||||
@property(nonatomic, readwrite, assign) YGValue height;
|
@property (nonatomic, readwrite, assign) YGValue height;
|
||||||
@property(nonatomic, readwrite, assign) YGValue minWidth;
|
@property (nonatomic, readwrite, assign) YGValue minWidth;
|
||||||
@property(nonatomic, readwrite, assign) YGValue minHeight;
|
@property (nonatomic, readwrite, assign) YGValue minHeight;
|
||||||
@property(nonatomic, readwrite, assign) YGValue maxWidth;
|
@property (nonatomic, readwrite, assign) YGValue maxWidth;
|
||||||
@property(nonatomic, readwrite, assign) YGValue maxHeight;
|
@property (nonatomic, readwrite, assign) YGValue maxHeight;
|
||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
@property(nonatomic, readwrite, assign) CGFloat aspectRatio;
|
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the resolved direction of this node. This won't be YGDirectionInherit
|
Get the resolved direction of this node. This won't be YGDirectionInherit
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) YGDirection resolvedDirection;
|
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform a layout calculation and update the frames of the views in the
|
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
||||||
hierarchy with the results. If the origin is not preserved, the root view's
|
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
||||||
layout results will applied from {0,0}.
|
|
||||||
*/
|
*/
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform a layout calculation and update the frames of the views in the
|
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
||||||
hierarchy with the results. If the origin is not preserved, the root view's
|
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
||||||
layout results will applied from {0,0}.
|
|
||||||
*/
|
*/
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the size of the view if no constraints were given. This could
|
Returns the size of the view if no constraints were given. This could equivalent to calling [self
|
||||||
equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) CGSize intrinsicSize;
|
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the size of the view based on provided constraints. Pass NaN for an
|
Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension.
|
||||||
unconstrained dimension.
|
|
||||||
*/
|
*/
|
||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||||
NS_SWIFT_NAME(calculateLayout(with:));
|
NS_SWIFT_NAME(calculateLayout(with:));
|
||||||
@@ -152,19 +140,19 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
|||||||
/**
|
/**
|
||||||
Returns the number of children that are using Flexbox.
|
Returns the number of children that are using Flexbox.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a BOOL indiciating whether or not we this node contains any subviews
|
Return a BOOL indiciating whether or not we this node contains any subviews that are included in
|
||||||
that are included in Yoga's layout.
|
Yoga's layout.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) BOOL isLeaf;
|
@property (nonatomic, readonly, assign) BOOL isLeaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return's a BOOL indicating if a view is dirty. When a node is dirty
|
Return's a BOOL indicating if a view is dirty. When a node is dirty
|
||||||
it usually indicates that it will be remeasured on the next layout pass.
|
it usually indicates that it will be remeasured on the next layout pass.
|
||||||
*/
|
*/
|
||||||
@property(nonatomic, readonly, assign) BOOL isDirty;
|
@property (nonatomic, readonly, assign) BOOL isDirty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
Mark that a view's layout needs to be recalculated. Only works for leaf views.
|
||||||
|
@@ -1,28 +1,32 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "UIView+Yoga.h"
|
|
||||||
#import "YGLayout+Private.h"
|
#import "YGLayout+Private.h"
|
||||||
|
#import "UIView+Yoga.h"
|
||||||
|
|
||||||
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
|
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
|
||||||
-(type)lowercased_name { \
|
- (type)lowercased_name \
|
||||||
|
{ \
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
-(void)set##capitalized_name : (type)lowercased_name { \
|
- (void)set##capitalized_name:(type)lowercased_name \
|
||||||
|
{ \
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
||||||
-(YGValue)lowercased_name { \
|
- (YGValue)lowercased_name \
|
||||||
|
{ \
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
-(void)set##capitalized_name : (YGValue)lowercased_name { \
|
- (void)set##capitalized_name:(YGValue)lowercased_name \
|
||||||
|
{ \
|
||||||
switch (lowercased_name.unit) { \
|
switch (lowercased_name.unit) { \
|
||||||
case YGUnitUndefined: \
|
case YGUnitUndefined: \
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
@@ -31,27 +35,27 @@
|
|||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
break; \
|
break; \
|
||||||
case YGUnitPercent: \
|
case YGUnitPercent: \
|
||||||
YGNodeStyleSet##capitalized_name##Percent( \
|
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
|
||||||
self.node, lowercased_name.value); \
|
|
||||||
break; \
|
break; \
|
||||||
default: \
|
default: \
|
||||||
NSAssert(NO, @"Not implemented"); \
|
NSAssert(NO, @"Not implemented"); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
||||||
-(YGValue)lowercased_name { \
|
- (YGValue)lowercased_name \
|
||||||
|
{ \
|
||||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
-(void)set##capitalized_name : (YGValue)lowercased_name { \
|
- (void)set##capitalized_name:(YGValue)lowercased_name \
|
||||||
|
{ \
|
||||||
switch (lowercased_name.unit) { \
|
switch (lowercased_name.unit) { \
|
||||||
case YGUnitPoint: \
|
case YGUnitPoint: \
|
||||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||||
break; \
|
break; \
|
||||||
case YGUnitPercent: \
|
case YGUnitPercent: \
|
||||||
YGNodeStyleSet##capitalized_name##Percent( \
|
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
|
||||||
self.node, lowercased_name.value); \
|
|
||||||
break; \
|
break; \
|
||||||
case YGUnitAuto: \
|
case YGUnitAuto: \
|
||||||
YGNodeStyleSet##capitalized_name##Auto(self.node); \
|
YGNodeStyleSet##capitalized_name##Auto(self.node); \
|
||||||
@@ -59,28 +63,27 @@
|
|||||||
default: \
|
default: \
|
||||||
NSAssert(NO, @"Not implemented"); \
|
NSAssert(NO, @"Not implemented"); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY_GETTER( \
|
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
|
||||||
type, lowercased_name, capitalized_name, property, edge) \
|
- (type)lowercased_name \
|
||||||
-(type)lowercased_name { \
|
{ \
|
||||||
return YGNodeStyleGet##property(self.node, edge); \
|
return YGNodeStyleGet##property(self.node, edge); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY_SETTER( \
|
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
|
||||||
lowercased_name, capitalized_name, property, edge) \
|
- (void)set##capitalized_name:(CGFloat)lowercased_name \
|
||||||
-(void)set##capitalized_name : (CGFloat)lowercased_name { \
|
{ \
|
||||||
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
|
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
||||||
YG_EDGE_PROPERTY_GETTER( \
|
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
|
||||||
CGFloat, lowercased_name, capitalized_name, property, edge) \
|
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||||
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGE_PROPERTY_SETTER( \
|
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
||||||
objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
|
||||||
-(void)set##objc_capitalized_name : (YGValue)objc_lowercased_name { \
|
{ \
|
||||||
switch (objc_lowercased_name.unit) { \
|
switch (objc_lowercased_name.unit) { \
|
||||||
case YGUnitUndefined: \
|
case YGUnitUndefined: \
|
||||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
||||||
@@ -89,117 +92,84 @@
|
|||||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
||||||
break; \
|
break; \
|
||||||
case YGUnitPercent: \
|
case YGUnitPercent: \
|
||||||
YGNodeStyleSet##c_name##Percent( \
|
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
|
||||||
self.node, edge, objc_lowercased_name.value); \
|
|
||||||
break; \
|
break; \
|
||||||
default: \
|
default: \
|
||||||
NSAssert(NO, @"Not implemented"); \
|
NSAssert(NO, @"Not implemented"); \
|
||||||
} \
|
} \
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_EDGE_PROPERTY_GETTER( \
|
|
||||||
YGValue, lowercased_name, capitalized_name, property, edge) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY_SETTER( \
|
|
||||||
lowercased_name, capitalized_name, property, edge)
|
|
||||||
|
|
||||||
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Left, \
|
|
||||||
capitalized_name##Left, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeLeft) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Top, \
|
|
||||||
capitalized_name##Top, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeTop) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Right, \
|
|
||||||
capitalized_name##Right, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeRight) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Bottom, \
|
|
||||||
capitalized_name##Bottom, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeBottom) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Start, \
|
|
||||||
capitalized_name##Start, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeStart) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##End, \
|
|
||||||
capitalized_name##End, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeEnd) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Horizontal, \
|
|
||||||
capitalized_name##Horizontal, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeHorizontal) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name##Vertical, \
|
|
||||||
capitalized_name##Vertical, \
|
|
||||||
capitalized_name, \
|
|
||||||
YGEdgeVertical) \
|
|
||||||
YG_VALUE_EDGE_PROPERTY( \
|
|
||||||
lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
|
|
||||||
|
|
||||||
YGValue YGPointValue(CGFloat value) {
|
|
||||||
return (YGValue){.value = value, .unit = YGUnitPoint};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGPercentValue(CGFloat value) {
|
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
||||||
return (YGValue){.value = value, .unit = YGUnitPercent};
|
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||||
|
|
||||||
|
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
|
||||||
|
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
|
||||||
|
|
||||||
|
YGValue YGPointValue(CGFloat value)
|
||||||
|
{
|
||||||
|
return (YGValue) { .value = value, .unit = YGUnitPoint };
|
||||||
|
}
|
||||||
|
|
||||||
|
YGValue YGPercentValue(CGFloat value)
|
||||||
|
{
|
||||||
|
return (YGValue) { .value = value, .unit = YGUnitPercent };
|
||||||
}
|
}
|
||||||
|
|
||||||
static YGConfigRef globalConfig;
|
static YGConfigRef globalConfig;
|
||||||
|
|
||||||
@interface YGLayout ()
|
@interface YGLayout ()
|
||||||
|
|
||||||
@property(nonatomic, weak, readonly) UIView* view;
|
@property (nonatomic, weak, readonly) UIView *view;
|
||||||
@property(nonatomic, assign, readonly) BOOL isUIView;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation YGLayout
|
@implementation YGLayout
|
||||||
|
|
||||||
@synthesize isEnabled = _isEnabled;
|
@synthesize isEnabled=_isEnabled;
|
||||||
@synthesize isIncludedInLayout = _isIncludedInLayout;
|
@synthesize isIncludedInLayout=_isIncludedInLayout;
|
||||||
@synthesize node = _node;
|
@synthesize node=_node;
|
||||||
|
|
||||||
+ (void)initialize {
|
+ (void)initialize
|
||||||
|
{
|
||||||
globalConfig = YGConfigNew();
|
globalConfig = YGConfigNew();
|
||||||
YGConfigSetExperimentalFeatureEnabled(
|
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
||||||
globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
|
||||||
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithView:(UIView*)view {
|
- (instancetype)initWithView:(UIView*)view
|
||||||
|
{
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
_view = view;
|
_view = view;
|
||||||
_node = YGNodeNewWithConfig(globalConfig);
|
_node = YGNodeNewWithConfig(globalConfig);
|
||||||
YGNodeSetContext(_node, (__bridge void*)view);
|
YGNodeSetContext(_node, (__bridge void *) view);
|
||||||
_isEnabled = NO;
|
_isEnabled = NO;
|
||||||
_isIncludedInLayout = YES;
|
_isIncludedInLayout = YES;
|
||||||
_isUIView = [view isMemberOfClass:[UIView class]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc
|
||||||
|
{
|
||||||
YGNodeFree(self.node);
|
YGNodeFree(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isDirty {
|
- (BOOL)isDirty
|
||||||
|
{
|
||||||
return YGNodeIsDirty(self.node);
|
return YGNodeIsDirty(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)markDirty {
|
- (void)markDirty
|
||||||
|
{
|
||||||
if (self.isDirty || !self.isLeaf) {
|
if (self.isDirty || !self.isLeaf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,24 +178,24 @@ static YGConfigRef globalConfig;
|
|||||||
// the measure function. Since we already know that this is a leaf,
|
// the measure function. Since we already know that this is a leaf,
|
||||||
// this *should* be fine. Forgive me Hack Gods.
|
// this *should* be fine. Forgive me Hack Gods.
|
||||||
const YGNodeRef node = self.node;
|
const YGNodeRef node = self.node;
|
||||||
if (!YGNodeHasMeasureFunc(node)) {
|
if (YGNodeGetMeasureFunc(node) == NULL) {
|
||||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeMarkDirty(node);
|
YGNodeMarkDirty(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger)numberOfChildren {
|
- (NSUInteger)numberOfChildren
|
||||||
|
{
|
||||||
return YGNodeGetChildCount(self.node);
|
return YGNodeGetChildCount(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isLeaf {
|
- (BOOL)isLeaf
|
||||||
NSAssert(
|
{
|
||||||
[NSThread isMainThread],
|
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
|
||||||
@"This method must be called on the main thread.");
|
|
||||||
if (self.isEnabled) {
|
if (self.isEnabled) {
|
||||||
for (UIView* subview in self.view.subviews) {
|
for (UIView *subview in self.view.subviews) {
|
||||||
YGLayout* const yoga = subview.yoga;
|
YGLayout *const yoga = subview.yoga;
|
||||||
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
if (yoga.isEnabled && yoga.isIncludedInLayout) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -237,11 +207,13 @@ static YGConfigRef globalConfig;
|
|||||||
|
|
||||||
#pragma mark - Style
|
#pragma mark - Style
|
||||||
|
|
||||||
- (YGPositionType)position {
|
- (YGPositionType)position
|
||||||
|
{
|
||||||
return YGNodeStyleGetPositionType(self.node);
|
return YGNodeStyleGetPositionType(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPosition:(YGPositionType)position {
|
- (void)setPosition:(YGPositionType)position
|
||||||
|
{
|
||||||
YGNodeStyleSetPositionType(self.node, position);
|
YGNodeStyleSetPositionType(self.node, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +227,6 @@ YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
|
|||||||
YG_PROPERTY(YGOverflow, overflow, Overflow)
|
YG_PROPERTY(YGOverflow, overflow, Overflow)
|
||||||
YG_PROPERTY(YGDisplay, display, Display)
|
YG_PROPERTY(YGDisplay, display, Display)
|
||||||
|
|
||||||
YG_PROPERTY(CGFloat, flex, Flex)
|
|
||||||
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
|
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
|
||||||
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
|
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
|
||||||
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
|
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
|
||||||
@@ -287,23 +258,25 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
|
|
||||||
#pragma mark - Layout and Sizing
|
#pragma mark - Layout and Sizing
|
||||||
|
|
||||||
- (YGDirection)resolvedDirection {
|
- (YGDirection)resolvedDirection
|
||||||
|
{
|
||||||
return YGNodeLayoutGetDirection(self.node);
|
return YGNodeLayoutGetDirection(self.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayout {
|
- (void)applyLayout
|
||||||
|
{
|
||||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
YGApplyLayoutToViewHierarchy(self.view, NO);
|
YGApplyLayoutToViewHierarchy(self.view, NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin {
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
|
{
|
||||||
[self calculateLayoutWithSize:self.view.bounds.size];
|
[self calculateLayoutWithSize:self.view.bounds.size];
|
||||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
dimensionFlexibility:
|
{
|
||||||
(YGDimensionFlexibility)dimensionFlexibility {
|
|
||||||
CGSize size = self.view.bounds.size;
|
CGSize size = self.view.bounds.size;
|
||||||
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
||||||
size.width = YGUndefined;
|
size.width = YGUndefined;
|
||||||
@@ -315,7 +288,9 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGSize)intrinsicSize {
|
|
||||||
|
- (CGSize)intrinsicSize
|
||||||
|
{
|
||||||
const CGSize constrainedSize = {
|
const CGSize constrainedSize = {
|
||||||
.width = YGUndefined,
|
.width = YGUndefined,
|
||||||
.height = YGUndefined,
|
.height = YGUndefined,
|
||||||
@@ -323,7 +298,8 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
return [self calculateLayoutWithSize:constrainedSize];
|
return [self calculateLayoutWithSize:constrainedSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGSize)calculateLayoutWithSize:(CGSize)size {
|
- (CGSize)calculateLayoutWithSize:(CGSize)size
|
||||||
|
{
|
||||||
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
|
||||||
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
|
||||||
|
|
||||||
@@ -331,9 +307,12 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
|
|
||||||
const YGNodeRef node = self.node;
|
const YGNodeRef node = self.node;
|
||||||
YGNodeCalculateLayout(
|
YGNodeCalculateLayout(
|
||||||
node, size.width, size.height, YGNodeStyleGetDirection(node));
|
node,
|
||||||
|
size.width,
|
||||||
|
size.height,
|
||||||
|
YGNodeStyleGetDirection(node));
|
||||||
|
|
||||||
return (CGSize){
|
return (CGSize) {
|
||||||
.width = YGNodeLayoutGetWidth(node),
|
.width = YGNodeLayoutGetWidth(node),
|
||||||
.height = YGNodeLayoutGetHeight(node),
|
.height = YGNodeLayoutGetHeight(node),
|
||||||
};
|
};
|
||||||
@@ -346,40 +325,28 @@ static YGSize YGMeasureView(
|
|||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode) {
|
YGMeasureMode heightMode)
|
||||||
const CGFloat constrainedWidth =
|
{
|
||||||
(widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
|
||||||
const CGFloat constrainedHeight =
|
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
|
||||||
(heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : height;
|
|
||||||
|
|
||||||
UIView* view = (__bridge UIView*)YGNodeGetContext(node);
|
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
||||||
CGSize sizeThatFits = CGSizeZero;
|
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||||
|
|
||||||
// The default implementation of sizeThatFits: returns the existing size of
|
|
||||||
// the view. That means that if we want to layout an empty UIView, which
|
|
||||||
// already has got a frame set, its measured size should be CGSizeZero, but
|
|
||||||
// UIKit returns the existing size.
|
|
||||||
//
|
|
||||||
// See https://github.com/facebook/yoga/issues/606 for more information.
|
|
||||||
if (!view.yoga.isUIView || [view.subviews count] > 0) {
|
|
||||||
sizeThatFits = [view sizeThatFits:(CGSize){
|
|
||||||
.width = constrainedWidth,
|
.width = constrainedWidth,
|
||||||
.height = constrainedHeight,
|
.height = constrainedHeight,
|
||||||
}];
|
}];
|
||||||
}
|
|
||||||
|
|
||||||
return (YGSize){
|
return (YGSize) {
|
||||||
.width = YGSanitizeMeasurement(
|
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
|
||||||
constrainedWidth, sizeThatFits.width, widthMode),
|
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
|
||||||
.height = YGSanitizeMeasurement(
|
|
||||||
constrainedHeight, sizeThatFits.height, heightMode),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGSanitizeMeasurement(
|
static CGFloat YGSanitizeMeasurement(
|
||||||
CGFloat constrainedSize,
|
CGFloat constrainedSize,
|
||||||
CGFloat measuredSize,
|
CGFloat measuredSize,
|
||||||
YGMeasureMode measureMode) {
|
YGMeasureMode measureMode)
|
||||||
|
{
|
||||||
CGFloat result;
|
CGFloat result;
|
||||||
if (measureMode == YGMeasureModeExactly) {
|
if (measureMode == YGMeasureModeExactly) {
|
||||||
result = constrainedSize;
|
result = constrainedSize;
|
||||||
@@ -392,14 +359,13 @@ static CGFloat YGSanitizeMeasurement(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL YGNodeHasExactSameChildren(
|
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
|
||||||
const YGNodeRef node,
|
{
|
||||||
NSArray<UIView*>* subviews) {
|
|
||||||
if (YGNodeGetChildCount(node) != subviews.count) {
|
if (YGNodeGetChildCount(node) != subviews.count) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < subviews.count; i++) {
|
for (int i=0; i<subviews.count; i++) {
|
||||||
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -408,8 +374,9 @@ static BOOL YGNodeHasExactSameChildren(
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGAttachNodesFromViewHierachy(UIView* const view) {
|
static void YGAttachNodesFromViewHierachy(UIView *const view)
|
||||||
YGLayout* const yoga = view.yoga;
|
{
|
||||||
|
YGLayout *const yoga = view.yoga;
|
||||||
const YGNodeRef node = yoga.node;
|
const YGNodeRef node = yoga.node;
|
||||||
|
|
||||||
// Only leaf nodes should have a measure function
|
// Only leaf nodes should have a measure function
|
||||||
@@ -419,9 +386,8 @@ static void YGAttachNodesFromViewHierachy(UIView* const view) {
|
|||||||
} else {
|
} else {
|
||||||
YGNodeSetMeasureFunc(node, NULL);
|
YGNodeSetMeasureFunc(node, NULL);
|
||||||
|
|
||||||
NSMutableArray<UIView*>* subviewsToInclude =
|
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
||||||
[[NSMutableArray alloc] initWithCapacity:view.subviews.count];
|
for (UIView *subview in view.subviews) {
|
||||||
for (UIView* subview in view.subviews) {
|
|
||||||
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
|
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
|
||||||
[subviewsToInclude addObject:subview];
|
[subviewsToInclude addObject:subview];
|
||||||
}
|
}
|
||||||
@@ -429,41 +395,44 @@ static void YGAttachNodesFromViewHierachy(UIView* const view) {
|
|||||||
|
|
||||||
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
|
||||||
YGRemoveAllChildren(node);
|
YGRemoveAllChildren(node);
|
||||||
for (int i = 0; i < subviewsToInclude.count; i++) {
|
for (int i=0; i<subviewsToInclude.count; i++) {
|
||||||
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UIView* const subview in subviewsToInclude) {
|
for (UIView *const subview in subviewsToInclude) {
|
||||||
YGAttachNodesFromViewHierachy(subview);
|
YGAttachNodesFromViewHierachy(subview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGRemoveAllChildren(const YGNodeRef node) {
|
static void YGRemoveAllChildren(const YGNodeRef node)
|
||||||
|
{
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGNodeRemoveAllChildren(node);
|
while (YGNodeGetChildCount(node) > 0) {
|
||||||
|
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGFloat YGRoundPixelValue(CGFloat value) {
|
static CGFloat YGRoundPixelValue(CGFloat value)
|
||||||
|
{
|
||||||
static CGFloat scale;
|
static CGFloat scale;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^() {
|
dispatch_once(&onceToken, ^(){
|
||||||
scale = [UIScreen mainScreen].scale;
|
scale = [UIScreen mainScreen].scale;
|
||||||
});
|
});
|
||||||
|
|
||||||
return roundf(value * scale) / scale;
|
return roundf(value * scale) / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
|
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
|
||||||
NSCAssert(
|
{
|
||||||
[NSThread isMainThread],
|
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
|
||||||
@"Framesetting should only be done on the main thread.");
|
|
||||||
|
|
||||||
const YGLayout* yoga = view.yoga;
|
const YGLayout *yoga = view.yoga;
|
||||||
|
|
||||||
if (!yoga.isIncludedInLayout) {
|
if (!yoga.isIncludedInLayout) {
|
||||||
return;
|
return;
|
||||||
@@ -481,23 +450,19 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
|
||||||
view.frame = (CGRect){
|
view.frame = (CGRect) {
|
||||||
.origin =
|
.origin = {
|
||||||
{
|
|
||||||
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
.x = YGRoundPixelValue(topLeft.x + origin.x),
|
||||||
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
.y = YGRoundPixelValue(topLeft.y + origin.y),
|
||||||
},
|
},
|
||||||
.size =
|
.size = {
|
||||||
{
|
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
|
||||||
.width = YGRoundPixelValue(bottomRight.x) -
|
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
|
||||||
YGRoundPixelValue(topLeft.x),
|
|
||||||
.height = YGRoundPixelValue(bottomRight.y) -
|
|
||||||
YGRoundPixelValue(topLeft.y),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!yoga.isLeaf) {
|
if (!yoga.isLeaf) {
|
||||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
for (NSUInteger i=0; i<view.subviews.count; i++) {
|
||||||
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import yoga;
|
|
||||||
postfix operator %
|
postfix operator %
|
||||||
|
|
||||||
extension Int {
|
extension Int {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -16,15 +16,17 @@
|
|||||||
|
|
||||||
@implementation YogaKitTests
|
@implementation YogaKitTests
|
||||||
|
|
||||||
- (void)testConfigureLayoutIsNoOpWithNilBlock {
|
- (void)testConfigureLayoutIsNoOpWithNilBlock
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
id block = nil;
|
id block = nil;
|
||||||
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testConfigureLayoutBlockWorksWithValidBlock {
|
- (void)testConfigureLayoutBlockWorksWithValidBlock
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
[view configureLayoutWithBlock:^(YGLayout* layout) {
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
[view configureLayoutWithBlock:^(YGLayout *layout){
|
||||||
XCTAssertNotNil(layout);
|
XCTAssertNotNil(layout);
|
||||||
layout.isEnabled = YES;
|
layout.isEnabled = YES;
|
||||||
layout.width = YGPointValue(25);
|
layout.width = YGPointValue(25);
|
||||||
@@ -34,11 +36,12 @@
|
|||||||
XCTAssertEqual(view.yoga.width.value, 25);
|
XCTAssertEqual(view.yoga.width.value, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedWithSingleView {
|
- (void)testNodesAreDeallocedWithSingleView
|
||||||
__weak YGLayout* layoutRef = nil;
|
{
|
||||||
|
__weak YGLayout *layoutRef = nil;
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view.yoga.flexBasis = YGPointValue(1);
|
view.yoga.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
layoutRef = view.yoga;
|
layoutRef = view.yoga;
|
||||||
@@ -50,16 +53,17 @@
|
|||||||
XCTAssertNil(layoutRef);
|
XCTAssertNil(layoutRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedCascade {
|
- (void)testNodesAreDeallocedCascade
|
||||||
__weak YGLayout* topLayout = nil;
|
{
|
||||||
__weak YGLayout* subviewLayout = nil;
|
__weak YGLayout *topLayout = nil;
|
||||||
|
__weak YGLayout *subviewLayout = nil;
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
topLayout = view.yoga;
|
topLayout = view.yoga;
|
||||||
topLayout.flexBasis = YGPointValue(1);
|
topLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subviewLayout = subview.yoga;
|
subviewLayout = subview.yoga;
|
||||||
subviewLayout.flexBasis = YGPointValue(1);
|
subviewLayout.flexBasis = YGPointValue(1);
|
||||||
|
|
||||||
@@ -70,8 +74,9 @@
|
|||||||
XCTAssertNil(subviewLayout);
|
XCTAssertNil(subviewLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testIsEnabled {
|
- (void)testIsEnabled
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertFalse(view.yoga.isEnabled);
|
XCTAssertFalse(view.yoga.isEnabled);
|
||||||
|
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
@@ -81,31 +86,30 @@
|
|||||||
XCTAssertFalse(view.yoga.isEnabled);
|
XCTAssertFalse(view.yoga.isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsAsserts {
|
- (void)testSizeThatFitsAsserts
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
dispatch_sync(
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL),
|
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
|
||||||
^(void) {
|
|
||||||
XCTAssertThrows(view.yoga.intrinsicSize);
|
XCTAssertThrows(view.yoga.intrinsicSize);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsSmoke {
|
- (void)testSizeThatFitsSmoke
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
container.yoga.alignItems = YGAlignFlexStart;
|
container.yoga.alignItems = YGAlignFlexStart;
|
||||||
|
|
||||||
UILabel* longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
longTextLabel.text =
|
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
|
||||||
@"This is a very very very very very very very very long piece of text.";
|
|
||||||
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||||
longTextLabel.numberOfLines = 1;
|
longTextLabel.numberOfLines = 1;
|
||||||
longTextLabel.yoga.isEnabled = YES;
|
longTextLabel.yoga.isEnabled = YES;
|
||||||
longTextLabel.yoga.flexShrink = 1;
|
longTextLabel.yoga.flexShrink = 1;
|
||||||
[container addSubview:longTextLabel];
|
[container addSubview:longTextLabel];
|
||||||
|
|
||||||
UIView* textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
textBadgeView.yoga.isEnabled = YES;
|
textBadgeView.yoga.isEnabled = YES;
|
||||||
textBadgeView.yoga.margin = YGPointValue(0);
|
textBadgeView.yoga.margin = YGPointValue(0);
|
||||||
textBadgeView.yoga.width = YGPointValue(10);
|
textBadgeView.yoga.width = YGPointValue(10);
|
||||||
@@ -120,31 +124,21 @@
|
|||||||
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
||||||
|
|
||||||
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
||||||
XCTAssertEqual(
|
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
|
||||||
longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width,
|
|
||||||
containerSize.width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testSizeThatFitsEmptyView {
|
- (void)testPreservingOrigin
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
|
{
|
||||||
view.yoga.isEnabled = YES;
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
|
||||||
|
|
||||||
const CGSize viewSize = view.yoga.intrinsicSize;
|
|
||||||
XCTAssertEqual(viewSize.height, 0);
|
|
||||||
XCTAssertEqual(viewSize.width, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)testPreservingOrigin {
|
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 75)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.flexBasis = YGPointValue(0);
|
view.yoga.flexBasis = YGPointValue(0);
|
||||||
view.yoga.flexGrow = 1;
|
view.yoga.flexGrow = 1;
|
||||||
[container addSubview:view];
|
[container addSubview:view];
|
||||||
|
|
||||||
UIView* view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
view2.yoga.isEnabled = YES;
|
view2.yoga.isEnabled = YES;
|
||||||
view2.yoga.marginTop = YGPointValue(25);
|
view2.yoga.marginTop = YGPointValue(25);
|
||||||
view2.yoga.flexBasis = YGPointValue(0);
|
view2.yoga.flexBasis = YGPointValue(0);
|
||||||
@@ -158,28 +152,28 @@
|
|||||||
XCTAssertEqual(25, view2.frame.origin.y);
|
XCTAssertEqual(25, view2.frame.origin.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleWidthGetsCorrectlySized {
|
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
[container addSubview:view];
|
[container addSubview:view];
|
||||||
|
|
||||||
[container.yoga
|
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
||||||
applyLayoutPreservingOrigin:YES
|
|
||||||
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
|
||||||
XCTAssertEqual(100, container.frame.size.width);
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
XCTAssertEqual(200, container.frame.size.height);
|
XCTAssertEqual(200, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleHeightGetsCorrectlySized {
|
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
@@ -192,11 +186,12 @@
|
|||||||
XCTAssertEqual(100, container.frame.size.height);
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized {
|
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
view.yoga.width = YGPointValue(100);
|
view.yoga.width = YGPointValue(100);
|
||||||
view.yoga.height = YGPointValue(100);
|
view.yoga.height = YGPointValue(100);
|
||||||
@@ -210,11 +205,12 @@
|
|||||||
XCTAssertEqual(100, container.frame.size.height);
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testMarkingDirtyOnlyWorksOnLeafNodes {
|
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview.yoga.isEnabled = YES;
|
subview.yoga.isEnabled = YES;
|
||||||
[container addSubview:subview];
|
[container addSubview:subview];
|
||||||
|
|
||||||
@@ -227,13 +223,14 @@
|
|||||||
XCTAssertTrue(subview.yoga.isDirty);
|
XCTAssertTrue(subview.yoga.isDirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation {
|
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
container.yoga.alignItems = YGAlignFlexStart;
|
container.yoga.alignItems = YGAlignFlexStart;
|
||||||
|
|
||||||
UILabel* view = [[UILabel alloc] initWithFrame:CGRectZero];
|
UILabel *view = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
view.text = @"This is a short text.";
|
view.text = @"This is a short text.";
|
||||||
view.numberOfLines = 1;
|
view.numberOfLines = 1;
|
||||||
view.yoga.isEnabled = YES;
|
view.yoga.isEnabled = YES;
|
||||||
@@ -251,70 +248,61 @@
|
|||||||
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
|
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testFrameAndOriginPlacement {
|
- (void)testFrameAndOriginPlacement
|
||||||
|
{
|
||||||
const CGSize containerSize = CGSizeMake(320, 50);
|
const CGSize containerSize = CGSizeMake(320, 50);
|
||||||
|
|
||||||
UIView* container = [[UIView alloc]
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||||
initWithFrame:CGRectMake(
|
|
||||||
0, 0, containerSize.width, containerSize.height)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
XCTAssertEqualWithAccuracy(
|
XCTAssertEqualWithAccuracy(subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
||||||
subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
XCTAssertEqualWithAccuracy(subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
||||||
XCTAssertEqualWithAccuracy(
|
|
||||||
subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
|
||||||
|
|
||||||
CGFloat totalWidth = 0;
|
CGFloat totalWidth = 0;
|
||||||
for (UIView* view in container.subviews) {
|
for (UIView *view in container.subviews) {
|
||||||
totalWidth += view.bounds.size.width;
|
totalWidth += view.bounds.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(
|
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
|
||||||
containerSize.width,
|
|
||||||
totalWidth,
|
|
||||||
@"The container's width is %.6f, the subviews take up %.6f",
|
|
||||||
containerSize.width,
|
|
||||||
totalWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder {
|
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
|
||||||
|
{
|
||||||
const CGSize containerSize = CGSizeMake(300, 50);
|
const CGSize containerSize = CGSizeMake(300, 50);
|
||||||
|
|
||||||
UIView* container = [[UIView alloc]
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||||
initWithFrame:CGRectMake(
|
|
||||||
0, 0, containerSize.width, containerSize.height)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
@@ -336,33 +324,32 @@
|
|||||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatWeRespectIncludeInLayoutFlag {
|
- (void)testThatWeRespectIncludeInLayoutFlag
|
||||||
|
{
|
||||||
const CGSize containerSize = CGSizeMake(300, 50);
|
const CGSize containerSize = CGSizeMake(300, 50);
|
||||||
|
|
||||||
UIView* container = [[UIView alloc]
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
|
||||||
initWithFrame:CGRectMake(
|
|
||||||
0, 0, containerSize.width, containerSize.height)];
|
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
for (UIView* subview in container.subviews) {
|
for (UIView *subview in container.subviews) {
|
||||||
XCTAssertEqual(subview.bounds.size.width, 100);
|
XCTAssertEqual(subview.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,27 +359,27 @@
|
|||||||
XCTAssertEqual(subview1.bounds.size.width, 150);
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertEqual(subview2.bounds.size.width, 150);
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
|
|
||||||
// We don't set the frame to zero, so, it should be set to what it was
|
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
||||||
// previously at.
|
|
||||||
XCTAssertEqual(subview3.bounds.size.width, 100);
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews {
|
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.isIncludedInLayout = NO;
|
subview1.yoga.isIncludedInLayout = NO;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.isIncludedInLayout = NO;
|
subview2.yoga.isIncludedInLayout = NO;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.isIncludedInLayout = YES;
|
subview3.yoga.isIncludedInLayout = YES;
|
||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
@@ -405,22 +392,23 @@
|
|||||||
XCTAssertEqual(container.yoga.numberOfChildren, 2);
|
XCTAssertEqual(container.yoga.numberOfChildren, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond {
|
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview3.yoga.isEnabled = YES;
|
subview3.yoga.isEnabled = YES;
|
||||||
subview3.yoga.flexGrow = 1;
|
subview3.yoga.flexGrow = 1;
|
||||||
subview3.yoga.isIncludedInLayout = NO;
|
subview3.yoga.isIncludedInLayout = NO;
|
||||||
@@ -440,12 +428,13 @@
|
|||||||
XCTAssertEqual(subview3.bounds.size.width, 100);
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testIsLeafFlag {
|
- (void)testIsLeafFlag
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i=0; i<10; i++) {
|
||||||
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
[view addSubview:subview];
|
[view addSubview:subview];
|
||||||
}
|
}
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
@@ -454,33 +443,34 @@
|
|||||||
view.yoga.width = YGPointValue(50);
|
view.yoga.width = YGPointValue(50);
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
|
|
||||||
UIView* const subview = view.subviews[0];
|
UIView *const subview = view.subviews[0];
|
||||||
subview.yoga.isEnabled = YES;
|
subview.yoga.isEnabled = YES;
|
||||||
subview.yoga.width = YGPointValue(50);
|
subview.yoga.width = YGPointValue(50);
|
||||||
XCTAssertFalse(view.yoga.isLeaf);
|
XCTAssertFalse(view.yoga.isLeaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatWeCorrectlyAttachNestedViews {
|
- (void)testThatWeCorrectlyAttachNestedViews
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionColumn;
|
container.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
subview1.yoga.width = YGPointValue(100);
|
subview1.yoga.width = YGPointValue(100);
|
||||||
subview1.yoga.flexGrow = 1;
|
subview1.yoga.flexGrow = 1;
|
||||||
subview1.yoga.flexDirection = YGFlexDirectionColumn;
|
subview1.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
subview2.yoga.width = YGPointValue(150);
|
subview2.yoga.width = YGPointValue(150);
|
||||||
subview2.yoga.flexGrow = 1;
|
subview2.yoga.flexGrow = 1;
|
||||||
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
||||||
[container addSubview:subview2];
|
[container addSubview:subview2];
|
||||||
|
|
||||||
for (UIView* view in @[ subview1, subview2 ]) {
|
for (UIView *view in @[subview1, subview2]) {
|
||||||
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
someView.yoga.isEnabled = YES;
|
someView.yoga.isEnabled = YES;
|
||||||
someView.yoga.flexGrow = 1;
|
someView.yoga.flexGrow = 1;
|
||||||
[view addSubview:someView];
|
[view addSubview:someView];
|
||||||
@@ -488,8 +478,8 @@
|
|||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
|
||||||
// Add the same amount of new views, reapply layout.
|
// Add the same amount of new views, reapply layout.
|
||||||
for (UIView* view in @[ subview1, subview2 ]) {
|
for (UIView *view in @[subview1, subview2]) {
|
||||||
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
someView.yoga.isEnabled = YES;
|
someView.yoga.isEnabled = YES;
|
||||||
someView.yoga.flexGrow = 1;
|
someView.yoga.flexGrow = 1;
|
||||||
[view addSubview:someView];
|
[view addSubview:someView];
|
||||||
@@ -498,7 +488,7 @@
|
|||||||
|
|
||||||
XCTAssertEqual(subview1.bounds.size.width, 100);
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
XCTAssertEqual(subview1.bounds.size.height, 25);
|
XCTAssertEqual(subview1.bounds.size.height, 25);
|
||||||
for (UIView* subview in subview1.subviews) {
|
for (UIView *subview in subview1.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertNotEqual(subviewSize.width, 0);
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
XCTAssertNotEqual(subviewSize.height, 0);
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
@@ -508,7 +498,7 @@
|
|||||||
|
|
||||||
XCTAssertEqual(subview2.bounds.size.width, 150);
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
XCTAssertEqual(subview2.bounds.size.height, 25);
|
XCTAssertEqual(subview2.bounds.size.height, 25);
|
||||||
for (UIView* subview in subview2.subviews) {
|
for (UIView *subview in subview2.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertNotEqual(subviewSize.width, 0);
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
XCTAssertNotEqual(subviewSize.height, 0);
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
@@ -517,15 +507,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatANonLeafNodeCanBecomeALeafNode {
|
- (void)testThatANonLeafNodeCanBecomeALeafNode
|
||||||
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
|
||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview1.yoga.isEnabled = YES;
|
subview1.yoga.isEnabled = YES;
|
||||||
[container addSubview:subview1];
|
[container addSubview:subview1];
|
||||||
|
|
||||||
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview2.yoga.isEnabled = YES;
|
subview2.yoga.isEnabled = YES;
|
||||||
[subview1 addSubview:subview2];
|
[subview1 addSubview:subview2];
|
||||||
|
|
||||||
@@ -534,15 +525,17 @@
|
|||||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPointPercent {
|
- (void)testPointPercent
|
||||||
|
{
|
||||||
XCTAssertEqual(YGPointValue(1).value, 1);
|
XCTAssertEqual(YGPointValue(1).value, 1);
|
||||||
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
||||||
XCTAssertEqual(YGPercentValue(2).value, 2);
|
XCTAssertEqual(YGPercentValue(2).value, 2);
|
||||||
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPositionalPropertiesWork {
|
- (void)testPositionalPropertiesWork
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
view.yoga.left = YGPointValue(1);
|
view.yoga.left = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.left.value, 1);
|
XCTAssertEqual(view.yoga.left.value, 1);
|
||||||
@@ -587,8 +580,9 @@
|
|||||||
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testMarginPropertiesWork {
|
- (void)testMarginPropertiesWork
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
view.yoga.margin = YGPointValue(1);
|
view.yoga.margin = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.margin.value, 1);
|
XCTAssertEqual(view.yoga.margin.value, 1);
|
||||||
@@ -654,8 +648,9 @@
|
|||||||
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testPaddingPropertiesWork {
|
- (void)testPaddingPropertiesWork
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
view.yoga.padding = YGPointValue(1);
|
view.yoga.padding = YGPointValue(1);
|
||||||
XCTAssertEqual(view.yoga.padding.value, 1);
|
XCTAssertEqual(view.yoga.padding.value, 1);
|
||||||
@@ -721,8 +716,9 @@
|
|||||||
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testBorderWidthPropertiesWork {
|
- (void)testBorderWidthPropertiesWork
|
||||||
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
|
||||||
view.yoga.borderWidth = 1;
|
view.yoga.borderWidth = 1;
|
||||||
XCTAssertEqual(view.yoga.borderWidth, 1);
|
XCTAssertEqual(view.yoga.borderWidth, 1);
|
||||||
|
@@ -1,10 +1,3 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// !$*UTF8*$!
|
// !$*UTF8*$!
|
||||||
{
|
{
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
@@ -11,8 +12,9 @@
|
|||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad
|
||||||
UIView* root = self.view;
|
{
|
||||||
|
UIView *root = self.view;
|
||||||
root.backgroundColor = [UIColor redColor];
|
root.backgroundColor = [UIColor redColor];
|
||||||
root.yoga.isEnabled = YES;
|
root.yoga.isEnabled = YES;
|
||||||
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
||||||
@@ -20,27 +22,29 @@
|
|||||||
root.yoga.alignItems = YGAlignCenter;
|
root.yoga.alignItems = YGAlignCenter;
|
||||||
root.yoga.justifyContent = YGJustifyCenter;
|
root.yoga.justifyContent = YGJustifyCenter;
|
||||||
|
|
||||||
UIView* child1 = [UIView new];
|
UIView *child1 = [UIView new];
|
||||||
child1.backgroundColor = [UIColor blueColor];
|
child1.backgroundColor = [UIColor blueColor];
|
||||||
child1.yoga.isEnabled = YES;
|
child1.yoga.isEnabled = YES;
|
||||||
child1.yoga.width = YGPointValue(100);
|
child1.yoga.width = YGPointValue(100);
|
||||||
child1.yoga.height = YGPointValue(100);
|
child1.yoga.height = YGPointValue(100);
|
||||||
|
|
||||||
UIView* child2 = [UIView new];
|
UIView *child2 = [UIView new];
|
||||||
child2.backgroundColor = [UIColor greenColor];
|
child2.backgroundColor = [UIColor greenColor];
|
||||||
child2.frame = (CGRect){
|
child2.frame = (CGRect) {
|
||||||
.size = {
|
.size = {
|
||||||
.width = 200,
|
.width = 200,
|
||||||
.height = 100,
|
.height = 100,
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
UIView* child3 = [UIView new];
|
UIView *child3 = [UIView new];
|
||||||
child3.backgroundColor = [UIColor yellowColor];
|
child3.backgroundColor = [UIColor yellowColor];
|
||||||
child3.frame = (CGRect){
|
child3.frame = (CGRect) {
|
||||||
.size = {
|
.size = {
|
||||||
.width = 100,
|
.width = 100,
|
||||||
.height = 100,
|
.height = 100,
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
[child2 addSubview:child3];
|
[child2 addSubview:child3];
|
||||||
[root addSubview:child1];
|
[root addSubview:child1];
|
||||||
@@ -48,4 +52,5 @@
|
|||||||
[root.yoga applyLayoutPreservingOrigin:NO];
|
[root.yoga applyLayoutPreservingOrigin:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
12
android/BUCK
12
android/BUCK
@@ -1,13 +1,12 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "JAVA_TARGET", "PROGUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "android_aar", "android_resource")
|
||||||
|
|
||||||
yoga_android_aar(
|
android_aar(
|
||||||
name = "android",
|
name = "android",
|
||||||
enable_relinker = True,
|
|
||||||
manifest_skeleton = "src/main/AndroidManifest.xml",
|
manifest_skeleton = "src/main/AndroidManifest.xml",
|
||||||
visibility = [
|
visibility = [
|
||||||
"PUBLIC",
|
"PUBLIC",
|
||||||
@@ -15,12 +14,13 @@ yoga_android_aar(
|
|||||||
deps = [
|
deps = [
|
||||||
ANDROID_JAVA_TARGET,
|
ANDROID_JAVA_TARGET,
|
||||||
ANDROID_RES_TARGET,
|
ANDROID_RES_TARGET,
|
||||||
|
INFER_ANNOTATIONS_TARGET,
|
||||||
JAVA_TARGET,
|
JAVA_TARGET,
|
||||||
PROGUARD_ANNOTATIONS_TARGET,
|
PROGRUARD_ANNOTATIONS_TARGET,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_android_resource(
|
android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.yoga.android",
|
package = "com.facebook.yoga.android",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
|
@@ -1,16 +1,14 @@
|
|||||||
/*
|
apply plugin: 'com.jfrog.bintray'
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
|
version = VERSION_NAME
|
||||||
|
group = GROUP
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion rootProject.compileSdkVersion
|
compileSdkVersion rootProject.compileSdkVersion
|
||||||
buildToolsVersion rootProject.buildToolsVersion
|
buildToolsVersion rootProject.buildToolsVersion
|
||||||
ndkVersion rootProject.ndkVersion
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion rootProject.minSdkVersion
|
minSdkVersion rootProject.minSdkVersion
|
||||||
@@ -27,10 +25,21 @@ dependencies {
|
|||||||
api project(':yoga')
|
api project(':yoga')
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't build Javadoc at this time as we can't disable "BUCK" files
|
task sourcesJar(type: Jar) {
|
||||||
// from mistakenly getting parsed as Java.
|
classifier = 'source'
|
||||||
tasks.withType(Javadoc).all {
|
from android.sourceSets.main.java.srcDirs
|
||||||
enabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.vanniktech.maven.publish'
|
task javadoc(type: Javadoc) {
|
||||||
|
failOnError false
|
||||||
|
source = android.sourceSets.main.java.sourceFiles
|
||||||
|
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
||||||
|
classpath += configurations.compile
|
||||||
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
from javadoc.destinationDir
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: rootProject.file('gradle/release.gradle')
|
||||||
|
@@ -1,10 +1,3 @@
|
|||||||
#
|
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
# file in the root directory of this source tree.
|
|
||||||
#
|
|
||||||
|
|
||||||
GROUP=com.facebook.yoga.android
|
GROUP=com.facebook.yoga.android
|
||||||
POM_NAME=YogaLayout
|
POM_NAME=YogaLayout
|
||||||
POM_DESCRIPTION=YogaLayout
|
POM_DESCRIPTION=YogaLayout
|
||||||
|
@@ -4,10 +4,9 @@
|
|||||||
# This source code is licensed under the license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
|
load("//:yoga_defs.bzl", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_RES_TARGET", "android_binary", "android_resource")
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
|
|
||||||
|
|
||||||
yoga_android_binary(
|
android_binary(
|
||||||
name = "sample",
|
name = "sample",
|
||||||
keystore = ":debug_keystore",
|
keystore = ":debug_keystore",
|
||||||
manifest = "AndroidManifest.xml",
|
manifest = "AndroidManifest.xml",
|
||||||
@@ -17,7 +16,7 @@ yoga_android_binary(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_android_resource(
|
android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.facebook.samples.yoga",
|
package = "com.facebook.samples.yoga",
|
||||||
res = "res",
|
res = "res",
|
||||||
@@ -29,7 +28,7 @@ yoga_android_resource(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
fb_native.keystore(
|
keystore(
|
||||||
name = "debug_keystore",
|
name = "debug_keystore",
|
||||||
properties = "debug.keystore.properties",
|
properties = "debug.keystore.properties",
|
||||||
store = "debug.keystore",
|
store = "debug.keystore",
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the license found in the
|
# This source code is licensed under the license found in the
|
||||||
# LICENSE-examples file in the root directory of this source tree.
|
# LICENSE-examples file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "android_library")
|
||||||
|
|
||||||
yoga_android_library(
|
android_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
autoglob = False,
|
|
||||||
visibility = [
|
visibility = [
|
||||||
"PUBLIC",
|
"PUBLIC",
|
||||||
],
|
],
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
/*
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE-examples file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) Facebook, Inc. and its affiliates.
|
Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
|
||||||
This source code is licensed under the MIT license found in the
|
This source code is licensed under the MIT license found in the
|
||||||
LICENSE file in the root directory of this source tree.
|
LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
|
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "android_library")
|
||||||
|
|
||||||
yoga_android_library(
|
android_library(
|
||||||
name = "android",
|
name = "android",
|
||||||
srcs = glob(["**/*.java"]),
|
srcs = glob(["**/*.java"]),
|
||||||
autoglob = False,
|
|
||||||
visibility = [
|
visibility = [
|
||||||
"PUBLIC",
|
"PUBLIC",
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -18,7 +18,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.facebook.yoga.YogaNodeFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Much like a {@link YogaLayout}, except this class does not render itself (the container) to the
|
* Much like a {@link YogaLayout}, except this class does not render itself (the container) to the
|
||||||
@@ -34,7 +33,7 @@ public class VirtualYogaLayout extends ViewGroup {
|
|||||||
|
|
||||||
final private List<View> mChildren = new LinkedList<>();
|
final private List<View> mChildren = new LinkedList<>();
|
||||||
final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
|
final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
|
||||||
final private YogaNode mYogaNode = YogaNodeFactory.create();
|
final private YogaNode mYogaNode = new YogaNode();
|
||||||
|
|
||||||
public VirtualYogaLayout(Context context) {
|
public VirtualYogaLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -74,7 +73,7 @@ public class VirtualYogaLayout extends ViewGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaNode node = YogaNodeFactory.create();
|
YogaNode node = new YogaNode();
|
||||||
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
|
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
|
||||||
YogaLayout.applyLayoutParams(lp, node, child);
|
YogaLayout.applyLayoutParams(lp, node, child);
|
||||||
node.setData(child);
|
node.setData(child);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -29,7 +29,6 @@ import com.facebook.yoga.YogaMeasureFunction;
|
|||||||
import com.facebook.yoga.YogaMeasureMode;
|
import com.facebook.yoga.YogaMeasureMode;
|
||||||
import com.facebook.yoga.YogaMeasureOutput;
|
import com.facebook.yoga.YogaMeasureOutput;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.facebook.yoga.YogaNodeFactory;
|
|
||||||
import com.facebook.yoga.YogaOverflow;
|
import com.facebook.yoga.YogaOverflow;
|
||||||
import com.facebook.yoga.YogaPositionType;
|
import com.facebook.yoga.YogaPositionType;
|
||||||
import com.facebook.yoga.YogaWrap;
|
import com.facebook.yoga.YogaWrap;
|
||||||
@@ -47,14 +46,14 @@ import java.util.Map;
|
|||||||
* <YogaLayout
|
* <YogaLayout
|
||||||
* xmlns:android="http://schemas.android.com/apk/res/android"
|
* xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
|
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
|
||||||
* android:layout_width="match_owner"
|
* android:layout_width="match_parent"
|
||||||
* android:layout_height="match_owner"
|
* android:layout_height="match_parent"
|
||||||
* yoga:flex_direction="row"
|
* yoga:flex_direction="row"
|
||||||
* yoga:padding_all="10dp"
|
* yoga:padding_all="10dp"
|
||||||
* >
|
* >
|
||||||
* <TextView
|
* <TextView
|
||||||
* android:layout_width="match_owner"
|
* android:layout_width="match_parent"
|
||||||
* android:layout_height="match_owner"
|
* android:layout_height="match_parent"
|
||||||
* android:text="Hello, World!"
|
* android:text="Hello, World!"
|
||||||
* yoga:flex="1"
|
* yoga:flex="1"
|
||||||
* />
|
* />
|
||||||
@@ -79,7 +78,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
mYogaNode = YogaNodeFactory.create();
|
mYogaNode = new YogaNode();
|
||||||
mYogaNodes = new HashMap<>();
|
mYogaNodes = new HashMap<>();
|
||||||
|
|
||||||
mYogaNode.setData(this);
|
mYogaNode.setData(this);
|
||||||
@@ -156,7 +155,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if(mYogaNodes.containsKey(child)) {
|
if(mYogaNodes.containsKey(child)) {
|
||||||
childNode = mYogaNodes.get(child);
|
childNode = mYogaNodes.get(child);
|
||||||
} else {
|
} else {
|
||||||
childNode = YogaNodeFactory.create();
|
childNode = new YogaNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
childNode.setData(child);
|
childNode.setData(child);
|
||||||
@@ -263,11 +262,11 @@ public class YogaLayout extends ViewGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final YogaNode owner = node.getOwner();
|
final YogaNode parent = node.getParent();
|
||||||
|
|
||||||
for (int i = 0; i < owner.getChildCount(); i++) {
|
for (int i = 0; i < parent.getChildCount(); i++) {
|
||||||
if (owner.getChildAt(i).equals(node)) {
|
if (parent.getChildAt(i).equals(node)) {
|
||||||
owner.removeChildAt(i);
|
parent.removeChildAt(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +315,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
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 owner's onLayout, in which
|
// 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.
|
// case our r-l and b-t are the size of our node.
|
||||||
if (!(getParent() instanceof YogaLayout)) {
|
if (!(getParent() instanceof YogaLayout)) {
|
||||||
createLayout(
|
createLayout(
|
||||||
@@ -700,7 +699,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
/**
|
/**
|
||||||
* Constructs a set of layout params, given width and height specs. In this case, we can set
|
* Constructs a set of layout params, given width and height specs. In this case, we can set
|
||||||
* the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other
|
* the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other
|
||||||
* options (such as {@code match_owner} or {@code wrap_content} are given, then the owner
|
* options (such as {@code match_parent} or {@code wrap_content} are given, then the parent
|
||||||
* LayoutParams will store them, and we deal with them during layout. (see
|
* LayoutParams will store them, and we deal with them during layout. (see
|
||||||
* {@link YogaLayout#createLayout})
|
* {@link YogaLayout#createLayout})
|
||||||
*
|
*
|
||||||
@@ -774,9 +773,9 @@ public class YogaLayout extends ViewGroup {
|
|||||||
* {@code View}'s measure function.
|
* {@code View}'s measure function.
|
||||||
*
|
*
|
||||||
* @param node The yoga node to measure
|
* @param node The yoga node to measure
|
||||||
* @param width The suggested width from the owner
|
* @param width The suggested width from the parent
|
||||||
* @param widthMode The type of suggestion for the width
|
* @param widthMode The type of suggestion for the width
|
||||||
* @param height The suggested height from the owner
|
* @param height The suggested height from the parent
|
||||||
* @param heightMode The type of suggestion for the height
|
* @param heightMode The type of suggestion for the height
|
||||||
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
||||||
*/
|
*/
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) Facebook, Inc. and its affiliates.
|
Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
|
||||||
This source code is licensed under the MIT license found in the
|
This source code is licensed under the MIT license found in the
|
||||||
LICENSE file in the root directory of this source tree.
|
LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
|
|
||||||
|
|
||||||
yoga_cxx_binary(
|
load("//:yoga_defs.bzl", "yoga_dep")
|
||||||
|
|
||||||
|
cxx_binary(
|
||||||
name = "benchmark",
|
name = "benchmark",
|
||||||
srcs = glob(["*.c"]),
|
srcs = glob(["*.c"]),
|
||||||
headers = subdir_glob([("", "*.h")]),
|
headers = subdir_glob([("", "*.h")]),
|
||||||
|
@@ -1,79 +1,15 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include "YGBenchmark.h"
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#define NUM_REPETITIONS 1000
|
static YGSize _measure(YGNodeRef node,
|
||||||
|
|
||||||
#define YGBENCHMARKS(BLOCK) \
|
|
||||||
int main(int argc, char const* argv[]) { \
|
|
||||||
clock_t __start; \
|
|
||||||
clock_t __endTimes[NUM_REPETITIONS]; \
|
|
||||||
{ BLOCK } \
|
|
||||||
return 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YGBENCHMARK(NAME, BLOCK) \
|
|
||||||
__start = clock(); \
|
|
||||||
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
|
||||||
{BLOCK} __endTimes[__i] = clock(); \
|
|
||||||
} \
|
|
||||||
__printBenchmarkResult(NAME, __start, __endTimes);
|
|
||||||
|
|
||||||
static int __compareDoubles(const void* a, const void* b) {
|
|
||||||
double arg1 = *(const double*) a;
|
|
||||||
double arg2 = *(const double*) b;
|
|
||||||
|
|
||||||
if (arg1 < arg2) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg1 > arg2) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __printBenchmarkResult(
|
|
||||||
char* name,
|
|
||||||
clock_t start,
|
|
||||||
clock_t* endTimes) {
|
|
||||||
double timesInMs[NUM_REPETITIONS];
|
|
||||||
double mean = 0;
|
|
||||||
clock_t lastEnd = start;
|
|
||||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
|
||||||
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
|
|
||||||
lastEnd = endTimes[i];
|
|
||||||
mean += timesInMs[i];
|
|
||||||
}
|
|
||||||
mean /= NUM_REPETITIONS;
|
|
||||||
|
|
||||||
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
|
|
||||||
double median = timesInMs[NUM_REPETITIONS / 2];
|
|
||||||
|
|
||||||
double variance = 0;
|
|
||||||
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
|
||||||
variance += pow(timesInMs[i] - mean, 2);
|
|
||||||
}
|
|
||||||
variance /= NUM_REPETITIONS;
|
|
||||||
double stddev = sqrt(variance);
|
|
||||||
|
|
||||||
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static YGSize _measure(
|
|
||||||
YGNodeRef node,
|
|
||||||
float width,
|
float width,
|
||||||
YGMeasureMode widthMode,
|
YGMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
@@ -85,6 +21,7 @@ static YGSize _measure(
|
|||||||
}
|
}
|
||||||
|
|
||||||
YGBENCHMARKS({
|
YGBENCHMARKS({
|
||||||
|
|
||||||
YGBENCHMARK("Stack with flex", {
|
YGBENCHMARK("Stack with flex", {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
YGNodeStyleSetWidth(root, 100);
|
YGNodeStyleSetWidth(root, 100);
|
||||||
@@ -160,10 +97,9 @@ YGBENCHMARKS({
|
|||||||
YGNodeStyleSetHeight(grandGrandChild, 10);
|
YGNodeStyleSetHeight(grandGrandChild, 10);
|
||||||
YGNodeInsertChild(grandChild, grandGrandChild, 0);
|
YGNodeInsertChild(grandChild, grandGrandChild, 0);
|
||||||
|
|
||||||
for (uint32_t iiii = 0; iiii < 10; iiii++) {
|
for (uint32_t iii = 0; iii < 10; iii++) {
|
||||||
const YGNodeRef grandGrandGrandChild = YGNodeNew();
|
const YGNodeRef grandGrandGrandChild = YGNodeNew();
|
||||||
YGNodeStyleSetFlexDirection(
|
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
|
||||||
grandGrandGrandChild, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
|
||||||
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
|
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
|
||||||
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
|
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
|
||||||
@@ -176,4 +112,5 @@ YGBENCHMARKS({
|
|||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
71
benchmark/YGBenchmark.h
Normal file
71
benchmark/YGBenchmark.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define NUM_REPETITIONS 1000
|
||||||
|
|
||||||
|
#define YGBENCHMARKS(BLOCK) \
|
||||||
|
int main(int argc, char const *argv[]) { \
|
||||||
|
clock_t __start; \
|
||||||
|
clock_t __endTimes[NUM_REPETITIONS]; \
|
||||||
|
{ BLOCK } \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define YGBENCHMARK(NAME, BLOCK) \
|
||||||
|
__start = clock(); \
|
||||||
|
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
|
||||||
|
{ BLOCK } \
|
||||||
|
__endTimes[__i] = clock(); \
|
||||||
|
} \
|
||||||
|
__printBenchmarkResult(NAME, __start, __endTimes);
|
||||||
|
|
||||||
|
int __compareDoubles(const void *a, const void *b) {
|
||||||
|
double arg1 = *(const double *) a;
|
||||||
|
double arg2 = *(const double *) b;
|
||||||
|
|
||||||
|
if (arg1 < arg2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg1 > arg2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
|
||||||
|
double timesInMs[NUM_REPETITIONS];
|
||||||
|
double mean = 0;
|
||||||
|
clock_t lastEnd = start;
|
||||||
|
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||||
|
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
|
||||||
|
lastEnd = endTimes[i];
|
||||||
|
mean += timesInMs[i];
|
||||||
|
}
|
||||||
|
mean /= NUM_REPETITIONS;
|
||||||
|
|
||||||
|
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
|
||||||
|
double median = timesInMs[NUM_REPETITIONS / 2];
|
||||||
|
|
||||||
|
double variance = 0;
|
||||||
|
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
|
||||||
|
variance += pow(timesInMs[i] - mean, 2);
|
||||||
|
}
|
||||||
|
variance /= NUM_REPETITIONS;
|
||||||
|
double stddev = sqrt(variance);
|
||||||
|
|
||||||
|
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
|
||||||
|
}
|
27
build.gradle
27
build.gradle
@@ -1,20 +1,15 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
jcenter()
|
||||||
mavenCentral()
|
maven { url 'https://maven.google.com/' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||||
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||||
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
@@ -22,17 +17,15 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
jcenter()
|
||||||
mavenCentral()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
minSdkVersion = 14
|
minSdkVersion = 14
|
||||||
targetSdkVersion = 29
|
targetSdkVersion = 25
|
||||||
compileSdkVersion = 29
|
compileSdkVersion = 26
|
||||||
buildToolsVersion = '30.0.2'
|
buildToolsVersion = '26.0.2'
|
||||||
ndkVersion = '21.3.6528147'
|
|
||||||
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
57
csharp/BUCK
57
csharp/BUCK
@@ -1,36 +1,29 @@
|
|||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
|
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "yoga_dep", "cxx_library", "is_apple_platform")
|
||||||
load(
|
|
||||||
"//tools/build_defs/oss:yoga_defs.bzl",
|
|
||||||
"BASE_COMPILER_FLAGS",
|
|
||||||
"yoga_apple_binary",
|
|
||||||
"yoga_cxx_library",
|
|
||||||
"yoga_dep",
|
|
||||||
)
|
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
|
||||||
|
|
||||||
fb_native.csharp_library(
|
csharp_library(
|
||||||
name = "yogalibnet46",
|
name = "yogalibnet46",
|
||||||
srcs = glob(["**/*.cs"]),
|
srcs = glob(["**/*.cs"]),
|
||||||
dll_name = "Facebook.Yoga.dll",
|
dll_name = "Facebook.Yoga.dll",
|
||||||
framework_ver = "net46",
|
framework_ver = "net46",
|
||||||
)
|
)
|
||||||
|
|
||||||
fb_native.csharp_library(
|
csharp_library(
|
||||||
name = "yogalibnet45",
|
name = "yogalibnet45",
|
||||||
srcs = glob(["**/*.cs"]),
|
srcs = glob(["**/*.cs"]),
|
||||||
dll_name = "Facebook.Yoga.dll",
|
dll_name = "Facebook.Yoga.dll",
|
||||||
framework_ver = "net45",
|
framework_ver = "net45",
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_cxx_library(
|
cxx_library(
|
||||||
name = "yoganet",
|
name = "yoganet",
|
||||||
srcs = ["Yoga/YGInterop.cpp"],
|
srcs = glob(["Yoga/YGInterop.cpp"]),
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
link_style = "static",
|
link_style = "static",
|
||||||
link_whole = True,
|
link_whole = True,
|
||||||
@@ -39,4 +32,40 @@ yoga_cxx_library(
|
|||||||
deps = [yoga_dep(":yoga")],
|
deps = [yoga_dep(":yoga")],
|
||||||
)
|
)
|
||||||
|
|
||||||
yoga_apple_binary()
|
if is_apple_platform():
|
||||||
|
yoganet_ios_srcs = []
|
||||||
|
for arch in [
|
||||||
|
'iphonesimulator-x86_64', 'iphoneos-arm64'
|
||||||
|
]:
|
||||||
|
name = 'yoganet-' + arch
|
||||||
|
yoganet_ios_srcs.append(':' + name)
|
||||||
|
genrule(
|
||||||
|
name = name,
|
||||||
|
srcs = [
|
||||||
|
yoga_dep(':yoga#%s,static' % arch),
|
||||||
|
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
|
||||||
|
yoga_dep('csharp:yoganet#%s,static' % arch),
|
||||||
|
],
|
||||||
|
out = 'libyoga-%s.a' % arch,
|
||||||
|
cmd = 'libtool -static -o $OUT $SRCS',
|
||||||
|
visibility = [yoga_dep('csharp:yoganet-ios')],
|
||||||
|
)
|
||||||
|
|
||||||
|
genrule(
|
||||||
|
name = 'yoganet-ios',
|
||||||
|
srcs = yoganet_ios_srcs,
|
||||||
|
out = 'libyoga.a',
|
||||||
|
cmd = 'lipo $SRCS -create -output $OUT',
|
||||||
|
visibility = ['PUBLIC'],
|
||||||
|
)
|
||||||
|
|
||||||
|
yoganet_macosx_target = 'csharp:yoganet#macosx-%s,dynamic'
|
||||||
|
genrule(
|
||||||
|
name = 'yoganet-macosx',
|
||||||
|
srcs = [
|
||||||
|
yoga_dep(yoganet_macosx_target % 'x86_64')
|
||||||
|
],
|
||||||
|
out = 'libyoga.dylib',
|
||||||
|
cmd = 'lipo $SRCS -create -output $OUT',
|
||||||
|
visibility = ['PUBLIC'],
|
||||||
|
)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -10,6 +10,12 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
|
#if WINDOWS_UWP_ARM
|
||||||
|
using YogaValueType = IntPtr;
|
||||||
|
#else
|
||||||
|
using YogaValueType = YogaValue;
|
||||||
|
#endif
|
||||||
|
|
||||||
internal static class Native
|
internal static class Native
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
||||||
@@ -43,6 +49,9 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGConfigFree(IntPtr node);
|
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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int YGConfigGetInstanceCount();
|
public static extern int YGConfigGetInstanceCount();
|
||||||
|
|
||||||
@@ -65,14 +74,6 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
|
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern void YGConfigSetUseLegacyStretchBehaviour(
|
|
||||||
YGConfigHandle config,
|
|
||||||
bool useLegacyStretchBehavior);
|
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);
|
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGConfigSetPointScaleFactor(
|
public static extern void YGConfigSetPointScaleFactor(
|
||||||
YGConfigHandle config,
|
YGConfigHandle config,
|
||||||
@@ -87,14 +88,6 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
|
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern void YGNodeSetIsReferenceBaseline(
|
|
||||||
YGNodeHandle node,
|
|
||||||
bool isReferenceBaseline);
|
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern bool YGNodeIsReferenceBaseline(YGNodeHandle node);
|
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeCalculateLayout(
|
public static extern void YGNodeCalculateLayout(
|
||||||
YGNodeHandle node,
|
YGNodeHandle node,
|
||||||
@@ -225,7 +218,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
|
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
|
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
|
||||||
@@ -237,7 +230,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
|
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
|
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
|
||||||
@@ -249,7 +242,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
|
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
|
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
|
||||||
@@ -258,7 +251,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
|
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
|
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
|
||||||
@@ -267,7 +260,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
|
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
|
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
|
||||||
@@ -276,7 +269,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
|
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
|
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
|
||||||
@@ -285,7 +278,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
|
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
|
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
|
||||||
@@ -304,7 +297,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
|
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
|
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
|
||||||
@@ -316,7 +309,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
|
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
|
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
|
||||||
@@ -325,7 +318,7 @@ namespace Facebook.Yoga
|
|||||||
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
|
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[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)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
|
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -117,19 +117,6 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UseLegacyStretchBehaviour
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float PointScaleFactor
|
public float PointScaleFactor
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -13,7 +13,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -26,7 +26,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -39,7 +39,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -52,7 +52,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -65,7 +65,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -78,7 +78,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -103,7 +103,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -116,7 +116,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -129,7 +129,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -142,7 +142,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -155,7 +155,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -168,7 +168,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -181,7 +181,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -194,7 +194,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -207,7 +207,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -236,7 +236,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -249,7 +249,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -262,7 +262,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -275,7 +275,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -288,7 +288,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -301,7 +301,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -314,7 +314,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -327,7 +327,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -340,7 +340,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -271,7 +271,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetFlexBasis(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -295,7 +295,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetWidth(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -319,7 +319,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetHeight(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -343,7 +343,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMaxWidth(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -363,7 +363,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMaxHeight(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -383,7 +383,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMinWidth(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -403,7 +403,7 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Native.YGNodeStyleGetMinHeight(_ygNode);
|
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
@@ -519,19 +519,6 @@ namespace Facebook.Yoga
|
|||||||
Native.YGNodeSetHasNewLayout(_ygNode, false);
|
Native.YGNodeSetHasNewLayout(_ygNode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsReferenceBaseline
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Native.YGNodeIsReferenceBaseline(_ygNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Native.YGNodeSetIsReferenceBaseline(_ygNode, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ValuesEqual(float f1, float f2)
|
public bool ValuesEqual(float f1, float f2)
|
||||||
{
|
{
|
||||||
if (float.IsNaN(f1) || float.IsNaN(f2))
|
if (float.IsNaN(f1) || float.IsNaN(f2))
|
||||||
@@ -673,5 +660,10 @@ namespace Facebook.Yoga
|
|||||||
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
||||||
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetInstanceCount()
|
||||||
|
{
|
||||||
|
return Native.YGNodeGetInstanceCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -91,5 +91,17 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
return Point(pointValue);
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,7 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
#
|
|
||||||
# This source code is licensed under the MIT license found in the
|
|
||||||
# LICENSE file in the root directory of this source tree.
|
|
||||||
|
|
||||||
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests
|
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests
|
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,11 +1,4 @@
|
|||||||
/*
|
using System;
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||||
using Facebook.Yoga;
|
using Facebook.Yoga;
|
||||||
|
|
||||||
@@ -213,8 +206,8 @@ namespace Facebook.Yoga.Universal.Tests
|
|||||||
return MeasureOutput.Make(123.4f, 81.7f);
|
return MeasureOutput.Make(123.4f, 81.7f);
|
||||||
});
|
});
|
||||||
node.CalculateLayout();
|
node.CalculateLayout();
|
||||||
Assert.AreEqual(124, node.LayoutWidth);
|
Assert.AreEqual(123, node.LayoutWidth);
|
||||||
Assert.AreEqual(82, node.LayoutHeight);
|
Assert.AreEqual(81, node.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -275,12 +268,7 @@ namespace Facebook.Yoga.Universal.Tests
|
|||||||
parent.Insert(0, child0);
|
parent.Insert(0, child0);
|
||||||
parent.Insert(0, child1);
|
parent.Insert(0, child1);
|
||||||
parent.CalculateLayout();
|
parent.CalculateLayout();
|
||||||
Assert.AreEqual(parent.Print(),
|
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
|
||||||
"<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>"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
@@ -9,11 +9,10 @@
|
|||||||
|
|
||||||
static YGInteropLogger gManagedLogger;
|
static YGInteropLogger gManagedLogger;
|
||||||
|
|
||||||
static int unmanagedLogger(
|
static int unmanagedLogger(const YGConfigRef config,
|
||||||
const YGConfigRef config,
|
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
YGLogLevel level,
|
YGLogLevel level,
|
||||||
const char* format,
|
const char *format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (gManagedLogger) {
|
if (gManagedLogger) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user