Compare commits
174 Commits
v1.12.0-pr
...
1.16.0
Author | SHA1 | Date | |
---|---|---|---|
|
26dbe8b4ff | ||
|
a5c2f7f27a | ||
|
10811e1a94 | ||
|
10f4bceac0 | ||
|
47717324d4 | ||
|
1043c35f2b | ||
|
fde89b056d | ||
|
a08a57b33c | ||
|
31de91bbac | ||
|
e6e224ce48 | ||
|
a04a6b5e8f | ||
|
442d84ccfc | ||
|
4a2ccc658e | ||
|
58622fa747 | ||
|
90cded3819 | ||
|
d1e188341b | ||
|
0f2350308e | ||
|
9b120eded9 | ||
|
a218880216 | ||
|
1a2802028b | ||
|
a37b286bae | ||
|
dcfdb955b3 | ||
|
72cefead02 | ||
|
884e064a99 | ||
|
3ed9bec05c | ||
|
dadf0473b7 | ||
|
947230958d | ||
|
095c991b85 | ||
|
825da1e868 | ||
|
5a25805cb5 | ||
|
adff8d96dd | ||
|
8c270e68cc | ||
|
a2aa1b7fca | ||
|
ae956f06fb | ||
|
8c0eed3c75 | ||
|
4e4ef06de1 | ||
|
a53c14dc75 | ||
|
c99fc9c4da | ||
|
2fb857d73d | ||
|
e6dfe04388 | ||
|
5e40e4b682 | ||
|
7c891db9af | ||
|
6d916ab063 | ||
|
59d680f4e9 | ||
|
be305b5d0f | ||
|
d676d917e3 | ||
|
838fc3f019 | ||
|
296982a29e | ||
|
1d0668692b | ||
|
39e512f691 | ||
|
0f250490d4 | ||
|
eeae39d707 | ||
|
ce517689ff | ||
|
9c82ba783f | ||
|
1c8e8d3aec | ||
|
cc27d85110 | ||
|
cd5324378d | ||
|
c6ae314202 | ||
|
73224c62b5 | ||
|
2c6a4485f5 | ||
|
cf005df828 | ||
|
f539d68049 | ||
|
39996512fc | ||
|
2dc5a16d1f | ||
|
d667ebd66e | ||
|
2b8217ce8d | ||
|
9dac56e824 | ||
|
a7e8aec3d9 | ||
|
6b5bf570c8 | ||
|
a130ac2f9c | ||
|
19fd066507 | ||
|
204e849218 | ||
|
8ff13c922a | ||
|
af219f8836 | ||
|
e33123f955 | ||
|
755fa07b39 | ||
|
2701d80078 | ||
|
c393ed1381 | ||
|
a4bdd9cd9b | ||
|
4a4325afb6 | ||
|
586eb6102a | ||
|
b1e6793460 | ||
|
8b17459254 | ||
|
195c166efe | ||
|
0908d3a173 | ||
|
f304990656 | ||
|
cea3865c74 | ||
|
b74c0d4766 | ||
|
54e863cef2 | ||
|
1938792517 | ||
|
aa71dbb5bd | ||
|
8dc46c0a87 | ||
|
1180afed9c | ||
|
1562bce9b4 | ||
|
a9514513a7 | ||
|
cf809b8e8b | ||
|
d7ff5c0689 | ||
|
e3156279fc | ||
|
0ce42d83e0 | ||
|
afc1108659 | ||
|
a15bf6e701 | ||
|
74fc37efc8 | ||
|
5824dbda66 | ||
|
e96a09e5ff | ||
|
9e20dfeea1 | ||
|
6e04631862 | ||
|
88b23ebb3d | ||
|
018916403e | ||
|
af38fd31f8 | ||
|
1e0ebdae2f | ||
|
1adbafe950 | ||
|
e51ca95713 | ||
|
a803421739 | ||
|
011c1964a0 | ||
|
05d205cf89 | ||
|
0a4f7bd558 | ||
|
cea862a6bf | ||
|
cc02a20c9e | ||
|
98fda9c587 | ||
|
2eed95f3e4 | ||
|
e5d3baca81 | ||
|
dee93017f7 | ||
|
e167642672 | ||
|
e9bb1efb03 | ||
|
3f7d03b443 | ||
|
ffce716557 | ||
|
fcfb19e9cf | ||
|
c5f105a7b6 | ||
|
b062d23947 | ||
|
7fc6fcb38c | ||
|
bc7e504b29 | ||
|
3d8afa9e90 | ||
|
a1e47e37ae | ||
|
e0bc0ebe29 | ||
|
498c0ff4bf | ||
|
d42d43e90f | ||
|
bfc6319daa | ||
|
74ce5afd9e | ||
|
c11faf2d56 | ||
|
5fad8008ab | ||
|
948ade4b1c | ||
|
b1a7f2b4d9 | ||
|
d44a6d936f | ||
|
1fc8472d35 | ||
|
c235301b52 | ||
|
2fb81500c1 | ||
|
68d9209dd9 | ||
|
e91569cdad | ||
|
f31917aa01 | ||
|
74202aecff | ||
|
9c2108c69e | ||
|
3d2836a947 | ||
|
e4856a2264 | ||
|
a2ee0f65bd | ||
|
85352c4e45 | ||
|
7d7b7b9e18 | ||
|
62d8a911ff | ||
|
ca46c67e9e | ||
|
5bb2265083 | ||
|
ab3bf40c7d | ||
|
f273e80c77 | ||
|
1471be54e3 | ||
|
f039835249 | ||
|
f793ba2d6b | ||
|
9f72ad05ce | ||
|
14f3827491 | ||
|
0d96098fd9 | ||
|
42e3b78f04 | ||
|
3ad49d27d9 | ||
|
3331a9e480 | ||
|
7890672ecc | ||
|
d7bfbf3646 | ||
|
6d271c05f6 | ||
|
a9bddf87ff |
@@ -9,7 +9,7 @@ AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
|
@@ -1 +1 @@
|
||||
3.0
|
||||
4.0
|
||||
|
@@ -1,5 +1,6 @@
|
||||
language: java
|
||||
os: linux
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
|
33
BUCK
33
BUCK
@@ -9,20 +9,17 @@ GMOCK_OVERRIDE_FLAGS = [
|
||||
"-Wno-inconsistent-missing-override",
|
||||
]
|
||||
|
||||
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
|
||||
"-std=c++1y",
|
||||
]
|
||||
|
||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
||||
"-std=c++1y",
|
||||
"-DDEBUG",
|
||||
"-DYG_ENABLE_EVENTS",
|
||||
]
|
||||
|
||||
yoga_cxx_library(
|
||||
name = "yoga",
|
||||
srcs = glob(["yoga/*.cpp"]),
|
||||
header_namespace = "",
|
||||
exported_headers = subdir_glob([("", "yoga/*.h")]),
|
||||
compiler_flags = COMPILER_FLAGS,
|
||||
srcs = glob(["yoga/**/*.cpp"]),
|
||||
compiler_flags = LIBRARY_COMPILER_FLAGS,
|
||||
public_include_directories = ["."],
|
||||
raw_headers = glob(["yoga/**/*.h"]),
|
||||
soname = "libyogacore.$(ext)",
|
||||
tests = [":YogaTests"],
|
||||
visibility = ["PUBLIC"],
|
||||
@@ -31,6 +28,21 @@ yoga_cxx_library(
|
||||
],
|
||||
)
|
||||
|
||||
yoga_cxx_library(
|
||||
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_dep("lib/fb:ndklog"),
|
||||
],
|
||||
)
|
||||
|
||||
yoga_cxx_test(
|
||||
name = "YogaTests",
|
||||
srcs = glob(["tests/*.cpp"]),
|
||||
@@ -39,7 +51,8 @@ yoga_cxx_test(
|
||||
contacts = ["emilsj@fb.com"],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
":yoga",
|
||||
":yogaForDebug",
|
||||
yoga_dep("testutil:testutil"),
|
||||
GTEST_TARGET,
|
||||
],
|
||||
)
|
||||
|
@@ -9,7 +9,9 @@ cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
file(GLOB yogacore_SRC yoga/*.cpp)
|
||||
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
|
||||
add_library(yogacore STATIC ${yogacore_SRC})
|
||||
|
||||
target_include_directories(yogacore PUBLIC .)
|
||||
target_link_libraries(yogacore android log)
|
||||
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
|
||||
|
@@ -1,3 +1,77 @@
|
||||
# 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.
|
||||
## Our Pledge
|
||||
|
||||
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
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# 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
|
||||
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
|
||||
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`.
|
||||
|
5212
ReactYoga.xcodeproj/project.pbxproj
Normal file
5212
ReactYoga.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
#
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'Yoga'
|
||||
spec.version = '1.12.0-pre.1'
|
||||
spec.version = '1.14.0'
|
||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||
spec.homepage = 'https://yogalayout.com/'
|
||||
spec.documentation_url = 'https://yogalayout.com/docs'
|
||||
@@ -19,7 +19,7 @@ Pod::Spec.new do |spec|
|
||||
:git => 'https://github.com/facebook/yoga.git',
|
||||
:tag => spec.version.to_s,
|
||||
}
|
||||
spec.platforms = { :ios => "4.3", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
|
||||
spec.platforms = { :ios => "8.0", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
|
||||
spec.module_name = 'yoga'
|
||||
spec.requires_arc = false
|
||||
spec.pod_target_xcconfig = {
|
||||
|
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
Normal file
10
YogaDev.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?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>
|
@@ -0,0 +1,8 @@
|
||||
<?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>
|
350
YogaDev/YogaDev.xcodeproj/project.pbxproj
Normal file
350
YogaDev/YogaDev.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,350 @@
|
||||
// !$*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 */;
|
||||
}
|
@@ -6,10 +6,10 @@
|
||||
#
|
||||
podspec = Pod::Spec.new do |spec|
|
||||
spec.name = 'YogaKit'
|
||||
spec.version = '1.12.0'
|
||||
spec.version = '1.14.0'
|
||||
spec.license = { :type => 'MIT', :file => "LICENSE" }
|
||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
|
||||
|
||||
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.'
|
||||
@@ -23,12 +23,11 @@ podspec = Pod::Spec.new do |spec|
|
||||
spec.platform = :ios
|
||||
spec.ios.deployment_target = '8.0'
|
||||
spec.ios.frameworks = 'UIKit'
|
||||
|
||||
spec.dependency 'Yoga', '~> 1.9'
|
||||
spec.dependency 'Yoga', '~> 1.14'
|
||||
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||
spec.swift_version = '3.0'
|
||||
spec.swift_version = '4.0'
|
||||
end
|
||||
|
||||
# See https://github.com/facebook/yoga/pull/366
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -180,7 +180,7 @@ static YGConfigRef globalConfig;
|
||||
// the measure function. Since we already know that this is a leaf,
|
||||
// this *should* be fine. Forgive me Hack Gods.
|
||||
const YGNodeRef node = self.node;
|
||||
if (YGNodeHasMeasureFunc(node)) {
|
||||
if (!YGNodeHasMeasureFunc(node)) {
|
||||
YGNodeSetMeasureFunc(node, YGMeasureView);
|
||||
}
|
||||
|
||||
|
@@ -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.
|
||||
-->
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
|
@@ -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.
|
||||
-->
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
import android.content.Intent;
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
import java.io.File;
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
@@ -1,5 +1,9 @@
|
||||
// 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;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
@@ -1,11 +1,9 @@
|
||||
/**
|
||||
* Copyright 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the license found in the
|
||||
* LICENSE-examples file in the root directory of this source tree.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.samples.yoga;
|
||||
|
||||
import android.content.Intent;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.yoga.android;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.yoga.android;
|
||||
|
||||
import android.content.Context;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.yoga.android;
|
||||
|
||||
import android.content.Context;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -43,9 +43,6 @@ namespace Facebook.Yoga
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void YGConfigFree(IntPtr node);
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int YGNodeGetInstanceCount();
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int YGConfigGetInstanceCount();
|
||||
|
||||
|
@@ -673,10 +673,5 @@ namespace Facebook.Yoga
|
||||
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
||||
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
||||
}
|
||||
|
||||
public static int GetInstanceCount()
|
||||
{
|
||||
return Native.YGNodeGetInstanceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,3 +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.
|
||||
*/
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Yoga.rc
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
|
||||
|
||||
using System;
|
||||
@@ -362,39 +361,6 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
@@ -419,6 +385,39 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(10f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(20f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child3.LayoutX);
|
||||
Assert.AreEqual(30f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(40f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(10f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
|
||||
|
||||
using System;
|
||||
@@ -214,8 +213,6 @@ namespace Facebook.Yoga
|
||||
root_child1_child0.FlexShrink = 1;
|
||||
root_child1_child0.FlexBasis = 0.Percent();
|
||||
root_child1_child0.Width = 20;
|
||||
root_child1_child0.MinWidth = 0;
|
||||
root_child1_child0.MinHeight = 0;
|
||||
root_child1.Insert(0, root_child1_child0);
|
||||
|
||||
YogaNode root_child2 = new YogaNode(config);
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html
|
||||
|
||||
using System;
|
||||
@@ -530,12 +529,12 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
Assert.AreEqual(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
@@ -548,12 +547,12 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(100f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(50f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
Assert.AreEqual(0f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||
Assert.AreEqual(0f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
|
||||
|
||||
using System;
|
||||
|
@@ -1,10 +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.
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
|
||||
|
||||
using System;
|
||||
|
286
enums.py
286
enums.py
@@ -3,107 +3,57 @@
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
|
||||
ENUMS = {
|
||||
'Direction': [
|
||||
'Inherit',
|
||||
'LTR',
|
||||
'RTL',
|
||||
"Direction": ["Inherit", "LTR", "RTL"],
|
||||
"Unit": ["Undefined", "Point", "Percent", "Auto"],
|
||||
"FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
|
||||
"Justify": [
|
||||
"FlexStart",
|
||||
"Center",
|
||||
"FlexEnd",
|
||||
"SpaceBetween",
|
||||
"SpaceAround",
|
||||
"SpaceEvenly",
|
||||
],
|
||||
'Unit': [
|
||||
'Undefined',
|
||||
'Point',
|
||||
'Percent',
|
||||
'Auto',
|
||||
"Overflow": ["Visible", "Hidden", "Scroll"],
|
||||
"Align": [
|
||||
"Auto",
|
||||
"FlexStart",
|
||||
"Center",
|
||||
"FlexEnd",
|
||||
"Stretch",
|
||||
"Baseline",
|
||||
"SpaceBetween",
|
||||
"SpaceAround",
|
||||
],
|
||||
'FlexDirection': [
|
||||
'Column',
|
||||
'ColumnReverse',
|
||||
'Row',
|
||||
'RowReverse',
|
||||
"PositionType": ["Relative", "Absolute"],
|
||||
"Display": ["Flex", "None"],
|
||||
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
|
||||
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
|
||||
"Dimension": ["Width", "Height"],
|
||||
"Edge": [
|
||||
"Left",
|
||||
"Top",
|
||||
"Right",
|
||||
"Bottom",
|
||||
"Start",
|
||||
"End",
|
||||
"Horizontal",
|
||||
"Vertical",
|
||||
"All",
|
||||
],
|
||||
'Justify': [
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'SpaceBetween',
|
||||
'SpaceAround',
|
||||
'SpaceEvenly',
|
||||
],
|
||||
'Overflow': [
|
||||
'Visible',
|
||||
'Hidden',
|
||||
'Scroll',
|
||||
],
|
||||
'Align': [
|
||||
'Auto',
|
||||
'FlexStart',
|
||||
'Center',
|
||||
'FlexEnd',
|
||||
'Stretch',
|
||||
'Baseline',
|
||||
'SpaceBetween',
|
||||
'SpaceAround',
|
||||
],
|
||||
'PositionType': [
|
||||
'Relative',
|
||||
'Absolute',
|
||||
],
|
||||
'Display': [
|
||||
'Flex',
|
||||
'None',
|
||||
],
|
||||
'Wrap': [
|
||||
'NoWrap',
|
||||
'Wrap',
|
||||
'WrapReverse',
|
||||
],
|
||||
'MeasureMode': [
|
||||
'Undefined',
|
||||
'Exactly',
|
||||
'AtMost',
|
||||
],
|
||||
'Dimension': [
|
||||
'Width',
|
||||
'Height',
|
||||
],
|
||||
'Edge': [
|
||||
'Left',
|
||||
'Top',
|
||||
'Right',
|
||||
'Bottom',
|
||||
'Start',
|
||||
'End',
|
||||
'Horizontal',
|
||||
'Vertical',
|
||||
'All',
|
||||
],
|
||||
'NodeType': [
|
||||
'Default',
|
||||
'Text',
|
||||
],
|
||||
'LogLevel': [
|
||||
'Error',
|
||||
'Warn',
|
||||
'Info',
|
||||
'Debug',
|
||||
'Verbose',
|
||||
'Fatal',
|
||||
],
|
||||
'ExperimentalFeature': [
|
||||
"NodeType": ["Default", "Text"],
|
||||
"LogLevel": ["Error", "Warn", "Info", "Debug", "Verbose", "Fatal"],
|
||||
"ExperimentalFeature": [
|
||||
# Mimic web flex-basis behavior.
|
||||
'WebFlexBasis',
|
||||
],
|
||||
'PrintOptions': [
|
||||
('Layout', 1),
|
||||
('Style', 2),
|
||||
('Children', 4),
|
||||
"WebFlexBasis"
|
||||
],
|
||||
"PrintOptions": [("Layout", 1), ("Style", 2), ("Children", 4)],
|
||||
}
|
||||
|
||||
LICENSE = """/**
|
||||
@@ -115,23 +65,25 @@ LICENSE = """/**
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def to_java_upper(symbol):
|
||||
symbol = str(symbol)
|
||||
out = ''
|
||||
out = ""
|
||||
for i in range(0, len(symbol)):
|
||||
c = symbol[i]
|
||||
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
|
||||
out += '_'
|
||||
out += "_"
|
||||
out += c.upper()
|
||||
return out
|
||||
|
||||
|
||||
def to_log_lower(symbol):
|
||||
symbol = str(symbol)
|
||||
out = ''
|
||||
out = ""
|
||||
for i in range(0, len(symbol)):
|
||||
c = symbol[i]
|
||||
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
|
||||
out += '-'
|
||||
out += "-"
|
||||
out += c.lower()
|
||||
return out
|
||||
|
||||
@@ -139,114 +91,128 @@ def to_log_lower(symbol):
|
||||
root = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# write out C & Objective-C headers
|
||||
with open(root + '/yoga/YGEnums.h', 'w') as f:
|
||||
with open(root + "/yoga/YGEnums.h", "w") as f:
|
||||
f.write(LICENSE)
|
||||
f.write('#pragma once\n\n')
|
||||
f.write("#pragma once\n\n")
|
||||
f.write('#include "YGMacros.h"\n\n')
|
||||
f.write('YG_EXTERN_C_BEGIN\n\n')
|
||||
f.write("YG_EXTERN_C_BEGIN\n\n")
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
f.write('#define YG%sCount %s\n' % (name, len(values)))
|
||||
f.write('typedef YG_ENUM_BEGIN(YG%s) {\n' % name)
|
||||
f.write("#define YG%sCount %s\n" % (name, len(values)))
|
||||
f.write("typedef YG_ENUM_BEGIN(YG%s) {\n" % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
|
||||
f.write(" YG%s%s = %d,\n" % (name, value[0], value[1]))
|
||||
else:
|
||||
f.write(' YG%s%s,\n' % (name, value))
|
||||
f.write('} YG_ENUM_END(YG%s);\n' % name)
|
||||
f.write('WIN_EXPORT const char *YG%sToString(const YG%s value);\n' % (name, name))
|
||||
f.write('\n')
|
||||
f.write('YG_EXTERN_C_END\n')
|
||||
f.write(" YG%s%s,\n" % (name, value))
|
||||
f.write("} YG_ENUM_END(YG%s);\n" % name)
|
||||
f.write(
|
||||
"WIN_EXPORT const char *YG%sToString(const YG%s value);\n" % (name, name)
|
||||
)
|
||||
f.write("\n")
|
||||
f.write("YG_EXTERN_C_END\n")
|
||||
|
||||
# write out C body for printing
|
||||
with open(root + '/yoga/YGEnums.cpp', 'w') as f:
|
||||
with open(root + "/yoga/YGEnums.cpp", "w") as f:
|
||||
f.write(LICENSE)
|
||||
f.write('#include "YGEnums.h"\n\n')
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
f.write('const char *YG%sToString(const YG%s value){\n' % (name, name))
|
||||
f.write(' switch(value){\n')
|
||||
f.write("const char *YG%sToString(const YG%s value){\n" % (name, name))
|
||||
f.write(" switch(value){\n")
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' case YG%s%s:\n' % (name, value[0]))
|
||||
f.write(" case YG%s%s:\n" % (name, value[0]))
|
||||
f.write(' return "%s";\n' % to_log_lower(value[0]))
|
||||
else:
|
||||
f.write(' case YG%s%s:\n' % (name, value))
|
||||
f.write(" case YG%s%s:\n" % (name, value))
|
||||
f.write(' return "%s";\n' % to_log_lower(value))
|
||||
f.write(' }\n')
|
||||
f.write(" }\n")
|
||||
f.write(' return "unknown";\n')
|
||||
f.write('}\n\n')
|
||||
f.write("}\n\n")
|
||||
|
||||
# write out java files
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f:
|
||||
f.write(LICENSE.replace('/**', '/*', 1))
|
||||
f.write('package com.facebook.yoga;\n\n')
|
||||
f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n')
|
||||
f.write('@DoNotStrip\n')
|
||||
f.write('public enum Yoga%s {\n' % name)
|
||||
with open(root + "/java/com/facebook/yoga/Yoga%s.java" % name, "w") as f:
|
||||
f.write(LICENSE.replace("/**", "/*", 1))
|
||||
f.write("package com.facebook.yoga;\n\n")
|
||||
f.write("import com.facebook.proguard.annotations.DoNotStrip;\n\n")
|
||||
f.write("@DoNotStrip\n")
|
||||
f.write("public enum Yoga%s {\n" % name)
|
||||
if len(values) > 0:
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s(%d)' % (to_java_upper(value[0]), value[1]))
|
||||
f.write(" %s(%d)" % (to_java_upper(value[0]), value[1]))
|
||||
else:
|
||||
f.write(' %s(%d)' % (to_java_upper(value), values.index(value)))
|
||||
f.write(" %s(%d)" % (to_java_upper(value), values.index(value)))
|
||||
if values.index(value) is len(values) - 1:
|
||||
f.write(';\n')
|
||||
f.write(";\n")
|
||||
else:
|
||||
f.write(',\n')
|
||||
f.write(",\n")
|
||||
else:
|
||||
f.write('__EMPTY(-1);')
|
||||
f.write('\n')
|
||||
f.write(' private int mIntValue;\n')
|
||||
f.write('\n')
|
||||
f.write(' Yoga%s(int intValue) {\n' % name)
|
||||
f.write(' mIntValue = intValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public int intValue() {\n')
|
||||
f.write(' return mIntValue;\n')
|
||||
f.write(' }\n')
|
||||
f.write('\n')
|
||||
f.write(' public static Yoga%s fromInt(int value) {\n' % name)
|
||||
f.write(' switch (value) {\n')
|
||||
f.write("__EMPTY(-1);")
|
||||
f.write("\n")
|
||||
f.write(" private int mIntValue;\n")
|
||||
f.write("\n")
|
||||
f.write(" Yoga%s(int intValue) {\n" % name)
|
||||
f.write(" mIntValue = intValue;\n")
|
||||
f.write(" }\n")
|
||||
f.write("\n")
|
||||
f.write(" public int intValue() {\n")
|
||||
f.write(" return mIntValue;\n")
|
||||
f.write(" }\n")
|
||||
f.write("\n")
|
||||
f.write(" public static Yoga%s fromInt(int value) {\n" % name)
|
||||
f.write(" switch (value) {\n")
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0])))
|
||||
f.write(
|
||||
" case %d: return %s;\n" % (value[1], to_java_upper(value[0]))
|
||||
)
|
||||
else:
|
||||
f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value)))
|
||||
f.write(' default: throw new IllegalArgumentException("Unknown enum value: " + value);\n')
|
||||
f.write(' }\n')
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
||||
f.write(
|
||||
" case %d: return %s;\n"
|
||||
% (values.index(value), to_java_upper(value))
|
||||
)
|
||||
f.write(
|
||||
' default: throw new IllegalArgumentException("Unknown enum value: " + value);\n'
|
||||
)
|
||||
f.write(" }\n")
|
||||
f.write(" }\n")
|
||||
f.write("}\n")
|
||||
|
||||
# write out csharp files
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f:
|
||||
with open(root + "/csharp/Facebook.Yoga/Yoga%s.cs" % name, "w") as f:
|
||||
f.write(LICENSE)
|
||||
f.write('namespace Facebook.Yoga\n{\n')
|
||||
f.write("namespace Facebook.Yoga\n{\n")
|
||||
if isinstance(next(iter(values or []), None), tuple):
|
||||
f.write(' [System.Flags]\n')
|
||||
f.write(' public enum Yoga%s\n {\n' % name)
|
||||
f.write(" [System.Flags]\n")
|
||||
f.write(" public enum Yoga%s\n {\n" % name)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s = %d,\n' % (value[0], value[1]))
|
||||
f.write(" %s = %d,\n" % (value[0], value[1]))
|
||||
else:
|
||||
f.write(' %s,\n' % value)
|
||||
f.write(' }\n')
|
||||
f.write('}\n')
|
||||
f.write(" %s,\n" % value)
|
||||
f.write(" }\n")
|
||||
f.write("}\n")
|
||||
|
||||
# write out javascript file
|
||||
with open(root + '/javascript/sources/YGEnums.js', 'w') as f:
|
||||
with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
||||
f.write(LICENSE)
|
||||
f.write('module.exports = {\n\n')
|
||||
f.write("module.exports = {\n\n")
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
f.write(' %s_COUNT: %s,\n' % (to_java_upper(name), len(values)))
|
||||
f.write(" %s_COUNT: %s,\n" % (to_java_upper(name), len(values)))
|
||||
base = 0
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
f.write(' %s_%s: %d,\n' % (to_java_upper(name), to_java_upper(value[0]), value[1]))
|
||||
f.write(
|
||||
" %s_%s: %d,\n"
|
||||
% (to_java_upper(name), to_java_upper(value[0]), value[1])
|
||||
)
|
||||
base = value[1] + 1
|
||||
else:
|
||||
f.write(' %s_%s: %d,\n' % (to_java_upper(name), to_java_upper(value), base))
|
||||
f.write(
|
||||
" %s_%s: %d,\n" % (to_java_upper(name), to_java_upper(value), base)
|
||||
)
|
||||
base += 1
|
||||
f.write('\n')
|
||||
f.write('};\n')
|
||||
f.write("\n")
|
||||
f.write("};\n")
|
||||
|
@@ -44,10 +44,9 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) {
|
||||
'/**',
|
||||
' * 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.',
|
||||
' * This source code is licensed under the MIT license found in the LICENSE',
|
||||
' * file in the root directory of this source tree.',
|
||||
' */',
|
||||
'',
|
||||
'// @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html',
|
||||
'',
|
||||
]);
|
||||
@@ -138,7 +137,7 @@ function checkDefaultValues() {
|
||||
{style:'bottom', value:'undefined'},
|
||||
{style:'display', value:'flex'},
|
||||
].forEach(function(item) {
|
||||
assert(item.value === getDefaultStyleValue(item.style),
|
||||
assert(isDefaultStyleValue(item.style, item.value),
|
||||
item.style + ' should be ' + item.value);
|
||||
});
|
||||
}
|
||||
@@ -157,9 +156,9 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
|
||||
style == 'width' ||
|
||||
style == 'height')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.style[style] !== getDefaultStyleValue(style)) {
|
||||
if (!isDefaultStyleValue(style, node.style[style])) {
|
||||
switch (style) {
|
||||
case 'direction':
|
||||
e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style]));
|
||||
@@ -400,21 +399,38 @@ function displayValue(e, value){
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultStyleValue(style) {
|
||||
if (style == 'position') {
|
||||
return 'relative';
|
||||
var DEFAULT_STYLES = new Map();
|
||||
|
||||
function isDefaultStyleValue(style, value) {
|
||||
let defaultStyle = DEFAULT_STYLES.get(style);
|
||||
if (defaultStyle == null) {
|
||||
switch (style) {
|
||||
case 'position':
|
||||
defaultStyle = new Set(['relative']);;
|
||||
break;
|
||||
|
||||
case 'left':
|
||||
case 'top':
|
||||
case 'right':
|
||||
case 'bottom':
|
||||
case 'start':
|
||||
case 'end':
|
||||
defaultStyle = new Set(['undefined']);
|
||||
break;
|
||||
|
||||
case 'min-height':
|
||||
case 'min-width':
|
||||
defaultStyle = new Set(['0', '0px', 'auto']);
|
||||
break;
|
||||
|
||||
default:
|
||||
var node = document.getElementById('default');
|
||||
defaultStyle = new Set([getComputedStyle(node, null)[style]]);
|
||||
break;
|
||||
}
|
||||
DEFAULT_STYLES.set(style, defaultStyle);
|
||||
}
|
||||
switch (style) {
|
||||
case 'left':
|
||||
case 'top':
|
||||
case 'right':
|
||||
case 'bottom':
|
||||
case 'start':
|
||||
case 'end':
|
||||
return 'undefined';
|
||||
}
|
||||
var node = document.getElementById('default');
|
||||
return getComputedStyle(node, null).getPropertyValue(style);
|
||||
return DEFAULT_STYLES.get(style).has(value);
|
||||
}
|
||||
|
||||
function getRoundedSize(node) {
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
|
||||
VERSION_NAME=1.12.0-SNAPSHOT
|
||||
VERSION_NAME=1.16.0
|
||||
POM_URL=https://github.com/facebook/yoga
|
||||
POM_SCM_URL=https://github.com/facebook/yoga.git
|
||||
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
||||
|
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
15
java/BUCK
15
java/BUCK
@@ -3,13 +3,18 @@
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
|
||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
|
||||
|
||||
CXX_LIBRARY_WHITELIST_FOR_TESTS = CXX_LIBRARY_WHITELIST + [
|
||||
yoga_cxx_lib("testutil:jni"),
|
||||
yoga_cxx_lib("testutil:testutil"),
|
||||
]
|
||||
|
||||
yoga_cxx_library(
|
||||
name = "jni",
|
||||
srcs = glob(["jni/*.cpp"]),
|
||||
headers = glob(["jni/*.h"]),
|
||||
header_namespace = "",
|
||||
header_namespace = "yoga/java",
|
||||
exported_headers = glob(["jni/*.h"]),
|
||||
allow_jni_merging = True,
|
||||
compiler_flags = [
|
||||
"-fno-omit-frame-pointer",
|
||||
@@ -45,6 +50,7 @@ yoga_java_library(
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
":jni",
|
||||
FBJNI_JAVA_TARGET,
|
||||
INFER_ANNOTATIONS_TARGET,
|
||||
JSR_305_TARGET,
|
||||
PROGRUARD_ANNOTATIONS_TARGET,
|
||||
@@ -55,11 +61,12 @@ yoga_java_library(
|
||||
yoga_java_test(
|
||||
name = "tests",
|
||||
srcs = glob(["tests/**/*.java"]),
|
||||
cxx_library_whitelist = CXX_LIBRARY_WHITELIST,
|
||||
cxx_library_whitelist = CXX_LIBRARY_WHITELIST_FOR_TESTS,
|
||||
use_cxx_libraries = True,
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
":java",
|
||||
yoga_dep("testutil:java"),
|
||||
JUNIT_TARGET,
|
||||
],
|
||||
)
|
||||
|
@@ -62,6 +62,7 @@ dependencies {
|
||||
compileOnly project(':yoga:proguard-annotations')
|
||||
implementation 'com.facebook.soloader:soloader:0.5.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testCompile project(':testutil')
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
|
42
java/com/facebook/yoga/LayoutPassReason.java
Normal file
42
java/com/facebook/yoga/LayoutPassReason.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
public enum LayoutPassReason {
|
||||
INITIAL(0),
|
||||
ABS_LAYOUT(1),
|
||||
STRETCH(2),
|
||||
MULTILINE_STRETCH(3),
|
||||
FLEX_LAYOUT(4),
|
||||
MEASURE(5),
|
||||
ABS_MEASURE(6),
|
||||
FLEX_MEASURE(7);
|
||||
|
||||
private final int mIntValue;
|
||||
|
||||
LayoutPassReason(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static LayoutPassReason fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return INITIAL;
|
||||
case 1: return ABS_LAYOUT;
|
||||
case 2: return STRETCH;
|
||||
case 3: return MULTILINE_STRETCH;
|
||||
case 4: return FLEX_LAYOUT;
|
||||
case 5: return MEASURE;
|
||||
case 6: return ABS_MEASURE;
|
||||
case 7: return FLEX_MEASURE;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,83 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaConfig {
|
||||
|
||||
public static int SPACING_TYPE = 1;
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("yoga");
|
||||
}
|
||||
|
||||
long mNativePointer;
|
||||
private YogaLogger mLogger;
|
||||
private YogaNodeCloneFunction mYogaNodeCloneFunction;
|
||||
public boolean avoidGlobalJNIRefs = false;
|
||||
|
||||
private native long jni_YGConfigNew();
|
||||
public YogaConfig() {
|
||||
mNativePointer = jni_YGConfigNew();
|
||||
mNativePointer = YogaNative.jni_YGConfigNew();
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
private native void jni_YGConfigFree(long nativePointer);
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
jni_YGConfigFree(mNativePointer);
|
||||
YogaNative.jni_YGConfigFree(mNativePointer);
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetExperimentalFeatureEnabled(
|
||||
long nativePointer,
|
||||
int feature,
|
||||
boolean enabled);
|
||||
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
|
||||
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
|
||||
YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
|
||||
public void setUseWebDefaults(boolean useWebDefaults) {
|
||||
jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
|
||||
YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
|
||||
public void setPrintTreeFlag(boolean enable) {
|
||||
jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
|
||||
YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
|
||||
public void setPointScaleFactor(float pixelsInPoint) {
|
||||
jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
|
||||
YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
|
||||
|
||||
/**
|
||||
* Yoga previously had an error where containers would take the maximum space possible instead of the minimum
|
||||
* like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch;
|
||||
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
|
||||
*/
|
||||
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
|
||||
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
||||
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
/**
|
||||
* If this flag is set then yoga would diff the layout without legacy flag and would set a bool in
|
||||
* YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false
|
||||
@@ -85,14 +64,13 @@ public class YogaConfig {
|
||||
*/
|
||||
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
|
||||
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
||||
public void setLogger(YogaLogger logger) {
|
||||
mLogger = logger;
|
||||
jni_YGConfigSetLogger(mNativePointer, logger);
|
||||
YogaNative.jni_YGConfigSetLogger(mNativePointer, logger);
|
||||
}
|
||||
|
||||
public YogaLogger getLogger() {
|
||||
|
7
java/com/facebook/yoga/YogaConfigFactory.java
Normal file
7
java/com/facebook/yoga/YogaConfigFactory.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.facebook.yoga;
|
||||
|
||||
public abstract class YogaConfigFactory {
|
||||
public static YogaConfig create() {
|
||||
return new YogaConfig();
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
34
java/com/facebook/yoga/YogaLayoutType.java
Normal file
34
java/com/facebook/yoga/YogaLayoutType.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
public enum YogaLayoutType {
|
||||
LAYOUT(0),
|
||||
MEASURE(1),
|
||||
CACHED_LAYOUT(2),
|
||||
CACHED_MEASURE(3);
|
||||
|
||||
private final int mIntValue;
|
||||
|
||||
YogaLayoutType(int intValue) {
|
||||
mIntValue = intValue;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return mIntValue;
|
||||
}
|
||||
|
||||
public static YogaLayoutType fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return LAYOUT;
|
||||
case 1: return MEASURE;
|
||||
case 2: return CACHED_LAYOUT;
|
||||
case 3: return CACHED_MEASURE;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
114
java/com/facebook/yoga/YogaNative.java
Normal file
114
java/com/facebook/yoga/YogaNative.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaNative {
|
||||
static {
|
||||
SoLoader.loadLibrary("yoga");
|
||||
}
|
||||
|
||||
// YGConfig related
|
||||
static native long jni_YGConfigNew();
|
||||
static native void jni_YGConfigFree(long nativePointer);
|
||||
static native void jni_YGConfigSetExperimentalFeatureEnabled(long nativePointer, int feature, boolean enabled);
|
||||
static native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
|
||||
static native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
|
||||
static native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
|
||||
static native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
|
||||
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
static native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
||||
|
||||
|
||||
// YGNode related
|
||||
static native long jni_YGNodeNew();
|
||||
static native long jni_YGNodeNewWithConfig(long configPointer);
|
||||
static native void jni_YGNodeFree(long nativePointer);
|
||||
static native void jni_YGNodeReset(long nativePointer);
|
||||
static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
|
||||
static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
|
||||
static native void jni_YGNodeClearChildren(long nativePointer);
|
||||
static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||
static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
|
||||
static native void jni_YGNodeMarkDirty(long nativePointer);
|
||||
static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
|
||||
static native boolean jni_YGNodeIsDirty(long nativePointer);
|
||||
static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
static native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||
static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
static native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
static native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
static native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
||||
static native float jni_YGNodeStyleGetFlex(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
||||
static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||
static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||
static native long jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||
static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||
static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
||||
static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
||||
static native long jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||
static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
||||
static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||
static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
static native long jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||
static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
||||
static native long jni_YGNodeStyleGetWidth(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
||||
static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetHeight(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
||||
static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMinWidth(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||
static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMinHeight(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||
static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||
static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||
static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
||||
static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
|
||||
static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
static native void jni_YGNodePrint(long nativePointer);
|
||||
static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
|
||||
static native long jni_YGNodeClone(long nativePointer);
|
||||
}
|
@@ -10,11 +10,11 @@ import javax.annotation.Nullable;
|
||||
|
||||
public abstract class YogaNode {
|
||||
public static YogaNode create() {
|
||||
return new YogaNodeJNI();
|
||||
return new YogaNodeJNIFinalizer();
|
||||
}
|
||||
|
||||
public static YogaNode create(YogaConfig config) {
|
||||
return new YogaNodeJNI(config);
|
||||
return new YogaNodeJNIFinalizer(config);
|
||||
}
|
||||
|
||||
public abstract void reset();
|
||||
@@ -211,11 +211,16 @@ public abstract class YogaNode {
|
||||
|
||||
public abstract boolean isMeasureDefined();
|
||||
|
||||
public abstract boolean isBaselineDefined();
|
||||
|
||||
public abstract void setData(Object data);
|
||||
|
||||
@Nullable
|
||||
public abstract Object getData();
|
||||
|
||||
public abstract void print();
|
||||
|
||||
public abstract void setStyleInputs(float[] styleInputs, int size);
|
||||
|
||||
public abstract YogaNode cloneWithoutChildren();
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
11
java/com/facebook/yoga/YogaNodeFactory.java
Normal file
11
java/com/facebook/yoga/YogaNodeFactory.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.facebook.yoga;
|
||||
|
||||
public abstract class YogaNodeFactory {
|
||||
public static YogaNode create() {
|
||||
return new YogaNodeJNIFinalizer();
|
||||
}
|
||||
|
||||
public static YogaNode create(YogaConfig config) {
|
||||
return new YogaNodeJNIFinalizer(config);
|
||||
}
|
||||
}
|
@@ -1,766 +0,0 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaNodeJNI extends YogaNode {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("yoga");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get native instance count. Useful for testing only.
|
||||
*/
|
||||
static native int jni_YGNodeGetInstanceCount();
|
||||
|
||||
private YogaNodeJNI mOwner;
|
||||
@Nullable private List<YogaNodeJNI> mChildren;
|
||||
private YogaMeasureFunction mMeasureFunction;
|
||||
private YogaBaselineFunction mBaselineFunction;
|
||||
private long mNativePointer;
|
||||
private Object mData;
|
||||
|
||||
/* Those flags needs be in sync with YGJNI.cpp */
|
||||
private static final int MARGIN = 1;
|
||||
private static final int PADDING = 2;
|
||||
private static final int BORDER = 4;
|
||||
|
||||
private final boolean mAvoidGlobalJNIRefs;
|
||||
|
||||
@DoNotStrip
|
||||
private float mWidth = YogaConstants.UNDEFINED;
|
||||
@DoNotStrip
|
||||
private float mHeight = YogaConstants.UNDEFINED;
|
||||
@DoNotStrip
|
||||
private float mTop = YogaConstants.UNDEFINED;
|
||||
@DoNotStrip
|
||||
private float mLeft = YogaConstants.UNDEFINED;
|
||||
@DoNotStrip
|
||||
private float mMarginLeft = 0;
|
||||
@DoNotStrip
|
||||
private float mMarginTop = 0;
|
||||
@DoNotStrip
|
||||
private float mMarginRight = 0;
|
||||
@DoNotStrip
|
||||
private float mMarginBottom = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingLeft = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingTop = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingRight = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingBottom = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderLeft = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderTop = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderRight = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderBottom = 0;
|
||||
@DoNotStrip
|
||||
private int mLayoutDirection = 0;
|
||||
@DoNotStrip
|
||||
private boolean mHasNewLayout = true;
|
||||
@DoNotStrip private boolean mDoesLegacyStretchFlagAffectsLayout = false;
|
||||
|
||||
private native long jni_YGNodeNew();
|
||||
public YogaNodeJNI() {
|
||||
mAvoidGlobalJNIRefs = false;
|
||||
mNativePointer = jni_YGNodeNew();
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
private native long jni_YGNodeNewWithConfig(long configPointer, boolean avoidGlobalJNIRefs);
|
||||
public YogaNodeJNI(YogaConfig config) {
|
||||
mAvoidGlobalJNIRefs = config.avoidGlobalJNIRefs;
|
||||
mNativePointer = jni_YGNodeNewWithConfig(config.mNativePointer, mAvoidGlobalJNIRefs);
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
freeNatives();
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeFree(long nativePointer);
|
||||
|
||||
/* frees the native underlying YGNode. Useful for testing. */
|
||||
public void freeNatives() {
|
||||
if (mNativePointer > 0) {
|
||||
long nativePointer = mNativePointer;
|
||||
mNativePointer = 0;
|
||||
jni_YGNodeFree(nativePointer);
|
||||
}
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeReset(long nativePointer);
|
||||
public void reset() {
|
||||
mHasNewLayout = true;
|
||||
|
||||
mWidth = YogaConstants.UNDEFINED;
|
||||
mHeight = YogaConstants.UNDEFINED;
|
||||
mTop = YogaConstants.UNDEFINED;
|
||||
mLeft = YogaConstants.UNDEFINED;
|
||||
mMarginLeft = 0;
|
||||
mMarginTop = 0;
|
||||
mMarginRight = 0;
|
||||
mMarginBottom = 0;
|
||||
mPaddingLeft = 0;
|
||||
mPaddingTop = 0;
|
||||
mPaddingRight = 0;
|
||||
mPaddingBottom = 0;
|
||||
mBorderLeft = 0;
|
||||
mBorderTop = 0;
|
||||
mBorderRight = 0;
|
||||
mBorderBottom = 0;
|
||||
mLayoutDirection = 0;
|
||||
|
||||
mMeasureFunction = null;
|
||||
mBaselineFunction = null;
|
||||
mData = null;
|
||||
mDoesLegacyStretchFlagAffectsLayout = false;
|
||||
|
||||
jni_YGNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return mChildren == null ? 0 : mChildren.size();
|
||||
}
|
||||
|
||||
public YogaNodeJNI getChildAt(int i) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException("YogaNode does not have children");
|
||||
}
|
||||
return mChildren.get(i);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
|
||||
public void addChildAt(YogaNode c, int i) {
|
||||
YogaNodeJNI child = (YogaNodeJNI) c;
|
||||
if (child.mOwner != null) {
|
||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||
}
|
||||
|
||||
if (mChildren == null) {
|
||||
mChildren = new ArrayList<>(4);
|
||||
}
|
||||
mChildren.add(i, child);
|
||||
child.mOwner = this;
|
||||
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
|
||||
|
||||
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
|
||||
jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
|
||||
}
|
||||
|
||||
private static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
|
||||
|
||||
public boolean isReferenceBaseline() {
|
||||
return jni_YGNodeIsReferenceBaseline(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeClearChildren(long nativePointer);
|
||||
|
||||
private void clearChildren() {
|
||||
mChildren = null;
|
||||
jni_YGNodeClearChildren(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||
public YogaNodeJNI removeChildAt(int i) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException(
|
||||
"Trying to remove a child of a YogaNode that does not have children");
|
||||
}
|
||||
final YogaNodeJNI child = mChildren.remove(i);
|
||||
child.mOwner = null;
|
||||
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
|
||||
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
|
||||
* to.
|
||||
* This method will return the parent of the {@link YogaNode} when the
|
||||
* {@link YogaNode} only belongs to one YogaTree or null when the
|
||||
* {@link YogaNode} is shared between two or more YogaTrees.
|
||||
*/
|
||||
@Nullable
|
||||
public YogaNodeJNI getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public YogaNodeJNI getParent() {
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
public int indexOf(YogaNode child) {
|
||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNI[] nodes);
|
||||
public void calculateLayout(float width, float height) {
|
||||
long[] nativePointers = null;
|
||||
YogaNodeJNI[] nodes = null;
|
||||
|
||||
if (mAvoidGlobalJNIRefs) {
|
||||
ArrayList<YogaNodeJNI> n = new ArrayList<>();
|
||||
n.add(this);
|
||||
for (int i = 0; i < n.size(); ++i) {
|
||||
List<YogaNodeJNI> children = n.get(i).mChildren;
|
||||
if (children != null) {
|
||||
n.addAll(children);
|
||||
}
|
||||
}
|
||||
|
||||
nodes = n.toArray(new YogaNodeJNI[n.size()]);
|
||||
nativePointers = new long[nodes.length];
|
||||
for (int i = 0; i < nodes.length; ++i) {
|
||||
nativePointers[i] = nodes[i].mNativePointer;
|
||||
}
|
||||
}
|
||||
|
||||
jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
|
||||
}
|
||||
|
||||
public boolean hasNewLayout() {
|
||||
return mHasNewLayout;
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeMarkDirty(long nativePointer);
|
||||
public void dirty() {
|
||||
jni_YGNodeMarkDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
|
||||
|
||||
public void dirtyAllDescendants() {
|
||||
jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
|
||||
}
|
||||
|
||||
private static native boolean jni_YGNodeIsDirty(long nativePointer);
|
||||
public boolean isDirty() {
|
||||
return jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
@Override
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNI) srcNode).mNativePointer);
|
||||
}
|
||||
|
||||
public void markLayoutSeen() {
|
||||
mHasNewLayout = false;
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||
public YogaDirection getStyleDirection() {
|
||||
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||
public void setDirection(YogaDirection direction) {
|
||||
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||
public YogaFlexDirection getFlexDirection() {
|
||||
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||
public YogaJustify getJustifyContent() {
|
||||
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
public void setJustifyContent(YogaJustify justifyContent) {
|
||||
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||
public YogaAlign getAlignItems() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
public void setAlignItems(YogaAlign alignItems) {
|
||||
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||
public YogaAlign getAlignSelf() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
public void setAlignSelf(YogaAlign alignSelf) {
|
||||
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||
public YogaAlign getAlignContent() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
public void setAlignContent(YogaAlign alignContent) {
|
||||
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||
public YogaPositionType getPositionType() {
|
||||
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
public void setPositionType(YogaPositionType positionType) {
|
||||
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
|
||||
public YogaWrap getWrap() {
|
||||
return YogaWrap.fromInt(jni_YGNodeStyleGetFlexWrap(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
public void setWrap(YogaWrap flexWrap) {
|
||||
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||
public YogaOverflow getOverflow() {
|
||||
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
public void setOverflow(YogaOverflow overflow) {
|
||||
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
}
|
||||
|
||||
private static native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
||||
public YogaDisplay getDisplay() {
|
||||
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
||||
public void setDisplay(YogaDisplay display) {
|
||||
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetFlex(long nativePointer);
|
||||
public float getFlex() {
|
||||
return jni_YGNodeStyleGetFlex(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
||||
public void setFlex(float flex) {
|
||||
jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
||||
public float getFlexGrow() {
|
||||
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||
public void setFlexGrow(float flexGrow) {
|
||||
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
||||
public float getFlexShrink() {
|
||||
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
||||
public YogaValue getFlexBasis() {
|
||||
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||
public void setFlexBasis(float flexBasis) {
|
||||
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
||||
public void setFlexBasisPercent(float percent) {
|
||||
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
||||
public void setFlexBasisAuto() {
|
||||
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||
public YogaValue getMargin(YogaEdge edge) {
|
||||
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
public void setMargin(YogaEdge edge, float margin) {
|
||||
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
||||
public void setMarginAuto(YogaEdge edge) {
|
||||
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||
public YogaValue getPadding(YogaEdge edge) {
|
||||
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
public void setPadding(YogaEdge edge, float padding) {
|
||||
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||
public float getBorder(YogaEdge edge) {
|
||||
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
public void setBorder(YogaEdge edge, float border) {
|
||||
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||
public YogaValue getPosition(YogaEdge edge) {
|
||||
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
public void setPosition(YogaEdge edge, float position) {
|
||||
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetWidth(long nativePointer);
|
||||
public YogaValue getWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
||||
public void setWidth(float width) {
|
||||
jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
||||
public void setWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
||||
public void setWidthAuto() {
|
||||
jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetHeight(long nativePointer);
|
||||
public YogaValue getHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
||||
public void setHeight(float height) {
|
||||
jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
||||
public void setHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
||||
public void setHeightAuto() {
|
||||
jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
|
||||
public YogaValue getMinWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||
public void setMinWidth(float minWidth) {
|
||||
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
||||
public void setMinWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
|
||||
public YogaValue getMinHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||
public void setMinHeight(float minHeight) {
|
||||
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
||||
public void setMinHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
||||
public YogaValue getMaxWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||
public void setMaxWidth(float maxWidth) {
|
||||
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
||||
public void setMaxWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
||||
public YogaValue getMaxHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||
public void setMaxHeight(float maxheight) {
|
||||
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
||||
public void setMaxHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
|
||||
public float getAspectRatio() {
|
||||
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
|
||||
public void setAspectRatio(float aspectRatio) {
|
||||
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||
}
|
||||
|
||||
public float getLayoutX() {
|
||||
return mLeft;
|
||||
}
|
||||
|
||||
public float getLayoutY() {
|
||||
return mTop;
|
||||
}
|
||||
|
||||
public float getLayoutWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public float getLayoutHeight() {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
||||
return mDoesLegacyStretchFlagAffectsLayout;
|
||||
}
|
||||
|
||||
public float getLayoutMargin(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return mMarginLeft;
|
||||
case TOP:
|
||||
return mMarginTop;
|
||||
case RIGHT:
|
||||
return mMarginRight;
|
||||
case BOTTOM:
|
||||
return mMarginBottom;
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mMarginRight : mMarginLeft;
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mMarginLeft : mMarginRight;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
|
||||
}
|
||||
}
|
||||
|
||||
public float getLayoutPadding(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return mPaddingLeft;
|
||||
case TOP:
|
||||
return mPaddingTop;
|
||||
case RIGHT:
|
||||
return mPaddingRight;
|
||||
case BOTTOM:
|
||||
return mPaddingBottom;
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mPaddingRight : mPaddingLeft;
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mPaddingLeft : mPaddingRight;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
|
||||
}
|
||||
}
|
||||
|
||||
public float getLayoutBorder(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return mBorderLeft;
|
||||
case TOP:
|
||||
return mBorderTop;
|
||||
case RIGHT:
|
||||
return mBorderRight;
|
||||
case BOTTOM:
|
||||
return mBorderBottom;
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mBorderRight : mBorderLeft;
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mBorderLeft : mBorderRight;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
|
||||
}
|
||||
}
|
||||
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.fromInt(mLayoutDirection);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||
mMeasureFunction = measureFunction;
|
||||
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||
}
|
||||
|
||||
// Implementation Note: Why this method needs to stay final
|
||||
//
|
||||
// We cache the jmethodid for this method in Yoga code. This means that even if a subclass
|
||||
// were to override measure, we'd still call this implementation from layout code since the
|
||||
// overriding method will have a different jmethodid. This is final to prevent that mistake.
|
||||
@DoNotStrip
|
||||
public final long measure(float width, int widthMode, float height, int heightMode) {
|
||||
if (!isMeasureDefined()) {
|
||||
throw new RuntimeException("Measure function isn't defined!");
|
||||
}
|
||||
|
||||
return mMeasureFunction.measure(
|
||||
this,
|
||||
width,
|
||||
YogaMeasureMode.fromInt(widthMode),
|
||||
height,
|
||||
YogaMeasureMode.fromInt(heightMode));
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
||||
mBaselineFunction = baselineFunction;
|
||||
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public final float baseline(float width, float height) {
|
||||
return mBaselineFunction.baseline(this, width, height);
|
||||
}
|
||||
|
||||
public boolean isMeasureDefined() {
|
||||
return mMeasureFunction != null;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
private static native void jni_YGNodePrint(long nativePointer);
|
||||
|
||||
/**
|
||||
* Use the set logger (defaults to adb log) to print out the styles, children, and computed
|
||||
* layout of the tree rooted at this node.
|
||||
*/
|
||||
public void print() {
|
||||
jni_YGNodePrint(mNativePointer);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
|
||||
|
||||
public void setStyleInputs(float[] styleInputsArray, int size) {
|
||||
jni_YGNodeSetStyleInputs(mNativePointer, styleInputsArray, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method replaces the child at childIndex position with the newNode received by parameter.
|
||||
* This is different than calling removeChildAt and addChildAt because this method ONLY replaces
|
||||
* the child in the mChildren datastructure. @DoNotStrip: called from JNI
|
||||
*
|
||||
* @return the nativePointer of the newNode {@linl YogaNode}
|
||||
*/
|
||||
@DoNotStrip
|
||||
private final long replaceChild(YogaNodeJNI newNode, int childIndex) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
|
||||
}
|
||||
mChildren.remove(childIndex);
|
||||
mChildren.add(childIndex, newNode);
|
||||
newNode.mOwner = this;
|
||||
return newNode.mNativePointer;
|
||||
}
|
||||
}
|
663
java/com/facebook/yoga/YogaNodeJNIBase.java
Normal file
663
java/com/facebook/yoga/YogaNodeJNIBase.java
Normal file
@@ -0,0 +1,663 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@DoNotStrip
|
||||
public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
/* Those flags needs be in sync with YGJNI.cpp */
|
||||
private static final byte MARGIN = 1;
|
||||
private static final byte PADDING = 2;
|
||||
private static final byte BORDER = 4;
|
||||
private static final byte DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
|
||||
private static final byte HAS_NEW_LAYOUT = 16;
|
||||
|
||||
private static final byte LAYOUT_EDGE_SET_FLAG_INDEX = 0;
|
||||
private static final byte LAYOUT_WIDTH_INDEX = 1;
|
||||
private static final byte LAYOUT_HEIGHT_INDEX = 2;
|
||||
private static final byte LAYOUT_LEFT_INDEX = 3;
|
||||
private static final byte LAYOUT_TOP_INDEX = 4;
|
||||
private static final byte LAYOUT_DIRECTION_INDEX = 5;
|
||||
private static final byte LAYOUT_MARGIN_START_INDEX = 6;
|
||||
private static final byte LAYOUT_PADDING_START_INDEX = 10;
|
||||
private static final byte LAYOUT_BORDER_START_INDEX = 14;
|
||||
|
||||
@Nullable private YogaNodeJNIBase mOwner;
|
||||
@Nullable private List<YogaNodeJNIBase> mChildren;
|
||||
@Nullable private YogaMeasureFunction mMeasureFunction;
|
||||
@Nullable private YogaBaselineFunction mBaselineFunction;
|
||||
protected long mNativePointer;
|
||||
@Nullable private Object mData;
|
||||
|
||||
@DoNotStrip
|
||||
private @Nullable float[] arr = null;
|
||||
|
||||
@DoNotStrip
|
||||
private int mLayoutDirection = 0;
|
||||
|
||||
private boolean mHasNewLayout = true;
|
||||
|
||||
private YogaNodeJNIBase(long nativePointer) {
|
||||
if (nativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
mNativePointer = nativePointer;
|
||||
}
|
||||
|
||||
YogaNodeJNIBase() {
|
||||
this(YogaNative.jni_YGNodeNew());
|
||||
}
|
||||
|
||||
YogaNodeJNIBase(YogaConfig config) {
|
||||
this(YogaNative.jni_YGNodeNewWithConfig(config.mNativePointer));
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mMeasureFunction = null;
|
||||
mBaselineFunction = null;
|
||||
mData = null;
|
||||
arr = null;
|
||||
mHasNewLayout = true;
|
||||
mLayoutDirection = 0;
|
||||
|
||||
YogaNative.jni_YGNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return mChildren == null ? 0 : mChildren.size();
|
||||
}
|
||||
|
||||
public YogaNodeJNIBase getChildAt(int i) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException("YogaNode does not have children");
|
||||
}
|
||||
return mChildren.get(i);
|
||||
}
|
||||
|
||||
public void addChildAt(YogaNode c, int i) {
|
||||
YogaNodeJNIBase child = (YogaNodeJNIBase) c;
|
||||
if (child.mOwner != null) {
|
||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||
}
|
||||
|
||||
if (mChildren == null) {
|
||||
mChildren = new ArrayList<>(4);
|
||||
}
|
||||
mChildren.add(i, child);
|
||||
child.mOwner = this;
|
||||
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
}
|
||||
|
||||
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
|
||||
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
|
||||
}
|
||||
|
||||
public boolean isReferenceBaseline() {
|
||||
return YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaNodeJNIBase cloneWithoutChildren() {
|
||||
try {
|
||||
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
||||
long clonedNativePointer = YogaNative.jni_YGNodeClone(mNativePointer);
|
||||
clonedYogaNode.mOwner = null;
|
||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||
clonedYogaNode.clearChildren();
|
||||
return clonedYogaNode;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
// This class implements Cloneable, this should not happen
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearChildren() {
|
||||
mChildren = null;
|
||||
YogaNative.jni_YGNodeClearChildren(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaNodeJNIBase removeChildAt(int i) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException(
|
||||
"Trying to remove a child of a YogaNode that does not have children");
|
||||
}
|
||||
final YogaNodeJNIBase child = mChildren.remove(i);
|
||||
child.mOwner = null;
|
||||
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
|
||||
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
|
||||
* to.
|
||||
* This method will return the parent of the {@link YogaNode} when the
|
||||
* {@link YogaNode} only belongs to one YogaTree or null when the
|
||||
* {@link YogaNode} is shared between two or more YogaTrees.
|
||||
*/
|
||||
@Nullable
|
||||
public YogaNodeJNIBase getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public YogaNodeJNIBase getParent() {
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
public int indexOf(YogaNode child) {
|
||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||
}
|
||||
|
||||
public void calculateLayout(float width, float height) {
|
||||
long[] nativePointers = null;
|
||||
YogaNodeJNIBase[] nodes = null;
|
||||
|
||||
ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
|
||||
n.add(this);
|
||||
for (int i = 0; i < n.size(); ++i) {
|
||||
List<YogaNodeJNIBase> children = n.get(i).mChildren;
|
||||
if (children != null) {
|
||||
n.addAll(children);
|
||||
}
|
||||
}
|
||||
|
||||
nodes = n.toArray(new YogaNodeJNIBase[n.size()]);
|
||||
nativePointers = new long[nodes.length];
|
||||
for (int i = 0; i < nodes.length; ++i) {
|
||||
nativePointers[i] = nodes[i].mNativePointer;
|
||||
}
|
||||
|
||||
YogaNative.jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
|
||||
}
|
||||
|
||||
public void dirty() {
|
||||
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
|
||||
}
|
||||
|
||||
public void dirtyAllDescendants() {
|
||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return YogaNative.jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||
}
|
||||
|
||||
public YogaDirection getStyleDirection() {
|
||||
return YogaDirection.fromInt(YogaNative.jni_YGNodeStyleGetDirection(mNativePointer));
|
||||
}
|
||||
|
||||
public void setDirection(YogaDirection direction) {
|
||||
YogaNative.jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
}
|
||||
|
||||
public YogaFlexDirection getFlexDirection() {
|
||||
return YogaFlexDirection.fromInt(YogaNative.jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
||||
}
|
||||
|
||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
}
|
||||
|
||||
public YogaJustify getJustifyContent() {
|
||||
return YogaJustify.fromInt(YogaNative.jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
||||
}
|
||||
|
||||
public void setJustifyContent(YogaJustify justifyContent) {
|
||||
YogaNative.jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
}
|
||||
|
||||
public YogaAlign getAlignItems() {
|
||||
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignItems(mNativePointer));
|
||||
}
|
||||
|
||||
public void setAlignItems(YogaAlign alignItems) {
|
||||
YogaNative.jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
}
|
||||
|
||||
public YogaAlign getAlignSelf() {
|
||||
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
||||
}
|
||||
|
||||
public void setAlignSelf(YogaAlign alignSelf) {
|
||||
YogaNative.jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
}
|
||||
|
||||
public YogaAlign getAlignContent() {
|
||||
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignContent(mNativePointer));
|
||||
}
|
||||
|
||||
public void setAlignContent(YogaAlign alignContent) {
|
||||
YogaNative.jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
}
|
||||
|
||||
public YogaPositionType getPositionType() {
|
||||
return YogaPositionType.fromInt(YogaNative.jni_YGNodeStyleGetPositionType(mNativePointer));
|
||||
}
|
||||
|
||||
public void setPositionType(YogaPositionType positionType) {
|
||||
YogaNative.jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
}
|
||||
|
||||
public YogaWrap getWrap() {
|
||||
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrap(mNativePointer));
|
||||
}
|
||||
|
||||
public void setWrap(YogaWrap flexWrap) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
}
|
||||
|
||||
public YogaOverflow getOverflow() {
|
||||
return YogaOverflow.fromInt(YogaNative.jni_YGNodeStyleGetOverflow(mNativePointer));
|
||||
}
|
||||
|
||||
public void setOverflow(YogaOverflow overflow) {
|
||||
YogaNative.jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
}
|
||||
|
||||
public YogaDisplay getDisplay() {
|
||||
return YogaDisplay.fromInt(YogaNative.jni_YGNodeStyleGetDisplay(mNativePointer));
|
||||
}
|
||||
|
||||
public void setDisplay(YogaDisplay display) {
|
||||
YogaNative.jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
||||
}
|
||||
|
||||
public float getFlex() {
|
||||
return YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlex(float flex) {
|
||||
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
|
||||
public float getFlexGrow() {
|
||||
return YogaNative.jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlexGrow(float flexGrow) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||
}
|
||||
|
||||
public float getFlexShrink() {
|
||||
return YogaNative.jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
||||
}
|
||||
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||
}
|
||||
|
||||
public YogaValue getFlexBasis() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
|
||||
}
|
||||
|
||||
public void setFlexBasis(float flexBasis) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
}
|
||||
|
||||
public void setFlexBasisPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setFlexBasisAuto() {
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMargin(YogaEdge edge) {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()));
|
||||
}
|
||||
|
||||
public void setMargin(YogaEdge edge, float margin) {
|
||||
YogaNative.jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
}
|
||||
|
||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
public void setMarginAuto(YogaEdge edge) {
|
||||
YogaNative.jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
public YogaValue getPadding(YogaEdge edge) {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()));
|
||||
}
|
||||
|
||||
public void setPadding(YogaEdge edge, float padding) {
|
||||
YogaNative.jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
}
|
||||
|
||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
public float getBorder(YogaEdge edge) {
|
||||
return YogaNative.jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
public void setBorder(YogaEdge edge, float border) {
|
||||
YogaNative.jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
}
|
||||
|
||||
public YogaValue getPosition(YogaEdge edge) {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()));
|
||||
}
|
||||
|
||||
public void setPosition(YogaEdge edge, float position) {
|
||||
YogaNative.jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
}
|
||||
|
||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
public YogaValue getWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setWidth(float width) {
|
||||
YogaNative.jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||
}
|
||||
|
||||
public void setWidthPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setWidthAuto() {
|
||||
YogaNative.jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setHeight(float height) {
|
||||
YogaNative.jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||
}
|
||||
|
||||
public void setHeightPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setHeightAuto() {
|
||||
YogaNative.jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMinWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMinWidth(float minWidth) {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
}
|
||||
|
||||
public void setMinWidthPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMinHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMinHeight(float minHeight) {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
}
|
||||
|
||||
public void setMinHeightPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMaxWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMaxWidth(float maxWidth) {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
}
|
||||
|
||||
public void setMaxWidthPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMaxHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMaxHeight(float maxheight) {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
}
|
||||
|
||||
public void setMaxHeightPercent(float percent) {
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public float getAspectRatio() {
|
||||
return YogaNative.jni_YGNodeStyleGetAspectRatio(mNativePointer);
|
||||
}
|
||||
|
||||
public void setAspectRatio(float aspectRatio) {
|
||||
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||
}
|
||||
|
||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||
mMeasureFunction = measureFunction;
|
||||
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||
}
|
||||
|
||||
// Implementation Note: Why this method needs to stay final
|
||||
//
|
||||
// We cache the jmethodid for this method in Yoga code. This means that even if a subclass
|
||||
// were to override measure, we'd still call this implementation from layout code since the
|
||||
// overriding method will have a different jmethodid. This is final to prevent that mistake.
|
||||
@DoNotStrip
|
||||
public final long measure(float width, int widthMode, float height, int heightMode) {
|
||||
if (!isMeasureDefined()) {
|
||||
throw new RuntimeException("Measure function isn't defined!");
|
||||
}
|
||||
|
||||
return mMeasureFunction.measure(
|
||||
this,
|
||||
width,
|
||||
YogaMeasureMode.fromInt(widthMode),
|
||||
height,
|
||||
YogaMeasureMode.fromInt(heightMode));
|
||||
}
|
||||
|
||||
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
||||
mBaselineFunction = baselineFunction;
|
||||
YogaNative.jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public final float baseline(float width, float height) {
|
||||
return mBaselineFunction.baseline(this, width, height);
|
||||
}
|
||||
|
||||
public boolean isMeasureDefined() {
|
||||
return mMeasureFunction != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBaselineDefined() {
|
||||
return mBaselineFunction != null;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Object getData() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the set logger (defaults to adb log) to print out the styles, children, and computed
|
||||
* layout of the tree rooted at this node.
|
||||
*/
|
||||
public void print() {
|
||||
YogaNative.jni_YGNodePrint(mNativePointer);
|
||||
}
|
||||
|
||||
public void setStyleInputs(float[] styleInputsArray, int size) {
|
||||
YogaNative.jni_YGNodeSetStyleInputs(mNativePointer, styleInputsArray, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method replaces the child at childIndex position with the newNode received by parameter.
|
||||
* This is different than calling removeChildAt and addChildAt because this method ONLY replaces
|
||||
* the child in the mChildren datastructure. @DoNotStrip: called from JNI
|
||||
*
|
||||
* @return the nativePointer of the newNode {@linl YogaNode}
|
||||
*/
|
||||
@DoNotStrip
|
||||
private final long replaceChild(YogaNodeJNIBase newNode, int childIndex) {
|
||||
if (mChildren == null) {
|
||||
throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
|
||||
}
|
||||
mChildren.remove(childIndex);
|
||||
mChildren.add(childIndex, newNode);
|
||||
newNode.mOwner = this;
|
||||
return newNode.mNativePointer;
|
||||
}
|
||||
|
||||
private static YogaValue valueFromLong(long raw) {
|
||||
return new YogaValue(Float.intBitsToFloat((int) raw), (int) (raw >> 32));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutX() {
|
||||
return arr != null ? arr[LAYOUT_LEFT_INDEX] : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutY() {
|
||||
return arr != null ? arr[LAYOUT_TOP_INDEX] : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutWidth() {
|
||||
return arr != null ? arr[LAYOUT_WIDTH_INDEX] : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutHeight() {
|
||||
return arr != null ? arr[LAYOUT_HEIGHT_INDEX] : 0;
|
||||
}
|
||||
|
||||
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
||||
return arr != null && (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & DOES_LEGACY_STRETCH_BEHAVIOUR) == DOES_LEGACY_STRETCH_BEHAVIOUR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutMargin(YogaEdge edge) {
|
||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return arr[LAYOUT_MARGIN_START_INDEX];
|
||||
case TOP:
|
||||
return arr[LAYOUT_MARGIN_START_INDEX + 1];
|
||||
case RIGHT:
|
||||
return arr[LAYOUT_MARGIN_START_INDEX + 2];
|
||||
case BOTTOM:
|
||||
return arr[LAYOUT_MARGIN_START_INDEX + 3];
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX + 2] : arr[LAYOUT_MARGIN_START_INDEX];
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX] : arr[LAYOUT_MARGIN_START_INDEX + 2];
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutPadding(YogaEdge edge) {
|
||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) {
|
||||
int paddingStartIndex = LAYOUT_PADDING_START_INDEX - ((((int)arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4);
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return arr[paddingStartIndex];
|
||||
case TOP:
|
||||
return arr[paddingStartIndex + 1];
|
||||
case RIGHT:
|
||||
return arr[paddingStartIndex + 2];
|
||||
case BOTTOM:
|
||||
return arr[paddingStartIndex + 3];
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex + 2] : arr[paddingStartIndex];
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex] : arr[paddingStartIndex + 2];
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutBorder(YogaEdge edge) {
|
||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & BORDER) == BORDER) {
|
||||
int borderStartIndex = LAYOUT_BORDER_START_INDEX - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4) - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) ? 0 : 4);
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return arr[borderStartIndex];
|
||||
case TOP:
|
||||
return arr[borderStartIndex + 1];
|
||||
case RIGHT:
|
||||
return arr[borderStartIndex + 2];
|
||||
case BOTTOM:
|
||||
return arr[borderStartIndex + 3];
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex + 2] : arr[borderStartIndex];
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex] : arr[borderStartIndex + 2];
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.fromInt(arr != null ? (int) arr[LAYOUT_DIRECTION_INDEX] : mLayoutDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNewLayout() {
|
||||
if (arr != null) {
|
||||
return (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & HAS_NEW_LAYOUT) == HAS_NEW_LAYOUT;
|
||||
} else {
|
||||
return mHasNewLayout;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markLayoutSeen() {
|
||||
if (arr != null) {
|
||||
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & ~(HAS_NEW_LAYOUT);
|
||||
}
|
||||
mHasNewLayout = false;
|
||||
}
|
||||
}
|
34
java/com/facebook/yoga/YogaNodeJNIFinalizer.java
Normal file
34
java/com/facebook/yoga/YogaNodeJNIFinalizer.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
|
||||
public YogaNodeJNIFinalizer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public YogaNodeJNIFinalizer(YogaConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
freeNatives();
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
public void freeNatives() {
|
||||
if (mNativePointer != 0) {
|
||||
long nativePointer = mNativePointer;
|
||||
mNativePointer = 0;
|
||||
YogaNative.jni_YGNodeFree(nativePointer);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,15 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaValue {
|
||||
static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED);
|
||||
static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT);
|
||||
@@ -23,7 +19,6 @@ public class YogaValue {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
YogaValue(float value, int unit) {
|
||||
this(value, YogaUnit.fromInt(unit));
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
/**
|
||||
* 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.yoga;
|
||||
|
||||
|
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <yoga/YGNode.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <yoga/Yoga-internal.h>
|
||||
#include <yoga/log.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
@@ -60,60 +63,77 @@ enum YGStyleInput {
|
||||
IsReferenceBaseline,
|
||||
};
|
||||
|
||||
class PtrJNodeMap {
|
||||
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
|
||||
std::map<YGNodeRef, size_t> ptrsToIdxs_;
|
||||
alias_ref<JNodeArray> javaNodes_;
|
||||
const short int LAYOUT_EDGE_SET_FLAG_INDEX = 0;
|
||||
const short int LAYOUT_WIDTH_INDEX = 1;
|
||||
const short int LAYOUT_HEIGHT_INDEX = 2;
|
||||
const short int LAYOUT_LEFT_INDEX = 3;
|
||||
const short int LAYOUT_TOP_INDEX = 4;
|
||||
const short int LAYOUT_DIRECTION_INDEX = 5;
|
||||
const short int LAYOUT_MARGIN_START_INDEX = 6;
|
||||
const short int LAYOUT_PADDING_START_INDEX = 10;
|
||||
const short int LAYOUT_BORDER_START_INDEX = 14;
|
||||
|
||||
namespace {
|
||||
|
||||
union YGNodeContext {
|
||||
uintptr_t edgesSet = 0;
|
||||
void* asVoidPtr;
|
||||
};
|
||||
|
||||
const int DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
|
||||
const int HAS_NEW_LAYOUT = 16;
|
||||
|
||||
class YGNodeEdges {
|
||||
uintptr_t edges_;
|
||||
|
||||
public:
|
||||
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
|
||||
PtrJNodeMap(
|
||||
alias_ref<JArrayLong> nativePointers,
|
||||
alias_ref<JNodeArray> javaNodes)
|
||||
: javaNodes_{javaNodes} {
|
||||
auto pin = nativePointers->pinCritical();
|
||||
auto ptrs = pin.get();
|
||||
for (size_t i = 0, n = pin.size(); i < n; ++i) {
|
||||
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
|
||||
}
|
||||
enum Edge {
|
||||
MARGIN = 1,
|
||||
PADDING = 2,
|
||||
BORDER = 4,
|
||||
};
|
||||
|
||||
YGNodeEdges(YGNodeRef node) {
|
||||
auto context = YGNodeContext{};
|
||||
context.asVoidPtr = node->getContext();
|
||||
edges_ = context.edgesSet;
|
||||
}
|
||||
|
||||
local_ref<JYogaNode> ref(YGNodeRef node) {
|
||||
auto idx = ptrsToIdxs_.find(node);
|
||||
if (idx == ptrsToIdxs_.end()) {
|
||||
return local_ref<JYogaNode>{};
|
||||
} else {
|
||||
return javaNodes_->getElement(idx->second);
|
||||
}
|
||||
void setOn(YGNodeRef node) {
|
||||
auto context = YGNodeContext{};
|
||||
context.edgesSet = edges_;
|
||||
node->setContext(context.asVoidPtr);
|
||||
}
|
||||
|
||||
bool has(Edge edge) { return (edges_ & edge) == edge; }
|
||||
|
||||
YGNodeEdges& add(Edge edge) {
|
||||
edges_ |= edge;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int get() { return edges_; }
|
||||
};
|
||||
|
||||
struct YogaValue {
|
||||
static constexpr jint NAN_BYTES = 0x7fc00000;
|
||||
|
||||
static jlong asJavaLong(const YGValue& value) {
|
||||
uint32_t valueBytes = 0;
|
||||
memcpy(&valueBytes, &value.value, sizeof valueBytes);
|
||||
return ((jlong) value.unit) << 32 | valueBytes;
|
||||
}
|
||||
constexpr static jlong undefinedAsJavaLong() {
|
||||
return ((jlong) YGUnitUndefined) << 32 | NAN_BYTES;
|
||||
}
|
||||
};
|
||||
|
||||
struct YGNodeContext {
|
||||
weak_ref<jobject>* ygNodeJObjectRef{nullptr};
|
||||
int edgeSetFlag = 0;
|
||||
~YGNodeContext() {
|
||||
delete ygNodeJObjectRef;
|
||||
}
|
||||
};
|
||||
|
||||
const int MARGIN = 1;
|
||||
const int PADDING = 2;
|
||||
const int BORDER = 3;
|
||||
|
||||
static inline YGNodeContext* ygNodeRefToYGNodeContext(YGNodeRef node) {
|
||||
return reinterpret_cast<YGNodeContext*>(node->getContext());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static inline local_ref<JYogaNode> YGNodeJobject(
|
||||
YGNodeRef node,
|
||||
void* layoutContext) {
|
||||
if (layoutContext == nullptr) {
|
||||
return (reinterpret_cast<weak_ref<JYogaNode>*>(
|
||||
ygNodeRefToYGNodeContext(node)->ygNodeJObjectRef))
|
||||
->lockLocal();
|
||||
} else {
|
||||
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
|
||||
}
|
||||
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
|
||||
}
|
||||
|
||||
static void YGTransferLayoutDirection(
|
||||
@@ -141,84 +161,59 @@ static void YGTransferLayoutOutputsRecursive(
|
||||
return;
|
||||
}
|
||||
|
||||
int edgeSetFlag = ygNodeRefToYGNodeContext(root)->edgeSetFlag;
|
||||
auto edgesSet = YGNodeEdges{root};
|
||||
|
||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||
bool marginFieldSet = edgesSet.has(YGNodeEdges::MARGIN);
|
||||
bool paddingFieldSet = edgesSet.has(YGNodeEdges::PADDING);
|
||||
bool borderFieldSet = edgesSet.has(YGNodeEdges::BORDER);
|
||||
|
||||
static auto marginLeftField =
|
||||
obj->getClass()->getField<jfloat>("mMarginLeft");
|
||||
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
||||
static auto marginRightField =
|
||||
obj->getClass()->getField<jfloat>("mMarginRight");
|
||||
static auto marginBottomField =
|
||||
obj->getClass()->getField<jfloat>("mMarginBottom");
|
||||
|
||||
static auto paddingLeftField =
|
||||
obj->getClass()->getField<jfloat>("mPaddingLeft");
|
||||
static auto paddingTopField =
|
||||
obj->getClass()->getField<jfloat>("mPaddingTop");
|
||||
static auto paddingRightField =
|
||||
obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||
static auto paddingBottomField =
|
||||
obj->getClass()->getField<jfloat>("mPaddingBottom");
|
||||
|
||||
static auto borderLeftField =
|
||||
obj->getClass()->getField<jfloat>("mBorderLeft");
|
||||
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
||||
static auto borderRightField =
|
||||
obj->getClass()->getField<jfloat>("mBorderRight");
|
||||
static auto borderBottomField =
|
||||
obj->getClass()->getField<jfloat>("mBorderBottom");
|
||||
|
||||
static auto hasNewLayoutField =
|
||||
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>(
|
||||
"mDoesLegacyStretchFlagAffectsLayout");
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||
obj->setFieldValue<jboolean>(
|
||||
doesLegacyStretchBehaviour,
|
||||
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
||||
|
||||
if ((edgeSetFlag & MARGIN) == MARGIN) {
|
||||
obj->setFieldValue(
|
||||
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||
int fieldFlags = edgesSet.get();
|
||||
fieldFlags |= HAS_NEW_LAYOUT;
|
||||
if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) {
|
||||
fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR;
|
||||
}
|
||||
|
||||
if ((edgeSetFlag & PADDING) == PADDING) {
|
||||
obj->setFieldValue(
|
||||
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||
obj->setFieldValue(
|
||||
paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
const int arrSize = 6 + (marginFieldSet ? 4 : 0) + (paddingFieldSet ? 4 : 0) +
|
||||
(borderFieldSet ? 4 : 0);
|
||||
float arr[18];
|
||||
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = fieldFlags;
|
||||
arr[LAYOUT_WIDTH_INDEX] = YGNodeLayoutGetWidth(root);
|
||||
arr[LAYOUT_HEIGHT_INDEX] = YGNodeLayoutGetHeight(root);
|
||||
arr[LAYOUT_LEFT_INDEX] = YGNodeLayoutGetLeft(root);
|
||||
arr[LAYOUT_TOP_INDEX] = YGNodeLayoutGetTop(root);
|
||||
arr[LAYOUT_DIRECTION_INDEX] =
|
||||
static_cast<jint>(YGNodeLayoutGetDirection(root));
|
||||
if (marginFieldSet) {
|
||||
arr[LAYOUT_MARGIN_START_INDEX] = YGNodeLayoutGetMargin(root, YGEdgeLeft);
|
||||
arr[LAYOUT_MARGIN_START_INDEX + 1] = YGNodeLayoutGetMargin(root, YGEdgeTop);
|
||||
arr[LAYOUT_MARGIN_START_INDEX + 2] =
|
||||
YGNodeLayoutGetMargin(root, YGEdgeRight);
|
||||
arr[LAYOUT_MARGIN_START_INDEX + 3] =
|
||||
YGNodeLayoutGetMargin(root, YGEdgeBottom);
|
||||
}
|
||||
if (paddingFieldSet) {
|
||||
int paddingStartIndex =
|
||||
LAYOUT_PADDING_START_INDEX - (marginFieldSet ? 0 : 4);
|
||||
arr[paddingStartIndex] = YGNodeLayoutGetPadding(root, YGEdgeLeft);
|
||||
arr[paddingStartIndex + 1] = YGNodeLayoutGetPadding(root, YGEdgeTop);
|
||||
arr[paddingStartIndex + 2] = YGNodeLayoutGetPadding(root, YGEdgeRight);
|
||||
arr[paddingStartIndex + 3] = YGNodeLayoutGetPadding(root, YGEdgeBottom);
|
||||
}
|
||||
|
||||
if ((edgeSetFlag & BORDER) == BORDER) {
|
||||
obj->setFieldValue(
|
||||
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||
if (borderFieldSet) {
|
||||
int borderStartIndex = LAYOUT_BORDER_START_INDEX -
|
||||
(marginFieldSet ? 0 : 4) - (paddingFieldSet ? 0 : 4);
|
||||
arr[borderStartIndex] = YGNodeLayoutGetBorder(root, YGEdgeLeft);
|
||||
arr[borderStartIndex + 1] = YGNodeLayoutGetBorder(root, YGEdgeTop);
|
||||
arr[borderStartIndex + 2] = YGNodeLayoutGetBorder(root, YGEdgeRight);
|
||||
arr[borderStartIndex + 3] = YGNodeLayoutGetBorder(root, YGEdgeBottom);
|
||||
}
|
||||
|
||||
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
||||
YGTransferLayoutDirection(root, obj);
|
||||
static auto arrField = obj->getClass()->getField<jfloatArray>("arr");
|
||||
local_ref<jfloatArray> arrFinal = make_float_array(arrSize);
|
||||
arrFinal->setRegion(0, arrSize, arr);
|
||||
obj->setFieldValue<jfloatArray>(arrField, arrFinal.get());
|
||||
|
||||
root->setHasNewLayout(false);
|
||||
|
||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||
@@ -258,6 +253,14 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
||||
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
||||
}
|
||||
|
||||
jlong jni_YGNodeClone(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
auto node = _jlong2YGNodeRef(nativePointer);
|
||||
const YGNodeRef clonedYogaNode = YGNodeClone(node);
|
||||
clonedYogaNode->setContext(node->getContext());
|
||||
|
||||
return reinterpret_cast<jlong>(clonedYogaNode);
|
||||
}
|
||||
|
||||
static YGSize YGJNIMeasureFunc(
|
||||
YGNodeRef node,
|
||||
float width,
|
||||
@@ -320,25 +323,16 @@ static int YGJNILogFunc(
|
||||
return result;
|
||||
}
|
||||
|
||||
YGNodeContext* createYGNodeContext(alias_ref<jobject> thiz) {
|
||||
YGNodeContext* ygNodeContext = new YGNodeContext();
|
||||
ygNodeContext->ygNodeJObjectRef = new weak_ref<jobject>(make_weak(thiz));
|
||||
return ygNodeContext;
|
||||
}
|
||||
|
||||
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
||||
const YGNodeRef node = YGNodeNew();
|
||||
node->setContext(createYGNodeContext(thiz));
|
||||
node->setContext(YGNodeContext{}.asVoidPtr);
|
||||
node->setPrintFunc(YGPrint);
|
||||
return reinterpret_cast<jlong>(node);
|
||||
}
|
||||
|
||||
jlong jni_YGNodeNewWithConfig(
|
||||
alias_ref<jobject> thiz,
|
||||
jlong configPointer,
|
||||
jboolean avoidGlobalJNIRefs) {
|
||||
jlong jni_YGNodeNewWithConfig(alias_ref<jclass>, jlong configPointer) {
|
||||
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
|
||||
node->setContext(createYGNodeContext(avoidGlobalJNIRefs ? nullptr : thiz));
|
||||
node->setContext(YGNodeContext{}.asVoidPtr);
|
||||
return reinterpret_cast<jlong>(node);
|
||||
}
|
||||
|
||||
@@ -347,10 +341,6 @@ void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
|
||||
return;
|
||||
}
|
||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||
auto context = node->getContext();
|
||||
if (context != nullptr) {
|
||||
delete reinterpret_cast<YGNodeContext*>(node->getContext());
|
||||
}
|
||||
YGNodeFree(node);
|
||||
}
|
||||
|
||||
@@ -367,11 +357,13 @@ void jni_YGNodeReset(jlong nativePointer) {
|
||||
}
|
||||
|
||||
void jni_YGNodePrint(jlong nativePointer) {
|
||||
#ifdef DEBUG
|
||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||
YGNodePrint(
|
||||
node,
|
||||
(YGPrintOptions)(
|
||||
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
||||
#endif
|
||||
}
|
||||
|
||||
void jni_YGNodeInsertChild(
|
||||
@@ -463,9 +455,8 @@ void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
||||
alias_ref<jobject>, jlong nativePointer) { \
|
||||
return JYogaValue::create( \
|
||||
jlong jni_YGNodeStyleGet##name(jlong nativePointer) { \
|
||||
return YogaValue::asJavaLong( \
|
||||
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
||||
} \
|
||||
\
|
||||
@@ -500,9 +491,8 @@ void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
||||
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
||||
alias_ref<jobject>, jlong nativePointer, jint edge) { \
|
||||
return JYogaValue::create(YGNodeStyleGet##name( \
|
||||
jlong jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
|
||||
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
||||
} \
|
||||
\
|
||||
@@ -563,11 +553,11 @@ YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
|
||||
|
||||
jlong jni_YGConfigNew(alias_ref<jobject>) {
|
||||
jlong jni_YGConfigNew(alias_ref<jclass>) {
|
||||
return reinterpret_cast<jlong>(YGConfigNew());
|
||||
}
|
||||
|
||||
void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
|
||||
void jni_YGConfigFree(alias_ref<jclass>, jlong nativePointer) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
// unique_ptr will destruct the underlying global_ref, if present.
|
||||
auto context = std::unique_ptr<global_ref<JYogaLogger>>{
|
||||
@@ -576,7 +566,7 @@ void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
|
||||
}
|
||||
|
||||
void jni_YGConfigSetExperimentalFeatureEnabled(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jint feature,
|
||||
jboolean enabled) {
|
||||
@@ -586,7 +576,7 @@ void jni_YGConfigSetExperimentalFeatureEnabled(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jboolean enabled) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -594,7 +584,7 @@ void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetUseWebDefaults(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jboolean useWebDefaults) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -602,7 +592,7 @@ void jni_YGConfigSetUseWebDefaults(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetPrintTreeFlag(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jboolean enable) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -610,7 +600,7 @@ void jni_YGConfigSetPrintTreeFlag(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetPointScaleFactor(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jfloat pixelsInPoint) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -618,7 +608,7 @@ void jni_YGConfigSetPointScaleFactor(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetUseLegacyStretchBehaviour(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
jboolean useLegacyStretchBehaviour) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -626,7 +616,7 @@ void jni_YGConfigSetUseLegacyStretchBehaviour(
|
||||
}
|
||||
|
||||
void jni_YGConfigSetLogger(
|
||||
alias_ref<jobject>,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
alias_ref<jobject> logger) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
@@ -655,6 +645,7 @@ static void YGNodeSetStyleInputs(
|
||||
float* styleInputs,
|
||||
int size) {
|
||||
const auto end = styleInputs + size;
|
||||
auto edgesSet = YGNodeEdges{node};
|
||||
while (styleInputs < end) {
|
||||
auto styleInputKey = static_cast<YGStyleInput>((int) *styleInputs++);
|
||||
switch (styleInputKey) {
|
||||
@@ -755,58 +746,55 @@ static void YGNodeSetStyleInputs(
|
||||
YGNodeStyleSetDisplay(node, static_cast<YGDisplay>(*styleInputs++));
|
||||
break;
|
||||
case Margin: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float marginValue = *styleInputs++;
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN;
|
||||
YGNodeStyleSetMargin(node, static_cast<YGEdge>(edge), marginValue);
|
||||
edgesSet.add(YGNodeEdges::MARGIN);
|
||||
YGNodeStyleSetMargin(node, edge, marginValue);
|
||||
break;
|
||||
}
|
||||
case MarginPercent: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float marginPercent = *styleInputs++;
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN;
|
||||
YGNodeStyleSetMarginPercent(
|
||||
node, static_cast<YGEdge>(edge), marginPercent);
|
||||
edgesSet.add(YGNodeEdges::MARGIN);
|
||||
YGNodeStyleSetMarginPercent(node, edge, marginPercent);
|
||||
break;
|
||||
}
|
||||
case MarginAuto: {
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN;
|
||||
edgesSet.add(YGNodeEdges::MARGIN);
|
||||
YGNodeStyleSetMarginAuto(node, static_cast<YGEdge>(*styleInputs++));
|
||||
break;
|
||||
}
|
||||
case Padding: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float paddingValue = *styleInputs++;
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= PADDING;
|
||||
YGNodeStyleSetPadding(node, static_cast<YGEdge>(edge), paddingValue);
|
||||
edgesSet.add(YGNodeEdges::PADDING);
|
||||
YGNodeStyleSetPadding(node, edge, paddingValue);
|
||||
break;
|
||||
}
|
||||
case PaddingPercent: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float paddingPercent = *styleInputs++;
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= PADDING;
|
||||
YGNodeStyleSetPaddingPercent(
|
||||
node, static_cast<YGEdge>(edge), paddingPercent);
|
||||
edgesSet.add(YGNodeEdges::PADDING);
|
||||
YGNodeStyleSetPaddingPercent(node, edge, paddingPercent);
|
||||
break;
|
||||
}
|
||||
case Border: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float borderValue = *styleInputs++;
|
||||
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= BORDER;
|
||||
YGNodeStyleSetBorder(node, static_cast<YGEdge>(edge), borderValue);
|
||||
edgesSet.add(YGNodeEdges::BORDER);
|
||||
YGNodeStyleSetBorder(node, edge, borderValue);
|
||||
break;
|
||||
}
|
||||
case Position: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float positionValue = *styleInputs++;
|
||||
YGNodeStyleSetPosition(node, static_cast<YGEdge>(edge), positionValue);
|
||||
YGNodeStyleSetPosition(node, edge, positionValue);
|
||||
break;
|
||||
}
|
||||
case PositionPercent: {
|
||||
float edge = *styleInputs++;
|
||||
auto edge = static_cast<YGEdge>(*styleInputs++);
|
||||
float positionPercent = *styleInputs++;
|
||||
YGNodeStyleSetPositionPercent(
|
||||
node, static_cast<YGEdge>(edge), positionPercent);
|
||||
YGNodeStyleSetPositionPercent(node, edge, positionPercent);
|
||||
break;
|
||||
}
|
||||
case IsReferenceBaseline: {
|
||||
@@ -817,10 +805,11 @@ static void YGNodeSetStyleInputs(
|
||||
break;
|
||||
}
|
||||
}
|
||||
edgesSet.setOn(node);
|
||||
}
|
||||
|
||||
void jni_YGNodeSetStyleInputs(
|
||||
alias_ref<jobject> thiz,
|
||||
alias_ref<jclass>,
|
||||
jlong nativePointer,
|
||||
alias_ref<JArrayFloat> styleInputs,
|
||||
jint size) {
|
||||
@@ -829,26 +818,18 @@ void jni_YGNodeSetStyleInputs(
|
||||
YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size);
|
||||
}
|
||||
|
||||
jint jni_YGNodeGetInstanceCount() {
|
||||
return YGNodeGetInstanceCount();
|
||||
}
|
||||
|
||||
local_ref<jobject> jni_YGNodeStyleGetMargin(
|
||||
alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jint edge) {
|
||||
jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag;
|
||||
if ((edgeSetFlag & MARGIN) != MARGIN) {
|
||||
return JYogaValue::create(YGValueUndefined);
|
||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
|
||||
return YogaValue::undefinedAsJavaLong();
|
||||
}
|
||||
return JYogaValue::create(
|
||||
return YogaValue::asJavaLong(
|
||||
YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge)));
|
||||
}
|
||||
|
||||
void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetMargin(
|
||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin));
|
||||
}
|
||||
@@ -858,33 +839,29 @@ void jni_YGNodeStyleSetMarginPercent(
|
||||
jint edge,
|
||||
jfloat percent) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetMarginPercent(
|
||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
||||
}
|
||||
|
||||
void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge));
|
||||
}
|
||||
|
||||
local_ref<jobject> jni_YGNodeStyleGetPadding(
|
||||
alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jint edge) {
|
||||
jlong jni_YGNodeStyleGetPadding(jlong nativePointer, jint edge) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag;
|
||||
if ((edgeSetFlag & PADDING) != PADDING) {
|
||||
return JYogaValue::create(YGValueUndefined);
|
||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::PADDING)) {
|
||||
return YogaValue::undefinedAsJavaLong();
|
||||
}
|
||||
return JYogaValue::create(
|
||||
return YogaValue::asJavaLong(
|
||||
YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge)));
|
||||
}
|
||||
|
||||
void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= PADDING;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetPadding(
|
||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding));
|
||||
}
|
||||
@@ -894,15 +871,14 @@ void jni_YGNodeStyleSetPaddingPercent(
|
||||
jint edge,
|
||||
jfloat percent) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= PADDING;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetPaddingPercent(
|
||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
||||
}
|
||||
|
||||
jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag;
|
||||
if ((edgeSetFlag & BORDER) != BORDER) {
|
||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::BORDER)) {
|
||||
return (jfloat) YGUndefined;
|
||||
}
|
||||
return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge));
|
||||
@@ -910,7 +886,7 @@ jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
|
||||
|
||||
void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
|
||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= BORDER;
|
||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::BORDER).setOn(yogaNodeRef);
|
||||
YGNodeStyleSetBorder(
|
||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
|
||||
}
|
||||
@@ -921,95 +897,93 @@ void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||
return initialize(vm, [] {
|
||||
JYogaNode::javaClassStatic()->registerNatives({
|
||||
YGMakeNativeMethod(jni_YGNodeNew),
|
||||
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
|
||||
YGMakeNativeMethod(jni_YGNodeFree),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeReset),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline),
|
||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty),
|
||||
YGMakeCriticalNativeMethod(
|
||||
jni_YGNodeMarkDirtyAndPropogateToDescendants),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexWrap),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlex),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
||||
YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
|
||||
});
|
||||
registerNatives(
|
||||
"com/facebook/yoga/YogaConfig",
|
||||
"com/facebook/yoga/YogaNative",
|
||||
{
|
||||
YGMakeNativeMethod(jni_YGNodeNew),
|
||||
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
|
||||
YGMakeNativeMethod(jni_YGNodeFree),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeReset),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline),
|
||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty),
|
||||
YGMakeCriticalNativeMethod(
|
||||
jni_YGNodeMarkDirtyAndPropogateToDescendants),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexWrap),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlex),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexBasis),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMargin),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPadding),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPosition),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
||||
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
||||
YGMakeNativeMethod(jni_YGNodeClone),
|
||||
YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
|
||||
YGMakeNativeMethod(jni_YGConfigNew),
|
||||
YGMakeNativeMethod(jni_YGConfigFree),
|
||||
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
|
@@ -1,23 +1,24 @@
|
||||
/**
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <yoga/YGValue.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <map>
|
||||
|
||||
using namespace facebook::jni;
|
||||
using namespace std;
|
||||
|
||||
struct JYogaNode : public facebook::jni::JavaClass<JYogaNode> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNI;";
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNIBase;";
|
||||
|
||||
jfloat baseline(jfloat width, jfloat height);
|
||||
jlong measure(jfloat width, jint widthMode, jfloat height, jint heightMode);
|
||||
};
|
||||
|
||||
struct JYogaConfig : public facebook::jni::JavaClass<JYogaConfig> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaConfig;";
|
||||
};
|
||||
|
||||
struct JYogaLogLevel : public facebook::jni::JavaClass<JYogaLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
|
||||
|
||||
@@ -33,10 +34,30 @@ struct JYogaLogger : public facebook::jni::JavaClass<JYogaLogger> {
|
||||
jstring);
|
||||
};
|
||||
|
||||
struct JYogaValue : public facebook::jni::JavaClass<JYogaValue> {
|
||||
constexpr static auto kJavaDescriptor = "Lcom/facebook/yoga/YogaValue;";
|
||||
class PtrJNodeMap {
|
||||
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
|
||||
std::map<YGNodeRef, size_t> ptrsToIdxs_;
|
||||
alias_ref<JNodeArray> javaNodes_;
|
||||
|
||||
static facebook::jni::local_ref<javaobject> create(YGValue value) {
|
||||
return newInstance(value.value, static_cast<int>(value.unit));
|
||||
public:
|
||||
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
|
||||
PtrJNodeMap(
|
||||
alias_ref<JArrayLong> nativePointers,
|
||||
alias_ref<JNodeArray> javaNodes)
|
||||
: javaNodes_{javaNodes} {
|
||||
auto pin = nativePointers->pinCritical();
|
||||
auto ptrs = pin.get();
|
||||
for (size_t i = 0, n = pin.size(); i < n; ++i) {
|
||||
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
local_ref<JYogaNode> ref(YGNodeRef node) {
|
||||
auto idx = ptrsToIdxs_.find(node);
|
||||
if (idx == ptrsToIdxs_.end()) {
|
||||
return local_ref<JYogaNode>{};
|
||||
} else {
|
||||
return javaNodes_->getElement(idx->second);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -6,3 +6,8 @@
|
||||
*/
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
sourceCompatibility = '1.7'
|
||||
targetCompatibility = '1.7'
|
||||
|
||||
apply from: rootProject.file('gradle/release.gradle')
|
||||
|
12
java/proguard-annotations/gradle.properties
Normal file
12
java/proguard-annotations/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# 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
|
||||
POM_NAME=Proguard Annotations
|
||||
POM_DESCRIPTION=Shared annotations for use with Proguard
|
||||
POM_ARTIFACT_ID=proguard-annotations
|
||||
POM_PACKAGING=jar
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user