Compare commits
78 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
aa5b296ac7 | ||
|
f2b5d0fef7 | ||
|
0684795a89 | ||
|
2ffc23f400 | ||
|
dc4d16401f | ||
|
849de89a58 | ||
|
f8a2903d02 | ||
|
60977de242 | ||
|
cb612bcfbe | ||
|
6be1c2cdb4 | ||
|
034ab0b3b1 | ||
|
8c50347f3c | ||
|
9f76fb6980 | ||
|
8b0ff0a25c | ||
|
8891ea1a7a | ||
|
ede2ad94bc | ||
|
eacf3cdbb4 | ||
|
3569a13b74 | ||
|
b2a96ec744 | ||
|
a505adb2b7 | ||
|
906b6e52f8 | ||
|
3292337754 | ||
|
eb4af86e3c | ||
|
1b3e971549 | ||
|
4615eee2d8 | ||
|
7c57245943 | ||
|
0d100ad7e9 | ||
|
0235789863 | ||
|
c080a46571 | ||
|
5f050cb590 | ||
|
25f14a1917 | ||
|
e9927377b5 | ||
|
3ea76f8a9b | ||
|
8a45ed9671 | ||
|
1520749351 | ||
|
f66f52d1ba | ||
|
49e18738c3 | ||
|
586b57009a | ||
|
5112564f08 | ||
|
34726a9926 | ||
|
5884ab7b76 | ||
|
60db018ce4 | ||
|
6b002bad3d | ||
|
5b173c1b61 | ||
|
bc2fb5c7ab | ||
|
ebdf82f491 | ||
|
36f6fa9861 | ||
|
91a34bb875 | ||
|
d342fb1879 | ||
|
b283572453 | ||
|
62a74a5ef9 | ||
|
a14aeb27bb | ||
|
249d010dad | ||
|
9b13fdeae4 | ||
|
794b6b35ce | ||
|
dcff4d3db2 | ||
|
b94466e502 | ||
|
11052053d8 | ||
|
6ab3984bba | ||
|
136e0c7e52 | ||
|
7e2ef926ea | ||
|
061981fb23 | ||
|
3d6fb2f2e5 | ||
|
a8e6123d47 | ||
|
406c8a2117 | ||
|
0445962bd4 | ||
|
09f0c2d8ce | ||
|
8dea884a69 | ||
|
57898762a2 | ||
|
01bf8d7b6c | ||
|
af8d55c08e | ||
|
53398b42c6 | ||
|
1bf142e048 | ||
|
0405c4f77d | ||
|
61595763b0 | ||
|
f6ecc8da7b | ||
|
32792a0de5 | ||
|
c3d60b55bd |
@@ -1,9 +1,9 @@
|
|||||||
[cxx]
|
[cxx]
|
||||||
gtest_dep = //lib/gtest:gtest
|
gtest_dep = //lib/gtest:gtest
|
||||||
[android]
|
[android]
|
||||||
target = Google Inc.:Google APIs:19
|
target = android-23
|
||||||
[ndk]
|
[ndk]
|
||||||
ndk_version = 12.1.2977051
|
ndk_version = 13.1.3345770
|
||||||
compiler = clang
|
compiler = clang
|
||||||
app_platform = android-19
|
app_platform = android-21
|
||||||
cpu_abis = armv7, x86
|
cpu_abis = arm64, armv7, x86, x86_64
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -63,3 +63,5 @@ Carthage/Build
|
|||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
.gradle
|
.gradle
|
||||||
|
# NDK/CMake
|
||||||
|
.externalNativeBuild
|
||||||
|
10
.travis.yml
10
.travis.yml
@@ -40,7 +40,11 @@ before_install:
|
|||||||
# iOS
|
# iOS
|
||||||
- |
|
- |
|
||||||
if [[ $TARGET = "ios" ]]; then
|
if [[ $TARGET = "ios" ]]; then
|
||||||
brew outdated xctool || brew upgrade xctool
|
brew outdated xctool || brew upgrade xctool;
|
||||||
|
gem install xcpretty --no-document --quiet;
|
||||||
|
gem install cocoapods --pre --no-document --quiet;
|
||||||
|
pod repo update --silent;
|
||||||
|
pod install --project-directory=YogaKit/YogaKitSample/;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Emscripten (used for js tests)
|
# Emscripten (used for js tests)
|
||||||
@@ -102,7 +106,9 @@ script:
|
|||||||
# iOS
|
# iOS
|
||||||
- |
|
- |
|
||||||
if [[ $TARGET = "ios" ]]; then
|
if [[ $TARGET = "ios" ]]; then
|
||||||
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64
|
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 &&
|
||||||
|
set -o pipefail &&
|
||||||
|
xcodebuild build -workspace YogaKit/YogaKitSample/YogaKitSample.xcworkspace -scheme YogaKitSample -sdk iphonesimulator | xcpretty -c
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Android
|
# Android
|
||||||
|
3
BUCK
3
BUCK
@@ -12,9 +12,8 @@ GMOCK_OVERRIDE_FLAGS = [
|
|||||||
"-Wno-inconsistent-missing-override",
|
"-Wno-inconsistent-missing-override",
|
||||||
]
|
]
|
||||||
|
|
||||||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
|
||||||
"-std=c11",
|
"-std=c11",
|
||||||
"-fPIC",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ["-std=c++11"]
|
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ["-std=c++11"]
|
||||||
|
17
CMakeLists.txt
Normal file
17
CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the BSD-style license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
|
file(GLOB yogacore_SRC yoga/*.c)
|
||||||
|
add_library(yogacore STATIC ${yogacore_SRC})
|
||||||
|
|
||||||
|
target_link_libraries(yogacore android log)
|
@@ -1,4 +1,4 @@
|
|||||||
# Yoga [](http://cocoapods.org/pods/YogaKit) [](https://www.npmjs.com/package/yoga-layout)
|
# 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)
|
||||||
|
|
||||||
[](https://travis-ci.org/facebook/yoga)
|
[](https://travis-ci.org/facebook/yoga)
|
||||||
[](https://travis-ci.org/facebook/yoga)
|
[](https://travis-ci.org/facebook/yoga)
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
[](https://travis-ci.org/facebook/yoga)
|
[](https://travis-ci.org/facebook/yoga)
|
||||||
[](https://travis-ci.org/facebook/yoga)
|
[](https://travis-ci.org/facebook/yoga)
|
||||||
|
|
||||||
|
[]()
|
||||||
|
[]()
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
YOGA_ROOT = '//...'
|
YOGA_ROOTS = ['//...']
|
||||||
JAVA_TARGET = '//java:java'
|
JAVA_TARGET = '//java:java'
|
||||||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
|
||||||
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
|
||||||
JUNIT_TARGET = '//lib/junit:junit'
|
JUNIT_TARGET = '//lib/junit:junit'
|
||||||
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
|
PROGRUARD_ANNOTATIONS_TARGET = '//java/proguard-annotations/src/main/java/com/facebook/proguard/annotations:annotations'
|
||||||
SOLOADER_TARGET = '//lib/soloader:soloader'
|
SOLOADER_TARGET = '//lib/soloader:soloader'
|
||||||
GTEST_TARGET = '//lib/gtest:gtest'
|
GTEST_TARGET = '//lib/gtest:gtest'
|
||||||
JNI_TARGET = '//lib/jni:jni'
|
JNI_TARGET = '//lib/jni:jni'
|
||||||
@@ -33,6 +33,10 @@ BASE_COMPILER_FLAGS = [
|
|||||||
'-O3',
|
'-O3',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
|
||||||
|
'-fPIC',
|
||||||
|
]
|
||||||
|
|
||||||
def yoga_dep(dep):
|
def yoga_dep(dep):
|
||||||
return '//' + dep
|
return '//' + dep
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |spec|
|
Pod::Spec.new do |spec|
|
||||||
spec.name = 'Yoga'
|
spec.name = 'Yoga'
|
||||||
spec.version = '1.2.0'
|
spec.version = '1.3.0'
|
||||||
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/'
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/'
|
||||||
@@ -11,7 +11,7 @@ Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => '1.2.0',
|
:tag => '1.3.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.module_name = 'yoga'
|
spec.module_name = 'yoga'
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
podspec = Pod::Spec.new do |spec|
|
podspec = Pod::Spec.new do |spec|
|
||||||
spec.name = 'YogaKit'
|
spec.name = 'YogaKit'
|
||||||
spec.version = '1.2.0'
|
spec.version = '1.3.0'
|
||||||
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
spec.license = { :type => 'BSD', :file => "LICENSE" }
|
||||||
spec.homepage = 'https://facebook.github.io/yoga/'
|
spec.homepage = 'https://facebook.github.io/yoga/'
|
||||||
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
|
||||||
@@ -11,14 +11,14 @@ podspec = Pod::Spec.new do |spec|
|
|||||||
spec.authors = 'Facebook'
|
spec.authors = 'Facebook'
|
||||||
spec.source = {
|
spec.source = {
|
||||||
:git => 'https://github.com/facebook/yoga.git',
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
:tag => '1.2.0',
|
:tag => '1.3.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.platform = :ios
|
spec.platform = :ios
|
||||||
spec.ios.deployment_target = '8.0'
|
spec.ios.deployment_target = '8.0'
|
||||||
spec.ios.frameworks = 'UIKit'
|
spec.ios.frameworks = 'UIKit'
|
||||||
|
|
||||||
spec.dependency 'Yoga', '~> 1.2'
|
spec.dependency 'Yoga', '~> 1.3'
|
||||||
spec.source_files = 'YogaKit/Source/*.{h,m}'
|
spec.source_files = 'YogaKit/Source/*.{h,m}'
|
||||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
|
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
|
||||||
|
|
||||||
```
|
```
|
||||||
pod 'YogaKit', '~> 1.1'
|
pod 'YogaKit', '~> 1.3'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
@@ -19,4 +19,4 @@ We also have a sample project. To try it out, clone this repo and open `YogaKitS
|
|||||||
## Contributing
|
## Contributing
|
||||||
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
|
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
|
||||||
|
|
||||||
See the [CONTRIBUTING](https://github.com/facebook/yoga/blob/master/CONTRIBUTING) file for how to help out.
|
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.
|
||||||
|
@@ -10,6 +10,11 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <yoga/YGEnums.h>
|
#import <yoga/YGEnums.h>
|
||||||
|
|
||||||
|
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
||||||
|
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
|
||||||
|
YGDimensionFlexibilityFlexibleHeigth = 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
@interface YGLayout : NSObject
|
@interface YGLayout : NSObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,6 +100,13 @@
|
|||||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
||||||
|
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
||||||
|
*/
|
||||||
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
|
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self
|
Returns the size of the view if no constraints were given. This could equivalent to calling [self
|
||||||
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||||
|
@@ -235,6 +235,20 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
|||||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||||
|
{
|
||||||
|
CGSize size = self.view.bounds.size;
|
||||||
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
||||||
|
size.width = YGUndefined;
|
||||||
|
}
|
||||||
|
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeigth) {
|
||||||
|
size.height = YGUndefined;
|
||||||
|
}
|
||||||
|
[self calculateLayoutWithSize:size];
|
||||||
|
YGApplyLayoutToViewHierarchy(self.view, NO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (CGSize)intrinsicSize
|
- (CGSize)intrinsicSize
|
||||||
{
|
{
|
||||||
const CGSize constrainedSize = {
|
const CGSize constrainedSize = {
|
||||||
|
@@ -21,7 +21,8 @@
|
|||||||
- (void)testConfigureLayoutIsNoOpWithNilBlock
|
- (void)testConfigureLayoutIsNoOpWithNilBlock
|
||||||
{
|
{
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertNoThrow([view configureLayoutWithBlock:nil]);
|
id block = nil;
|
||||||
|
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testConfigureLayoutBlockWorksWithValidBlock
|
- (void)testConfigureLayoutBlockWorksWithValidBlock
|
||||||
@@ -153,6 +154,54 @@
|
|||||||
XCTAssertEqual(25, view2.frame.origin.y);
|
XCTAssertEqual(25, view2.frame.origin.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
|
||||||
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = 100;
|
||||||
|
view.yoga.height = 100;
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
||||||
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
|
XCTAssertEqual(200, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
|
||||||
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = 100;
|
||||||
|
view.yoga.height = 100;
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleHeigth];
|
||||||
|
XCTAssertEqual(200, container.frame.size.width);
|
||||||
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
|
||||||
|
{
|
||||||
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||||
|
container.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
view.yoga.width = 100;
|
||||||
|
view.yoga.height = 100;
|
||||||
|
[container addSubview:view];
|
||||||
|
|
||||||
|
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth | YGDimensionFlexibilityFlexibleHeigth];
|
||||||
|
XCTAssertEqual(100, container.frame.size.width);
|
||||||
|
XCTAssertEqual(100, container.frame.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
|
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
|
||||||
{
|
{
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
@@ -4,9 +4,9 @@ PODS:
|
|||||||
- IGListKit/Default (2.1.0):
|
- IGListKit/Default (2.1.0):
|
||||||
- IGListKit/Diffing
|
- IGListKit/Diffing
|
||||||
- IGListKit/Diffing (2.1.0)
|
- IGListKit/Diffing (2.1.0)
|
||||||
- Yoga (1.2.0)
|
- Yoga (1.3.0)
|
||||||
- YogaKit (1.2.0):
|
- YogaKit (1.3.0):
|
||||||
- Yoga (~> 1.2)
|
- Yoga (~> 1.3)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- IGListKit (~> 2.1.0)
|
- IGListKit (~> 2.1.0)
|
||||||
@@ -18,8 +18,8 @@ EXTERNAL SOURCES:
|
|||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
|
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
|
||||||
Yoga: 20fc010c282cc5f3c27ce512de1329cd1e72b077
|
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
|
||||||
YogaKit: 72d5c8a806dc5cf2aa50c93a6dd88913cdbec6fe
|
YogaKit: cddeccc6a8d2aff563e4c738d3bddb290a6de4cb
|
||||||
|
|
||||||
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
|
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
|
||||||
|
|
||||||
|
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0820"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "638A944E1E215CC800A726AD"
|
||||||
|
BuildableName = "YogaKitSampleTests.xctest"
|
||||||
|
BlueprintName = "YogaKitSampleTests"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "13687D421DF8748300E7C260"
|
||||||
|
BuildableName = "YogaKitSample.app"
|
||||||
|
BlueprintName = "YogaKitSample"
|
||||||
|
ReferencedContainer = "container:YogaKitSample.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
@@ -15,32 +15,38 @@ final class BasicViewController: UIViewController {
|
|||||||
|
|
||||||
let root = self.view!
|
let root = self.view!
|
||||||
root.backgroundColor = .white
|
root.backgroundColor = .white
|
||||||
root.yoga.isEnabled = true
|
root.configureLayout { (layout) in
|
||||||
root.yoga.width = containerSize.width
|
layout.isEnabled = true
|
||||||
root.yoga.height = containerSize.height
|
layout.width = containerSize.width
|
||||||
root.yoga.alignItems = .center
|
layout.height = containerSize.height
|
||||||
root.yoga.justifyContent = .center
|
layout.alignItems = .center
|
||||||
|
layout.justifyContent = .center
|
||||||
|
}
|
||||||
|
|
||||||
let child1 = UIView()
|
let child1 = UIView()
|
||||||
child1.backgroundColor = .blue
|
child1.backgroundColor = .blue
|
||||||
child1.yoga.isEnabled = true
|
child1.configureLayout { (layout) in
|
||||||
child1.yoga.width = 100
|
layout.isEnabled = true
|
||||||
child1.yoga.height = 10
|
layout.width = 100
|
||||||
child1.yoga.marginBottom = 25
|
layout.height = 10
|
||||||
|
layout.marginBottom = 25
|
||||||
|
}
|
||||||
root.addSubview(child1)
|
root.addSubview(child1)
|
||||||
|
|
||||||
let child2 = UIView()
|
let child2 = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
|
||||||
child2.yoga.isEnabled = true
|
|
||||||
child2.yoga.alignSelf = .flexEnd
|
|
||||||
child2.backgroundColor = .green
|
child2.backgroundColor = .green
|
||||||
child2.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
|
child2.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.alignSelf = .flexEnd
|
||||||
|
}
|
||||||
root.addSubview(child2)
|
root.addSubview(child2)
|
||||||
|
|
||||||
let child3 = UIView()
|
let child3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
||||||
child3.yoga.isEnabled = true
|
|
||||||
child3.yoga.alignSelf = .flexStart
|
|
||||||
child3.backgroundColor = .yellow
|
child3.backgroundColor = .yellow
|
||||||
child3.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
|
child3.configureLayout { (layout) in
|
||||||
|
layout.isEnabled = true
|
||||||
|
layout.alignSelf = .flexStart
|
||||||
|
}
|
||||||
root.addSubview(child3)
|
root.addSubview(child3)
|
||||||
|
|
||||||
root.yoga.applyLayout(preservingOrigin: true)
|
root.yoga.applyLayout(preservingOrigin: true)
|
||||||
|
@@ -17,40 +17,50 @@ final class LayoutInclusionViewController: UIViewController {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
let root = self.view!
|
let root = self.view!
|
||||||
root.backgroundColor = .white
|
root.backgroundColor = .white
|
||||||
root.yoga.isEnabled = true
|
root.configureLayout { (layout) in
|
||||||
root.yoga.flexDirection = .column
|
layout.isEnabled = true
|
||||||
root.yoga.justifyContent = .spaceAround
|
layout.flexDirection = .column
|
||||||
|
layout.justifyContent = .spaceAround
|
||||||
|
}
|
||||||
|
|
||||||
contentView.backgroundColor = .clear
|
contentView.backgroundColor = .clear
|
||||||
contentView.layer.borderColor = UIColor.lightGray.cgColor
|
contentView.layer.borderColor = UIColor.lightGray.cgColor
|
||||||
contentView.layer.borderWidth = 1.0
|
contentView.layer.borderWidth = 1.0
|
||||||
contentView.yoga.isEnabled = true
|
contentView.configureLayout { (layout) in
|
||||||
contentView.yoga.height = 300
|
layout.isEnabled = true
|
||||||
contentView.yoga.width = self.view.bounds.size.width
|
layout.height = 300
|
||||||
contentView.yoga.flexDirection = .row
|
layout.width = self.view.bounds.size.width
|
||||||
contentView.yoga.justifyContent = .center
|
layout.flexDirection = .row
|
||||||
contentView.yoga.paddingHorizontal = 25
|
layout.justifyContent = .center
|
||||||
|
layout.paddingHorizontal = 25
|
||||||
|
}
|
||||||
self.view.addSubview(contentView)
|
self.view.addSubview(contentView)
|
||||||
|
|
||||||
let redView = UIView(frame: .zero)
|
let redView = UIView(frame: .zero)
|
||||||
redView.backgroundColor = .red
|
redView.backgroundColor = .red
|
||||||
redView.yoga.isEnabled = true
|
redView.configureLayout { (layout) in
|
||||||
redView.yoga.flexGrow = 1
|
layout.isEnabled = true
|
||||||
redView.yoga.flexShrink = 1
|
layout.flexGrow = 1
|
||||||
|
layout.flexShrink = 1
|
||||||
|
}
|
||||||
contentView.addSubview(redView)
|
contentView.addSubview(redView)
|
||||||
|
|
||||||
disappearingView.backgroundColor = .blue
|
disappearingView.backgroundColor = .blue
|
||||||
disappearingView.yoga.isEnabled = true
|
disappearingView.configureLayout { (layout) in
|
||||||
disappearingView.yoga.flexGrow = 1
|
layout.isEnabled = true
|
||||||
|
layout.flexGrow = 1
|
||||||
|
}
|
||||||
contentView.addSubview(disappearingView)
|
contentView.addSubview(disappearingView)
|
||||||
|
|
||||||
button.setTitle("Add Blue View", for: UIControlState.selected)
|
button.setTitle("Add Blue View", for: UIControlState.selected)
|
||||||
button.setTitle("Remove Blue View", for: UIControlState.normal)
|
button.setTitle("Remove Blue View", for: UIControlState.normal)
|
||||||
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
|
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
|
||||||
button.yoga.isEnabled = true
|
button.configureLayout { (layout) in
|
||||||
button.yoga.height = 300
|
layout.isEnabled = true
|
||||||
button.yoga.width = 300
|
layout.height = 300
|
||||||
button.yoga.alignSelf = .center
|
layout.width = 300
|
||||||
|
layout.alignSelf = .center
|
||||||
|
}
|
||||||
root.addSubview(button)
|
root.addSubview(button)
|
||||||
|
|
||||||
root.yoga.applyLayout(preservingOrigin: false)
|
root.yoga.applyLayout(preservingOrigin: false)
|
||||||
|
@@ -15,9 +15,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
|
|||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
|
|
||||||
contentView.yoga.isEnabled = true
|
contentView.configureLayout { (layout) in
|
||||||
contentView.yoga.flexDirection = .column
|
layout.isEnabled = true
|
||||||
contentView.yoga.justifyContent = .flexEnd
|
layout.flexDirection = .column
|
||||||
|
layout.justifyContent = .flexEnd
|
||||||
|
}
|
||||||
|
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.numberOfLines = 1
|
label.numberOfLines = 1
|
||||||
@@ -26,9 +28,11 @@ final class SingleLabelCollectionCell: UICollectionViewCell {
|
|||||||
|
|
||||||
let border = UIView(frame: .zero)
|
let border = UIView(frame: .zero)
|
||||||
border.backgroundColor = .lightGray
|
border.backgroundColor = .lightGray
|
||||||
border.yoga.isEnabled = true
|
border.configureLayout { (layout) in
|
||||||
border.yoga.height = 0.5
|
layout.isEnabled = true
|
||||||
border.yoga.marginHorizontal = 25
|
layout.height = 0.5
|
||||||
|
layout.marginHorizontal = 25
|
||||||
|
}
|
||||||
contentView.addSubview(border)
|
contentView.addSubview(border)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,3 @@ android_resource(
|
|||||||
"PUBLIC",
|
"PUBLIC",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
project_config(
|
|
||||||
src_target = ":android",
|
|
||||||
)
|
|
||||||
|
21
android/README.md
Normal file
21
android/README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# YogaLayout [](https://facebook.github.io/yoga/docs/api/android/) [](https://facebook.github.io/yoga/docs/api/android/) [](https://bintray.com/facebook/maven/com.facebook.yoga.android%3Ayoga-layout/_latestVersion)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
YogaLayout is available via jcenter:
|
||||||
|
|
||||||
|
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Check out the docs [here](https://facebook.github.io/yoga/docs/api/android/).
|
||||||
|
|
||||||
|
We also have a sample project. To try it, clone the repo and run (with a device attached)
|
||||||
|
|
||||||
|
buck install -r android/sample
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
We welcome all pull-requests! At Facebook we sync the open source version of YogaKit daily, so we're always testing the latest changes.
|
||||||
|
|
||||||
|
See the CONTRIBUTING file for how to help out.
|
@@ -1,31 +1,28 @@
|
|||||||
apply plugin: "com.jfrog.bintray"
|
apply plugin: 'com.jfrog.bintray'
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
targetCompatibility = '1.7'
|
version = '1.4.1'
|
||||||
sourceCompatibility = '1.7'
|
|
||||||
|
|
||||||
version = '1.2.0'
|
|
||||||
group = 'com.facebook.yoga.android'
|
group = 'com.facebook.yoga.android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion rootProject.compileSdkVersion
|
||||||
buildToolsVersion "19.1.0"
|
buildToolsVersion rootProject.buildToolsVersion
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 15
|
minSdkVersion rootProject.minSdkVersion
|
||||||
targetSdkVersion 19
|
targetSdkVersion rootProject.targetSdkVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility rootProject.targetCompatibilityVersion
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility rootProject.sourceCompatibilityVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.facebook.yoga:yoga:1.2.0'
|
compile project(':yoga')
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
@@ -46,7 +43,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
bintrayName = "com.facebook.yoga.android:yoga-layout"
|
bintrayName = 'com.facebook.yoga.android:yoga-layout'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
|
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
android:targetSdkVersion="19"
|
android:targetSdkVersion="19"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
@@ -42,6 +44,11 @@
|
|||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".BenchmarkActivity"
|
||||||
|
android:exported="false"
|
||||||
|
/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -33,7 +33,3 @@ keystore(
|
|||||||
properties = "debug.keystore.properties",
|
properties = "debug.keystore.properties",
|
||||||
store = "debug.keystore",
|
store = "debug.keystore",
|
||||||
)
|
)
|
||||||
|
|
||||||
project_config(
|
|
||||||
src_target = ":sample",
|
|
||||||
)
|
|
||||||
|
@@ -0,0 +1,113 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
import com.facebook.yoga.android.YogaViewLayoutFactory;
|
||||||
|
|
||||||
|
public class BenchmarkActivity extends ActionBarActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.benchmark_select_layout);
|
||||||
|
|
||||||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||||
|
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
|
||||||
|
|
||||||
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
|
|
||||||
|
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
|
||||||
|
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||||
|
viewPager.setCurrentItem(tab.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Inflate")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Measure")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
actionBar.addTab(
|
||||||
|
actionBar.newTab()
|
||||||
|
.setText("Layout")
|
||||||
|
.setTabListener(tabListener));
|
||||||
|
|
||||||
|
viewPager.setOnPageChangeListener(
|
||||||
|
new ViewPager.SimpleOnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
// When swiping between pages, select the
|
||||||
|
// corresponding tab.
|
||||||
|
actionBar.setSelectedNavigationItem(position);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
viewPager.setOffscreenPageLimit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.action_bar_benchmark, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// There is only one option
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
this.finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PagerAdapter extends FragmentPagerAdapter {
|
||||||
|
public PagerAdapter(FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
return new BenchmarkInflate();
|
||||||
|
case 1:
|
||||||
|
return new BenchmarkMeasure();
|
||||||
|
default:
|
||||||
|
return new BenchmarkLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,193 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.Math;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.os.Environment;
|
||||||
|
|
||||||
|
import static java.util.Collections.sort;
|
||||||
|
|
||||||
|
public class BenchmarkAggregator {
|
||||||
|
|
||||||
|
private final int GRAPH_WIDTH = 30;
|
||||||
|
private final int GRAPH_HEIGHT = 6;
|
||||||
|
|
||||||
|
private List<Long> times;
|
||||||
|
private boolean tracing;
|
||||||
|
private long lastTraceStart;
|
||||||
|
|
||||||
|
private boolean statsFresh;
|
||||||
|
private long mean;
|
||||||
|
private long variance;
|
||||||
|
private long stddev;
|
||||||
|
private long min;
|
||||||
|
private long max;
|
||||||
|
private long p10;
|
||||||
|
private long p50;
|
||||||
|
private long p90;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public BenchmarkAggregator(String name) {
|
||||||
|
times = new ArrayList<>();
|
||||||
|
tracing = false;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startTrace() {
|
||||||
|
if (tracing) {
|
||||||
|
throw new RuntimeException("Cannot start trace while running previous one");
|
||||||
|
}
|
||||||
|
tracing = true;
|
||||||
|
lastTraceStart = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endTrace() {
|
||||||
|
if (!tracing) {
|
||||||
|
throw new RuntimeException("Cannot stop trace if none are running!");
|
||||||
|
}
|
||||||
|
times.add(System.nanoTime() - lastTraceStart);
|
||||||
|
tracing = false;
|
||||||
|
statsFresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void computeStats() {
|
||||||
|
if (statsFresh) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(times);
|
||||||
|
|
||||||
|
min = Long.MAX_VALUE;
|
||||||
|
max = -1;
|
||||||
|
mean = 0;
|
||||||
|
for (long f: times) {
|
||||||
|
mean += f;
|
||||||
|
if (f < min) {
|
||||||
|
min = f;
|
||||||
|
}
|
||||||
|
if (f > max) {
|
||||||
|
max = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mean /= times.size();
|
||||||
|
|
||||||
|
variance = 0;
|
||||||
|
for (long f: times) {
|
||||||
|
variance += (f-mean)*(f-mean);
|
||||||
|
}
|
||||||
|
variance /= times.size();
|
||||||
|
stddev = (long) Math.sqrt((double) variance);
|
||||||
|
|
||||||
|
p10 = times.get(times.size()*10/100);
|
||||||
|
p50 = times.get(times.size()*50/100);
|
||||||
|
p90 = times.get(times.size()*90/100);
|
||||||
|
|
||||||
|
statsFresh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
computeStats();
|
||||||
|
return String.format(
|
||||||
|
"%s:\n" +
|
||||||
|
"| %d samples\n" +
|
||||||
|
"| Mean %.3f\u00B1%.3fms\n" + // plusminus
|
||||||
|
"| Min %.3fms ; Max %.3fms\n" +
|
||||||
|
"| p10 %.3fms ; p50 %.3fms ; p90 %.3fms\n" +
|
||||||
|
"%s",
|
||||||
|
name,
|
||||||
|
times.size(),
|
||||||
|
mean/10e6,
|
||||||
|
stddev/10e6,
|
||||||
|
min/10e6,
|
||||||
|
max/10e6,
|
||||||
|
p10/10e6,
|
||||||
|
p50/10e6,
|
||||||
|
p90/10e6,
|
||||||
|
makeGraph());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeGraph() {
|
||||||
|
char canvas[][] = new char[GRAPH_HEIGHT][GRAPH_WIDTH];
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
canvas[i][j] = ' ';
|
||||||
|
|
||||||
|
long bucketSize = (p90 - p10) / GRAPH_WIDTH+1;
|
||||||
|
int bucketCount[] = new int[GRAPH_WIDTH];
|
||||||
|
for (long time : times) {
|
||||||
|
if (time<p90 && time>p10) {
|
||||||
|
bucketCount[(int) ((time - p10) / bucketSize)]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxBucket = 0;
|
||||||
|
for (int i = 0; i < GRAPH_WIDTH; i++)
|
||||||
|
if (bucketCount[i] > maxBucket) {
|
||||||
|
maxBucket = bucketCount[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
if (i < bucketCount[j] * GRAPH_HEIGHT / maxBucket) {
|
||||||
|
canvas[i][j] = 'Z';
|
||||||
|
}
|
||||||
|
|
||||||
|
String graph = new String();
|
||||||
|
for (int i = 0; i < GRAPH_HEIGHT; i++)
|
||||||
|
{
|
||||||
|
int percentage = 100 * (GRAPH_HEIGHT - i - 1) * maxBucket / (times.size() * GRAPH_HEIGHT);
|
||||||
|
graph += String.format("| %2d%% ", percentage);
|
||||||
|
for (int j = 0; j < GRAPH_WIDTH; j++)
|
||||||
|
graph += canvas[GRAPH_HEIGHT-1-i][j];
|
||||||
|
graph += '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
graph += "| p10";
|
||||||
|
for (int i = 0; i < GRAPH_WIDTH-6; i++)
|
||||||
|
graph += " ";
|
||||||
|
graph += "p90\n";
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the collected times to a file on the device. This allows us to grab the raw data
|
||||||
|
* and perform more in-depth analysis.
|
||||||
|
*/
|
||||||
|
public void dump(Context context) {
|
||||||
|
String state = Environment.getExternalStorageState();
|
||||||
|
if (!Environment.MEDIA_MOUNTED.equals(state)) {
|
||||||
|
Log.e("YogaLayoutBenchmark","No external file storage");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
|
String filename = format.format(new Date()) + "_" + name.replace(' ','_');
|
||||||
|
File file = new File(context.getExternalFilesDir(
|
||||||
|
Environment.DIRECTORY_DOCUMENTS), filename);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PrintWriter printWriter = new PrintWriter(file);
|
||||||
|
for (long l : times) {
|
||||||
|
printWriter.println(l);
|
||||||
|
}
|
||||||
|
printWriter.close();
|
||||||
|
|
||||||
|
Log.i("YogaLayoutBenchmark","Benchmark data saved in "+file.getPath());
|
||||||
|
} catch (java.io.IOException e) {
|
||||||
|
Log.e("YogaLayoutBenchmark", "Could not save benchmark data", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,110 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
import com.facebook.yoga.android.YogaLayout;
|
||||||
|
|
||||||
|
public class BenchmarkFragment extends Fragment implements AdapterView.OnItemSelectedListener {
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
|
protected com.facebook.yoga.android.YogaLayout rootLayout;
|
||||||
|
protected int yogaLayout;
|
||||||
|
protected int linearLayout;
|
||||||
|
|
||||||
|
static final Random random = new Random();
|
||||||
|
|
||||||
|
static void randomizeText(View root) {
|
||||||
|
if (root instanceof TextView) {
|
||||||
|
((TextView) root).setText("" + random.nextInt(1000));
|
||||||
|
((TextView) root).setTextSize(10 + random.nextInt(20));
|
||||||
|
ViewParent parent = root.getParent();
|
||||||
|
if (parent instanceof YogaLayout) {
|
||||||
|
((YogaLayout) parent).invalidate(root);
|
||||||
|
}
|
||||||
|
} else if (root instanceof ViewGroup) {
|
||||||
|
for (int i = 0; i < ((ViewGroup) root).getChildCount(); i++) {
|
||||||
|
randomizeText(((ViewGroup) root).getChildAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BenchmarkFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
mInflater = inflater;
|
||||||
|
|
||||||
|
rootLayout = (YogaLayout) inflater.inflate(
|
||||||
|
R.layout.benchmark_fragment,
|
||||||
|
container,
|
||||||
|
false);
|
||||||
|
|
||||||
|
Spinner benchmarkSelect = (Spinner) rootLayout.findViewById(R.id.benchmarkSelect);
|
||||||
|
String[] items = new String[]{"Basic", "Typical", "Nested"};
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
|
||||||
|
benchmarkSelect.setAdapter(adapter);
|
||||||
|
benchmarkSelect.setOnItemSelectedListener(this);
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||||
|
switch (pos) {
|
||||||
|
case 0:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_1;
|
||||||
|
linearLayout = R.layout.benchmark_layout_1_linear;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_2;
|
||||||
|
linearLayout = R.layout.benchmark_layout_2_linear;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
yogaLayout = R.layout.benchmark_layout_3;
|
||||||
|
linearLayout = R.layout.benchmark_layout_3_linear;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
yogaLayout = R.layout.benchmark_layout_1;
|
||||||
|
linearLayout = R.layout.benchmark_layout_1_linear;
|
||||||
|
updatePreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePreview() {
|
||||||
|
LinearLayout previewLayout = (LinearLayout) rootLayout.findViewById(R.id.preview);
|
||||||
|
View v = mInflater.inflate(yogaLayout, rootLayout, false);
|
||||||
|
v.setLayoutParams(new LinearLayout.LayoutParams(
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
previewLayout.removeAllViews();
|
||||||
|
previewLayout.addView(v);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
public class BenchmarkInflate extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
inflater.inflate(yogaLayout, null);
|
||||||
|
inflater.inflate(linearLayout, null);
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Inflate");
|
||||||
|
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Inflate");
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
yogaInflationAggregator.startTrace();
|
||||||
|
inflater.inflate(yogaLayout, null);
|
||||||
|
yogaInflationAggregator.endTrace();
|
||||||
|
linearInflationAggregator.startTrace();
|
||||||
|
inflater.inflate(linearLayout, null);
|
||||||
|
linearInflationAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
rootLayout.invalidate();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,74 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BenchmarkLayout extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Layout");
|
||||||
|
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Layout");
|
||||||
|
View yogaView = inflater.inflate(yogaLayout, null);
|
||||||
|
View linearView = inflater.inflate(linearLayout, null);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
randomizeText(yogaView);
|
||||||
|
randomizeText(linearView);
|
||||||
|
yogaView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
linearView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
yogaInflationAggregator.startTrace();
|
||||||
|
yogaView.layout(0, 0, yogaView.getMeasuredWidth(), yogaView.getMeasuredHeight());
|
||||||
|
yogaInflationAggregator.endTrace();
|
||||||
|
linearInflationAggregator.startTrace();
|
||||||
|
linearView.layout(0, 0, linearView.getMeasuredWidth(), linearView.getMeasuredHeight());
|
||||||
|
linearInflationAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaInflationAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearInflationAggregator.toString());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,75 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.facebook.samples.yoga.R;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class BenchmarkMeasure extends BenchmarkFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(
|
||||||
|
LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
|
Button b = (Button) rootLayout.findViewById(R.id.btn);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
startBenchmark();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return rootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startBenchmark() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
final int ITERATIONS = 500;
|
||||||
|
|
||||||
|
BenchmarkAggregator yogaMeasureAggregator = new BenchmarkAggregator("Yoga Measure");
|
||||||
|
BenchmarkAggregator linearMeasureAggregator = new BenchmarkAggregator("Linear Measure");
|
||||||
|
View yogaView = inflater.inflate(yogaLayout, null);
|
||||||
|
View linearView = inflater.inflate(linearLayout, null);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
|
randomizeText(yogaView);
|
||||||
|
randomizeText(linearView);
|
||||||
|
yogaMeasureAggregator.startTrace();
|
||||||
|
yogaView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
yogaMeasureAggregator.endTrace();
|
||||||
|
linearMeasureAggregator.startTrace();
|
||||||
|
linearView.measure(
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
|
||||||
|
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
|
||||||
|
linearMeasureAggregator.endTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setText(
|
||||||
|
yogaMeasureAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearMeasureAggregator.toString());
|
||||||
|
Log.i(
|
||||||
|
"YogaLayoutBenchmark",
|
||||||
|
yogaMeasureAggregator.toString()+
|
||||||
|
"\n"+
|
||||||
|
linearMeasureAggregator.toString());
|
||||||
|
|
||||||
|
yogaMeasureAggregator.dump(getActivity());
|
||||||
|
linearMeasureAggregator.dump(getActivity());
|
||||||
|
}
|
||||||
|
}
|
@@ -8,9 +8,13 @@
|
|||||||
|
|
||||||
package com.facebook.samples.yoga;
|
package com.facebook.samples.yoga;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.Menu;
|
||||||
|
|
||||||
import com.facebook.samples.yoga.R;
|
import com.facebook.samples.yoga.R;
|
||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
@@ -31,4 +35,20 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.main_layout);
|
setContentView(R.layout.main_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.action_bar_home, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// There is only one option
|
||||||
|
Intent intent = new Intent(this, BenchmarkActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
this.finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
50
android/sample/res/layout/benchmark_fragment.xml
Normal file
50
android/sample/res/layout/benchmark_fragment.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<YogaLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/rt"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_height="50dp"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Run benchmark"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/benchmarkSelect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
/>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/preview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
/>
|
||||||
|
</YogaLayout>
|
30
android/sample/res/layout/benchmark_layout_1.xml
Normal file
30
android/sample/res/layout/benchmark_layout_1.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<YogaLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_alignItems="center"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_flex="0"
|
||||||
|
yoga:yg_marginAll="5dp"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
yoga:yg_flex="0"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_2_text"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
yoga:yg_marginHorizontal="5dp"
|
||||||
|
/>
|
||||||
|
</YogaLayout>
|
28
android/sample/res/layout/benchmark_layout_1_linear.xml
Normal file
28
android/sample/res/layout/benchmark_layout_1_linear.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:text="@string/child_2_text"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
104
android/sample/res/layout/benchmark_layout_2.xml
Normal file
104
android/sample/res/layout/benchmark_layout_2.xml
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<YogaLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:height="40dp"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginAll="10dp"
|
||||||
|
yoga:yg_aspectRatio="1"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:height="40dp"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
yoga:yg_justifyContent="space_around"
|
||||||
|
>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:height="8dp"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_aspectRatio="1"
|
||||||
|
/>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:height="8dp"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_aspectRatio="1"
|
||||||
|
/>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:height="8dp"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_alignItems="stretch"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_aspectRatio="1"
|
||||||
|
/>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</YogaLayout>
|
96
android/sample/res/layout/benchmark_layout_2_linear.xml
Normal file
96
android/sample/res/layout/benchmark_layout_2_linear.xml
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="8dp"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="8dp"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textSize="5sp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
android:layout_width="8dp"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
206
android/sample/res/layout/benchmark_layout_3.xml
Normal file
206
android/sample/res/layout/benchmark_layout_3.xml
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<YogaLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_alignItems="center"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_justifyContent="center"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="column"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
yoga:yg_marginLeft="10dp"
|
||||||
|
/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:yg_flexDirection="row"
|
||||||
|
yoga:yg_flex="1"
|
||||||
|
>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</YogaLayout>
|
204
android/sample/res/layout/benchmark_layout_3_linear.xml
Normal file
204
android/sample/res/layout/benchmark_layout_3_linear.xml
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_blue"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:background="@color/yoga_grey"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
7
android/sample/res/layout/benchmark_select_layout.xml
Normal file
7
android/sample/res/layout/benchmark_select_layout.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/viewpager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
@@ -18,10 +18,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/sample_children_background"
|
android:background="@drawable/sample_children_background"
|
||||||
yoga:yg_margin_horizontal="10dp"
|
yoga:yg_marginHorizontal="10dp"
|
||||||
yoga:yg_margin_top="5dp"
|
yoga:yg_marginTop="5dp"
|
||||||
yoga:yg_flex_direction="row"
|
yoga:yg_flexDirection="row"
|
||||||
yoga:yg_align_items="center"
|
yoga:yg_alignItems="center"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
@@ -35,17 +35,17 @@
|
|||||||
android:text="@string/child_1_text"
|
android:text="@string/child_1_text"
|
||||||
android:textColor="@color/children_text"
|
android:textColor="@color/children_text"
|
||||||
yoga:yg_flex="1"
|
yoga:yg_flex="1"
|
||||||
yoga:yg_margin_start="8dp"
|
yoga:yg_marginStart="8dp"
|
||||||
/>
|
/>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
<YogaLayout
|
<YogaLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/sample_children_background"
|
android:background="@drawable/sample_children_background"
|
||||||
yoga:yg_margin_horizontal="10dp"
|
yoga:yg_marginHorizontal="10dp"
|
||||||
yoga:yg_margin_top="5dp"
|
yoga:yg_marginTop="5dp"
|
||||||
yoga:yg_flex_direction="row"
|
yoga:yg_flexDirection="row"
|
||||||
yoga:yg_align_items="center"
|
yoga:yg_alignItems="center"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
@@ -59,17 +59,17 @@
|
|||||||
android:text="@string/child_2_text"
|
android:text="@string/child_2_text"
|
||||||
android:textColor="@color/children_text"
|
android:textColor="@color/children_text"
|
||||||
yoga:yg_flex="1"
|
yoga:yg_flex="1"
|
||||||
yoga:yg_margin_start="8dp"
|
yoga:yg_marginStart="8dp"
|
||||||
/>
|
/>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
<YogaLayout
|
<YogaLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/sample_children_background"
|
android:background="@drawable/sample_children_background"
|
||||||
yoga:yg_margin_horizontal="10dp"
|
yoga:yg_marginHorizontal="10dp"
|
||||||
yoga:yg_margin_top="5dp"
|
yoga:yg_marginTop="5dp"
|
||||||
yoga:yg_flex_direction="row"
|
yoga:yg_flexDirection="row"
|
||||||
yoga:yg_align_items="center"
|
yoga:yg_alignItems="center"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
@@ -83,17 +83,17 @@
|
|||||||
android:text="@string/child_3_text"
|
android:text="@string/child_3_text"
|
||||||
android:textColor="@color/children_text"
|
android:textColor="@color/children_text"
|
||||||
yoga:yg_flex="1"
|
yoga:yg_flex="1"
|
||||||
yoga:yg_margin_start="8dp"
|
yoga:yg_marginStart="8dp"
|
||||||
/>
|
/>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
<YogaLayout
|
<YogaLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/sample_children_background"
|
android:background="@drawable/sample_children_background"
|
||||||
yoga:yg_margin_horizontal="10dp"
|
yoga:yg_marginHorizontal="10dp"
|
||||||
yoga:yg_margin_top="5dp"
|
yoga:yg_marginTop="5dp"
|
||||||
yoga:yg_flex_direction="row"
|
yoga:yg_flexDirection="row"
|
||||||
yoga:yg_align_items="center"
|
yoga:yg_alignItems="center"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
@@ -107,17 +107,17 @@
|
|||||||
android:text="@string/child_4_text"
|
android:text="@string/child_4_text"
|
||||||
android:textColor="@color/children_text"
|
android:textColor="@color/children_text"
|
||||||
yoga:yg_flex="1"
|
yoga:yg_flex="1"
|
||||||
yoga:yg_margin_start="8dp"
|
yoga:yg_marginStart="8dp"
|
||||||
/>
|
/>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
<YogaLayout
|
<YogaLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/sample_children_background"
|
android:background="@drawable/sample_children_background"
|
||||||
yoga:yg_margin_horizontal="10dp"
|
yoga:yg_marginHorizontal="10dp"
|
||||||
yoga:yg_margin_top="5dp"
|
yoga:yg_marginTop="5dp"
|
||||||
yoga:yg_flex_direction="row"
|
yoga:yg_flexDirection="row"
|
||||||
yoga:yg_align_items="center"
|
yoga:yg_alignItems="center"
|
||||||
>
|
>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
android:text="@string/child_5_text"
|
android:text="@string/child_5_text"
|
||||||
android:textColor="@color/children_text"
|
android:textColor="@color/children_text"
|
||||||
yoga:yg_flex="1"
|
yoga:yg_flex="1"
|
||||||
yoga:yg_margin_start="10dp"
|
yoga:yg_marginStart="10dp"
|
||||||
/>
|
/>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
</YogaLayout>
|
</YogaLayout>
|
||||||
|
19
android/sample/res/menu/action_bar_benchmark.xml
Normal file
19
android/sample/res/menu/action_bar_benchmark.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2014-present, Facebook, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
This source code is licensed under the license found in the
|
||||||
|
LICENSE-examples file in the root directory of this source tree.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_home"
|
||||||
|
android:title="Home"
|
||||||
|
android:showAsAction="always"
|
||||||
|
/>
|
||||||
|
</menu>
|
19
android/sample/res/menu/action_bar_home.xml
Normal file
19
android/sample/res/menu/action_bar_home.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2014-present, Facebook, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
This source code is licensed under the license found in the
|
||||||
|
LICENSE-examples file in the root directory of this source tree.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_benchmark"
|
||||||
|
android:title="Benchmark"
|
||||||
|
android:showAsAction="always"
|
||||||
|
/>
|
||||||
|
</menu>
|
@@ -23,6 +23,7 @@ import android.util.SparseArray;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.facebook.yoga.android.R;
|
import com.facebook.yoga.android.R;
|
||||||
import com.facebook.yoga.YogaAlign;
|
import com.facebook.yoga.YogaAlign;
|
||||||
@@ -36,7 +37,7 @@ import com.facebook.yoga.YogaMeasureFunction;
|
|||||||
import com.facebook.yoga.YogaMeasureMode;
|
import com.facebook.yoga.YogaMeasureMode;
|
||||||
import com.facebook.yoga.YogaMeasureOutput;
|
import com.facebook.yoga.YogaMeasureOutput;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.facebook.yoga.YogaNodeAPI;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.facebook.yoga.YogaOverflow;
|
import com.facebook.yoga.YogaOverflow;
|
||||||
import com.facebook.yoga.YogaPositionType;
|
import com.facebook.yoga.YogaPositionType;
|
||||||
import com.facebook.yoga.YogaWrap;
|
import com.facebook.yoga.YogaWrap;
|
||||||
@@ -51,7 +52,7 @@ import com.facebook.yoga.YogaWrap;
|
|||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* <YogaLayout
|
* <YogaLayout
|
||||||
* xmlns:android="http://schemas.android.com/apk/res/android"
|
* xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
* xmlns:yoga="http://schemas.android.com/lib/com.facebook.yoga.android"
|
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
|
||||||
* android:layout_width="match_parent"
|
* android:layout_width="match_parent"
|
||||||
* android:layout_height="match_parent"
|
* android:layout_height="match_parent"
|
||||||
* yoga:flex_direction="row"
|
* yoga:flex_direction="row"
|
||||||
@@ -90,15 +91,20 @@ public class YogaLayout extends ViewGroup {
|
|||||||
mYogaNode.setData(this);
|
mYogaNode.setData(this);
|
||||||
mYogaNode.setMeasureFunction(new ViewMeasureFunction());
|
mYogaNode.setMeasureFunction(new ViewMeasureFunction());
|
||||||
|
|
||||||
final LayoutParams layoutParams = new LayoutParams(context, attrs);
|
LayoutParams layoutParams = null;
|
||||||
|
if (attrs != null) {
|
||||||
|
layoutParams = new LayoutParams(context, attrs);
|
||||||
|
} else {
|
||||||
|
layoutParams = (LayoutParams) generateDefaultLayoutParams();
|
||||||
|
}
|
||||||
applyLayoutParams(layoutParams, mYogaNode, this);
|
applyLayoutParams(layoutParams, mYogaNode, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaNode getYogaNode() {
|
public YogaNode getYogaNode() {
|
||||||
return mYogaNode;
|
return mYogaNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaNode getYogaNodeForView(View view) {
|
public YogaNode getYogaNodeForView(View view) {
|
||||||
return mYogaNodes.get(view);
|
return mYogaNodes.get(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +159,11 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if (child instanceof YogaLayout) {
|
if (child instanceof YogaLayout) {
|
||||||
childNode = ((YogaLayout) child).getYogaNode();
|
childNode = ((YogaLayout) child).getYogaNode();
|
||||||
} else {
|
} else {
|
||||||
childNode = new YogaNode();
|
if(mYogaNodes.containsKey(child)) {
|
||||||
|
childNode = mYogaNodes.get(child);
|
||||||
|
} else {
|
||||||
|
childNode = new YogaNode();
|
||||||
|
}
|
||||||
|
|
||||||
childNode.setData(child);
|
childNode.setData(child);
|
||||||
childNode.setMeasureFunction(new ViewMeasureFunction());
|
childNode.setMeasureFunction(new ViewMeasureFunction());
|
||||||
@@ -278,6 +288,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
|
|
||||||
private void applyLayoutRecursive(YogaNode node, float xOffset, float yOffset) {
|
private void applyLayoutRecursive(YogaNode node, float xOffset, float yOffset) {
|
||||||
View view = (View) node.getData();
|
View view = (View) node.getData();
|
||||||
|
|
||||||
if (view != null && view != this) {
|
if (view != null && view != this) {
|
||||||
if (view.getVisibility() == GONE) {
|
if (view.getVisibility() == GONE) {
|
||||||
return;
|
return;
|
||||||
@@ -360,7 +371,6 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if (widthMode == MeasureSpec.AT_MOST) {
|
if (widthMode == MeasureSpec.AT_MOST) {
|
||||||
mYogaNode.setMaxWidth(widthSize);
|
mYogaNode.setMaxWidth(widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
mYogaNode.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
mYogaNode.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,31 +413,31 @@ public class YogaLayout extends ViewGroup {
|
|||||||
final int attribute = layoutParameters.numericAttributes.keyAt(i);
|
final int attribute = layoutParameters.numericAttributes.keyAt(i);
|
||||||
final float value = layoutParameters.numericAttributes.valueAt(i);
|
final float value = layoutParameters.numericAttributes.valueAt(i);
|
||||||
|
|
||||||
if (attribute == R.styleable.yoga_yg_align_content) {
|
if (attribute == R.styleable.yoga_yg_alignContent) {
|
||||||
node.setAlignContent(YogaAlign.fromInt(Math.round(value)));
|
node.setAlignContent(YogaAlign.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_align_items) {
|
} else if (attribute == R.styleable.yoga_yg_alignItems) {
|
||||||
node.setAlignItems(YogaAlign.fromInt(Math.round(value)));
|
node.setAlignItems(YogaAlign.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_align_self) {
|
} else if (attribute == R.styleable.yoga_yg_alignSelf) {
|
||||||
node.setAlignSelf(YogaAlign.fromInt(Math.round(value)));
|
node.setAlignSelf(YogaAlign.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_aspect_ratio) {
|
} else if (attribute == R.styleable.yoga_yg_aspectRatio) {
|
||||||
node.setAspectRatio(value);
|
node.setAspectRatio(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_left) {
|
} else if (attribute == R.styleable.yoga_yg_borderLeft) {
|
||||||
node.setBorder(YogaEdge.LEFT, value);
|
node.setBorder(YogaEdge.LEFT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_top) {
|
} else if (attribute == R.styleable.yoga_yg_borderTop) {
|
||||||
node.setBorder(YogaEdge.TOP, value);
|
node.setBorder(YogaEdge.TOP, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_right) {
|
} else if (attribute == R.styleable.yoga_yg_borderRight) {
|
||||||
node.setBorder(YogaEdge.RIGHT, value);
|
node.setBorder(YogaEdge.RIGHT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_borderBottom) {
|
||||||
node.setBorder(YogaEdge.BOTTOM, value);
|
node.setBorder(YogaEdge.BOTTOM, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_start) {
|
} else if (attribute == R.styleable.yoga_yg_borderStart) {
|
||||||
node.setBorder(YogaEdge.START, value);
|
node.setBorder(YogaEdge.START, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_end) {
|
} else if (attribute == R.styleable.yoga_yg_borderEnd) {
|
||||||
node.setBorder(YogaEdge.END, value);
|
node.setBorder(YogaEdge.END, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_borderHorizontal) {
|
||||||
node.setBorder(YogaEdge.HORIZONTAL, value);
|
node.setBorder(YogaEdge.HORIZONTAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_borderVertical) {
|
||||||
node.setBorder(YogaEdge.VERTICAL, value);
|
node.setBorder(YogaEdge.VERTICAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_border_all) {
|
} else if (attribute == R.styleable.yoga_yg_borderAll) {
|
||||||
node.setBorder(YogaEdge.ALL, value);
|
node.setBorder(YogaEdge.ALL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_direction) {
|
} else if (attribute == R.styleable.yoga_yg_direction) {
|
||||||
node.setDirection(YogaDirection.fromInt(Math.round(value)));
|
node.setDirection(YogaDirection.fromInt(Math.round(value)));
|
||||||
@@ -435,83 +445,83 @@ public class YogaLayout extends ViewGroup {
|
|||||||
node.setDisplay(YogaDisplay.fromInt(Math.round(value)));
|
node.setDisplay(YogaDisplay.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_flex) {
|
} else if (attribute == R.styleable.yoga_yg_flex) {
|
||||||
node.setFlex(value);
|
node.setFlex(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_flex_basis) {
|
} else if (attribute == R.styleable.yoga_yg_flexBasis) {
|
||||||
node.setFlexBasis(value);
|
node.setFlexBasis(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_flex_direction) {
|
} else if (attribute == R.styleable.yoga_yg_flexDirection) {
|
||||||
node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value)));
|
node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_flex_grow) {
|
} else if (attribute == R.styleable.yoga_yg_flexGrow) {
|
||||||
node.setFlexGrow(value);
|
node.setFlexGrow(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_flex_shrink) {
|
} else if (attribute == R.styleable.yoga_yg_flexShrink) {
|
||||||
node.setFlexShrink(value);
|
node.setFlexShrink(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_height) {
|
} else if (attribute == R.styleable.yoga_yg_height) {
|
||||||
node.setHeight(value);
|
node.setHeight(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_left) {
|
} else if (attribute == R.styleable.yoga_yg_marginLeft) {
|
||||||
node.setMargin(YogaEdge.LEFT, value);
|
node.setMargin(YogaEdge.LEFT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_justify_content) {
|
} else if (attribute == R.styleable.yoga_yg_justifyContent) {
|
||||||
node.setJustifyContent(YogaJustify.fromInt(Math.round(value)));
|
node.setJustifyContent(YogaJustify.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_top) {
|
} else if (attribute == R.styleable.yoga_yg_marginTop) {
|
||||||
node.setMargin(YogaEdge.TOP, value);
|
node.setMargin(YogaEdge.TOP, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_right) {
|
} else if (attribute == R.styleable.yoga_yg_marginRight) {
|
||||||
node.setMargin(YogaEdge.RIGHT, value);
|
node.setMargin(YogaEdge.RIGHT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
|
||||||
node.setMargin(YogaEdge.BOTTOM, value);
|
node.setMargin(YogaEdge.BOTTOM, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_start) {
|
} else if (attribute == R.styleable.yoga_yg_marginStart) {
|
||||||
node.setMargin(YogaEdge.START, value);
|
node.setMargin(YogaEdge.START, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_end) {
|
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
|
||||||
node.setMargin(YogaEdge.END, value);
|
node.setMargin(YogaEdge.END, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
|
||||||
node.setMargin(YogaEdge.HORIZONTAL, value);
|
node.setMargin(YogaEdge.HORIZONTAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
|
||||||
node.setMargin(YogaEdge.VERTICAL, value);
|
node.setMargin(YogaEdge.VERTICAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_all) {
|
} else if (attribute == R.styleable.yoga_yg_marginAll) {
|
||||||
node.setMargin(YogaEdge.ALL, value);
|
node.setMargin(YogaEdge.ALL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_max_height) {
|
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
|
||||||
node.setMaxHeight(value);
|
node.setMaxHeight(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_max_width) {
|
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
|
||||||
node.setMaxWidth(value);
|
node.setMaxWidth(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_min_height) {
|
} else if (attribute == R.styleable.yoga_yg_minHeight) {
|
||||||
node.setMinHeight(value);
|
node.setMinHeight(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_min_width) {
|
} else if (attribute == R.styleable.yoga_yg_minWidth) {
|
||||||
node.setMinWidth(value);
|
node.setMinWidth(value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_overflow) {
|
} else if (attribute == R.styleable.yoga_yg_overflow) {
|
||||||
node.setOverflow(YogaOverflow.fromInt(Math.round(value)));
|
node.setOverflow(YogaOverflow.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_left) {
|
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
|
||||||
node.setPadding(YogaEdge.LEFT, value);
|
node.setPadding(YogaEdge.LEFT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_top) {
|
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
|
||||||
node.setPadding(YogaEdge.TOP, value);
|
node.setPadding(YogaEdge.TOP, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_right) {
|
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
|
||||||
node.setPadding(YogaEdge.RIGHT, value);
|
node.setPadding(YogaEdge.RIGHT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
|
||||||
node.setPadding(YogaEdge.BOTTOM, value);
|
node.setPadding(YogaEdge.BOTTOM, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_start) {
|
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
|
||||||
node.setPadding(YogaEdge.START, value);
|
node.setPadding(YogaEdge.START, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_end) {
|
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
|
||||||
node.setPadding(YogaEdge.END, value);
|
node.setPadding(YogaEdge.END, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
|
||||||
node.setPadding(YogaEdge.HORIZONTAL, value);
|
node.setPadding(YogaEdge.HORIZONTAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
|
||||||
node.setPadding(YogaEdge.VERTICAL, value);
|
node.setPadding(YogaEdge.VERTICAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_all) {
|
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
|
||||||
node.setPadding(YogaEdge.ALL, value);
|
node.setPadding(YogaEdge.ALL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_left) {
|
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
|
||||||
node.setPosition(YogaEdge.LEFT, value);
|
node.setPosition(YogaEdge.LEFT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_top) {
|
} else if (attribute == R.styleable.yoga_yg_positionTop) {
|
||||||
node.setPosition(YogaEdge.TOP, value);
|
node.setPosition(YogaEdge.TOP, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_right) {
|
} else if (attribute == R.styleable.yoga_yg_positionRight) {
|
||||||
node.setPosition(YogaEdge.RIGHT, value);
|
node.setPosition(YogaEdge.RIGHT, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
|
||||||
node.setPosition(YogaEdge.BOTTOM, value);
|
node.setPosition(YogaEdge.BOTTOM, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_start) {
|
} else if (attribute == R.styleable.yoga_yg_positionStart) {
|
||||||
node.setPosition(YogaEdge.START, value);
|
node.setPosition(YogaEdge.START, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_end) {
|
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
|
||||||
node.setPosition(YogaEdge.END, value);
|
node.setPosition(YogaEdge.END, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
|
||||||
node.setPosition(YogaEdge.HORIZONTAL, value);
|
node.setPosition(YogaEdge.HORIZONTAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
|
||||||
node.setPosition(YogaEdge.VERTICAL, value);
|
node.setPosition(YogaEdge.VERTICAL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_all) {
|
} else if (attribute == R.styleable.yoga_yg_positionAll) {
|
||||||
node.setPosition(YogaEdge.ALL, value);
|
node.setPosition(YogaEdge.ALL, value);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_type) {
|
} else if (attribute == R.styleable.yoga_yg_positionType) {
|
||||||
node.setPositionType(YogaPositionType.fromInt(Math.round(value)));
|
node.setPositionType(YogaPositionType.fromInt(Math.round(value)));
|
||||||
} else if (attribute == R.styleable.yoga_yg_width) {
|
} else if (attribute == R.styleable.yoga_yg_width) {
|
||||||
node.setWidth(value);
|
node.setWidth(value);
|
||||||
@@ -525,23 +535,23 @@ public class YogaLayout extends ViewGroup {
|
|||||||
final String value = layoutParameters.stringAttributes.valueAt(i);
|
final String value = layoutParameters.stringAttributes.valueAt(i);
|
||||||
|
|
||||||
if (value.equals("auto")) {
|
if (value.equals("auto")) {
|
||||||
if (attribute == R.styleable.yoga_yg_margin_left) {
|
if (attribute == R.styleable.yoga_yg_marginLeft) {
|
||||||
node.setMarginAuto(YogaEdge.LEFT);
|
node.setMarginAuto(YogaEdge.LEFT);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_top) {
|
} else if (attribute == R.styleable.yoga_yg_marginTop) {
|
||||||
node.setMarginAuto(YogaEdge.TOP);
|
node.setMarginAuto(YogaEdge.TOP);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_right) {
|
} else if (attribute == R.styleable.yoga_yg_marginRight) {
|
||||||
node.setMarginAuto(YogaEdge.RIGHT);
|
node.setMarginAuto(YogaEdge.RIGHT);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
|
||||||
node.setMarginAuto(YogaEdge.BOTTOM);
|
node.setMarginAuto(YogaEdge.BOTTOM);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_start) {
|
} else if (attribute == R.styleable.yoga_yg_marginStart) {
|
||||||
node.setMarginAuto(YogaEdge.START);
|
node.setMarginAuto(YogaEdge.START);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_end) {
|
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
|
||||||
node.setMarginAuto(YogaEdge.END);
|
node.setMarginAuto(YogaEdge.END);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
|
||||||
node.setMarginAuto(YogaEdge.HORIZONTAL);
|
node.setMarginAuto(YogaEdge.HORIZONTAL);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
|
||||||
node.setMarginAuto(YogaEdge.VERTICAL);
|
node.setMarginAuto(YogaEdge.VERTICAL);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_all) {
|
} else if (attribute == R.styleable.yoga_yg_marginAll) {
|
||||||
node.setMarginAuto(YogaEdge.ALL);
|
node.setMarginAuto(YogaEdge.ALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -549,71 +559,71 @@ public class YogaLayout extends ViewGroup {
|
|||||||
if (value.endsWith("%")) {
|
if (value.endsWith("%")) {
|
||||||
final float numericValue = Float.parseFloat(value.substring(0, value.length()-1));
|
final float numericValue = Float.parseFloat(value.substring(0, value.length()-1));
|
||||||
|
|
||||||
if (attribute == R.styleable.yoga_yg_flex_basis) {
|
if (attribute == R.styleable.yoga_yg_flexBasis) {
|
||||||
node.setFlexBasisPercent(numericValue);
|
node.setFlexBasisPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_height) {
|
} else if (attribute == R.styleable.yoga_yg_height) {
|
||||||
node.setHeightPercent(numericValue);
|
node.setHeightPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_left) {
|
} else if (attribute == R.styleable.yoga_yg_marginLeft) {
|
||||||
node.setMarginPercent(YogaEdge.LEFT, numericValue);
|
node.setMarginPercent(YogaEdge.LEFT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_top) {
|
} else if (attribute == R.styleable.yoga_yg_marginTop) {
|
||||||
node.setMarginPercent(YogaEdge.TOP, numericValue);
|
node.setMarginPercent(YogaEdge.TOP, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_right) {
|
} else if (attribute == R.styleable.yoga_yg_marginRight) {
|
||||||
node.setMarginPercent(YogaEdge.RIGHT, numericValue);
|
node.setMarginPercent(YogaEdge.RIGHT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_marginBottom) {
|
||||||
node.setMarginPercent(YogaEdge.BOTTOM, numericValue);
|
node.setMarginPercent(YogaEdge.BOTTOM, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_start) {
|
} else if (attribute == R.styleable.yoga_yg_marginStart) {
|
||||||
node.setMarginPercent(YogaEdge.START, numericValue);
|
node.setMarginPercent(YogaEdge.START, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_end) {
|
} else if (attribute == R.styleable.yoga_yg_marginEnd) {
|
||||||
node.setMarginPercent(YogaEdge.END, numericValue);
|
node.setMarginPercent(YogaEdge.END, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_marginHorizontal) {
|
||||||
node.setMarginPercent(YogaEdge.HORIZONTAL, numericValue);
|
node.setMarginPercent(YogaEdge.HORIZONTAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_marginVertical) {
|
||||||
node.setMarginPercent(YogaEdge.VERTICAL, numericValue);
|
node.setMarginPercent(YogaEdge.VERTICAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_margin_all) {
|
} else if (attribute == R.styleable.yoga_yg_marginAll) {
|
||||||
node.setMarginPercent(YogaEdge.ALL, numericValue);
|
node.setMarginPercent(YogaEdge.ALL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_max_height) {
|
} else if (attribute == R.styleable.yoga_yg_maxHeight) {
|
||||||
node.setMaxHeightPercent(numericValue);
|
node.setMaxHeightPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_max_width) {
|
} else if (attribute == R.styleable.yoga_yg_maxWidth) {
|
||||||
node.setMaxWidthPercent(numericValue);
|
node.setMaxWidthPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_min_height) {
|
} else if (attribute == R.styleable.yoga_yg_minHeight) {
|
||||||
node.setMinHeightPercent(numericValue);
|
node.setMinHeightPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_min_width) {
|
} else if (attribute == R.styleable.yoga_yg_minWidth) {
|
||||||
node.setMinWidthPercent(numericValue);
|
node.setMinWidthPercent(numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_left) {
|
} else if (attribute == R.styleable.yoga_yg_paddingLeft) {
|
||||||
node.setPaddingPercent(YogaEdge.LEFT, numericValue);
|
node.setPaddingPercent(YogaEdge.LEFT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_top) {
|
} else if (attribute == R.styleable.yoga_yg_paddingTop) {
|
||||||
node.setPaddingPercent(YogaEdge.TOP, numericValue);
|
node.setPaddingPercent(YogaEdge.TOP, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_right) {
|
} else if (attribute == R.styleable.yoga_yg_paddingRight) {
|
||||||
node.setPaddingPercent(YogaEdge.RIGHT, numericValue);
|
node.setPaddingPercent(YogaEdge.RIGHT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_paddingBottom) {
|
||||||
node.setPaddingPercent(YogaEdge.BOTTOM, numericValue);
|
node.setPaddingPercent(YogaEdge.BOTTOM, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_start) {
|
} else if (attribute == R.styleable.yoga_yg_paddingStart) {
|
||||||
node.setPaddingPercent(YogaEdge.START, numericValue);
|
node.setPaddingPercent(YogaEdge.START, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_end) {
|
} else if (attribute == R.styleable.yoga_yg_paddingEnd) {
|
||||||
node.setPaddingPercent(YogaEdge.END, numericValue);
|
node.setPaddingPercent(YogaEdge.END, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_paddingHorizontal) {
|
||||||
node.setPaddingPercent(YogaEdge.HORIZONTAL, numericValue);
|
node.setPaddingPercent(YogaEdge.HORIZONTAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_paddingVertical) {
|
||||||
node.setPaddingPercent(YogaEdge.VERTICAL, numericValue);
|
node.setPaddingPercent(YogaEdge.VERTICAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_padding_all) {
|
} else if (attribute == R.styleable.yoga_yg_paddingAll) {
|
||||||
node.setPaddingPercent(YogaEdge.ALL, numericValue);
|
node.setPaddingPercent(YogaEdge.ALL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_left) {
|
} else if (attribute == R.styleable.yoga_yg_positionLeft) {
|
||||||
node.setPositionPercent(YogaEdge.LEFT, numericValue);
|
node.setPositionPercent(YogaEdge.LEFT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_top) {
|
} else if (attribute == R.styleable.yoga_yg_positionTop) {
|
||||||
node.setPositionPercent(YogaEdge.TOP, numericValue);
|
node.setPositionPercent(YogaEdge.TOP, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_right) {
|
} else if (attribute == R.styleable.yoga_yg_positionRight) {
|
||||||
node.setPositionPercent(YogaEdge.RIGHT, numericValue);
|
node.setPositionPercent(YogaEdge.RIGHT, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_bottom) {
|
} else if (attribute == R.styleable.yoga_yg_positionBottom) {
|
||||||
node.setPositionPercent(YogaEdge.BOTTOM, numericValue);
|
node.setPositionPercent(YogaEdge.BOTTOM, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_start) {
|
} else if (attribute == R.styleable.yoga_yg_positionStart) {
|
||||||
node.setPositionPercent(YogaEdge.START, numericValue);
|
node.setPositionPercent(YogaEdge.START, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_end) {
|
} else if (attribute == R.styleable.yoga_yg_positionEnd) {
|
||||||
node.setPositionPercent(YogaEdge.END, numericValue);
|
node.setPositionPercent(YogaEdge.END, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_horizontal) {
|
} else if (attribute == R.styleable.yoga_yg_positionHorizontal) {
|
||||||
node.setPositionPercent(YogaEdge.HORIZONTAL, numericValue);
|
node.setPositionPercent(YogaEdge.HORIZONTAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_vertical) {
|
} else if (attribute == R.styleable.yoga_yg_positionVertical) {
|
||||||
node.setPositionPercent(YogaEdge.VERTICAL, numericValue);
|
node.setPositionPercent(YogaEdge.VERTICAL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_position_all) {
|
} else if (attribute == R.styleable.yoga_yg_positionAll) {
|
||||||
node.setPositionPercent(YogaEdge.ALL, numericValue);
|
node.setPositionPercent(YogaEdge.ALL, numericValue);
|
||||||
} else if (attribute == R.styleable.yoga_yg_width) {
|
} else if (attribute == R.styleable.yoga_yg_width) {
|
||||||
node.setWidthPercent(numericValue);
|
node.setWidthPercent(numericValue);
|
||||||
@@ -779,7 +789,7 @@ public class YogaLayout extends ViewGroup {
|
|||||||
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
||||||
*/
|
*/
|
||||||
public long measure(
|
public long measure(
|
||||||
YogaNodeAPI node,
|
YogaNode node,
|
||||||
float width,
|
float width,
|
||||||
YogaMeasureMode widthMode,
|
YogaMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<declare-styleable name="yoga">
|
<declare-styleable name="yoga">
|
||||||
|
|
||||||
<attr name="yg_align_content" format="enum">
|
<attr name="yg_alignContent" format="enum">
|
||||||
<enum name="auto" value="0"/>
|
<enum name="auto" value="0"/>
|
||||||
<enum name="flex_start" value="1"/>
|
<enum name="flex_start" value="1"/>
|
||||||
<enum name="center" value="2"/>
|
<enum name="center" value="2"/>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<enum name="baseline" value="5"/>
|
<enum name="baseline" value="5"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_align_items" format="enum">
|
<attr name="yg_alignItems" format="enum">
|
||||||
<enum name="auto" value="0"/>
|
<enum name="auto" value="0"/>
|
||||||
<enum name="flex_start" value="1"/>
|
<enum name="flex_start" value="1"/>
|
||||||
<enum name="center" value="2"/>
|
<enum name="center" value="2"/>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<enum name="baseline" value="5"/>
|
<enum name="baseline" value="5"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_align_self" format="enum">
|
<attr name="yg_alignSelf" format="enum">
|
||||||
<enum name="auto" value="0"/>
|
<enum name="auto" value="0"/>
|
||||||
<enum name="flex_start" value="1"/>
|
<enum name="flex_start" value="1"/>
|
||||||
<enum name="center" value="2"/>
|
<enum name="center" value="2"/>
|
||||||
@@ -39,17 +39,17 @@
|
|||||||
<enum name="baseline" value="5"/>
|
<enum name="baseline" value="5"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_aspect_ratio" format="float"/>
|
<attr name="yg_aspectRatio" format="float"/>
|
||||||
|
|
||||||
<attr name="yg_border_left" format="dimension"/>
|
<attr name="yg_borderLeft" format="dimension"/>
|
||||||
<attr name="yg_border_top" format="dimension"/>
|
<attr name="yg_borderTop" format="dimension"/>
|
||||||
<attr name="yg_border_right" format="dimension"/>
|
<attr name="yg_borderRight" format="dimension"/>
|
||||||
<attr name="yg_border_bottom" format="dimension"/>
|
<attr name="yg_borderBottom" format="dimension"/>
|
||||||
<attr name="yg_border_start" format="dimension"/>
|
<attr name="yg_borderStart" format="dimension"/>
|
||||||
<attr name="yg_border_end" format="dimension"/>
|
<attr name="yg_borderEnd" format="dimension"/>
|
||||||
<attr name="yg_border_horizontal" format="dimension"/>
|
<attr name="yg_borderHorizontal" format="dimension"/>
|
||||||
<attr name="yg_border_vertical" format="dimension"/>
|
<attr name="yg_borderVertical" format="dimension"/>
|
||||||
<attr name="yg_border_all" format="dimension"/>
|
<attr name="yg_borderAll" format="dimension"/>
|
||||||
|
|
||||||
<attr name="yg_direction" format="enum">
|
<attr name="yg_direction" format="enum">
|
||||||
<enum name="inherit" value="0"/>
|
<enum name="inherit" value="0"/>
|
||||||
@@ -64,22 +64,22 @@
|
|||||||
|
|
||||||
<attr name="yg_flex" format="float"/>
|
<attr name="yg_flex" format="float"/>
|
||||||
|
|
||||||
<attr name="yg_flex_basis" format="float|string"/>
|
<attr name="yg_flexBasis" format="float|string"/>
|
||||||
|
|
||||||
<attr name="yg_flex_direction" format="enum">
|
<attr name="yg_flexDirection" format="enum">
|
||||||
<enum name="column" value="0"/>
|
<enum name="column" value="0"/>
|
||||||
<enum name="column_reverse" value="1"/>
|
<enum name="column_reverse" value="1"/>
|
||||||
<enum name="row" value="2"/>
|
<enum name="row" value="2"/>
|
||||||
<enum name="row_reverse" value="3"/>
|
<enum name="row_reverse" value="3"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_flex_grow" format="float"/>
|
<attr name="yg_flexGrow" format="float"/>
|
||||||
|
|
||||||
<attr name="yg_flex_shrink" format="float"/>
|
<attr name="yg_flexShrink" format="float"/>
|
||||||
|
|
||||||
<attr name="yg_height" format="dimension|string"/>
|
<attr name="yg_height" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_justify_content" format="enum">
|
<attr name="yg_justifyContent" format="enum">
|
||||||
<enum name="flex_start" value="0"/>
|
<enum name="flex_start" value="0"/>
|
||||||
<enum name="center" value="1"/>
|
<enum name="center" value="1"/>
|
||||||
<enum name="flex_end" value="2"/>
|
<enum name="flex_end" value="2"/>
|
||||||
@@ -87,23 +87,23 @@
|
|||||||
<enum name="space_around" value="4"/>
|
<enum name="space_around" value="4"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_margin_left" format="dimension|string"/>
|
<attr name="yg_marginLeft" format="dimension|string"/>
|
||||||
<attr name="yg_margin_top" format="dimension|string"/>
|
<attr name="yg_marginTop" format="dimension|string"/>
|
||||||
<attr name="yg_margin_right" format="dimension|string"/>
|
<attr name="yg_marginRight" format="dimension|string"/>
|
||||||
<attr name="yg_margin_bottom" format="dimension|string"/>
|
<attr name="yg_marginBottom" format="dimension|string"/>
|
||||||
<attr name="yg_margin_start" format="dimension|string"/>
|
<attr name="yg_marginStart" format="dimension|string"/>
|
||||||
<attr name="yg_margin_end" format="dimension|string"/>
|
<attr name="yg_marginEnd" format="dimension|string"/>
|
||||||
<attr name="yg_margin_horizontal" format="dimension|string"/>
|
<attr name="yg_marginHorizontal" format="dimension|string"/>
|
||||||
<attr name="yg_margin_vertical" format="dimension|string"/>
|
<attr name="yg_marginVertical" format="dimension|string"/>
|
||||||
<attr name="yg_margin_all" format="dimension|string"/>
|
<attr name="yg_marginAll" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_max_height" format="dimension|string"/>
|
<attr name="yg_maxHeight" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_max_width" format="dimension|string"/>
|
<attr name="yg_maxWidth" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_min_height" format="dimension|string"/>
|
<attr name="yg_minHeight" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_min_width" format="dimension|string"/>
|
<attr name="yg_minWidth" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_overflow" format="enum">
|
<attr name="yg_overflow" format="enum">
|
||||||
<enum name="visible" value="0"/>
|
<enum name="visible" value="0"/>
|
||||||
@@ -111,27 +111,27 @@
|
|||||||
<enum name="scroll" value="2"/>
|
<enum name="scroll" value="2"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|
||||||
<attr name="yg_padding_left" format="dimension|string"/>
|
<attr name="yg_paddingLeft" format="dimension|string"/>
|
||||||
<attr name="yg_padding_top" format="dimension|string"/>
|
<attr name="yg_paddingTop" format="dimension|string"/>
|
||||||
<attr name="yg_padding_right" format="dimension|string"/>
|
<attr name="yg_paddingRight" format="dimension|string"/>
|
||||||
<attr name="yg_padding_bottom" format="dimension|string"/>
|
<attr name="yg_paddingBottom" format="dimension|string"/>
|
||||||
<attr name="yg_padding_start" format="dimension|string"/>
|
<attr name="yg_paddingStart" format="dimension|string"/>
|
||||||
<attr name="yg_padding_end" format="dimension|string"/>
|
<attr name="yg_paddingEnd" format="dimension|string"/>
|
||||||
<attr name="yg_padding_horizontal" format="dimension|string"/>
|
<attr name="yg_paddingHorizontal" format="dimension|string"/>
|
||||||
<attr name="yg_padding_vertical" format="dimension|string"/>
|
<attr name="yg_paddingVertical" format="dimension|string"/>
|
||||||
<attr name="yg_padding_all" format="dimension|string"/>
|
<attr name="yg_paddingAll" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_position_left" format="dimension|string"/>
|
<attr name="yg_positionLeft" format="dimension|string"/>
|
||||||
<attr name="yg_position_top" format="dimension|string"/>
|
<attr name="yg_positionTop" format="dimension|string"/>
|
||||||
<attr name="yg_position_right" format="dimension|string"/>
|
<attr name="yg_positionRight" format="dimension|string"/>
|
||||||
<attr name="yg_position_bottom" format="dimension|string"/>
|
<attr name="yg_positionBottom" format="dimension|string"/>
|
||||||
<attr name="yg_position_start" format="dimension|string"/>
|
<attr name="yg_positionStart" format="dimension|string"/>
|
||||||
<attr name="yg_position_end" format="dimension|string"/>
|
<attr name="yg_positionEnd" format="dimension|string"/>
|
||||||
<attr name="yg_position_horizontal" format="dimension|string"/>
|
<attr name="yg_positionHorizontal" format="dimension|string"/>
|
||||||
<attr name="yg_position_vertical" format="dimension|string"/>
|
<attr name="yg_positionVertical" format="dimension|string"/>
|
||||||
<attr name="yg_position_all" format="dimension|string"/>
|
<attr name="yg_positionAll" format="dimension|string"/>
|
||||||
|
|
||||||
<attr name="yg_position_type" format="enum">
|
<attr name="yg_positionType" format="enum">
|
||||||
<enum name="relative" value="0"/>
|
<enum name="relative" value="0"/>
|
||||||
<enum name="absolute" value="1"/>
|
<enum name="absolute" value="1"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
17
build.gradle
17
build.gradle
@@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||||
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
|
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
|
||||||
@@ -18,15 +18,18 @@ buildscript {
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
flatDir {
|
|
||||||
dirs "${rootDir}/lib/jsr-305"
|
|
||||||
dirs "${rootDir}/lib/soloader"
|
|
||||||
dirs "${rootDir}/lib/appcompat"
|
|
||||||
dirs "${rootDir}/lib/android-support"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
minSdkVersion = 15
|
||||||
|
targetSdkVersion = 25
|
||||||
|
compileSdkVersion = 25
|
||||||
|
buildToolsVersion = '25.0.2'
|
||||||
|
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
|
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||||
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)YogaConfig.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaDimension.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaDimension.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaDirection.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaDirection.cs" />
|
||||||
|
@@ -28,7 +28,7 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
internal class YGNodeHandle : SafeHandle
|
internal class YGNodeHandle : SafeHandle
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
private GCHandle _managed;
|
private GCHandle _managed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -46,27 +46,37 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
protected override bool ReleaseHandle()
|
protected override bool ReleaseHandle()
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
if (_managed.IsAllocated)
|
ReleaseManaged();
|
||||||
{
|
|
||||||
_managed.Free();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
Native.YGNodeFree(this.handle);
|
Native.YGNodeFree(this.handle);
|
||||||
GC.KeepAlive(this);
|
GC.KeepAlive(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
public void SetContext(YogaNode node)
|
public void SetContext(YogaNode node)
|
||||||
{
|
{
|
||||||
if (!_managed.IsAllocated)
|
if (!_managed.IsAllocated)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
// Weak causes 'GCHandle value belongs to a different domain' error
|
||||||
|
_managed = GCHandle.Alloc(node);
|
||||||
|
#else
|
||||||
_managed = GCHandle.Alloc(node, GCHandleType.Weak);
|
_managed = GCHandle.Alloc(node, GCHandleType.Weak);
|
||||||
|
#endif
|
||||||
Native.YGNodeSetContext(this.handle, GCHandle.ToIntPtr(_managed));
|
Native.YGNodeSetContext(this.handle, GCHandle.ToIntPtr(_managed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReleaseManaged()
|
||||||
|
{
|
||||||
|
if (_managed.IsAllocated)
|
||||||
|
{
|
||||||
|
_managed.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static YogaNode GetManaged(IntPtr ygNodePtr)
|
public static YogaNode GetManaged(IntPtr ygNodePtr)
|
||||||
{
|
{
|
||||||
var node =
|
var node =
|
||||||
@@ -83,10 +93,6 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
internal class YGConfigHandle : SafeHandle
|
internal class YGConfigHandle : SafeHandle
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
|
||||||
private GCHandle _managed;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private YGConfigHandle() : base(IntPtr.Zero, true)
|
private YGConfigHandle() : base(IntPtr.Zero, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -101,12 +107,6 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
protected override bool ReleaseHandle()
|
protected override bool ReleaseHandle()
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
|
||||||
if (_managed.IsAllocated)
|
|
||||||
{
|
|
||||||
_managed.Free();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Native.YGConfigFree(this.handle);
|
Native.YGConfigFree(this.handle);
|
||||||
GC.KeepAlive(this);
|
GC.KeepAlive(this);
|
||||||
return true;
|
return true;
|
||||||
@@ -138,6 +138,9 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int YGNodeGetInstanceCount();
|
public static extern int YGNodeGetInstanceCount();
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern int YGConfigGetInstanceCount();
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGConfigSetExperimentalFeatureEnabled(
|
public static extern void YGConfigSetExperimentalFeatureEnabled(
|
||||||
YGConfigHandle config,
|
YGConfigHandle config,
|
||||||
@@ -149,6 +152,19 @@ namespace Facebook.Yoga
|
|||||||
YGConfigHandle config,
|
YGConfigHandle config,
|
||||||
YogaExperimentalFeature feature);
|
YogaExperimentalFeature feature);
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void YGConfigSetUseWebDefaults(
|
||||||
|
YGConfigHandle config,
|
||||||
|
bool useWebDefaults);
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
|
||||||
|
|
||||||
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void YGConfigSetPointScaleFactor(
|
||||||
|
YGConfigHandle config,
|
||||||
|
float pixelsInPoint);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGNodeInsertChild(
|
public static extern void YGNodeInsertChild(
|
||||||
YGNodeHandle node,
|
YGNodeHandle node,
|
||||||
@@ -429,9 +445,9 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IOS
|
#region AOT
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr YGNodeGetContext(IntPtr node);
|
public static extern IntPtr YGNodeGetContext(IntPtr node);
|
||||||
|
|
||||||
|
72
csharp/Facebook.Yoga/YogaConfig.cs
Normal file
72
csharp/Facebook.Yoga/YogaConfig.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Facebook.Yoga
|
||||||
|
{
|
||||||
|
public class YogaConfig
|
||||||
|
{
|
||||||
|
private Native.YGConfigHandle _ygConfig;
|
||||||
|
|
||||||
|
public YogaConfig()
|
||||||
|
{
|
||||||
|
_ygConfig = Native.YGConfigNew();
|
||||||
|
if (_ygConfig.IsInvalid)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Failed to allocate native memory");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Native.YGConfigHandle Handle
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return _ygConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetExperimentalFeatureEnabled(
|
||||||
|
YogaExperimentalFeature feature,
|
||||||
|
bool enabled)
|
||||||
|
{
|
||||||
|
Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
|
||||||
|
{
|
||||||
|
return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseWebDefaults
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Native.YGConfigGetUseWebDefaults(_ygConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Native.YGConfigSetUseWebDefaults(_ygConfig, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float PointScaleFactor
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Native.YGConfigSetPointScaleFactor(_ygConfig, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetInstanceCount()
|
||||||
|
{
|
||||||
|
return Native.YGConfigGetInstanceCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -13,6 +13,9 @@ using System.Runtime.InteropServices;
|
|||||||
#if __IOS__
|
#if __IOS__
|
||||||
using ObjCRuntime;
|
using ObjCRuntime;
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
using AOT;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
@@ -26,7 +29,7 @@ namespace Facebook.Yoga
|
|||||||
|
|
||||||
public static Func Logger = null;
|
public static Func Logger = null;
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
[MonoPInvokeCallback(typeof(Func))]
|
[MonoPInvokeCallback(typeof(Func))]
|
||||||
#endif
|
#endif
|
||||||
public static void LoggerInternal(YogaLogLevel level, string message)
|
public static void LoggerInternal(YogaLogLevel level, string message)
|
||||||
|
@@ -12,60 +12,30 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
#endif
|
#endif
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
using ObjCRuntime;
|
using ObjCRuntime;
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
using AOT;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
public class YogaConfig
|
|
||||||
{
|
|
||||||
|
|
||||||
private Native.YGConfigHandle _ygConfig;
|
|
||||||
|
|
||||||
public YogaConfig()
|
|
||||||
{
|
|
||||||
_ygConfig = Native.YGConfigNew();
|
|
||||||
if (_ygConfig.IsInvalid)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Failed to allocate native memory");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal Native.YGConfigHandle Handle {
|
|
||||||
get {
|
|
||||||
return _ygConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetExperimentalFeatureEnabled(
|
|
||||||
YogaExperimentalFeature feature,
|
|
||||||
bool enabled)
|
|
||||||
{
|
|
||||||
Native.YGConfigSetExperimentalFeatureEnabled(_ygConfig, feature, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
|
|
||||||
{
|
|
||||||
return Native.YGConfigIsExperimentalFeatureEnabled(_ygConfig, feature);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class YogaNode : IEnumerable<YogaNode>
|
public partial class YogaNode : IEnumerable<YogaNode>
|
||||||
{
|
{
|
||||||
private Native.YGNodeHandle _ygNode;
|
private readonly Native.YGNodeHandle _ygNode;
|
||||||
|
private readonly YogaConfig _config;
|
||||||
private WeakReference _parent;
|
private WeakReference _parent;
|
||||||
private List<YogaNode> _children;
|
private List<YogaNode> _children;
|
||||||
private MeasureFunction _measureFunction;
|
private MeasureFunction _measureFunction;
|
||||||
private BaselineFunction _baselineFunction;
|
private BaselineFunction _baselineFunction;
|
||||||
private object _data;
|
private object _data;
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
private static YogaMeasureFunc _managedMeasure = MeasureInternalIOS;
|
private static YogaMeasureFunc _managedMeasure;
|
||||||
private static YogaBaselineFunc _managedBaseline = BaselineInternalIOS;
|
private static YogaBaselineFunc _managedBaseline;
|
||||||
#else
|
#else
|
||||||
private YogaMeasureFunc _managedMeasure;
|
private YogaMeasureFunc _managedMeasure;
|
||||||
private YogaBaselineFunc _managedBaseline;
|
private YogaBaselineFunc _managedBaseline;
|
||||||
@@ -86,7 +56,15 @@ namespace Facebook.Yoga
|
|||||||
{
|
{
|
||||||
YogaLogger.Initialize();
|
YogaLogger.Initialize();
|
||||||
|
|
||||||
_ygNode = Native.YGNodeNewWithConfig(config.Handle);
|
if (config != null)
|
||||||
|
{
|
||||||
|
_config = config;
|
||||||
|
_ygNode = Native.YGNodeNewWithConfig(_config.Handle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ygNode = Native.YGNodeNew();
|
||||||
|
}
|
||||||
if (_ygNode.IsInvalid)
|
if (_ygNode.IsInvalid)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Failed to allocate native memory");
|
throw new InvalidOperationException("Failed to allocate native memory");
|
||||||
@@ -94,7 +72,7 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
|
|
||||||
public YogaNode(YogaNode srcNode)
|
public YogaNode(YogaNode srcNode)
|
||||||
: this()
|
: this(srcNode._config)
|
||||||
{
|
{
|
||||||
CopyStyle(srcNode);
|
CopyStyle(srcNode);
|
||||||
}
|
}
|
||||||
@@ -106,6 +84,9 @@ namespace Facebook.Yoga
|
|||||||
_data = null;
|
_data = null;
|
||||||
|
|
||||||
Native.YGNodeReset(_ygNode);
|
Native.YGNodeReset(_ygNode);
|
||||||
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
|
_ygNode.ReleaseManaged();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDirty
|
public bool IsDirty
|
||||||
@@ -466,7 +447,7 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float StyleAspectRatio
|
public float AspectRatio
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -595,6 +576,20 @@ namespace Facebook.Yoga
|
|||||||
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
|
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddChild(YogaNode child)
|
||||||
|
{
|
||||||
|
Insert(Count, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveChild(YogaNode child)
|
||||||
|
{
|
||||||
|
int index = IndexOf(child);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
RemoveAt(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
if (_children != null)
|
if (_children != null)
|
||||||
@@ -616,12 +611,17 @@ namespace Facebook.Yoga
|
|||||||
_measureFunction = measureFunction;
|
_measureFunction = measureFunction;
|
||||||
if (measureFunction != null)
|
if (measureFunction != null)
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
|
_managedMeasure = MeasureInternalAOT;
|
||||||
_ygNode.SetContext(this);
|
_ygNode.SetContext(this);
|
||||||
#else
|
#else
|
||||||
_managedMeasure = MeasureInternal;
|
_managedMeasure = MeasureInternal;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_managedMeasure = null;
|
||||||
|
}
|
||||||
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
|
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,12 +630,17 @@ namespace Facebook.Yoga
|
|||||||
_baselineFunction = baselineFunction;
|
_baselineFunction = baselineFunction;
|
||||||
if (baselineFunction != null)
|
if (baselineFunction != null)
|
||||||
{
|
{
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
|
_managedBaseline = BaselineInternalAOT;
|
||||||
_ygNode.SetContext(this);
|
_ygNode.SetContext(this);
|
||||||
#else
|
#else
|
||||||
_managedBaseline = BaselineInternal;
|
_managedBaseline = BaselineInternal;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_managedBaseline = null;
|
||||||
|
}
|
||||||
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
|
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,9 +653,9 @@ namespace Facebook.Yoga
|
|||||||
Native.YGNodeStyleGetDirection(_ygNode));
|
Native.YGNodeStyleGetDirection(_ygNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
|
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
|
||||||
private static YogaSize MeasureInternalIOS(
|
private static YogaSize MeasureInternalAOT(
|
||||||
IntPtr ygNodePtr,
|
IntPtr ygNodePtr,
|
||||||
float width,
|
float width,
|
||||||
YogaMeasureMode widthMode,
|
YogaMeasureMode widthMode,
|
||||||
@@ -677,9 +682,9 @@ namespace Facebook.Yoga
|
|||||||
return _measureFunction(this, width, widthMode, height, heightMode);
|
return _measureFunction(this, width, widthMode, height, heightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
|
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||||
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
|
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
|
||||||
private static float BaselineInternalIOS(
|
private static float BaselineInternalAOT(
|
||||||
IntPtr ygNodePtr,
|
IntPtr ygNodePtr,
|
||||||
float width,
|
float width,
|
||||||
float height)
|
float height)
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace Facebook.Yoga
|
namespace Facebook.Yoga
|
||||||
{
|
{
|
||||||
|
[System.Flags]
|
||||||
public enum YogaPrintOptions
|
public enum YogaPrintOptions
|
||||||
{
|
{
|
||||||
Layout = 1,
|
Layout = 1,
|
||||||
|
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Facebook.Yoga</RootNamespace>
|
||||||
|
<AssemblyName>Facebook.Yoga</AssemblyName>
|
||||||
|
<DefaultLanguage>en-US</DefaultLanguage>
|
||||||
|
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||||
|
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
|
||||||
|
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||||
|
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;WINDOWS_UWP_ARM</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP;WINDOWS_UWP_ARM</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||||
|
<None Include="project.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="..\..\Facebook.Yoga\Facebook.Yoga.Shared.projitems" Label="Shared" />
|
||||||
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
16
csharp/Windows/Facebook.Yoga.Universal/project.json
Normal file
16
csharp/Windows/Facebook.Yoga.Universal/project.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"uap10.0": {}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"win10-arm": {},
|
||||||
|
"win10-arm-aot": {},
|
||||||
|
"win10-x86": {},
|
||||||
|
"win10-x86-aot": {},
|
||||||
|
"win10-x64": {},
|
||||||
|
"win10-x64-aot": {}
|
||||||
|
}
|
||||||
|
}
|
@@ -29,11 +29,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Desktop.Tests
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0C76D2FE-6767-44FE-B03D-21B2076BAA73}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0C76D2FE-6767-44FE-B03D-21B2076BAA73}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{6669329B-017F-45B3-8611-53AFD065E45C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal", "Facebook.Yoga.Universal\Facebook.Yoga.Universal.csproj", "{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||||
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}*SharedItemsImports = 4
|
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}*SharedItemsImports = 4
|
||||||
..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{4edc82d9-a201-4831-8fe0-98f468f8e4ae}*SharedItemsImports = 13
|
..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{4edc82d9-a201-4831-8fe0-98f468f8e4ae}*SharedItemsImports = 13
|
||||||
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
|
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
|
||||||
|
..\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{d6477ad6-9edd-4eba-8c60-cd31f77c52c6}*SharedItemsImports = 4
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -118,6 +123,22 @@ Global
|
|||||||
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|ARM.ActiveCfg = Release|ARM
|
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|ARM.ActiveCfg = Release|ARM
|
||||||
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x64.ActiveCfg = Release|x64
|
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x64.ActiveCfg = Release|x64
|
||||||
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x86.ActiveCfg = Release|x86
|
{0C76D2FE-6767-44FE-B03D-21B2076BAA73}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|ARM.Build.0 = Debug|ARM
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.ActiveCfg = Release|ARM
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|ARM.Build.0 = Release|ARM
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -130,5 +151,6 @@ Global
|
|||||||
{4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC}
|
{4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {39A2FFDA-C093-4FA6-8143-45B5019E7DAC}
|
||||||
{AC23F444-5545-4196-8B9F-5C1F6B3E7FB3} = {5289E508-8386-45A1-A12B-258A5899CD45}
|
{AC23F444-5545-4196-8B9F-5C1F6B3E7FB3} = {5289E508-8386-45A1-A12B-258A5899CD45}
|
||||||
{0C76D2FE-6767-44FE-B03D-21B2076BAA73} = {5289E508-8386-45A1-A12B-258A5899CD45}
|
{0C76D2FE-6767-44FE-B03D-21B2076BAA73} = {5289E508-8386-45A1-A12B-258A5899CD45}
|
||||||
|
{D6477AD6-9EDD-4EBA-8C60-CD31F77C52C6} = {6669329B-017F-45B3-8611-53AFD065E45C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@@ -243,6 +243,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGEnums.c" />
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
@@ -252,6 +253,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
<ClCompile Include="..\..\yoga\Yoga.c" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
||||||
<ClCompile Include="YGInterop.cpp" />
|
<ClCompile Include="YGInterop.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
@@ -228,6 +228,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||||
|
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
@@ -237,6 +238,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
<ClCompile Include="..\..\yoga\Yoga.c" />
|
||||||
|
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
||||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
||||||
<ClCompile Include="YGInterop.cpp" />
|
<ClCompile Include="YGInterop.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
echo $ANDROID_SDK
|
||||||
if buck --version >/dev/null 2>&1; then true; else
|
if buck --version >/dev/null 2>&1; then true; else
|
||||||
echo "Building Buck!"
|
echo "Building Buck!"
|
||||||
mkdir lib
|
mkdir lib
|
||||||
|
@@ -12,10 +12,6 @@
|
|||||||
<description>A subset of CSS's flexbox layout algorithm and box model.</description>
|
<description>A subset of CSS's flexbox layout algorithm and box model.</description>
|
||||||
<copyright>Copyright 2016 Facebook</copyright>
|
<copyright>Copyright 2016 Facebook</copyright>
|
||||||
<tags>flexbox flex-box css layout css-layout yoga facebook native</tags>
|
<tags>flexbox flex-box css layout css-layout yoga facebook native</tags>
|
||||||
<dependencies>
|
|
||||||
<group targetFramework=".NETStandard1.1" />
|
|
||||||
<group targetFramework="uap10.0" />
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<!-- build -->
|
<!-- build -->
|
||||||
@@ -28,7 +24,7 @@
|
|||||||
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\netstandard"/>
|
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\netstandard"/>
|
||||||
|
|
||||||
<!-- UAP -->
|
<!-- UAP -->
|
||||||
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\uap10.0"/>
|
<file src="..\yoga_universal\bin\Release\Facebook.Yoga.dll" target="lib\uap10.0"/>
|
||||||
|
|
||||||
<!-- net45 -->
|
<!-- net45 -->
|
||||||
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\net45" />
|
<file src="..\yoga_windows\bin\Release\Facebook.Yoga.dll" target="lib\net45" />
|
||||||
@@ -44,24 +40,24 @@
|
|||||||
<file src="..\yoga_android\bin\Release\Facebook.Yoga.dll" target="lib\MonoAndroid" />
|
<file src="..\yoga_android\bin\Release\Facebook.Yoga.dll" target="lib\MonoAndroid" />
|
||||||
|
|
||||||
<!-- runtimes -->
|
<!-- runtimes -->
|
||||||
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win10-x86\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win10-x86\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win10-x86\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win10-x86\lib\netstandard1.0"/>
|
||||||
|
|
||||||
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win10-x64\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win10-x64\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win10-x64\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win10-x64\lib\netstandard1.0"/>
|
||||||
|
|
||||||
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win10-arm\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win10-arm\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win10-arm\lib\netstandard"/>
|
<file src="..\yoga_universal\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win10-arm\lib\netstandard1.0"/>
|
||||||
|
|
||||||
|
|
||||||
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win-x86\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.dll" target="runtimes\win-x86\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win-x86\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\x86\Release\Facebook.Yoga.pdb" target="runtimes\win-x86\lib\netstandard1.0"/>
|
||||||
|
|
||||||
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win-x64\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.dll" target="runtimes\win-x64\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win-x64\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\x64\Release\Facebook.Yoga.pdb" target="runtimes\win-x64\lib\netstandard1.0"/>
|
||||||
|
|
||||||
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win8-arm\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.dll" target="runtimes\win8-arm\lib\netstandard1.0"/>
|
||||||
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win8-arm\lib\netstandard"/>
|
<file src="..\yoga_windows\bin\ARM\Release\Facebook.Yoga.pdb" target="runtimes\win8-arm\lib\netstandard1.0"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- Native -->
|
<!-- Native -->
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)YGMinMaxDimensionTest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YGMinMaxDimensionTest.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YGPaddingTest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YGPaddingTest.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YGRoundingTest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YGRoundingTest.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)YogaConfigTest.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeSpacingTest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeSpacingTest.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeTest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaNodeTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -719,5 +719,31 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_position_root_with_rtl_should_position_withoutdirection()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.Left = 72;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(72f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(72f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1587,5 +1587,233 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
Assert.AreEqual(20f, root_child3.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_align_items_center_child_with_margin_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.AlignItems = YogaAlign.Center;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.MarginLeft = 10;
|
||||||
|
root_child0_child0.MarginRight = 10;
|
||||||
|
root_child0_child0.Width = 52;
|
||||||
|
root_child0_child0.Height = 52;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(10f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(10f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_align_items_flex_end_child_with_margin_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.AlignItems = YogaAlign.FlexEnd;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.MarginLeft = 10;
|
||||||
|
root_child0_child0.MarginRight = 10;
|
||||||
|
root_child0_child0.Width = 52;
|
||||||
|
root_child0_child0.Height = 52;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(10f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(10f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_align_items_center_child_without_margin_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.AlignItems = YogaAlign.Center;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.Width = 72;
|
||||||
|
root_child0_child0.Height = 72;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_align_items_flex_end_child_without_margin_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.AlignItems = YogaAlign.FlexEnd;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.Width = 72;
|
||||||
|
root_child0_child0.Height = 72;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1352,5 +1352,260 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_should_not_be_part_of_max_height()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.Width = 250;
|
||||||
|
root.Height = 250;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginTop = 20;
|
||||||
|
root_child0.Width = 100;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root_child0.MaxHeight = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(250f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(250f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_should_not_be_part_of_max_width()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.Width = 250;
|
||||||
|
root.Height = 250;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginLeft = 20;
|
||||||
|
root_child0.Width = 100;
|
||||||
|
root_child0.MaxWidth = 100;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(250f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(250f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(150f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_auto_left_right_child_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginLeft = YogaValue.Auto();
|
||||||
|
root_child0.MarginRight = YogaValue.Auto();
|
||||||
|
root_child0.Width = 72;
|
||||||
|
root_child0.Height = 72;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_auto_left_child_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginLeft = YogaValue.Auto();
|
||||||
|
root_child0.Width = 72;
|
||||||
|
root_child0.Height = 72;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_fix_left_auto_right_child_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginLeft = 10;
|
||||||
|
root_child0.MarginRight = YogaValue.Auto();
|
||||||
|
root_child0.Width = 72;
|
||||||
|
root_child0.Height = 72;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-20f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_margin_auto_left_fix_right_child_bigger_than_parent()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.Width = 52;
|
||||||
|
root.Height = 52;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.MarginLeft = YogaValue.Auto();
|
||||||
|
root_child0.MarginRight = 10;
|
||||||
|
root_child0.Width = 72;
|
||||||
|
root_child0.Height = 72;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(52f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(52f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-30f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(-10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(72f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -475,6 +475,99 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
|
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_flex_grow_child()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexGrow = 1;
|
||||||
|
root_child0.FlexBasis = 0;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_flex_grow_within_constrained_min_max_column()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.MinHeight = 100;
|
||||||
|
root.MaxHeight = 200;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexGrow = 1;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.Height = 50;
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_flex_grow_within_max_width()
|
public void Test_flex_grow_within_max_width()
|
||||||
{
|
{
|
||||||
|
@@ -1146,5 +1146,76 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
|
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_percent_absolute_position()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.Width = 60;
|
||||||
|
root.Height = 50;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Left = 50.Percent();
|
||||||
|
root_child0.Width = 100.Percent();
|
||||||
|
root_child0.Height = 50;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode(config);
|
||||||
|
root_child0_child0.Width = 100.Percent();
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child1 = new YogaNode(config);
|
||||||
|
root_child0_child1.Width = 100.Percent();
|
||||||
|
root_child0.Insert(1, root_child0_child1);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(60f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(-60f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -684,17 +684,17 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||||
|
|
||||||
root.StyleDirection = YogaDirection.RTL;
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
root.CalculateLayout();
|
root.CalculateLayout();
|
||||||
@@ -707,17 +707,17 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -793,5 +793,308 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_rounding_inner_node_controversy_horizontal()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.Width = 320;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexGrow = 1;
|
||||||
|
root_child0.Height = 10;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.FlexGrow = 1;
|
||||||
|
root_child1.Height = 10;
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
|
||||||
|
YogaNode root_child1_child0 = new YogaNode(config);
|
||||||
|
root_child1_child0.FlexGrow = 1;
|
||||||
|
root_child1_child0.Height = 10;
|
||||||
|
root_child1.Insert(0, root_child1_child0);
|
||||||
|
|
||||||
|
YogaNode root_child2 = new YogaNode(config);
|
||||||
|
root_child2.FlexGrow = 1;
|
||||||
|
root_child2.Height = 10;
|
||||||
|
root.Insert(2, root_child2);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(320f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(107f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(107f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(106f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(106f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(213f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(107f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(320f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(213f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(107f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(107f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(106f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(106f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(107f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_rounding_inner_node_controversy_vertical()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.Height = 320;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexGrow = 1;
|
||||||
|
root_child0.Width = 10;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.FlexGrow = 1;
|
||||||
|
root_child1.Width = 10;
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
|
||||||
|
YogaNode root_child1_child0 = new YogaNode(config);
|
||||||
|
root_child1_child0.FlexGrow = 1;
|
||||||
|
root_child1_child0.Width = 10;
|
||||||
|
root_child1.Insert(0, root_child1_child0);
|
||||||
|
|
||||||
|
YogaNode root_child2 = new YogaNode(config);
|
||||||
|
root_child2.FlexGrow = 1;
|
||||||
|
root_child2.Width = 10;
|
||||||
|
root.Insert(2, root_child2);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(107f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(213f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child2.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(107f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(213f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child2.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_rounding_inner_node_controversy_combined()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.Width = 640;
|
||||||
|
root.Height = 320;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexGrow = 1;
|
||||||
|
root_child0.Height = 100.Percent();
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.FlexGrow = 1;
|
||||||
|
root_child1.Height = 100.Percent();
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
|
||||||
|
YogaNode root_child1_child0 = new YogaNode(config);
|
||||||
|
root_child1_child0.FlexGrow = 1;
|
||||||
|
root_child1_child0.Width = 100.Percent();
|
||||||
|
root_child1.Insert(0, root_child1_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1_child1 = new YogaNode(config);
|
||||||
|
root_child1_child1.FlexGrow = 1;
|
||||||
|
root_child1_child1.Width = 100.Percent();
|
||||||
|
root_child1.Insert(1, root_child1_child1);
|
||||||
|
|
||||||
|
YogaNode root_child1_child1_child0 = new YogaNode(config);
|
||||||
|
root_child1_child1_child0.FlexGrow = 1;
|
||||||
|
root_child1_child1_child0.Width = 100.Percent();
|
||||||
|
root_child1_child1.Insert(0, root_child1_child1_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1_child2 = new YogaNode(config);
|
||||||
|
root_child1_child2.FlexGrow = 1;
|
||||||
|
root_child1_child2.Width = 100.Percent();
|
||||||
|
root_child1.Insert(2, root_child1_child2);
|
||||||
|
|
||||||
|
YogaNode root_child2 = new YogaNode(config);
|
||||||
|
root_child2.FlexGrow = 1;
|
||||||
|
root_child2.Height = 100.Percent();
|
||||||
|
root.Insert(2, root_child2);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(640f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(213f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(213f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child1.LayoutX);
|
||||||
|
Assert.AreEqual(107f, root_child1_child1.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child2.LayoutX);
|
||||||
|
Assert.AreEqual(213f, root_child1_child2.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child1_child2.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(427f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(213f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child2.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(640f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(427f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(213f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(213f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child1.LayoutX);
|
||||||
|
Assert.AreEqual(107f, root_child1_child1.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child1.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child1_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1_child1_child0.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child1_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(106f, root_child1_child1_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1_child2.LayoutX);
|
||||||
|
Assert.AreEqual(213f, root_child1_child2.LayoutY);
|
||||||
|
Assert.AreEqual(214f, root_child1_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(107f, root_child1_child2.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||||
|
Assert.AreEqual(213f, root_child2.LayoutWidth);
|
||||||
|
Assert.AreEqual(320f, root_child2.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
136
csharp/tests/Facebook.Yoga/YogaConfigTest.cs
Normal file
136
csharp/tests/Facebook.Yoga/YogaConfigTest.cs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link YogaConfig}.
|
||||||
|
*/
|
||||||
|
namespace Facebook.Yoga
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class YogaConfigTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestUseWebDefaults()
|
||||||
|
{
|
||||||
|
YogaNode node0 = new YogaNode(new YogaConfig{UseWebDefaults = true});
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
|
||||||
|
|
||||||
|
node0.Reset();
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
|
||||||
|
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
config.UseWebDefaults = true;
|
||||||
|
YogaNode node1 = new YogaNode(config);
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
|
||||||
|
|
||||||
|
node1.Reset();
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDefaultConfig()
|
||||||
|
{
|
||||||
|
YogaNode node0 = new YogaNode();
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Column, node0.FlexDirection);
|
||||||
|
|
||||||
|
YogaNode node1 = new YogaNode(new YogaConfig());
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Column, node1.FlexDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCopyConstructor()
|
||||||
|
{
|
||||||
|
YogaNode srcNode = new YogaNode(new YogaConfig{UseWebDefaults = true});
|
||||||
|
YogaNode node0 = new YogaNode(srcNode);
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
|
||||||
|
|
||||||
|
node0.FlexDirection = YogaFlexDirection.Column;
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Column, node0.FlexDirection);
|
||||||
|
|
||||||
|
node0.Reset();
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node0.FlexDirection);
|
||||||
|
|
||||||
|
YogaNode node1 = new YogaNode(srcNode)
|
||||||
|
{
|
||||||
|
FlexDirection = YogaFlexDirection.Column
|
||||||
|
};
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Column, node1.FlexDirection);
|
||||||
|
|
||||||
|
node1.Reset();
|
||||||
|
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ForceGC()
|
||||||
|
{
|
||||||
|
YogaNodeTest.ForceGC();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDestructor()
|
||||||
|
{
|
||||||
|
ForceGC();
|
||||||
|
int instanceCount = YogaConfig.GetInstanceCount();
|
||||||
|
TestDestructorForGC(instanceCount);
|
||||||
|
ForceGC();
|
||||||
|
Assert.AreEqual(instanceCount, YogaConfig.GetInstanceCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestDestructorForGC(int instanceCount)
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
Assert.IsNotNull(config);
|
||||||
|
Assert.AreEqual(instanceCount + 1, YogaConfig.GetInstanceCount());
|
||||||
|
config = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRetainConfig()
|
||||||
|
{
|
||||||
|
ForceGC();
|
||||||
|
int nodeInstanceCount = YogaNode.GetInstanceCount();
|
||||||
|
int configInstanceCount = YogaConfig.GetInstanceCount();
|
||||||
|
TestRetainConfigForGC(nodeInstanceCount, configInstanceCount);
|
||||||
|
ForceGC();
|
||||||
|
|
||||||
|
Assert.AreEqual(nodeInstanceCount, YogaNode.GetInstanceCount());
|
||||||
|
Assert.AreEqual(configInstanceCount, YogaConfig.GetInstanceCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestRetainConfigForGC(int nodeInstanceCount, int configInstanceCount)
|
||||||
|
{
|
||||||
|
ForceGC();
|
||||||
|
Assert.AreEqual(nodeInstanceCount, YogaNode.GetInstanceCount());
|
||||||
|
Assert.AreEqual(configInstanceCount, YogaConfig.GetInstanceCount());
|
||||||
|
YogaNode node = TestRetainConfigForGC2(nodeInstanceCount, configInstanceCount);
|
||||||
|
ForceGC();
|
||||||
|
Assert.IsNotNull(node);
|
||||||
|
Assert.AreEqual(configInstanceCount + 1, YogaConfig.GetInstanceCount());
|
||||||
|
Assert.AreEqual(nodeInstanceCount + 1, YogaNode.GetInstanceCount());
|
||||||
|
node = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private YogaNode TestRetainConfigForGC2(int nodeInstanceCount, int configInstanceCount)
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
Assert.IsNotNull(config);
|
||||||
|
Assert.AreEqual(configInstanceCount + 1, YogaConfig.GetInstanceCount());
|
||||||
|
|
||||||
|
YogaNode node = new YogaNode(config);
|
||||||
|
Assert.IsNotNull(node);
|
||||||
|
Assert.AreEqual(nodeInstanceCount + 1, YogaNode.GetInstanceCount());
|
||||||
|
|
||||||
|
config = null;
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -73,25 +73,22 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.NullReferenceException")]
|
|
||||||
public void TestRemoveAtFromEmpty()
|
public void TestRemoveAtFromEmpty()
|
||||||
{
|
{
|
||||||
YogaNode parent = new YogaNode();
|
YogaNode parent = new YogaNode();
|
||||||
parent.RemoveAt(0);
|
Assert.Throws<NullReferenceException>(() => parent.RemoveAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.ArgumentOutOfRangeException")]
|
|
||||||
public void TestRemoveAtOutOfRange()
|
public void TestRemoveAtOutOfRange()
|
||||||
{
|
{
|
||||||
YogaNode parent = new YogaNode();
|
YogaNode parent = new YogaNode();
|
||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
parent.Insert(0, child);
|
parent.Insert(0, child);
|
||||||
parent.RemoveAt(1);
|
Assert.Throws<ArgumentOutOfRangeException>(() => parent.RemoveAt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.InvalidOperationException")]
|
|
||||||
public void TestCannotAddChildToMultipleParents()
|
public void TestCannotAddChildToMultipleParents()
|
||||||
{
|
{
|
||||||
YogaNode parent1 = new YogaNode();
|
YogaNode parent1 = new YogaNode();
|
||||||
@@ -99,7 +96,7 @@ namespace Facebook.Yoga
|
|||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
|
|
||||||
parent1.Insert(0, child);
|
parent1.Insert(0, child);
|
||||||
parent2.Insert(0, child);
|
Assert.Throws<InvalidOperationException>(() => parent2.Insert(0, child));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -113,23 +110,21 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.InvalidOperationException")]
|
|
||||||
public void TestResetParent()
|
public void TestResetParent()
|
||||||
{
|
{
|
||||||
YogaNode parent = new YogaNode();
|
YogaNode parent = new YogaNode();
|
||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
parent.Insert(0, child);
|
parent.Insert(0, child);
|
||||||
parent.Reset();
|
Assert.Throws<InvalidOperationException>(() => parent.Reset());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.InvalidOperationException")]
|
|
||||||
public void TestResetChild()
|
public void TestResetChild()
|
||||||
{
|
{
|
||||||
YogaNode parent = new YogaNode();
|
YogaNode parent = new YogaNode();
|
||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
parent.Insert(0, child);
|
parent.Insert(0, child);
|
||||||
child.Reset();
|
Assert.Throws<InvalidOperationException>(() => child.Reset());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -174,7 +169,6 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.InvalidOperationException")]
|
|
||||||
public void TestChildWithMeasureFunc()
|
public void TestChildWithMeasureFunc()
|
||||||
{
|
{
|
||||||
YogaNode node = new YogaNode();
|
YogaNode node = new YogaNode();
|
||||||
@@ -182,19 +176,20 @@ namespace Facebook.Yoga
|
|||||||
return MeasureOutput.Make(100, 150);
|
return MeasureOutput.Make(100, 150);
|
||||||
});
|
});
|
||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
node.Insert(0, child);
|
Assert.Throws<InvalidOperationException>(() => node.Insert(0, child));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("System.InvalidOperationException")]
|
|
||||||
public void TestMeasureFuncWithChild()
|
public void TestMeasureFuncWithChild()
|
||||||
{
|
{
|
||||||
YogaNode node = new YogaNode();
|
YogaNode node = new YogaNode();
|
||||||
YogaNode child = new YogaNode();
|
YogaNode child = new YogaNode();
|
||||||
node.Insert(0, child);
|
node.Insert(0, child);
|
||||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
Assert.Throws<InvalidOperationException>(() =>
|
||||||
return MeasureOutput.Make(100, 150);
|
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||||
});
|
return MeasureOutput.Make(100, 150);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -260,7 +255,7 @@ namespace Facebook.Yoga
|
|||||||
parent.Insert(0, child0);
|
parent.Insert(0, child0);
|
||||||
parent.Insert(0, child1);
|
parent.Insert(0, child1);
|
||||||
parent.CalculateLayout();
|
parent.CalculateLayout();
|
||||||
Assert.AreEqual("{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 100pt, height: 120pt, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 35pt, height: 45pt, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, flexBasis: nan%, overflow: 'visible', width: 30pt, height: 40pt, },\n]},\n", parent.Print());
|
Assert.AreEqual("<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" >\n <div layout=\"width: 35; height: 45; top: 0; left: 0;\" style=\"width: 35px; height: 45px; \" ></div>\n <div layout=\"width: 30; height: 40; top: 45; left: 0;\" style=\"width: 30px; height: 40px; \" ></div>\n</div>", parent.Print());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -306,7 +301,7 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(90.Pt(), node4.MaxHeight);
|
Assert.AreEqual(90.Pt(), node4.MaxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ForceGC()
|
public static void ForceGC()
|
||||||
{
|
{
|
||||||
GC.Collect(GC.MaxGeneration);
|
GC.Collect(GC.MaxGeneration);
|
||||||
GC.WaitForPendingFinalizers();
|
GC.WaitForPendingFinalizers();
|
||||||
@@ -365,6 +360,7 @@ namespace Facebook.Yoga
|
|||||||
child = null;
|
child = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if YOGA_ENABLE_GC_TEST
|
||||||
[Test]
|
[Test]
|
||||||
public void TestParentDestructor()
|
public void TestParentDestructor()
|
||||||
{
|
{
|
||||||
@@ -386,6 +382,7 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount());
|
||||||
parent.Insert(0, child);
|
parent.Insert(0, child);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestClearWithChildDestructor()
|
public void TestClearWithChildDestructor()
|
||||||
|
@@ -11,14 +11,14 @@ GEM
|
|||||||
coffee-script (2.4.1)
|
coffee-script (2.4.1)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.10.0)
|
coffee-script-source (1.12.2)
|
||||||
colorator (1.1.0)
|
colorator (1.1.0)
|
||||||
ethon (0.9.1)
|
ethon (0.10.1)
|
||||||
ffi (>= 1.3.0)
|
ffi (>= 1.3.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
faraday (0.9.2)
|
faraday (0.12.0.1)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.9.14)
|
ffi (1.9.18)
|
||||||
forwardable-extended (2.6.0)
|
forwardable-extended (2.6.0)
|
||||||
gemoji (2.1.0)
|
gemoji (2.1.0)
|
||||||
github-pages (104)
|
github-pages (104)
|
||||||
@@ -51,10 +51,10 @@ GEM
|
|||||||
octokit (~> 4.0)
|
octokit (~> 4.0)
|
||||||
public_suffix (~> 1.4)
|
public_suffix (~> 1.4)
|
||||||
typhoeus (~> 0.7)
|
typhoeus (~> 0.7)
|
||||||
html-pipeline (2.4.2)
|
html-pipeline (2.5.0)
|
||||||
activesupport (>= 2)
|
activesupport (>= 2)
|
||||||
nokogiri (>= 1.4)
|
nokogiri (>= 1.4)
|
||||||
i18n (0.7.0)
|
i18n (0.8.1)
|
||||||
jekyll (3.3.0)
|
jekyll (3.3.0)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
colorator (~> 1.0)
|
colorator (~> 1.0)
|
||||||
@@ -98,7 +98,7 @@ GEM
|
|||||||
gemoji (~> 2.0)
|
gemoji (~> 2.0)
|
||||||
html-pipeline (~> 2.2)
|
html-pipeline (~> 2.2)
|
||||||
jekyll (>= 3.0)
|
jekyll (>= 3.0)
|
||||||
json (1.8.3)
|
json (1.8.6)
|
||||||
kramdown (1.11.1)
|
kramdown (1.11.1)
|
||||||
liquid (3.0.6)
|
liquid (3.0.6)
|
||||||
listen (3.0.6)
|
listen (3.0.6)
|
||||||
@@ -107,33 +107,33 @@ GEM
|
|||||||
mercenary (0.3.6)
|
mercenary (0.3.6)
|
||||||
mini_portile2 (2.1.0)
|
mini_portile2 (2.1.0)
|
||||||
minima (2.0.0)
|
minima (2.0.0)
|
||||||
minitest (5.9.1)
|
minitest (5.10.1)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
net-dns (0.8.0)
|
net-dns (0.8.0)
|
||||||
nokogiri (1.6.8.1)
|
nokogiri (1.7.1)
|
||||||
mini_portile2 (~> 2.1.0)
|
mini_portile2 (~> 2.1.0)
|
||||||
octokit (4.4.1)
|
octokit (4.6.2)
|
||||||
sawyer (~> 0.7.0, >= 0.5.3)
|
sawyer (~> 0.8.0, >= 0.5.3)
|
||||||
pathutil (0.14.0)
|
pathutil (0.14.0)
|
||||||
forwardable-extended (~> 2.6)
|
forwardable-extended (~> 2.6)
|
||||||
public_suffix (1.5.3)
|
public_suffix (1.5.3)
|
||||||
rb-fsevent (0.9.8)
|
rb-fsevent (0.9.8)
|
||||||
rb-inotify (0.9.7)
|
rb-inotify (0.9.8)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
rouge (1.11.1)
|
rouge (1.11.1)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sass (3.4.22)
|
sass (3.4.23)
|
||||||
sawyer (0.7.0)
|
sawyer (0.8.1)
|
||||||
addressable (>= 2.3.5, < 2.5)
|
addressable (>= 2.3.5, < 2.6)
|
||||||
faraday (~> 0.8, < 0.10)
|
faraday (~> 0.8, < 1.0)
|
||||||
terminal-table (1.7.3)
|
terminal-table (1.7.3)
|
||||||
unicode-display_width (~> 1.1.1)
|
unicode-display_width (~> 1.1.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.6)
|
||||||
typhoeus (0.8.0)
|
typhoeus (0.8.0)
|
||||||
ethon (>= 0.8.0)
|
ethon (>= 0.8.0)
|
||||||
tzinfo (1.2.2)
|
tzinfo (1.2.3)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
unicode-display_width (1.1.1)
|
unicode-display_width (1.1.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@@ -142,4 +142,4 @@ DEPENDENCIES
|
|||||||
github-pages (~> 104)
|
github-pages (~> 104)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.13.1
|
1.14.6
|
||||||
|
@@ -4,7 +4,7 @@ This directory will contain the user, feature and API documentation for Yoga. Th
|
|||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
|
|
||||||
See [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to add or modify content.
|
See [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) for details on how to add or modify content.
|
||||||
|
|
||||||
### Run the Site Locally
|
### Run the Site Locally
|
||||||
|
|
||||||
|
@@ -6,15 +6,56 @@ permalink: /docs/api/android/
|
|||||||
---
|
---
|
||||||
|
|
||||||
To include the java bindings and `.so` libraries, add to your build:
|
To include the java bindings and `.so` libraries, add to your build:
|
||||||
<script src="https://gist.github.com/rspencer01/e3cb51e789147b359d842aac6fa30f9f.js"></script>
|
|
||||||
|
|
||||||
There is an easy interface to Yoga called `YogaLayout`. This is a view group that lays out its children using Yoga. We recommend looking at the sample app for details on its usage. However, as an overview you can simply define XML layouts such as
|
```java
|
||||||
<script src="https://gist.github.com/rspencer01/c1964b98f0c60de7c49683a049ed0640.js"></script>
|
compile 'com.facebook.yoga:yoga:1.2.0'
|
||||||
|
```
|
||||||
|
|
||||||
|
There is an easy interface to Yoga called `YogaLayout`. This is a view group that lays out its children using Yoga. We recommend looking at the sample app for details on its usage. However, as an overview you can simply define XML layouts such as:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<YogaLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
yoga:align_items="stretch"
|
||||||
|
>
|
||||||
|
<YogaLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/sample_children_background"
|
||||||
|
yoga:margin_horizontal="10dp"
|
||||||
|
yoga:margin_top="5dp"
|
||||||
|
yoga:flex_direction="row"
|
||||||
|
yoga:align_items="center"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:src="@drawable/ic_launcher"
|
||||||
|
yoga:flex="0"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/child_1_text"
|
||||||
|
android:textColor="@color/children_text"
|
||||||
|
yoga:flex="1"
|
||||||
|
yoga:margin_start="8dp"
|
||||||
|
/>
|
||||||
|
</YogaLayout>
|
||||||
|
</YogaLayout>
|
||||||
|
```
|
||||||
|
|
||||||
Note that there are some caveats, such as requiring the custom `YogaLayoutViewFactory` in order to have tags `YogaLayout` instead of `com.facebook.samples.yoga.YogaLayout`.
|
Note that there are some caveats, such as requiring the custom `YogaLayoutViewFactory` in order to have tags `YogaLayout` instead of `com.facebook.samples.yoga.YogaLayout`.
|
||||||
|
|
||||||
To include this in your project, add to your build:
|
To include this in your project, add to your build:
|
||||||
<script src="https://gist.github.com/rspencer01/499a9e02185985bf3167f818d9c3398f.js"></script>
|
|
||||||
|
```java
|
||||||
|
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
|
||||||
|
```
|
||||||
|
|
||||||
## layout\_width and layout\_height
|
## layout\_width and layout\_height
|
||||||
|
|
||||||
|
@@ -10,7 +10,12 @@ permalink: /docs/api/c/
|
|||||||
|
|
||||||
The following functions control the lifecycle of a `YGNodeRef`.
|
The following functions control the lifecycle of a `YGNodeRef`.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/99e454d04df4765147f407bde131feca.js"></script>
|
```c
|
||||||
|
YGNodeRef YGNodeNew();
|
||||||
|
void YGNodeReset(YGNodeRef node);
|
||||||
|
void YGNodeFree(YGNodeRef node);
|
||||||
|
void YGNodeFreeRecursive(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
- `YGNodeReset` will reset a node to its initial state so it can be re-used without needing to re-allocate a new node.
|
- `YGNodeReset` will reset a node to its initial state so it can be re-used without needing to re-allocate a new node.
|
||||||
- `YGNodeFreeRecursive` is mostly used for testing and will free not only the node itself but also its children.
|
- `YGNodeFreeRecursive` is mostly used for testing and will free not only the node itself but also its children.
|
||||||
@@ -19,19 +24,167 @@ The following functions control the lifecycle of a `YGNodeRef`.
|
|||||||
|
|
||||||
The following functions help manage the children of a node.
|
The following functions help manage the children of a node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/7e162314294087bb78817c064d345afb.js"></script>
|
```c
|
||||||
|
void YGNodeInsertChild(YGNodeRef node, YGNodeRef child, uint32_t index);
|
||||||
|
void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child);
|
||||||
|
YGNodeRef YGNodeGetChild(YGNodeRef node, uint32_t index);
|
||||||
|
uint32_t YGNodeChildCount(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
### Style getters & setters
|
### Style getters & setters
|
||||||
|
|
||||||
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/74913a3326d952ff5a65dabe5ce4baf8.js"></script>
|
```c
|
||||||
|
typedef enum YGDirection {
|
||||||
|
YGDirectionInherit,
|
||||||
|
YGDirectionLTR,
|
||||||
|
YGDirectionRTL,
|
||||||
|
} YGDirection;
|
||||||
|
|
||||||
|
void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction);
|
||||||
|
YGDirection YGNodeStyleGetDirection(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGFlexDirection {
|
||||||
|
YGFlexDirectionColumn,
|
||||||
|
YGFlexDirectionColumnReverse,
|
||||||
|
YGFlexDirectionRow,
|
||||||
|
YGFlexDirectionRowReverse,
|
||||||
|
} YGFlexDirection;
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexDirection(YGNodeRef node,
|
||||||
|
YGFlexDirection flexDirection);
|
||||||
|
YGFlexDirection YGNodeStyleGetFlexDirection(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGJustify {
|
||||||
|
YGJustifyFlexStart,
|
||||||
|
YGJustifyCenter,
|
||||||
|
YGJustifyFlexEnd,
|
||||||
|
YGJustifySpaceBetween,
|
||||||
|
YGJustifySpaceAround,
|
||||||
|
} YGJustify;
|
||||||
|
|
||||||
|
void YGNodeStyleSetJustifyContent(YGNodeRef node,
|
||||||
|
YGJustify justifyContent);
|
||||||
|
YGJustify YGNodeStyleGetJustifyContent(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGAlign {
|
||||||
|
YGAlignAuto,
|
||||||
|
YGAlignFlexStart,
|
||||||
|
YGAlignCenter,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignStretch,
|
||||||
|
} YGAlign;
|
||||||
|
|
||||||
|
void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent);
|
||||||
|
YGAlign YGNodeStyleGetAlignContent(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetAlignItems(YGNodeRef node, YGAlign alignItems);
|
||||||
|
YGAlign YGNodeStyleGetAlignItems(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetAlignSelf(YGNodeRef node, YGAlign alignSelf);
|
||||||
|
YGAlign YGNodeStyleGetAlignSelf(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGPositionType {
|
||||||
|
YGPositionTypeRelative,
|
||||||
|
YGPositionTypeAbsolute,
|
||||||
|
} YGPositionType;
|
||||||
|
|
||||||
|
void YGNodeStyleSetPositionType(YGNodeRef node,
|
||||||
|
YGPositionType positionType);
|
||||||
|
YGPositionType YGNodeStyleGetPositionType(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGWrap {
|
||||||
|
YGWrapNoWrap,
|
||||||
|
YGWrapWrap,
|
||||||
|
} YGWrap;
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexWrap(YGNodeRef node, YGWrap flexWrap);
|
||||||
|
YGWrap YGNodeStyleGetFlexWrap(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGOverflow {
|
||||||
|
YGOverflowVisible,
|
||||||
|
YGOverflowHidden,
|
||||||
|
YGOverflowScroll,
|
||||||
|
} YGOverflow;
|
||||||
|
|
||||||
|
void YGNodeStyleSetOverflow(YGNodeRef node, YGOverflow overflow);
|
||||||
|
YGOverflow YGNodeStyleGetOverflow(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlex(YGNodeRef node, float flex);
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow);
|
||||||
|
float YGNodeStyleGetFlexGrow(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink);
|
||||||
|
float YGNodeStyleGetFlexShrink(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis);
|
||||||
|
float YGNodeStyleGetFlexBasis(YGNodeRef node);
|
||||||
|
|
||||||
|
typedef enum YGEdge {
|
||||||
|
YGEdgeLeft,
|
||||||
|
YGEdgeTop,
|
||||||
|
YGEdgeRight,
|
||||||
|
YGEdgeBottom,
|
||||||
|
YGEdgeStart,
|
||||||
|
YGEdgeEnd,
|
||||||
|
YGEdgeHorizontal,
|
||||||
|
YGEdgeVertical,
|
||||||
|
YGEdgeAll,
|
||||||
|
} YGEdge;
|
||||||
|
|
||||||
|
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
|
||||||
|
float YGNodeStyleGetPosition(YGNodeRef node, YGEdge edge);
|
||||||
|
|
||||||
|
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
|
||||||
|
float YGNodeStyleGetMargin(YGNodeRef node, YGEdge edge);
|
||||||
|
|
||||||
|
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float padding);
|
||||||
|
float YGNodeStyleGetPadding(YGNodeRef node, YGEdge edge);
|
||||||
|
|
||||||
|
void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border);
|
||||||
|
float YGNodeStyleGetBorder(YGNodeRef node, YGEdge edge);
|
||||||
|
|
||||||
|
void YGNodeStyleSetWidth(YGNodeRef node, float width);
|
||||||
|
float YGNodeStyleGetWidth(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetHeight(YGNodeRef node, float height);
|
||||||
|
float YGNodeStyleGetHeight(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth);
|
||||||
|
float YGNodeStyleGetMinWidth(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight);
|
||||||
|
float YGNodeStyleGetMinHeight(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth);
|
||||||
|
float YGNodeStyleGetMaxWidth(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight);
|
||||||
|
float YGNodeStyleGetMaxHeight(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio);
|
||||||
|
float YGNodeStyleGetAspectRatio(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
### Layout results
|
### Layout results
|
||||||
|
|
||||||
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `YGNodeCalculateLayout` with the desired width and height or `YGUndefined` to perform the layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `YGNodeCalculateLayout` with the desired width and height or `YGUndefined` to perform the layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/7c7c9c61b69daff5b925719065fb0dc9.js"></script>
|
```c
|
||||||
|
void YGNodeCalculateLayout(YGNodeRef node,
|
||||||
|
float availableWidth,
|
||||||
|
float availableHeight,
|
||||||
|
YGDirection parentDirection);
|
||||||
|
float YGNodeLayoutGetLeft(YGNodeRef node);
|
||||||
|
float YGNodeLayoutGetTop(YGNodeRef node);
|
||||||
|
float YGNodeLayoutGetRight(YGNodeRef node);
|
||||||
|
float YGNodeLayoutGetBottom(YGNodeRef node);
|
||||||
|
float YGNodeLayoutGetWidth(YGNodeRef node);
|
||||||
|
float YGNodeLayoutGetHeight(YGNodeRef node);
|
||||||
|
YGDirection YGNodeLayoutGetDirection(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
### Custom measurements
|
### Custom measurements
|
||||||
|
|
||||||
@@ -41,34 +194,103 @@ Certain nodes need the ability to measure themselves, the most common example is
|
|||||||
|
|
||||||
> A measure function can only be attached to a leaf node in the hierarchy.
|
> A measure function can only be attached to a leaf node in the hierarchy.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/73f9118d8bd27f9cb3744c08f1e53a32.js"></script>
|
```c
|
||||||
|
typedef enum YGMeasureMode {
|
||||||
|
YGMeasureModeUndefined,
|
||||||
|
YGMeasureModeExactly,
|
||||||
|
YGMeasureModeAtMost,
|
||||||
|
} YGMeasureMode;
|
||||||
|
|
||||||
|
typedef struct YGSize {
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
} YGSize;
|
||||||
|
|
||||||
|
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
||||||
|
float width,
|
||||||
|
YGMeasureMode widthMode,
|
||||||
|
float height,
|
||||||
|
YGMeasureMode heightMode);
|
||||||
|
|
||||||
|
void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc);
|
||||||
|
YGMeasureFunc YGNodeGetMeasureFunc(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeMarkDirty(YGNodeRef node);
|
||||||
|
bool YGNodeIsDirty(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
### Context
|
### Context
|
||||||
|
|
||||||
Context is important when integrating Yoga into another layout system. Context allows you to associate another object with a `YGNodeRef`. This context can then be retrieved from a `YGNodeRef` when for example its measure function is called. This is what enables Yoga to rely on the Android and iOS system implementations of text measurement in React Native.
|
Context is important when integrating Yoga into another layout system. Context allows you to associate another object with a `YGNodeRef`. This context can then be retrieved from a `YGNodeRef` when for example its measure function is called. This is what enables Yoga to rely on the Android and iOS system implementations of text measurement in React Native.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/c3d23a1b880d59627e959f3447a9511b.js"></script>
|
```c
|
||||||
|
void YGNodeSetContext(YGNodeRef node, void *context);
|
||||||
|
void *YGNodeGetContext(YGNodeRef node);
|
||||||
|
```
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
|
|
||||||
Yoga will by default log to stdout and stderr. You may however customize this to instead log to your own logger.
|
Yoga will by default log to stdout and stderr. You may however customize this to instead log to your own logger.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/b538718ffd7a55efc80845468e0f063e.js"></script>
|
```c
|
||||||
|
typedef enum YGLogLevel {
|
||||||
|
YGLogLevelError,
|
||||||
|
YGLogLevelWarn,
|
||||||
|
YGLogLevelInfo,
|
||||||
|
YGLogLevelDebug,
|
||||||
|
YGLogLevelVerbose,
|
||||||
|
} YGLogLevel;
|
||||||
|
|
||||||
|
typedef int (*YGLogger)(YGLogLevel level, char *format, va_list args);
|
||||||
|
void YGSetLogger(YGLogger logger);
|
||||||
|
void YGLog(YGLogLevel level, char *message, ...);
|
||||||
|
```
|
||||||
|
|
||||||
### Experiments
|
### Experiments
|
||||||
|
|
||||||
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/002516a55e10947e4bdcf5484eee8745.js"></script>
|
```c
|
||||||
|
typedef enum YGExperimentalFeature {
|
||||||
|
// Current experiments
|
||||||
|
} YGExperimentalFeature;
|
||||||
|
|
||||||
|
void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature,
|
||||||
|
bool enabled);
|
||||||
|
bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
|
||||||
|
```
|
||||||
|
|
||||||
### Custom allocators
|
### Custom allocators
|
||||||
|
|
||||||
You may want to swap out the allocator used in Yoga. These functions allow that.
|
You may want to swap out the allocator used in Yoga. These functions allow that.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/f45053d4f09a9faaf94a8fc071f0224f.js"></script>
|
```c
|
||||||
|
typedef void *(*YGMalloc)(size_t size);
|
||||||
|
typedef void *(*YGCalloc)(size_t count, size_t size);
|
||||||
|
typedef void *(*YGRealloc)(void *ptr, size_t size);
|
||||||
|
typedef void (*YGFree)(void *ptr);
|
||||||
|
|
||||||
|
void YGSetMemoryFuncs(YGMalloc cssMalloc,
|
||||||
|
YGCalloc cssCalloc,
|
||||||
|
YGRealloc cssRealloc,
|
||||||
|
YGFree cssFree);
|
||||||
|
```
|
||||||
|
|
||||||
### Printing
|
### Printing
|
||||||
|
|
||||||
Yoga has some hooks to print debug information while calculating layout. With the printing APIs you can add additional information to a node when it is printed.
|
Yoga has some hooks to print debug information while calculating layout. With the printing APIs you can add additional information to a node when it is printed.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/c9fbaba914d699ecc91841f4f5515f20.js"></script>
|
```c
|
||||||
|
typedef enum YGPrintOptions {
|
||||||
|
YGPrintOptionsLayout = 1,
|
||||||
|
YGPrintOptionsStyle = 2,
|
||||||
|
YGPrintOptionsChildren = 4,
|
||||||
|
} YGPrintOptions;
|
||||||
|
|
||||||
|
typedef void (*YGPrintFunc)(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
|
||||||
|
YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node);
|
||||||
|
|
||||||
|
void YGNodePrint(YGNodeRef node, YGPrintOptions options);
|
||||||
|
```
|
||||||
|
@@ -10,25 +10,176 @@ permalink: /docs/api/csharp/
|
|||||||
|
|
||||||
Create a `YogaNode` via its default constructor or the static `Create()` builder method and use `Reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
|
Create a `YogaNode` via its default constructor or the static `Create()` builder method and use `Reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/ce73212ee5fdb543d463822c3dd172b4.js"></script>
|
```csharp
|
||||||
|
YogaNode();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
static YogaNode Create(
|
||||||
|
YogaDirection? styleDirection = null,
|
||||||
|
YogaFlexDirection? flexDirection = null,
|
||||||
|
YogaJustify? justifyContent = null,
|
||||||
|
YogaAlign? alignContent = null,
|
||||||
|
YogaAlign? alignItems = null,
|
||||||
|
YogaAlign? alignSelf = null,
|
||||||
|
YogaPositionType? positionType = null,
|
||||||
|
YogaWrap? wrap = null,
|
||||||
|
YogaOverflow? overflow = null,
|
||||||
|
float? flex = null,
|
||||||
|
float? flexGrow = null,
|
||||||
|
float? flexShrink = null,
|
||||||
|
float? flexBasis = null,
|
||||||
|
Spacing position = null,
|
||||||
|
Spacing margin = null,
|
||||||
|
Spacing padding = null,
|
||||||
|
Spacing border = null,
|
||||||
|
float? Width = null,
|
||||||
|
float? Height = null,
|
||||||
|
float? MaxWidth = null,
|
||||||
|
float? MaxHeight = null,
|
||||||
|
float? MinWidth = null,
|
||||||
|
float? MinHeight = null);
|
||||||
|
```
|
||||||
|
|
||||||
### Children
|
### Children
|
||||||
|
|
||||||
The following methods help manage the children of a node.
|
The following methods help manage the children of a node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/2b0ea738d3c24644fa98910b276620e4.js"></script>
|
```csharp
|
||||||
|
int Count { get };
|
||||||
|
YogaNode this[int index] { get };
|
||||||
|
void Insert(int index, YogaNode node);
|
||||||
|
void RemoveAt(int index);
|
||||||
|
void Clear();
|
||||||
|
int IndexOf(YogaNode node);
|
||||||
|
```
|
||||||
|
|
||||||
### Style getters & setters
|
### Style getters & setters
|
||||||
|
|
||||||
The large part of Yoga's API consists of properties, setters, and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
The large part of Yoga's API consists of properties, setters, and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/a84208768e0006b8421a322c40f98539.js"></script>
|
```csharp
|
||||||
|
enum YogaDirection
|
||||||
|
{
|
||||||
|
Inherit,
|
||||||
|
LTR,
|
||||||
|
RTL,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaDirection StyleDirection {get, set};
|
||||||
|
|
||||||
|
enum YogaFlexDirection
|
||||||
|
{
|
||||||
|
Column,
|
||||||
|
ColumnReverse,
|
||||||
|
Row,
|
||||||
|
RowReverse,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaFlexDirection FlexDirection {get, set};
|
||||||
|
|
||||||
|
enum YogaJustify
|
||||||
|
{
|
||||||
|
FlexStart,
|
||||||
|
Center,
|
||||||
|
FlexEnd,
|
||||||
|
SpaceBetween,
|
||||||
|
SpaceAround,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaJustify JustifyContent {get, set};
|
||||||
|
|
||||||
|
enum YogaAlign
|
||||||
|
{
|
||||||
|
Auto,
|
||||||
|
FlexStart,
|
||||||
|
Center,
|
||||||
|
FlexEnd,
|
||||||
|
Stretch,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaAlign AlignItems {get, set};
|
||||||
|
YogaAlign AlignSelf {get, set};
|
||||||
|
YogaAlign AlignContent {get, set};
|
||||||
|
|
||||||
|
enum YogaPositionType
|
||||||
|
{
|
||||||
|
Relative,
|
||||||
|
Absolute,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaPositionType PositionType {get, set};
|
||||||
|
|
||||||
|
enum YogaWrap
|
||||||
|
{
|
||||||
|
NoWrap,
|
||||||
|
Wrap,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaWrap Wrap {get, set};
|
||||||
|
|
||||||
|
enum YogaOverflow
|
||||||
|
{
|
||||||
|
Visible,
|
||||||
|
Hidden,
|
||||||
|
Scroll,
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaOverflow Overflow {get, set};
|
||||||
|
|
||||||
|
float Flex {set};
|
||||||
|
float FlexGrow {get, set};
|
||||||
|
float FlexShrink {get, set};
|
||||||
|
float FlexBasis {get, set};
|
||||||
|
|
||||||
|
enum YogaEdge
|
||||||
|
{
|
||||||
|
Left,
|
||||||
|
Top,
|
||||||
|
Right,
|
||||||
|
Bottom,
|
||||||
|
Start,
|
||||||
|
End,
|
||||||
|
Horizontal,
|
||||||
|
Vertical,
|
||||||
|
All,
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetMargin(YogaEdge edge);
|
||||||
|
void SetMargin(YogaEdge edge, float margin);
|
||||||
|
|
||||||
|
float GetPadding(YogaEdge edge);
|
||||||
|
void SetPadding(YogaEdge edge, float padding);
|
||||||
|
|
||||||
|
float GetBorder(YogaEdge edge);
|
||||||
|
void SetBorder(YogaEdge edge, float border);
|
||||||
|
|
||||||
|
float GetPosition(YogaEdge edge);
|
||||||
|
void SetPosition(YogaEdge edge, float position);
|
||||||
|
|
||||||
|
float Width {get, set};
|
||||||
|
float Height {get, set};
|
||||||
|
|
||||||
|
float MaxWidth {get, set};
|
||||||
|
float MinWidth {get, set};
|
||||||
|
|
||||||
|
float MaxHeight {get, set};
|
||||||
|
float MinHeight {get, set};
|
||||||
|
|
||||||
|
float AspectRatio {get, set};
|
||||||
|
```
|
||||||
|
|
||||||
### Layout results
|
### Layout results
|
||||||
|
|
||||||
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `CalculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `CalculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/b50acf9fc0877affeb0fc3e55b5c6b4c.js"></script>
|
```csharp
|
||||||
|
void CalculateLayout();
|
||||||
|
float LayoutX {get};
|
||||||
|
float LayoutY {get};
|
||||||
|
float LayoutWidth {get};
|
||||||
|
float LayoutHeight {get};
|
||||||
|
YogaDirection LayoutDirection {get};
|
||||||
|
```
|
||||||
|
|
||||||
### Custom measurements
|
### Custom measurements
|
||||||
|
|
||||||
@@ -38,16 +189,53 @@ Certain nodes need to ability to measure themselves, the most common example is
|
|||||||
|
|
||||||
> A measure function can only be attached to a leaf node in the hierarchy.
|
> A measure function can only be attached to a leaf node in the hierarchy.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/57178307f515e5ea1ccfbedc05df429b.js"></script>
|
```csharp
|
||||||
|
enum YogaMeasureMode
|
||||||
|
{
|
||||||
|
Undefined,
|
||||||
|
Exactly,
|
||||||
|
AtMost,
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate long MeasureFunction(
|
||||||
|
YogaNode node,
|
||||||
|
float width,
|
||||||
|
YogaMeasureMode widthMode,
|
||||||
|
float height,
|
||||||
|
YogaMeasureMode heightMode);
|
||||||
|
|
||||||
|
class MeasureOutput
|
||||||
|
{
|
||||||
|
public static long Make(int width, int height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMeasureFunction(MeasureFunction measureFunction);
|
||||||
|
bool IsMeasureDefined();
|
||||||
|
|
||||||
|
bool IsDirty {get};
|
||||||
|
void MarkDirty();
|
||||||
|
```
|
||||||
|
|
||||||
### Data
|
### Data
|
||||||
|
|
||||||
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
|
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/c099f826623d70fd6bf7dece14e76700.js"></script>
|
```csharp
|
||||||
|
object Data {get, set}
|
||||||
|
```
|
||||||
|
|
||||||
### Experiments
|
### Experiments
|
||||||
|
|
||||||
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>
|
```csharp
|
||||||
|
enum YogaExperimentalFeature {
|
||||||
|
// Current experiments
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setExperimentalFeatureEnabled(
|
||||||
|
YogaExperimentalFeature feature,
|
||||||
|
boolean enabled);
|
||||||
|
static boolean isExperimentalFeatureEnabled(
|
||||||
|
YogaExperimentalFeature feature);
|
||||||
|
```
|
||||||
|
@@ -10,25 +10,166 @@ permalink: /docs/api/java/
|
|||||||
|
|
||||||
Create a `YogaNode` via its default constructor and use `reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
|
Create a `YogaNode` via its default constructor and use `reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/8775de8c778eb99a05a38e8257f0b4a7.js"></script>
|
```java
|
||||||
|
YogaNode();
|
||||||
|
void reset();
|
||||||
|
```
|
||||||
|
|
||||||
### Children
|
### Children
|
||||||
|
|
||||||
The following methods help manage the children of a node.
|
The following methods help manage the children of a node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/5d1c64d8d3be7f7942435c4f5bec45a5.js"></script>
|
```java
|
||||||
|
int getChildCount();
|
||||||
|
YogaNodeType getChildAt(int i);
|
||||||
|
void addChildAt(YogaNodeType child, int i);
|
||||||
|
YogaNodeType removeChildAt(int i);
|
||||||
|
YogaNodeType getParent();
|
||||||
|
int indexOf(YogaNodeType child);
|
||||||
|
```
|
||||||
|
|
||||||
### Style getters & setters
|
### Style getters & setters
|
||||||
|
|
||||||
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/f94ca2aa69441a3060a7c9f5126f202f.js"></script>
|
```java
|
||||||
|
enum YogaDirection {
|
||||||
|
INHERIT,
|
||||||
|
LTR,
|
||||||
|
RTL
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaDirection getStyleDirection();
|
||||||
|
void setDirection(YogaDirection direction);
|
||||||
|
|
||||||
|
enum YogaFlexDirection {
|
||||||
|
COLUMN,
|
||||||
|
COLUMN_REVERSE,
|
||||||
|
ROW,
|
||||||
|
ROW_REVERSE
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaFlexDirection getFlexDirection();
|
||||||
|
void setFlexDirection(YogaFlexDirection flexDirection);
|
||||||
|
|
||||||
|
enum YogaJustify {
|
||||||
|
FLEX_START,
|
||||||
|
CENTER,
|
||||||
|
FLEX_END,
|
||||||
|
SPACE_BETWEEN,
|
||||||
|
SPACE_AROUND
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaJustify getJustifyContent();
|
||||||
|
void setJustifyContent(YogaJustify justifyContent);
|
||||||
|
|
||||||
|
enum YogaAlign {
|
||||||
|
AUTO,
|
||||||
|
FLEX_START,
|
||||||
|
CENTER,
|
||||||
|
FLEX_END,
|
||||||
|
STRETCH
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaAlign getAlignItems();
|
||||||
|
void setAlignItems(YogaAlign alignItems);
|
||||||
|
|
||||||
|
YogaAlign getAlignSelf();
|
||||||
|
void setAlignSelf(YogaAlign alignSelf);
|
||||||
|
|
||||||
|
YogaAlign getAlignContent();
|
||||||
|
void setAlignContent(YogaAlign alignContent);
|
||||||
|
|
||||||
|
enum YogaPositionType {
|
||||||
|
RELATIVE,
|
||||||
|
ABSOLUTE
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaPositionType getPositionType();
|
||||||
|
void setPositionType(YogaPositionType positionType);
|
||||||
|
|
||||||
|
enum YogaWrap {
|
||||||
|
NO_WRAP,
|
||||||
|
WRAP
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWrap(YogaWrap flexWrap);
|
||||||
|
|
||||||
|
enum YogaOverflow {
|
||||||
|
VISIBLE,
|
||||||
|
HIDDEN,
|
||||||
|
SCROLL
|
||||||
|
}
|
||||||
|
|
||||||
|
YogaOverflow getOverflow();
|
||||||
|
void setOverflow(YogaOverflow overflow);
|
||||||
|
|
||||||
|
void setFlex(float flex);
|
||||||
|
float getFlexGrow();
|
||||||
|
void setFlexGrow(float flexGrow);
|
||||||
|
float getFlexShrink();
|
||||||
|
void setFlexShrink(float flexShrink);
|
||||||
|
float getFlexBasis();
|
||||||
|
void setFlexBasis(float flexBasis);
|
||||||
|
|
||||||
|
enum YogaEdge {
|
||||||
|
LEFT,
|
||||||
|
TOP,
|
||||||
|
RIGHT,
|
||||||
|
BOTTOM,
|
||||||
|
START,
|
||||||
|
END,
|
||||||
|
HORIZONTAL,
|
||||||
|
VERTICAL,
|
||||||
|
ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
float getMargin(YogaEdge edge);
|
||||||
|
void setMargin(YogaEdge edge, float margin);
|
||||||
|
|
||||||
|
float getPadding(YogaEdge edge);
|
||||||
|
void setPadding(YogaEdge edge, float padding);
|
||||||
|
|
||||||
|
float getBorder(YogaEdge edge);
|
||||||
|
void setBorder(YogaEdge edge, float border);
|
||||||
|
|
||||||
|
float getPosition(YogaEdge edge);
|
||||||
|
void setPosition(YogaEdge edge, float position);
|
||||||
|
|
||||||
|
float getWidth();
|
||||||
|
void setWidth(float width);
|
||||||
|
|
||||||
|
float getHeight();
|
||||||
|
void setHeight(float height);
|
||||||
|
|
||||||
|
float getMaxWidth();
|
||||||
|
void setMaxWidth(float maxWidth);
|
||||||
|
|
||||||
|
float getMinWidth();
|
||||||
|
void setMinWidth(float minWidth);
|
||||||
|
|
||||||
|
float getMaxHeight();
|
||||||
|
void setMaxHeight(float maxHeight);
|
||||||
|
|
||||||
|
float getMinHeight();
|
||||||
|
void setMinHeight(float minHeight);
|
||||||
|
|
||||||
|
float getAspectRatio();
|
||||||
|
void setAspectRatio(float aspectRatio);
|
||||||
|
```
|
||||||
|
|
||||||
### Layout results
|
### Layout results
|
||||||
|
|
||||||
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `calculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `calculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/613a80ae11abce423a4806521e1e315b.js"></script>
|
```java
|
||||||
|
void calculateLayout();
|
||||||
|
float getLayoutX();
|
||||||
|
float getLayoutY();
|
||||||
|
float getLayoutWidth();
|
||||||
|
float getLayoutHeight();
|
||||||
|
YogaDirection getLayoutDirection();
|
||||||
|
```
|
||||||
|
|
||||||
### Custom measurements
|
### Custom measurements
|
||||||
|
|
||||||
@@ -38,22 +179,74 @@ Certain nodes need to ability to measure themselves, the most common example is
|
|||||||
|
|
||||||
> A measure function can only be attached to a leaf node in the hierarchy.
|
> A measure function can only be attached to a leaf node in the hierarchy.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/70fd958b87647abbba604956709a9026.js"></script>
|
```java
|
||||||
|
enum YogaMeasureMode {
|
||||||
|
UNDEFINED,
|
||||||
|
EXACTLY,
|
||||||
|
AT_MOST
|
||||||
|
}
|
||||||
|
|
||||||
|
interface YogaMeasureFunction {
|
||||||
|
long measure(
|
||||||
|
YogaNode node,
|
||||||
|
float width,
|
||||||
|
YogaMeasureMode widthMode,
|
||||||
|
float height,
|
||||||
|
YogaMeasureMode heightMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
class YogaMeasureOutput {
|
||||||
|
static long make(int width, int height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMeasureFunction(YogaMeasureFunction measureFunction);
|
||||||
|
boolean isMeasureDefined();
|
||||||
|
|
||||||
|
boolean isDirty();
|
||||||
|
void dirty();
|
||||||
|
```
|
||||||
|
|
||||||
### Data
|
### Data
|
||||||
|
|
||||||
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
|
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/3f10f3fa91120960b71783780f528973.js"></script>
|
```java
|
||||||
|
void setData(Object data);
|
||||||
|
Object getData();
|
||||||
|
```
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
|
|
||||||
Yoga will by default log to stdout and stderr (or logcat on Android). You may however customize this to instead log to your own logger.
|
Yoga will by default log to stdout and stderr (or logcat on Android). You may however customize this to instead log to your own logger.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/6d012f5d48be0e98b7f9c2225c358f6e.js"></script>
|
```java
|
||||||
|
enum YogaLogLevel {
|
||||||
|
ERROR,
|
||||||
|
WARN,
|
||||||
|
INFO,
|
||||||
|
DEBUG,
|
||||||
|
VERBOSE
|
||||||
|
}
|
||||||
|
|
||||||
|
interface YogaLogger {
|
||||||
|
void log(YogaLogLevel level, String message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLogger(YogaLogger logger);
|
||||||
|
```
|
||||||
|
|
||||||
### Experiments
|
### Experiments
|
||||||
|
|
||||||
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>
|
```java
|
||||||
|
enum YogaExperimentalFeature {
|
||||||
|
// Current experiments
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setExperimentalFeatureEnabled(
|
||||||
|
YogaExperimentalFeature feature,
|
||||||
|
boolean enabled);
|
||||||
|
static boolean isExperimentalFeatureEnabled(
|
||||||
|
YogaExperimentalFeature feature);
|
||||||
|
```
|
||||||
|
@@ -19,13 +19,22 @@ For now we recommend including Yoga as a [git submodule](https://git-scm.com/doc
|
|||||||
|
|
||||||
Yoga ships with an [iOS example](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample). To get it running:
|
Yoga ships with an [iOS example](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample). To get it running:
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/903b16185b24c957acc4cd250c6e73d9.js"></script>
|
```sh
|
||||||
|
$ git clone https://github.com/facebook/yoga.git
|
||||||
|
$ cd open yoga/YogaKit/YogaKitSample/
|
||||||
|
$ pod install
|
||||||
|
$ open YogaKitSample.xcworkspace
|
||||||
|
```
|
||||||
|
|
||||||
#### Android
|
#### Android
|
||||||
|
|
||||||
Yoga ships with an [Android example too](https://github.com/facebook/yoga/tree/master/android/sample). To get it running on an attached device (or emulator):
|
Yoga ships with an [Android example too](https://github.com/facebook/yoga/tree/master/android/sample). To get it running on an attached device (or emulator):
|
||||||
|
|
||||||
<script src="https://gist.github.com/rspencer01/a512f7cd24055c948675be15d48eba78.js"></script>
|
```sh
|
||||||
|
$ git clone https://github.com/facebook/yoga.git
|
||||||
|
$ cd yoga
|
||||||
|
$ buck install -r android/sample
|
||||||
|
```
|
||||||
|
|
||||||
Actually, this is more than just an example, and more a layout system for Android using Yoga in general (see `YogaLayout`). For more information see the [Android API section](/yoga/docs/api/android).
|
Actually, this is more than just an example, and more a layout system for Android using Yoga in general (see `YogaLayout`). For more information see the [Android API section](/yoga/docs/api/android).
|
||||||
|
|
||||||
@@ -35,4 +44,15 @@ Yoga uses [Buck](https://buckbuild.com/) as its build system. Buck is not requir
|
|||||||
|
|
||||||
If you are using Buck all you need to do is reference the language bindings you want to use in your `BUCK` file.
|
If you are using Buck all you need to do is reference the language bindings you want to use in your `BUCK` file.
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/895b4ec79425882b8d4676b6545d6943.js"></script>
|
```sh
|
||||||
|
deps = [
|
||||||
|
# C
|
||||||
|
'//path/to/submodule/yoga:yoga',
|
||||||
|
|
||||||
|
# Java
|
||||||
|
'//path/to/submodule/yoga/java:jni',
|
||||||
|
|
||||||
|
# Objective-C
|
||||||
|
'//path/to/submodule/yoga/YogaKit:YogaKit',
|
||||||
|
]
|
||||||
|
```
|
||||||
|
@@ -15,7 +15,23 @@ Yoga aims to be compatible with Flexbox according to the [w3 specification](http
|
|||||||
|
|
||||||
Yoga has chosen to change the default values of some properties to better fit mobile layout use cases. The following CSS block describes the differences in default values from the [Flexbox w3 specification](https://www.w3.org/TR/css3-flexbox).
|
Yoga has chosen to change the default values of some properties to better fit mobile layout use cases. The following CSS block describes the differences in default values from the [Flexbox w3 specification](https://www.w3.org/TR/css3-flexbox).
|
||||||
|
|
||||||
<script src="https://gist.github.com/emilsjolander/f9b3981cab44c51afa9ac446b8fdb60c.js"></script>
|
```css
|
||||||
|
div {
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-content: flex-start;
|
||||||
|
|
||||||
|
border-width: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
min-width: 0px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
We have set up a [JSFiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) so you can see these default values in action.
|
We have set up a [JSFiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) so you can see these default values in action.
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
.rougeHighlight { background-color: $code-bg; color: #93a1a1 }
|
.rougeHighlight { background-color: $code-bg; color: #000 }
|
||||||
.rougeHighlight .c { color: #586e75 } /* Comment */
|
.rougeHighlight .c { color: #586e75 } /* Comment */
|
||||||
.rougeHighlight .err { color: #93a1a1 } /* Error */
|
.rougeHighlight .err { color: #93a1a1 } /* Error */
|
||||||
.rougeHighlight .g { color: #93a1a1 } /* Generic */
|
.rougeHighlight .g { color: #93a1a1 } /* Generic */
|
||||||
.rougeHighlight .k { color: #859900 } /* Keyword */
|
.rougeHighlight .k { color: #859900 } /* Keyword */
|
||||||
.rougeHighlight .l { color: #93a1a1 } /* Literal */
|
.rougeHighlight .l { color: #93a1a1 } /* Literal */
|
||||||
.rougeHighlight .n { color: #93a1a1 } /* Name */
|
.rougeHighlight .n { color: #795da3 } /* Name */
|
||||||
.rougeHighlight .o { color: #859900 } /* Operator */
|
.rougeHighlight .o { color: #859900 } /* Operator */
|
||||||
.rougeHighlight .x { color: #cb4b16 } /* Other */
|
.rougeHighlight .x { color: #cb4b16 } /* Other */
|
||||||
.rougeHighlight .p { color: #93a1a1 } /* Punctuation */
|
.rougeHighlight .p { color: #000000 } /* Punctuation */
|
||||||
.rougeHighlight .cm { color: #586e75 } /* Comment.Multiline */
|
.rougeHighlight .cm { color: #586e75 } /* Comment.Multiline */
|
||||||
.rougeHighlight .cp { color: #859900 } /* Comment.Preproc */
|
.rougeHighlight .cp { color: #859900 } /* Comment.Preproc */
|
||||||
.rougeHighlight .c1 { color: #72c02c; } /* Comment.Single */
|
.rougeHighlight .c1 { color: #72c02c; } /* Comment.Single */
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
.rougeHighlight .gh { color: #cb4b16 } /* Generic.Heading */
|
.rougeHighlight .gh { color: #cb4b16 } /* Generic.Heading */
|
||||||
.rougeHighlight .gi { color: #859900 } /* Generic.Inserted */
|
.rougeHighlight .gi { color: #859900 } /* Generic.Inserted */
|
||||||
.rougeHighlight .go { color: #93a1a1 } /* Generic.Output */
|
.rougeHighlight .go { color: #93a1a1 } /* Generic.Output */
|
||||||
.rougeHighlight .gp { color: #93a1a1 } /* Generic.Prompt */
|
.rougeHighlight .gp { color: #000000 } /* Generic.Prompt */
|
||||||
.rougeHighlight .gs { color: #93a1a1; font-weight: bold } /* Generic.Strong */
|
.rougeHighlight .gs { color: #93a1a1; font-weight: bold } /* Generic.Strong */
|
||||||
.rougeHighlight .gu { color: #cb4b16 } /* Generic.Subheading */
|
.rougeHighlight .gu { color: #cb4b16 } /* Generic.Subheading */
|
||||||
.rougeHighlight .gt { color: #93a1a1 } /* Generic.Traceback */
|
.rougeHighlight .gt { color: #93a1a1 } /* Generic.Traceback */
|
||||||
@@ -41,11 +41,11 @@
|
|||||||
.rougeHighlight .ni { color: #cb4b16 } /* Name.Entity */
|
.rougeHighlight .ni { color: #cb4b16 } /* Name.Entity */
|
||||||
.rougeHighlight .ne { color: #cb4b16 } /* Name.Exception */
|
.rougeHighlight .ne { color: #cb4b16 } /* Name.Exception */
|
||||||
.rougeHighlight .nf { color: #268bd2 } /* Name.Function */
|
.rougeHighlight .nf { color: #268bd2 } /* Name.Function */
|
||||||
.rougeHighlight .nl { color: #93a1a1 } /* Name.Label */
|
.rougeHighlight .nl { color: #0086b3 } /* Name.Label */
|
||||||
.rougeHighlight .nn { color: #93a1a1 } /* Name.Namespace */
|
.rougeHighlight .nn { color: #93a1a1 } /* Name.Namespace */
|
||||||
.rougeHighlight .nx { color: #93a1a1 } /* Name.Other */
|
.rougeHighlight .nx { color: #93a1a1 } /* Name.Other */
|
||||||
.rougeHighlight .py { color: #93a1a1 } /* Name.Property */
|
.rougeHighlight .py { color: #93a1a1 } /* Name.Property */
|
||||||
.rougeHighlight .nt { color: #268bd2 } /* Name.Tag */
|
.rougeHighlight .nt { color: #63a35c } /* Name.Tag */
|
||||||
.rougeHighlight .nv { color: #268bd2 } /* Name.Variable */
|
.rougeHighlight .nv { color: #268bd2 } /* Name.Variable */
|
||||||
.rougeHighlight .ow { color: #859900 } /* Operator.Word */
|
.rougeHighlight .ow { color: #859900 } /* Operator.Word */
|
||||||
.rougeHighlight .w { color: #93a1a1 } /* Text.Whitespace */
|
.rougeHighlight .w { color: #93a1a1 } /* Text.Whitespace */
|
||||||
@@ -72,11 +72,12 @@
|
|||||||
|
|
||||||
.highlighter-rouge {
|
.highlighter-rouge {
|
||||||
color: darken(#72c02c, 8%);
|
color: darken(#72c02c, 8%);
|
||||||
font: 800 12px/1.5em Hack, monospace;
|
font: 500 12px/1.8em "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
||||||
.rougeHighlight {
|
.rougeHighlight {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
@@ -97,8 +98,9 @@
|
|||||||
flex: 1 1;
|
flex: 1 1;
|
||||||
|
|
||||||
&.gutter {
|
&.gutter {
|
||||||
border-right: 1px solid lighten($code-bg, 10%);
|
border-right: 1px solid darken($code-bg, 10%);
|
||||||
color: lighten($code-bg, 15%);
|
color: darken($code-bg, 25%);
|
||||||
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
max-width: 40px;
|
max-width: 40px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
|
@@ -86,7 +86,7 @@ $sidenav-overlay: lighten($sidenav, 10%);
|
|||||||
$sidenav-active: darken($sidenav, 10%);
|
$sidenav-active: darken($sidenav, 10%);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$code-bg: #002b36;
|
$code-bg: #ffffff;
|
||||||
|
|
||||||
|
|
||||||
$header-height: 34px;
|
$header-height: 34px;
|
||||||
|
128
docs/index.md
128
docs/index.md
@@ -13,8 +13,28 @@ id: home
|
|||||||
<div class="yoga" style="background-color: #303846; flex-grow: 1; height: 25px; align-self: center;"></div>
|
<div class="yoga" style="background-color: #303846; flex-grow: 1; height: 25px; align-self: center;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blockContent gistsample">
|
<div class="blockContent">
|
||||||
<script src="https://gist.github.com/emilsjolander/40685eadad702e0227374f3e33daaa12.js"></script>
|
<div markdown="1" style="width: 700px; max-width: 100%;">
|
||||||
|
```c
|
||||||
|
YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 500);
|
||||||
|
YGNodeStyleSetHeight(root, 120);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetPadding(root, YGEdgeAll, 20);
|
||||||
|
|
||||||
|
YGNodeRef image = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(image, 80);
|
||||||
|
YGNodeStyleSetMargin(image, YGEdgeEnd, 20);
|
||||||
|
|
||||||
|
YGNodeRef text = YGNodeNew();
|
||||||
|
YGNodeStyleSetHeight(text, 25);
|
||||||
|
YGNodeStyleSetAlignSelf(text, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(text, 1);
|
||||||
|
|
||||||
|
YGNodeInsertChild(root, image, 0);
|
||||||
|
YGNodeInsertChild(root, text, 1);
|
||||||
|
```
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,8 +48,28 @@ id: home
|
|||||||
<div class="yoga" style="background-color: #303846; height: 25px; width: 100px;"></div>
|
<div class="yoga" style="background-color: #303846; height: 25px; width: 100px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blockContent gistsample">
|
<div class="blockContent">
|
||||||
<script src="https://gist.github.com/dshahidehpour/a426c443a1e02c5432b22b09c457ede0.js"></script>
|
<div markdown="1" style="width: 700px; max-width: 100%;">
|
||||||
|
```objc
|
||||||
|
UIView *root = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 300)];
|
||||||
|
[root configureLayoutWithBlock:^void(YGLayout *layout) {
|
||||||
|
layout.isEnabled = YES;
|
||||||
|
layout.alignItems = YGAlignCenter;
|
||||||
|
layout.justifyContent = YGJustifyContentCenter;
|
||||||
|
layout.padding = 20.0f;
|
||||||
|
}];
|
||||||
|
|
||||||
|
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
|
||||||
|
[image configureLayoutWithBlock:^void(YGLayout *layout) {
|
||||||
|
layout.isEnabled = YES;
|
||||||
|
layout.marginBottom = 20.0f;
|
||||||
|
}];
|
||||||
|
[root addSubview:image];
|
||||||
|
|
||||||
|
UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 25, 100)];
|
||||||
|
[root addSubview:text];
|
||||||
|
```
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,8 +83,31 @@ id: home
|
|||||||
<div class="yoga" style="background-color: #97dccf; width: 50px; height: 50px; position: absolute; right: 20px; top: 20px;"></div>
|
<div class="yoga" style="background-color: #97dccf; width: 50px; height: 50px; position: absolute; right: 20px; top: 20px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blockContent gistsample">
|
<div class="blockContent">
|
||||||
<script src="https://gist.github.com/emilsjolander/f7b9b5dc2b97577bab2f1e6e1bf80b62.js"></script>
|
<div markdown="1" style="width: 700px; max-width: 100%;">
|
||||||
|
```java
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(500);
|
||||||
|
root.setHeight(300);
|
||||||
|
root.setAlignItems(CENTER);
|
||||||
|
root.setJustifyContent(CENTER);
|
||||||
|
root.setPadding(ALL, 20);
|
||||||
|
|
||||||
|
YogaNode text = new YogaNode();
|
||||||
|
text.setWidth(200);
|
||||||
|
text.setHeight(25);
|
||||||
|
|
||||||
|
YogaNode image = new YogaNode();
|
||||||
|
image.setWidth(50);
|
||||||
|
image.setHeight(50);
|
||||||
|
image.setPositionType(ABSOLUTE);
|
||||||
|
image.setPosition(END, 20);
|
||||||
|
image.setPosition(TOP, 20);
|
||||||
|
|
||||||
|
root.addChildAt(text, 0);
|
||||||
|
root.addChildAt(image, 1);
|
||||||
|
```
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -58,8 +121,26 @@ id: home
|
|||||||
<div class="yoga" style="background-color: #303846; margin: 20px; height: 25px; width: 300px;"></div>
|
<div class="yoga" style="background-color: #303846; margin: 20px; height: 25px; width: 300px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blockContent gistsample">
|
<div class="blockContent">
|
||||||
<script src="https://gist.github.com/emilsjolander/29b91608b66d56d3df81f53101ad9d8b.js"></script>
|
<div markdown="1" style="width: 700px; max-width: 100%;">
|
||||||
|
```csharp
|
||||||
|
YogaNode root = YogaNode.Create(
|
||||||
|
width: 500,
|
||||||
|
height: 300,
|
||||||
|
);
|
||||||
|
|
||||||
|
YogaNode image = YogaNode.Create(flexGrow: 1);
|
||||||
|
|
||||||
|
YogaNode text = YogaNode.Create(
|
||||||
|
width: 300,
|
||||||
|
height: 25,
|
||||||
|
margin: new Spacing(left: 20, top: 20, right: 20, bottom: 20),
|
||||||
|
);
|
||||||
|
|
||||||
|
root.Insert(image, 0);
|
||||||
|
root.Insert(text, 1);
|
||||||
|
```
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -76,8 +157,35 @@ id: home
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blockContent gistsample">
|
<div class="blockContent">
|
||||||
<script src="https://gist.github.com/rspencer01/0b3e467a58ab56a23f60579ea193189f.js"></script>
|
<div markdown="1" style="width: 700px; max-width: 100%;">
|
||||||
|
```xml
|
||||||
|
<YogaLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
yoga:justify_content="stretch">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:flex="1"/>
|
||||||
|
<VirtualYogaLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:padding_all="20px"
|
||||||
|
yoga:flex_direction="row"
|
||||||
|
yoga:align_items="center">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
yoga:flex="1"
|
||||||
|
yoga:margin_start="20px"/>
|
||||||
|
</VirtualYogaLayout>
|
||||||
|
</YogaLayout>
|
||||||
|
```
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
31
enums.py
31
enums.py
@@ -125,6 +125,16 @@ def to_java_upper(symbol):
|
|||||||
out += c.upper()
|
out += c.upper()
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def to_log_lower(symbol):
|
||||||
|
symbol = str(symbol)
|
||||||
|
out = ''
|
||||||
|
for i in range(0, len(symbol)):
|
||||||
|
c = symbol[i]
|
||||||
|
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
|
||||||
|
out += '-'
|
||||||
|
out += c.lower()
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
root = os.path.dirname(os.path.abspath(__file__))
|
root = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
@@ -143,9 +153,28 @@ with open(root + '/yoga/YGEnums.h', 'w') as f:
|
|||||||
else:
|
else:
|
||||||
f.write(' YG%s%s,\n' % (name, value))
|
f.write(' YG%s%s,\n' % (name, value))
|
||||||
f.write('} YG_ENUM_END(YG%s);\n' % name)
|
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('\n')
|
||||||
f.write('YG_EXTERN_C_END\n')
|
f.write('YG_EXTERN_C_END\n')
|
||||||
|
|
||||||
|
# write out C body for printing
|
||||||
|
with open(root + '/yoga/YGEnums.c', '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')
|
||||||
|
for value in values:
|
||||||
|
if isinstance(value, tuple):
|
||||||
|
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(' return "%s";\n' % to_log_lower(value))
|
||||||
|
f.write(' }\n')
|
||||||
|
f.write(' return "unknown";\n')
|
||||||
|
f.write('}\n\n')
|
||||||
|
|
||||||
# write out java files
|
# write out java files
|
||||||
for name, values in sorted(ENUMS.items()):
|
for name, values in sorted(ENUMS.items()):
|
||||||
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f:
|
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f:
|
||||||
@@ -194,6 +223,8 @@ 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(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(' public enum Yoga%s\n {\n' % name)
|
||||||
for value in values:
|
for value in values:
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
|
@@ -26,37 +26,40 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
<div id="absolute_layout_align_items_and_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_flex_end" style="height: 100px; width: 110px; flex-grow: 1; align-items: flex-end; justify-content: flex-end;">
|
<div id="absolute_layout_align_items_and_justify_content_flex_end" style="height: 100px; width: 110px; flex-grow: 1; align-items: flex-end; justify-content: flex-end;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; justify-content: center;">
|
<div id="absolute_layout_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center;">
|
<div id="absolute_layout_align_items_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_center_on_child_only" style="height: 100px; width: 110px; flex-grow: 1;">
|
<div id="absolute_layout_align_items_center_on_child_only" style="height: 100px; width: 110px; flex-grow: 1;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;align-self: center;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;align-self: center;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_center_and_top_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
<div id="absolute_layout_align_items_and_justify_content_center_and_top_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;top:10px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;top:10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_center_and_bottom_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
<div id="absolute_layout_align_items_and_justify_content_center_and_bottom_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;bottom:10px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;bottom:10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_center_and_left_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
<div id="absolute_layout_align_items_and_justify_content_center_and_left_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;left:5px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;left:5px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="absolute_layout_align_items_and_justify_content_center_and_right_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
<div id="absolute_layout_align_items_and_justify_content_center_and_right_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
<div style="position: absolute; width: 60px; height: 40px;right:5px;"></div>
|
<div style="position: absolute; width: 60px; height: 40px;right:5px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="position_root_with_rtl_should_position_withoutdirection" style="height: 52px; width: 52px; left: 72px; ">
|
||||||
</div>
|
</div>
|
@@ -133,8 +133,6 @@
|
|||||||
<div style="width: 50px; height: 20px;flex-direction:column;"></div>
|
<div style="width: 50px; height: 20px;flex-direction:column;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="align_baseline_multiline_row_and_column" style="width: 100px; height: 100px; flex-direction:row; align-items: baseline;flex-wrap:wrap;">
|
<div id="align_baseline_multiline_row_and_column" style="width: 100px; height: 100px; flex-direction:row; align-items: baseline;flex-wrap:wrap;">
|
||||||
<div style="width: 50px; height: 50px;"></div>
|
<div style="width: 50px; height: 50px;"></div>
|
||||||
<div style="width: 50px; height: 50px;flex-direction:column;">
|
<div style="width: 50px; height: 50px;flex-direction:column;">
|
||||||
@@ -145,3 +143,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="width: 50px; height: 20px;"></div>
|
<div style="width: 50px; height: 20px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="align_items_center_child_with_margin_bigger_than_parent" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
|
||||||
|
<div style="align-items: center;">
|
||||||
|
<div style="width: 52px; height: 52px; margin-left: 10px; margin-right: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="align_items_flex_end_child_with_margin_bigger_than_parent" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
|
||||||
|
<div style="align-items: flex-end;">
|
||||||
|
<div style="width: 52px; height: 52px; margin-left: 10px; margin-right: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="align_items_center_child_without_margin_bigger_than_parent" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
|
||||||
|
<div style="align-items: center;">
|
||||||
|
<div style="width: 72px; height: 72px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="align_items_flex_end_child_without_margin_bigger_than_parent" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
|
||||||
|
<div style="align-items: flex-end;">
|
||||||
|
<div style="width: 72px; height: 72px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -116,3 +116,27 @@
|
|||||||
<div style="width: 50px; height: 50px; margin-top:auto; margin-bottom:auto;"></div>
|
<div style="width: 50px; height: 50px; margin-top:auto; margin-bottom:auto;"></div>
|
||||||
<div style="width: 50px; height: 50px;"></div>
|
<div style="width: 50px; height: 50px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_should_not_be_part_of_max_height" style="width: 250px; height: 250px;">
|
||||||
|
<div style="width: 100px; height: 100px; max-height: 100px; margin-top: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_should_not_be_part_of_max_width" style="width: 250px; height: 250px;">
|
||||||
|
<div style="width: 100px; height: 100px; max-width: 100px; margin-left: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_auto_left_right_child_bigger_than_parent" style="height: 52px; width: 52px; justify-content: center;">
|
||||||
|
<div style="width: 72px; height: 72px; margin-left: auto; margin-right:auto;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_auto_left_child_bigger_than_parent" style="height: 52px; width: 52px; justify-content: center;">
|
||||||
|
<div style="width: 72px; height: 72px; margin-left: auto;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_fix_left_auto_right_child_bigger_than_parent" style="height: 52px; width: 52px; justify-content: center;">
|
||||||
|
<div style="width: 72px; height: 72px; margin-left: 10px; margin-right: auto;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="margin_auto_left_fix_right_child_bigger_than_parent" style="height: 52px; width: 52px; justify-content: center;">
|
||||||
|
<div style="width: 72px; height: 72px; margin-left: auto; margin-right: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
@@ -41,6 +41,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="flex_grow_child" style="flex-direction: row;">
|
||||||
|
<div style="height: 100px; flex-grow: 1; flex-basis: 0px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="flex_grow_within_constrained_min_max_column" style="min-height: 100px; max-height: 200px">
|
||||||
|
<div style="flex-grow:1;"></div>
|
||||||
|
<div style="height: 50px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
|
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
|
||||||
<div style="flex-direction: row; max-width: 100px;">
|
<div style="flex-direction: row; max-width: 100px;">
|
||||||
<div style="height: 20px; flex-grow: 1;"></div>
|
<div style="height: 20px; flex-grow: 1;"></div>
|
||||||
|
@@ -100,3 +100,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="percent_absolute_position" style="width: 60px; height: 50px;">
|
||||||
|
<div style="height: 50px; width: 100%; left: 50%; position: absolute; flex-direction: row;">
|
||||||
|
<div style="width: 100%;"></div>
|
||||||
|
<div style="width: 100%;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -62,3 +62,34 @@
|
|||||||
<div style="height: 10px; flex-grow:1;"></div>
|
<div style="height: 10px; flex-grow:1;"></div>
|
||||||
<div style="height: 10px; flex-grow:1;"></div>
|
<div style="height: 10px; flex-grow:1;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="rounding_inner_node_controversy_horizontal" experiments="Rounding" style="width: 320px; flex-direction: row;">
|
||||||
|
<div style="height: 10px; flex-grow:1;"></div>
|
||||||
|
<div style="height: 10px; flex-grow:1;">
|
||||||
|
<div style="height: 10px; flex-grow:1;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="height: 10px; flex-grow:1;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="rounding_inner_node_controversy_vertical" experiments="Rounding" style="height: 320px;">
|
||||||
|
<div style="width: 10px; flex-grow:1;"></div>
|
||||||
|
<div style="width: 10px; flex-grow:1;">
|
||||||
|
<div style="width: 10px; flex-grow:1;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="width: 10px; flex-grow:1;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="rounding_inner_node_controversy_combined" experiments="Rounding" style="width: 640px; height: 320px; flex-direction: row;">
|
||||||
|
<div style="height: 100%; flex-grow:1;"></div>
|
||||||
|
<div style="height: 100%; flex-grow:1; flex-direction: column;">
|
||||||
|
<div style="width: 100%; flex-grow:1;"></div>
|
||||||
|
<div style="width: 100%; flex-grow:1;">
|
||||||
|
<div style="flex-grow:1; width: 100%;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="width: 100%; flex-grow:1;"></div>
|
||||||
|
</div>
|
||||||
|
<div style="height: 100%; flex-grow:1;"></div>
|
||||||
|
</div>
|
||||||
|
@@ -183,7 +183,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
}},
|
}},
|
||||||
|
|
||||||
YGNodeStyleSetDisplay:{value:function(nodeName, value) {
|
YGNodeStyleSetDisplay:{value:function(nodeName, value) {
|
||||||
this.push(nodeName + '.setDisplay(' + toValueJavascript(value) + ');');
|
this.push(nodeName + '.setDisplay(' + toValueJava(value) + ');');
|
||||||
}},
|
}},
|
||||||
|
|
||||||
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
|
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
|
||||||
|
@@ -43,10 +43,12 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
emitTestPrologue:{value:function(name, experiments) {
|
emitTestPrologue:{value:function(name, experiments) {
|
||||||
this.push('it(' + JSON.stringify(name) + ', function () {');
|
this.push('it(' + JSON.stringify(name) + ', function () {');
|
||||||
this.pushIndent();
|
this.pushIndent();
|
||||||
|
this.push('var config = Yoga.Config.create();');
|
||||||
|
this.push('');
|
||||||
|
|
||||||
if (experiments.length > 0) {
|
if (experiments.length > 0) {
|
||||||
for (var i in experiments) {
|
for (var i in experiments) {
|
||||||
this.push('Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_' + toJavascriptUpper(experiments[i]) + ', true);');
|
this.push('config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_' + toJavascriptUpper(experiments[i]) + ', true);');
|
||||||
}
|
}
|
||||||
this.push('');
|
this.push('');
|
||||||
}
|
}
|
||||||
@@ -69,13 +71,8 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
this.push('root.freeRecursive();');
|
this.push('root.freeRecursive();');
|
||||||
this.popIndent();
|
this.popIndent();
|
||||||
this.push('}');
|
this.push('}');
|
||||||
|
this.push('');
|
||||||
if (experiments.length > 0) {
|
this.push('config.free();');
|
||||||
this.push('');
|
|
||||||
for (var i in experiments) {
|
|
||||||
this.push('Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_' + toJavascriptUpper(experiments[i]) + ', false);');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.popIndent();
|
this.popIndent();
|
||||||
this.push('}');
|
this.push('}');
|
||||||
|
@@ -420,25 +420,46 @@ function getDefaultStyleValue(style) {
|
|||||||
return getComputedStyle(node, null).getPropertyValue(style);
|
return getComputedStyle(node, null).getPropertyValue(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateTree(root) {
|
function getRoundedSize(node) {
|
||||||
|
var boundingRect = node.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
width: Math.round(boundingRect.right) - Math.round(boundingRect.left),
|
||||||
|
height: Math.round(boundingRect.bottom) - Math.round(boundingRect.top)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateTree(root, roundToPixelGrid) {
|
||||||
var rootLayout = [];
|
var rootLayout = [];
|
||||||
|
|
||||||
|
// Any occurrence of "Rounding" mark during node tree traverse turns this feature on for whole subtree.
|
||||||
|
if ((root.getAttribute('experiments') || '').split(' ').indexOf('Rounding') != -1) {
|
||||||
|
roundToPixelGrid = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < root.children.length; i++) {
|
for (var i = 0; i < root.children.length; i++) {
|
||||||
var child = root.children[i];
|
var child = root.children[i];
|
||||||
rootLayout.push({
|
var layout = {
|
||||||
name: child.id !== '' ? child.id : 'INSERT_NAME_HERE',
|
name: child.id !== '' ? child.id : 'INSERT_NAME_HERE',
|
||||||
left: child.offsetLeft + child.parentNode.clientLeft,
|
left: child.offsetLeft + child.parentNode.clientLeft,
|
||||||
top: child.offsetTop + child.parentNode.clientTop,
|
top: child.offsetTop + child.parentNode.clientTop,
|
||||||
width: child.offsetWidth,
|
width: child.offsetWidth,
|
||||||
height: child.offsetHeight,
|
height: child.offsetHeight,
|
||||||
children: calculateTree(child),
|
children: calculateTree(child, roundToPixelGrid),
|
||||||
style: getYogaStyle(child),
|
style: getYogaStyle(child),
|
||||||
declaredStyle: child.style,
|
declaredStyle: child.style,
|
||||||
rawStyle: child.getAttribute('style'),
|
rawStyle: child.getAttribute('style'),
|
||||||
experiments: child.getAttribute('experiments')
|
experiments: child.getAttribute('experiments')
|
||||||
? child.getAttribute('experiments').split(' ')
|
? child.getAttribute('experiments').split(' ')
|
||||||
: [],
|
: [],
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (roundToPixelGrid) {
|
||||||
|
var size = getRoundedSize(child);
|
||||||
|
layout.width = size.width;
|
||||||
|
layout.height = size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
rootLayout.push(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rootLayout;
|
return rootLayout;
|
||||||
|
@@ -48,6 +48,8 @@ Dir['fixtures/*.html'].each do |file|
|
|||||||
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
print logs[4]
|
||||||
|
|
||||||
f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w')
|
f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w')
|
||||||
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
||||||
f.close
|
f.close
|
||||||
|
4
gradle.properties
Normal file
4
gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
bintrayUsername=
|
||||||
|
bintrayApiKey=
|
||||||
|
bintrayGpgPassword=
|
||||||
|
dryRun=false
|
@@ -12,15 +12,15 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def getBintrayUsername() {
|
def getBintrayUsername() {
|
||||||
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
|
return property('bintrayUsername') || System.getenv('BINTRAY_USERNAME')
|
||||||
}
|
}
|
||||||
|
|
||||||
def getBintrayApiKey() {
|
def getBintrayApiKey() {
|
||||||
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
return property('bintrayApiKey') || System.getenv('BINTRAY_API_KEY')
|
||||||
}
|
}
|
||||||
|
|
||||||
def getBintrayGpgPassword() {
|
def getBintrayGpgPassword() {
|
||||||
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
|
return property('bintrayGpgPassword') || System.getenv('BINTRAY_GPG_PASSWORD')
|
||||||
}
|
}
|
||||||
|
|
||||||
def dryRunOnly() {
|
def dryRunOnly() {
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Tue Apr 18 14:49:25 CEST 2017
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
|
172
gradlew
vendored
Executable file
172
gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save ( ) {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
40
java/CMakeLists.txt
Normal file
40
java/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the BSD-style license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
|
# configure import libs
|
||||||
|
set(libfb_DIR ${CMAKE_SOURCE_DIR}/../lib/fb/src/main/cpp)
|
||||||
|
set(yogacore_DIR ${CMAKE_SOURCE_DIR}/..)
|
||||||
|
|
||||||
|
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
|
||||||
|
|
||||||
|
set(libfb_build_DIR ${build_DIR}/libfb/${ANDROID_ABI})
|
||||||
|
set(yogacore_build_DIR ${build_DIR}/yogacore/${ANDROID_ABI})
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY ${build_DIR})
|
||||||
|
|
||||||
|
add_subdirectory(${libfb_DIR} ${libfb_build_DIR})
|
||||||
|
add_subdirectory(${yogacore_DIR} ${yogacore_build_DIR})
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
-fexceptions
|
||||||
|
-Wall
|
||||||
|
-std=c++11)
|
||||||
|
|
||||||
|
add_library(yoga SHARED jni/YGJNI.cpp)
|
||||||
|
|
||||||
|
target_include_directories(yoga PRIVATE
|
||||||
|
${libfb_DIR}/include
|
||||||
|
${yogacore_DIR})
|
||||||
|
|
||||||
|
target_link_libraries(yoga yogacore fb)
|
@@ -1,32 +1,39 @@
|
|||||||
apply plugin: "com.jfrog.bintray"
|
apply plugin: 'com.jfrog.bintray'
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: 'com.github.dcendents.android-maven'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
targetCompatibility = '1.7'
|
version = '1.4.2'
|
||||||
sourceCompatibility = '1.7'
|
|
||||||
|
|
||||||
version = '1.2.0'
|
|
||||||
group = 'com.facebook.yoga'
|
group = 'com.facebook.yoga'
|
||||||
|
|
||||||
// We currently build the native libraries with buck and bundle them together
|
|
||||||
// at this point into the AAR
|
|
||||||
task buckBuildAndCopy(type: Exec) {
|
|
||||||
commandLine '../scripts/build_natives_for_gradle.sh'
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion rootProject.compileSdkVersion
|
||||||
buildToolsVersion "19.1.0"
|
buildToolsVersion rootProject.buildToolsVersion
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 15
|
minSdkVersion rootProject.minSdkVersion
|
||||||
targetSdkVersion 19
|
targetSdkVersion rootProject.targetSdkVersion
|
||||||
|
|
||||||
|
ndk {
|
||||||
|
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path 'CMakeLists.txt'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility rootProject.targetCompatibilityVersion
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility rootProject.sourceCompatibilityVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -39,11 +46,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preBuild.dependsOn buckBuildAndCopy
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(name: 'jsr305')
|
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
||||||
compile(name: 'soloader-0.1.0', ext: 'aar')
|
compile 'com.facebook.soloader:soloader:0.2.0'
|
||||||
|
provided project(':yoga:proguard-annotations')
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
@@ -64,7 +70,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
bintrayName = "com.facebook.yoga:yoga"
|
bintrayName = 'com.facebook.yoga:yoga'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
|
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
|
||||||
|
@@ -18,5 +18,5 @@ public interface YogaBaselineFunction {
|
|||||||
* default to the computed height of the node.
|
* default to the computed height of the node.
|
||||||
*/
|
*/
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
float baseline(YogaNodeAPI node, float width, float height);
|
float baseline(YogaNode node, float width, float height);
|
||||||
}
|
}
|
||||||
|
@@ -46,4 +46,9 @@ public class YogaConfig {
|
|||||||
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
|
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
|
||||||
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
|
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
|
||||||
|
public void setUseWebDefaults(boolean useWebDefaults) {
|
||||||
|
jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ public interface YogaMeasureFunction {
|
|||||||
*/
|
*/
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
long measure(
|
long measure(
|
||||||
YogaNodeAPI node,
|
YogaNode node,
|
||||||
float width,
|
float width,
|
||||||
YogaMeasureMode widthMode,
|
YogaMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
|
@@ -18,7 +18,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
|||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public class YogaNode implements YogaNodeAPI<YogaNode> {
|
public class YogaNode {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SoLoader.loadLibrary("yoga");
|
SoLoader.loadLibrary("yoga");
|
||||||
@@ -42,9 +42,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
private long mNativePointer;
|
private long mNativePointer;
|
||||||
private Object mData;
|
private Object mData;
|
||||||
|
|
||||||
private boolean mHasSetPadding = false;
|
/* Those flags needs be in sync with YGJNI.cpp */
|
||||||
private boolean mHasSetMargin = false;
|
private final static int MARGIN = 1;
|
||||||
private boolean mHasSetBorder = false;
|
private final static int PADDING = 2;
|
||||||
|
private final static int BORDER = 4;
|
||||||
|
|
||||||
|
@DoNotStrip
|
||||||
|
private int mEdgeSetFlag = 0;
|
||||||
|
|
||||||
private boolean mHasSetPosition = false;
|
private boolean mHasSetPosition = false;
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
@@ -81,6 +86,8 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
private float mBorderBottom = 0;
|
private float mBorderBottom = 0;
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
private int mLayoutDirection = 0;
|
private int mLayoutDirection = 0;
|
||||||
|
@DoNotStrip
|
||||||
|
private boolean mHasNewLayout = true;
|
||||||
|
|
||||||
private native long jni_YGNodeNew();
|
private native long jni_YGNodeNew();
|
||||||
public YogaNode() {
|
public YogaNode() {
|
||||||
@@ -99,7 +106,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeFree(long nativePointer);
|
private native void jni_YGNodeFree(long nativePointer);
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
try {
|
try {
|
||||||
jni_YGNodeFree(mNativePointer);
|
jni_YGNodeFree(mNativePointer);
|
||||||
@@ -109,37 +115,45 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeReset(long nativePointer);
|
private native void jni_YGNodeReset(long nativePointer);
|
||||||
@Override
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mHasSetPadding = false;
|
mEdgeSetFlag = 0;
|
||||||
mHasSetMargin = false;
|
|
||||||
mHasSetBorder = false;
|
|
||||||
mHasSetPosition = false;
|
mHasSetPosition = false;
|
||||||
|
mHasNewLayout = true;
|
||||||
|
|
||||||
mWidth = YogaConstants.UNDEFINED;
|
mWidth = YogaConstants.UNDEFINED;
|
||||||
mHeight = YogaConstants.UNDEFINED;
|
mHeight = YogaConstants.UNDEFINED;
|
||||||
mTop = YogaConstants.UNDEFINED;
|
mTop = YogaConstants.UNDEFINED;
|
||||||
mLeft = 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;
|
mLayoutDirection = 0;
|
||||||
|
|
||||||
mMeasureFunction = null;
|
mMeasureFunction = null;
|
||||||
|
mBaselineFunction = null;
|
||||||
mData = null;
|
mData = null;
|
||||||
|
|
||||||
jni_YGNodeReset(mNativePointer);
|
jni_YGNodeReset(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return mChildren == null ? 0 : mChildren.size();
|
return mChildren == null ? 0 : mChildren.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public YogaNode getChildAt(int i) {
|
public YogaNode getChildAt(int i) {
|
||||||
return mChildren.get(i);
|
return mChildren.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||||
@Override
|
|
||||||
public void addChildAt(YogaNode child, int i) {
|
public void addChildAt(YogaNode child, int i) {
|
||||||
if (child.mParent != null) {
|
if (child.mParent != null) {
|
||||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||||
@@ -154,7 +168,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||||
@Override
|
|
||||||
public YogaNode removeChildAt(int i) {
|
public YogaNode removeChildAt(int i) {
|
||||||
|
|
||||||
final YogaNode child = mChildren.remove(i);
|
final YogaNode child = mChildren.remove(i);
|
||||||
@@ -163,292 +176,244 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable
|
public @Nullable
|
||||||
YogaNode getParent() {
|
YogaNode getParent() {
|
||||||
return mParent;
|
return mParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int indexOf(YogaNode child) {
|
public int indexOf(YogaNode child) {
|
||||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
|
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
|
||||||
@Override
|
|
||||||
public void calculateLayout(float width, float height) {
|
public void calculateLayout(float width, float height) {
|
||||||
jni_YGNodeCalculateLayout(mNativePointer, width, height);
|
jni_YGNodeCalculateLayout(mNativePointer, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native boolean jni_YGNodeHasNewLayout(long nativePointer);
|
|
||||||
@Override
|
|
||||||
public boolean hasNewLayout() {
|
public boolean hasNewLayout() {
|
||||||
return jni_YGNodeHasNewLayout(mNativePointer);
|
return mHasNewLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeMarkDirty(long nativePointer);
|
private native void jni_YGNodeMarkDirty(long nativePointer);
|
||||||
@Override
|
|
||||||
public void dirty() {
|
public void dirty() {
|
||||||
jni_YGNodeMarkDirty(mNativePointer);
|
jni_YGNodeMarkDirty(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native boolean jni_YGNodeIsDirty(long nativePointer);
|
private native boolean jni_YGNodeIsDirty(long nativePointer);
|
||||||
@Override
|
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
return jni_YGNodeIsDirty(mNativePointer);
|
return jni_YGNodeIsDirty(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeMarkLayoutSeen(long nativePointer);
|
|
||||||
@Override
|
|
||||||
public void markLayoutSeen() {
|
|
||||||
jni_YGNodeMarkLayoutSeen(mNativePointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||||
@Override
|
|
||||||
public void copyStyle(YogaNode srcNode) {
|
public void copyStyle(YogaNode srcNode) {
|
||||||
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markLayoutSeen() {
|
||||||
|
mHasNewLayout = false;
|
||||||
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetDirection(long nativePointer);
|
private native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaDirection getStyleDirection() {
|
public YogaDirection getStyleDirection() {
|
||||||
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
|
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||||
@Override
|
|
||||||
public void setDirection(YogaDirection direction) {
|
public void setDirection(YogaDirection direction) {
|
||||||
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaFlexDirection getFlexDirection() {
|
public YogaFlexDirection getFlexDirection() {
|
||||||
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||||
@Override
|
|
||||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||||
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaJustify getJustifyContent() {
|
public YogaJustify getJustifyContent() {
|
||||||
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||||
@Override
|
|
||||||
public void setJustifyContent(YogaJustify justifyContent) {
|
public void setJustifyContent(YogaJustify justifyContent) {
|
||||||
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaAlign getAlignItems() {
|
public YogaAlign getAlignItems() {
|
||||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
|
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||||
@Override
|
|
||||||
public void setAlignItems(YogaAlign alignItems) {
|
public void setAlignItems(YogaAlign alignItems) {
|
||||||
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaAlign getAlignSelf() {
|
public YogaAlign getAlignSelf() {
|
||||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||||
@Override
|
|
||||||
public void setAlignSelf(YogaAlign alignSelf) {
|
public void setAlignSelf(YogaAlign alignSelf) {
|
||||||
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaAlign getAlignContent() {
|
public YogaAlign getAlignContent() {
|
||||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
|
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||||
@Override
|
|
||||||
public void setAlignContent(YogaAlign alignContent) {
|
public void setAlignContent(YogaAlign alignContent) {
|
||||||
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaPositionType getPositionType() {
|
public YogaPositionType getPositionType() {
|
||||||
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
|
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||||
@Override
|
|
||||||
public void setPositionType(YogaPositionType positionType) {
|
public void setPositionType(YogaPositionType positionType) {
|
||||||
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||||
@Override
|
|
||||||
public void setWrap(YogaWrap flexWrap) {
|
public void setWrap(YogaWrap flexWrap) {
|
||||||
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaOverflow getOverflow() {
|
public YogaOverflow getOverflow() {
|
||||||
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
|
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||||
@Override
|
|
||||||
public void setOverflow(YogaOverflow overflow) {
|
public void setOverflow(YogaOverflow overflow) {
|
||||||
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
private native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaDisplay getDisplay() {
|
public YogaDisplay getDisplay() {
|
||||||
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
|
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
||||||
@Override
|
|
||||||
public void setDisplay(YogaDisplay display) {
|
public void setDisplay(YogaDisplay display) {
|
||||||
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
||||||
@Override
|
|
||||||
public void setFlex(float flex) {
|
public void setFlex(float flex) {
|
||||||
jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
||||||
@Override
|
|
||||||
public float getFlexGrow() {
|
public float getFlexGrow() {
|
||||||
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||||
@Override
|
|
||||||
public void setFlexGrow(float flexGrow) {
|
public void setFlexGrow(float flexGrow) {
|
||||||
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
||||||
@Override
|
|
||||||
public float getFlexShrink() {
|
public float getFlexShrink() {
|
||||||
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||||
@Override
|
|
||||||
public void setFlexShrink(float flexShrink) {
|
public void setFlexShrink(float flexShrink) {
|
||||||
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getFlexBasis() {
|
public YogaValue getFlexBasis() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||||
@Override
|
|
||||||
public void setFlexBasis(float flexBasis) {
|
public void setFlexBasis(float flexBasis) {
|
||||||
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setFlexBasisPercent(float percent) {
|
public void setFlexBasisPercent(float percent) {
|
||||||
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
private native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
||||||
@Override
|
|
||||||
public void setFlexBasisAuto() {
|
public void setFlexBasisAuto() {
|
||||||
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||||
@Override
|
|
||||||
public YogaValue getMargin(YogaEdge edge) {
|
public YogaValue getMargin(YogaEdge edge) {
|
||||||
if (!mHasSetMargin) {
|
if (!((mEdgeSetFlag & MARGIN) == MARGIN)) {
|
||||||
return YogaValue.UNDEFINED;
|
return YogaValue.UNDEFINED;
|
||||||
}
|
}
|
||||||
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||||
@Override
|
|
||||||
public void setMargin(YogaEdge edge, float margin) {
|
public void setMargin(YogaEdge edge, float margin) {
|
||||||
mHasSetMargin = true;
|
mEdgeSetFlag |= MARGIN;
|
||||||
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
||||||
@Override
|
|
||||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||||
mHasSetMargin = true;
|
mEdgeSetFlag |= MARGIN;
|
||||||
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
private native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
||||||
@Override
|
|
||||||
public void setMarginAuto(YogaEdge edge) {
|
public void setMarginAuto(YogaEdge edge) {
|
||||||
mHasSetMargin = true;
|
mEdgeSetFlag |= MARGIN;
|
||||||
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||||
@Override
|
|
||||||
public YogaValue getPadding(YogaEdge edge) {
|
public YogaValue getPadding(YogaEdge edge) {
|
||||||
if (!mHasSetPadding) {
|
if (!((mEdgeSetFlag & PADDING) == PADDING)) {
|
||||||
return YogaValue.UNDEFINED;
|
return YogaValue.UNDEFINED;
|
||||||
}
|
}
|
||||||
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||||
@Override
|
|
||||||
public void setPadding(YogaEdge edge, float padding) {
|
public void setPadding(YogaEdge edge, float padding) {
|
||||||
mHasSetPadding = true;
|
mEdgeSetFlag |= PADDING;
|
||||||
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
||||||
@Override
|
|
||||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||||
mHasSetPadding = true;
|
mEdgeSetFlag |= PADDING;
|
||||||
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||||
@Override
|
|
||||||
public float getBorder(YogaEdge edge) {
|
public float getBorder(YogaEdge edge) {
|
||||||
if (!mHasSetBorder) {
|
if (!((mEdgeSetFlag & BORDER) == BORDER)) {
|
||||||
return YogaConstants.UNDEFINED;
|
return YogaConstants.UNDEFINED;
|
||||||
}
|
}
|
||||||
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||||
@Override
|
|
||||||
public void setBorder(YogaEdge edge, float border) {
|
public void setBorder(YogaEdge edge, float border) {
|
||||||
mHasSetBorder = true;
|
mEdgeSetFlag |= BORDER;
|
||||||
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||||
@Override
|
|
||||||
public YogaValue getPosition(YogaEdge edge) {
|
public YogaValue getPosition(YogaEdge edge) {
|
||||||
if (!mHasSetPosition) {
|
if (!mHasSetPosition) {
|
||||||
return YogaValue.UNDEFINED;
|
return YogaValue.UNDEFINED;
|
||||||
@@ -457,135 +422,113 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||||
@Override
|
|
||||||
public void setPosition(YogaEdge edge, float position) {
|
public void setPosition(YogaEdge edge, float position) {
|
||||||
mHasSetPosition = true;
|
mHasSetPosition = true;
|
||||||
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
||||||
@Override
|
|
||||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||||
mHasSetPosition = true;
|
mHasSetPosition = true;
|
||||||
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
|
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getWidth() {
|
public YogaValue getWidth() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
||||||
@Override
|
|
||||||
public void setWidth(float width) {
|
public void setWidth(float width) {
|
||||||
jni_YGNodeStyleSetWidth(mNativePointer, width);
|
jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setWidthPercent(float percent) {
|
public void setWidthPercent(float percent) {
|
||||||
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
private native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
||||||
@Override
|
|
||||||
public void setWidthAuto() {
|
public void setWidthAuto() {
|
||||||
jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
|
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getHeight() {
|
public YogaValue getHeight() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
||||||
@Override
|
|
||||||
public void setHeight(float height) {
|
public void setHeight(float height) {
|
||||||
jni_YGNodeStyleSetHeight(mNativePointer, height);
|
jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setHeightPercent(float percent) {
|
public void setHeightPercent(float percent) {
|
||||||
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
private native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
||||||
@Override
|
|
||||||
public void setHeightAuto() {
|
public void setHeightAuto() {
|
||||||
jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
|
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getMinWidth() {
|
public YogaValue getMinWidth() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||||
@Override
|
|
||||||
public void setMinWidth(float minWidth) {
|
public void setMinWidth(float minWidth) {
|
||||||
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setMinWidthPercent(float percent) {
|
public void setMinWidthPercent(float percent) {
|
||||||
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
|
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getMinHeight() {
|
public YogaValue getMinHeight() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||||
@Override
|
|
||||||
public void setMinHeight(float minHeight) {
|
public void setMinHeight(float minHeight) {
|
||||||
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setMinHeightPercent(float percent) {
|
public void setMinHeightPercent(float percent) {
|
||||||
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getMaxWidth() {
|
public YogaValue getMaxWidth() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||||
@Override
|
|
||||||
public void setMaxWidth(float maxWidth) {
|
public void setMaxWidth(float maxWidth) {
|
||||||
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setMaxWidthPercent(float percent) {
|
public void setMaxWidthPercent(float percent) {
|
||||||
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
||||||
@Override
|
|
||||||
public YogaValue getMaxHeight() {
|
public YogaValue getMaxHeight() {
|
||||||
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
|
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||||
@Override
|
|
||||||
public void setMaxHeight(float maxheight) {
|
public void setMaxHeight(float maxheight) {
|
||||||
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
||||||
@Override
|
|
||||||
public void setMaxHeightPercent(float percent) {
|
public void setMaxHeightPercent(float percent) {
|
||||||
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
||||||
}
|
}
|
||||||
@@ -600,27 +543,22 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutX() {
|
public float getLayoutX() {
|
||||||
return mLeft;
|
return mLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutY() {
|
public float getLayoutY() {
|
||||||
return mTop;
|
return mTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutWidth() {
|
public float getLayoutWidth() {
|
||||||
return mWidth;
|
return mWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutHeight() {
|
public float getLayoutHeight() {
|
||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutMargin(YogaEdge edge) {
|
public float getLayoutMargin(YogaEdge edge) {
|
||||||
switch (edge) {
|
switch (edge) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@@ -640,7 +578,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutPadding(YogaEdge edge) {
|
public float getLayoutPadding(YogaEdge edge) {
|
||||||
switch (edge) {
|
switch (edge) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@@ -660,7 +597,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutBorder(YogaEdge edge) {
|
public float getLayoutBorder(YogaEdge edge) {
|
||||||
switch (edge) {
|
switch (edge) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
@@ -680,13 +616,11 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public YogaDirection getLayoutDirection() {
|
public YogaDirection getLayoutDirection() {
|
||||||
return YogaDirection.fromInt(mLayoutDirection);
|
return YogaDirection.fromInt(mLayoutDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||||
@Override
|
|
||||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||||
mMeasureFunction = measureFunction;
|
mMeasureFunction = measureFunction;
|
||||||
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||||
@@ -712,7 +646,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||||
@Override
|
|
||||||
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
||||||
mBaselineFunction = baselineFunction;
|
mBaselineFunction = baselineFunction;
|
||||||
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
||||||
@@ -723,17 +656,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
return mBaselineFunction.baseline(this, width, height);
|
return mBaselineFunction.baseline(this, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMeasureDefined() {
|
public boolean isMeasureDefined() {
|
||||||
return mMeasureFunction != null;
|
return mMeasureFunction != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setData(Object data) {
|
public void setData(Object data) {
|
||||||
mData = data;
|
mData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getData() {
|
public Object getData() {
|
||||||
return mData;
|
return mData;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user