Compare commits
64 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2c91e1e7d2 | ||
|
c3982b6c1e | ||
|
ae33c6c19c | ||
|
bcd68b997f | ||
|
fcfa1b9f01 | ||
|
d9a0822517 | ||
|
097e99b699 | ||
|
ff7bec703b | ||
|
c7ab004922 | ||
|
91230ae177 | ||
|
40eba60cf5 | ||
|
fb4cfed20d | ||
|
d3a9a84ac4 | ||
|
accad5366f | ||
|
8eca67e257 | ||
|
40e1bf6ce3 | ||
|
7b89a1dd48 | ||
|
203577724e | ||
|
e3dbef7cbd | ||
|
0ee3303791 | ||
|
83fddd8af6 | ||
|
77c05b5ff6 | ||
|
7c324f058c | ||
|
3db38f2a80 | ||
|
f6b17183c5 | ||
|
8f9d7e243e | ||
|
fde4db9383 | ||
|
3178e3bf15 | ||
|
cdfd05c742 | ||
|
76f6a54327 | ||
|
c91e4b3566 | ||
|
e24561bcef | ||
|
363e941867 | ||
|
3fb2c1888c | ||
|
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 |
@@ -1,7 +1,7 @@
|
||||
[cxx]
|
||||
gtest_dep = //lib/gtest:gtest
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:19
|
||||
target = android-23
|
||||
[ndk]
|
||||
ndk_version = 13.1.3345770
|
||||
compiler = clang
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -63,3 +63,5 @@ Carthage/Build
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
# NDK/CMake
|
||||
.externalNativeBuild
|
||||
|
12
.travis.yml
12
.travis.yml
@@ -19,9 +19,9 @@ env:
|
||||
- TARGET=android
|
||||
|
||||
before_install:
|
||||
- openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties
|
||||
- brew update > /dev/null
|
||||
- brew tap facebook/fb
|
||||
- brew install buck
|
||||
- brew install --HEAD facebook/fb/buck
|
||||
|
||||
# Java
|
||||
- |
|
||||
@@ -53,8 +53,8 @@ before_install:
|
||||
if [[ $TARGET = "js" ]]; then
|
||||
wget -O /tmp/emsdk-portable.tar.gz https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz &&
|
||||
tar xf /tmp/emsdk-portable.tar.gz -C /tmp/ &&
|
||||
/tmp/emsdk_portable/emsdk install latest >& /dev/null &&
|
||||
/tmp/emsdk_portable/emsdk activate latest
|
||||
/tmp/emsdk-portable/emsdk install latest 2>&1 | grep -v '^x ' &&
|
||||
/tmp/emsdk-portable/emsdk activate latest
|
||||
fi
|
||||
|
||||
# Android
|
||||
@@ -63,7 +63,7 @@ before_install:
|
||||
brew cask install java;
|
||||
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);
|
||||
export PATH=$JAVA_HOME/bin:$PATH;
|
||||
brew install android-sdk;
|
||||
brew install caskroom/cask/android-sdk;
|
||||
export ANDROID_SDK=/usr/local/Cellar/android-sdk/24.4.1_1;
|
||||
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1;
|
||||
brew install lib32stdc++6 lib32z1;
|
||||
@@ -77,7 +77,7 @@ before_install:
|
||||
cd javascript &&
|
||||
npm install &&
|
||||
unset CC && unset CXX && unset LINK &&
|
||||
source /tmp/emsdk_portable/emsdk_env.sh &&
|
||||
source /tmp/emsdk-portable/emsdk_env.sh &&
|
||||
npm run build:browser
|
||||
) fi
|
||||
|
||||
|
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)
|
@@ -9,6 +9,7 @@ SOLOADER_TARGET = '//lib/soloader:soloader'
|
||||
GTEST_TARGET = '//lib/gtest:gtest'
|
||||
JNI_TARGET = '//lib/jni:jni'
|
||||
FBJNI_TARGET = '//lib/fb:fbjni'
|
||||
FBJNI_JAVA_TARGET = '//lib/fb/src/main/java/com/facebook/jni:jni'
|
||||
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
|
||||
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
|
||||
ANDROID_TARGET = '//android:android'
|
||||
|
@@ -15,11 +15,11 @@ podspec = Pod::Spec.new do |spec|
|
||||
}
|
||||
|
||||
spec.platform = :ios
|
||||
spec.ios.deployment_target = '8.0'
|
||||
spec.ios.deployment_target = '7.0'
|
||||
spec.ios.frameworks = 'UIKit'
|
||||
|
||||
spec.dependency 'Yoga', '~> 1.3'
|
||||
spec.source_files = 'YogaKit/Source/*.{h,m}'
|
||||
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
|
||||
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
|
||||
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
|
||||
end
|
||||
|
@@ -9,6 +9,17 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <yoga/YGEnums.h>
|
||||
#import <yoga/Yoga.h>
|
||||
|
||||
extern YGValue YGPointValue(CGFloat value)
|
||||
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
||||
extern YGValue YGPercentValue(CGFloat value)
|
||||
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
|
||||
|
||||
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
|
||||
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
|
||||
YGDimensionFlexibilityFlexibleHeigth = 1 << 1,
|
||||
};
|
||||
|
||||
@interface YGLayout : NSObject
|
||||
|
||||
@@ -36,34 +47,34 @@
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
|
||||
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
|
||||
@property (nonatomic, readwrite, assign) CGFloat flexBasis;
|
||||
@property (nonatomic, readwrite, assign) YGValue flexBasis;
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat left;
|
||||
@property (nonatomic, readwrite, assign) CGFloat top;
|
||||
@property (nonatomic, readwrite, assign) CGFloat right;
|
||||
@property (nonatomic, readwrite, assign) CGFloat bottom;
|
||||
@property (nonatomic, readwrite, assign) CGFloat start;
|
||||
@property (nonatomic, readwrite, assign) CGFloat end;
|
||||
@property (nonatomic, readwrite, assign) YGValue left;
|
||||
@property (nonatomic, readwrite, assign) YGValue top;
|
||||
@property (nonatomic, readwrite, assign) YGValue right;
|
||||
@property (nonatomic, readwrite, assign) YGValue bottom;
|
||||
@property (nonatomic, readwrite, assign) YGValue start;
|
||||
@property (nonatomic, readwrite, assign) YGValue end;
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginLeft;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginTop;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginRight;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginBottom;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginStart;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginEnd;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginHorizontal;
|
||||
@property (nonatomic, readwrite, assign) CGFloat marginVertical;
|
||||
@property (nonatomic, readwrite, assign) CGFloat margin;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginLeft;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginTop;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginRight;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginBottom;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginStart;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginEnd;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
|
||||
@property (nonatomic, readwrite, assign) YGValue marginVertical;
|
||||
@property (nonatomic, readwrite, assign) YGValue margin;
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingLeft;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingTop;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingRight;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingBottom;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingStart;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingEnd;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingHorizontal;
|
||||
@property (nonatomic, readwrite, assign) CGFloat paddingVertical;
|
||||
@property (nonatomic, readwrite, assign) CGFloat padding;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingTop;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingRight;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingStart;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
|
||||
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
|
||||
@property (nonatomic, readwrite, assign) YGValue padding;
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
|
||||
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
|
||||
@@ -73,12 +84,12 @@
|
||||
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
|
||||
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
|
||||
|
||||
@property (nonatomic, readwrite, assign) CGFloat width;
|
||||
@property (nonatomic, readwrite, assign) CGFloat height;
|
||||
@property (nonatomic, readwrite, assign) CGFloat minWidth;
|
||||
@property (nonatomic, readwrite, assign) CGFloat minHeight;
|
||||
@property (nonatomic, readwrite, assign) CGFloat maxWidth;
|
||||
@property (nonatomic, readwrite, assign) CGFloat maxHeight;
|
||||
@property (nonatomic, readwrite, assign) YGValue width;
|
||||
@property (nonatomic, readwrite, assign) YGValue height;
|
||||
@property (nonatomic, readwrite, assign) YGValue minWidth;
|
||||
@property (nonatomic, readwrite, assign) YGValue minHeight;
|
||||
@property (nonatomic, readwrite, assign) YGValue maxWidth;
|
||||
@property (nonatomic, readwrite, assign) YGValue maxHeight;
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
|
||||
@@ -95,6 +106,14 @@
|
||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
|
||||
|
||||
/**
|
||||
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
|
||||
If the origin is not preserved, the root view's layout results will applied from {0,0}.
|
||||
*/
|
||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
|
||||
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
|
||||
|
||||
/**
|
||||
Returns the size of the view if no constraints were given. This could equivalent to calling [self
|
||||
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
|
||||
|
@@ -22,23 +22,27 @@
|
||||
}
|
||||
|
||||
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
|
||||
- (CGFloat)lowercased_name \
|
||||
- (YGValue)lowercased_name \
|
||||
{ \
|
||||
YGValue value = YGNodeStyleGet##capitalized_name(self.node); \
|
||||
if (value.unit == YGUnitPoint) { \
|
||||
return value.value; \
|
||||
} else { \
|
||||
return YGUndefined; \
|
||||
} \
|
||||
return YGNodeStyleGet##capitalized_name(self.node); \
|
||||
} \
|
||||
\
|
||||
- (void)set##capitalized_name:(CGFloat)lowercased_name \
|
||||
- (void)set##capitalized_name:(YGValue)lowercased_name \
|
||||
{ \
|
||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
|
||||
switch (lowercased_name.unit) { \
|
||||
case YGUnitPoint: \
|
||||
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
|
||||
break; \
|
||||
case YGUnitPercent: \
|
||||
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
|
||||
break; \
|
||||
default: \
|
||||
NSAssert(NO, @"Not implemented"); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
|
||||
- (CGFloat)lowercased_name \
|
||||
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
|
||||
- (type)lowercased_name \
|
||||
{ \
|
||||
return YGNodeStyleGet##property(self.node, edge); \
|
||||
}
|
||||
@@ -50,28 +54,26 @@
|
||||
}
|
||||
|
||||
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
||||
YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
|
||||
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
|
||||
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||
|
||||
#define YG_VALUE_EDGE_PROPERTY_GETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
||||
- (CGFloat)objc_lowercased_name \
|
||||
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
||||
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
|
||||
{ \
|
||||
YGValue value = YGNodeStyleGet##c_name(self.node, edge); \
|
||||
if (value.unit == YGUnitPoint) { \
|
||||
return value.value; \
|
||||
} else { \
|
||||
return YGUndefined; \
|
||||
switch (objc_lowercased_name.unit) { \
|
||||
case YGUnitPoint: \
|
||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
|
||||
break; \
|
||||
case YGUnitPercent: \
|
||||
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
|
||||
break; \
|
||||
default: \
|
||||
NSAssert(NO, @"Not implemented"); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
|
||||
- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \
|
||||
{ \
|
||||
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \
|
||||
}
|
||||
|
||||
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
|
||||
YG_VALUE_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
|
||||
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
|
||||
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
|
||||
|
||||
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
|
||||
@@ -85,6 +87,16 @@ YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal
|
||||
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
|
||||
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
|
||||
|
||||
YGValue YGPointValue(CGFloat value)
|
||||
{
|
||||
return (YGValue) { .value = value, .unit = YGUnitPoint };
|
||||
}
|
||||
|
||||
YGValue YGPercentValue(CGFloat value)
|
||||
{
|
||||
return (YGValue) { .value = value, .unit = YGUnitPercent };
|
||||
}
|
||||
|
||||
static YGConfigRef globalConfig;
|
||||
|
||||
@interface YGLayout ()
|
||||
@@ -103,6 +115,7 @@ static YGConfigRef globalConfig;
|
||||
{
|
||||
globalConfig = YGConfigNew();
|
||||
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
|
||||
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
|
||||
}
|
||||
|
||||
- (instancetype)initWithView:(UIView*)view
|
||||
@@ -235,6 +248,20 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
|
||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||
}
|
||||
|
||||
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
|
||||
{
|
||||
CGSize size = self.view.bounds.size;
|
||||
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
|
||||
size.width = YGUndefined;
|
||||
}
|
||||
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeigth) {
|
||||
size.height = YGUndefined;
|
||||
}
|
||||
[self calculateLayoutWithSize:size];
|
||||
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
|
||||
}
|
||||
|
||||
|
||||
- (CGSize)intrinsicSize
|
||||
{
|
||||
const CGSize constrainedSize = {
|
||||
|
46
YogaKit/Source/YGLayoutExtensions.swift
Normal file
46
YogaKit/Source/YGLayoutExtensions.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
postfix operator %
|
||||
|
||||
extension Int {
|
||||
public static postfix func %(value: Int) -> YGValue {
|
||||
return YGValue(value: Float(value), unit: .percent)
|
||||
}
|
||||
}
|
||||
|
||||
extension Float {
|
||||
public static postfix func %(value: Float) -> YGValue {
|
||||
return YGValue(value: value, unit: .percent)
|
||||
}
|
||||
}
|
||||
|
||||
extension CGFloat {
|
||||
public static postfix func %(value: CGFloat) -> YGValue {
|
||||
return YGValue(value: Float(value), unit: .percent)
|
||||
}
|
||||
}
|
||||
|
||||
extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
|
||||
public init(integerLiteral value: Int) {
|
||||
self = YGValue(value: Float(value), unit: .point)
|
||||
}
|
||||
|
||||
public init(floatLiteral value: Float) {
|
||||
self = YGValue(value: value, unit: .point)
|
||||
}
|
||||
|
||||
public init(_ value: Float) {
|
||||
self = YGValue(value: value, unit: .point)
|
||||
}
|
||||
|
||||
public init(_ value: CGFloat) {
|
||||
self = YGValue(value: Float(value), unit: .point)
|
||||
}
|
||||
}
|
@@ -21,7 +21,8 @@
|
||||
- (void)testConfigureLayoutIsNoOpWithNilBlock
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
XCTAssertNoThrow([view configureLayoutWithBlock:nil]);
|
||||
id block = nil;
|
||||
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
|
||||
}
|
||||
|
||||
- (void)testConfigureLayoutBlockWorksWithValidBlock
|
||||
@@ -30,11 +31,11 @@
|
||||
[view configureLayoutWithBlock:^(YGLayout *layout){
|
||||
XCTAssertNotNil(layout);
|
||||
layout.isEnabled = YES;
|
||||
layout.width = 25;
|
||||
layout.width = YGPointValue(25);
|
||||
}];
|
||||
|
||||
XCTAssertTrue(view.yoga.isEnabled);
|
||||
XCTAssertEqual(view.yoga.width, 25);
|
||||
XCTAssertEqual(view.yoga.width.value, 25);
|
||||
}
|
||||
|
||||
- (void)testNodesAreDeallocedWithSingleView
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
@autoreleasepool {
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
view.yoga.flexBasis = 1;
|
||||
view.yoga.flexBasis = YGPointValue(1);
|
||||
|
||||
layoutRef = view.yoga;
|
||||
XCTAssertNotNil(layoutRef);
|
||||
@@ -62,11 +63,11 @@
|
||||
@autoreleasepool {
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
topLayout = view.yoga;
|
||||
topLayout.flexBasis = 1;
|
||||
topLayout.flexBasis = YGPointValue(1);
|
||||
|
||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subviewLayout = subview.yoga;
|
||||
subviewLayout.flexBasis = 1;
|
||||
subviewLayout.flexBasis = YGPointValue(1);
|
||||
|
||||
view = nil;
|
||||
}
|
||||
@@ -112,9 +113,9 @@
|
||||
|
||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
textBadgeView.yoga.isEnabled = YES;
|
||||
textBadgeView.yoga.margin = 0;
|
||||
textBadgeView.yoga.width = 10;
|
||||
textBadgeView.yoga.height = 10;
|
||||
textBadgeView.yoga.margin = YGPointValue(0);
|
||||
textBadgeView.yoga.width = YGPointValue(10);
|
||||
textBadgeView.yoga.height = YGPointValue(10);
|
||||
[container addSubview:textBadgeView];
|
||||
|
||||
const CGSize textBadgeViewSize = textBadgeView.yoga.intrinsicSize;
|
||||
@@ -135,14 +136,14 @@
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
view.yoga.isEnabled = YES;
|
||||
view.yoga.flexBasis = 0;
|
||||
view.yoga.flexBasis = YGPointValue(0);
|
||||
view.yoga.flexGrow = 1;
|
||||
[container addSubview:view];
|
||||
|
||||
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
view2.yoga.isEnabled = YES;
|
||||
view2.yoga.marginTop = 25;
|
||||
view2.yoga.flexBasis = 0;
|
||||
view2.yoga.marginTop = YGPointValue(25);
|
||||
view2.yoga.flexBasis = YGPointValue(0);
|
||||
view2.yoga.flexGrow = 1;
|
||||
[container addSubview:view2];
|
||||
|
||||
@@ -153,6 +154,54 @@
|
||||
XCTAssertEqual(25, view2.frame.origin.y);
|
||||
}
|
||||
|
||||
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||
container.yoga.isEnabled = YES;
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||
view.yoga.isEnabled = YES;
|
||||
view.yoga.width = YGPointValue(100);
|
||||
view.yoga.height = YGPointValue(100);
|
||||
[container addSubview:view];
|
||||
|
||||
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
|
||||
XCTAssertEqual(100, container.frame.size.width);
|
||||
XCTAssertEqual(200, container.frame.size.height);
|
||||
}
|
||||
|
||||
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
|
||||
container.yoga.isEnabled = YES;
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||
view.yoga.isEnabled = YES;
|
||||
view.yoga.width = YGPointValue(100);
|
||||
view.yoga.height = YGPointValue(100);
|
||||
[container addSubview:view];
|
||||
|
||||
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility: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 = YGPointValue(100);
|
||||
view.yoga.height = YGPointValue(100);
|
||||
[container addSubview:view];
|
||||
|
||||
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth | YGDimensionFlexibilityFlexibleHeigth];
|
||||
XCTAssertEqual(100, container.frame.size.width);
|
||||
XCTAssertEqual(100, container.frame.size.height);
|
||||
}
|
||||
|
||||
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
|
||||
{
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
@@ -388,12 +437,12 @@
|
||||
XCTAssertTrue(view.yoga.isLeaf);
|
||||
|
||||
view.yoga.isEnabled = YES;
|
||||
view.yoga.width = 50.0;
|
||||
view.yoga.width = YGPointValue(50);
|
||||
XCTAssertTrue(view.yoga.isLeaf);
|
||||
|
||||
UIView *const subview = view.subviews[0];
|
||||
subview.yoga.isEnabled = YES;
|
||||
subview.yoga.width = 50.0;
|
||||
subview.yoga.width = YGPointValue(50);
|
||||
XCTAssertFalse(view.yoga.isLeaf);
|
||||
}
|
||||
|
||||
@@ -405,14 +454,14 @@
|
||||
|
||||
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subview1.yoga.isEnabled = YES;
|
||||
subview1.yoga.width = 100;
|
||||
subview1.yoga.width = YGPointValue(100);
|
||||
subview1.yoga.flexGrow = 1;
|
||||
subview1.yoga.flexDirection = YGFlexDirectionColumn;
|
||||
[container addSubview:subview1];
|
||||
|
||||
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
subview2.yoga.isEnabled = YES;
|
||||
subview2.yoga.width = 150;
|
||||
subview2.yoga.width = YGPointValue(150);
|
||||
subview2.yoga.flexGrow = 1;
|
||||
subview2.yoga.flexDirection = YGFlexDirectionColumn;
|
||||
[container addSubview:subview2];
|
||||
@@ -473,155 +522,195 @@
|
||||
[container.yoga applyLayoutPreservingOrigin:YES];
|
||||
}
|
||||
|
||||
- (void)testPointPercent
|
||||
{
|
||||
XCTAssertEqual(YGPointValue(1).value, 1);
|
||||
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
|
||||
XCTAssertEqual(YGPercentValue(2).value, 2);
|
||||
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
|
||||
}
|
||||
|
||||
- (void)testPositionalPropertiesWork
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
|
||||
view.yoga.left = 1;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.left, 1);
|
||||
view.yoga.left = YGPointValue(1);
|
||||
XCTAssertEqual(view.yoga.left.value, 1);
|
||||
XCTAssertEqual(view.yoga.left.unit, YGUnitPoint);
|
||||
view.yoga.left = YGPercentValue(2);
|
||||
XCTAssertEqual(view.yoga.left.value, 2);
|
||||
XCTAssertEqual(view.yoga.left.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.right = 2;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.right, 2);
|
||||
view.yoga.right = YGPointValue(3);
|
||||
XCTAssertEqual(view.yoga.right.value, 3);
|
||||
XCTAssertEqual(view.yoga.right.unit, YGUnitPoint);
|
||||
view.yoga.right = YGPercentValue(4);
|
||||
XCTAssertEqual(view.yoga.right.value, 4);
|
||||
XCTAssertEqual(view.yoga.right.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.top = 3;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.top, 3);
|
||||
view.yoga.top = YGPointValue(5);
|
||||
XCTAssertEqual(view.yoga.top.value, 5);
|
||||
XCTAssertEqual(view.yoga.top.unit, YGUnitPoint);
|
||||
view.yoga.top = YGPercentValue(6);
|
||||
XCTAssertEqual(view.yoga.top.value, 6);
|
||||
XCTAssertEqual(view.yoga.top.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.bottom = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.bottom, 4);
|
||||
view.yoga.bottom = YGPointValue(7);
|
||||
XCTAssertEqual(view.yoga.bottom.value, 7);
|
||||
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPoint);
|
||||
view.yoga.bottom = YGPercentValue(8);
|
||||
XCTAssertEqual(view.yoga.bottom.value, 8);
|
||||
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.start = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.start, 5);
|
||||
view.yoga.start = YGPointValue(9);
|
||||
XCTAssertEqual(view.yoga.start.value, 9);
|
||||
XCTAssertEqual(view.yoga.start.unit, YGUnitPoint);
|
||||
view.yoga.start = YGPercentValue(10);
|
||||
XCTAssertEqual(view.yoga.start.value, 10);
|
||||
XCTAssertEqual(view.yoga.start.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.end = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.end, 6);
|
||||
view.yoga.end = YGPointValue(11);
|
||||
XCTAssertEqual(view.yoga.end.value, 11);
|
||||
XCTAssertEqual(view.yoga.end.unit, YGUnitPoint);
|
||||
view.yoga.end = YGPercentValue(12);
|
||||
XCTAssertEqual(view.yoga.end.value, 12);
|
||||
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
|
||||
}
|
||||
|
||||
- (void)testMarginPropertiesWork
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
|
||||
view.yoga.margin = 1;
|
||||
XCTAssertEqual(view.yoga.margin, 1);
|
||||
XCTAssertTrue(isnan(view.yoga.marginLeft));
|
||||
XCTAssertTrue(isnan(view.yoga.marginRight));
|
||||
XCTAssertTrue(isnan(view.yoga.marginStart));
|
||||
XCTAssertTrue(isnan(view.yoga.marginEnd));
|
||||
XCTAssertTrue(isnan(view.yoga.marginTop));
|
||||
XCTAssertTrue(isnan(view.yoga.marginBottom));
|
||||
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
|
||||
XCTAssertTrue(isnan(view.yoga.marginVertical));
|
||||
view.yoga.margin = YGPointValue(1);
|
||||
XCTAssertEqual(view.yoga.margin.value, 1);
|
||||
XCTAssertEqual(view.yoga.margin.unit, YGUnitPoint);
|
||||
view.yoga.margin = YGPercentValue(2);
|
||||
XCTAssertEqual(view.yoga.margin.value, 2);
|
||||
XCTAssertEqual(view.yoga.margin.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginHorizontal = 2;
|
||||
XCTAssertEqual(view.yoga.marginHorizontal, 2);
|
||||
XCTAssertTrue(isnan(view.yoga.marginLeft));
|
||||
XCTAssertTrue(isnan(view.yoga.marginRight));
|
||||
XCTAssertTrue(isnan(view.yoga.marginStart));
|
||||
XCTAssertTrue(isnan(view.yoga.marginEnd));
|
||||
view.yoga.marginHorizontal = YGPointValue(3);
|
||||
XCTAssertEqual(view.yoga.marginHorizontal.value, 3);
|
||||
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPoint);
|
||||
view.yoga.marginHorizontal = YGPercentValue(4);
|
||||
XCTAssertEqual(view.yoga.marginHorizontal.value, 4);
|
||||
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginVertical = 3;
|
||||
XCTAssertEqual(view.yoga.marginVertical, 3);
|
||||
XCTAssertTrue(isnan(view.yoga.marginTop));
|
||||
XCTAssertTrue(isnan(view.yoga.marginBottom));
|
||||
view.yoga.marginVertical = YGPointValue(5);
|
||||
XCTAssertEqual(view.yoga.marginVertical.value, 5);
|
||||
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPoint);
|
||||
view.yoga.marginVertical = YGPercentValue(6);
|
||||
XCTAssertEqual(view.yoga.marginVertical.value, 6);
|
||||
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginLeft = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginLeft, 4);
|
||||
view.yoga.marginLeft = YGPointValue(7);
|
||||
XCTAssertEqual(view.yoga.marginLeft.value, 7);
|
||||
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPoint);
|
||||
view.yoga.marginLeft = YGPercentValue(8);
|
||||
XCTAssertEqual(view.yoga.marginLeft.value, 8);
|
||||
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginRight = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginRight, 5);
|
||||
view.yoga.marginRight = YGPointValue(9);
|
||||
XCTAssertEqual(view.yoga.marginRight.value, 9);
|
||||
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPoint);
|
||||
view.yoga.marginRight = YGPercentValue(10);
|
||||
XCTAssertEqual(view.yoga.marginRight.value, 10);
|
||||
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginTop = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginTop, 6);
|
||||
view.yoga.marginTop = YGPointValue(11);
|
||||
XCTAssertEqual(view.yoga.marginTop.value, 11);
|
||||
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPoint);
|
||||
view.yoga.marginTop = YGPercentValue(12);
|
||||
XCTAssertEqual(view.yoga.marginTop.value, 12);
|
||||
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginBottom = 7;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginBottom, 7);
|
||||
view.yoga.marginBottom = YGPointValue(13);
|
||||
XCTAssertEqual(view.yoga.marginBottom.value, 13);
|
||||
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPoint);
|
||||
view.yoga.marginBottom = YGPercentValue(14);
|
||||
XCTAssertEqual(view.yoga.marginBottom.value, 14);
|
||||
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginStart = 8;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginStart, 8);
|
||||
view.yoga.marginStart = YGPointValue(15);
|
||||
XCTAssertEqual(view.yoga.marginStart.value, 15);
|
||||
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPoint);
|
||||
view.yoga.marginStart = YGPercentValue(16);
|
||||
XCTAssertEqual(view.yoga.marginStart.value, 16);
|
||||
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.marginEnd = 9;
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9);
|
||||
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.marginEnd, 9);
|
||||
view.yoga.marginEnd = YGPointValue(17);
|
||||
XCTAssertEqual(view.yoga.marginEnd.value, 17);
|
||||
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPoint);
|
||||
view.yoga.marginEnd = YGPercentValue(18);
|
||||
XCTAssertEqual(view.yoga.marginEnd.value, 18);
|
||||
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
|
||||
}
|
||||
|
||||
- (void)testPaddingPropertiesWork
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
|
||||
view.yoga.padding = 1;
|
||||
XCTAssertEqual(view.yoga.padding, 1);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingLeft));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingRight));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingStart));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingEnd));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingTop));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingBottom));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingVertical));
|
||||
view.yoga.padding = YGPointValue(1);
|
||||
XCTAssertEqual(view.yoga.padding.value, 1);
|
||||
XCTAssertEqual(view.yoga.padding.unit, YGUnitPoint);
|
||||
view.yoga.padding = YGPercentValue(2);
|
||||
XCTAssertEqual(view.yoga.padding.value, 2);
|
||||
XCTAssertEqual(view.yoga.padding.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingHorizontal = 2;
|
||||
XCTAssertEqual(view.yoga.paddingHorizontal, 2);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingLeft));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingRight));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingStart));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingEnd));
|
||||
view.yoga.paddingHorizontal = YGPointValue(3);
|
||||
XCTAssertEqual(view.yoga.paddingHorizontal.value, 3);
|
||||
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPoint);
|
||||
view.yoga.paddingHorizontal = YGPercentValue(4);
|
||||
XCTAssertEqual(view.yoga.paddingHorizontal.value, 4);
|
||||
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingVertical = 3;
|
||||
XCTAssertEqual(view.yoga.paddingVertical, 3);
|
||||
XCTAssertTrue(isnan(view.yoga.paddingTop));
|
||||
XCTAssertTrue(isnan(view.yoga.paddingBottom));
|
||||
view.yoga.paddingVertical = YGPointValue(5);
|
||||
XCTAssertEqual(view.yoga.paddingVertical.value, 5);
|
||||
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPoint);
|
||||
view.yoga.paddingVertical = YGPercentValue(6);
|
||||
XCTAssertEqual(view.yoga.paddingVertical.value, 6);
|
||||
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingLeft = 4;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingLeft, 4);
|
||||
view.yoga.paddingLeft = YGPointValue(7);
|
||||
XCTAssertEqual(view.yoga.paddingLeft.value, 7);
|
||||
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPoint);
|
||||
view.yoga.paddingLeft = YGPercentValue(8);
|
||||
XCTAssertEqual(view.yoga.paddingLeft.value, 8);
|
||||
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingRight = 5;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingRight, 5);
|
||||
view.yoga.paddingRight = YGPointValue(9);
|
||||
XCTAssertEqual(view.yoga.paddingRight.value, 9);
|
||||
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPoint);
|
||||
view.yoga.paddingRight = YGPercentValue(10);
|
||||
XCTAssertEqual(view.yoga.paddingRight.value, 10);
|
||||
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingTop = 6;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingTop, 6);
|
||||
view.yoga.paddingTop = YGPointValue(11);
|
||||
XCTAssertEqual(view.yoga.paddingTop.value, 11);
|
||||
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPoint);
|
||||
view.yoga.paddingTop = YGPercentValue(12);
|
||||
XCTAssertEqual(view.yoga.paddingTop.value, 12);
|
||||
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingBottom = 7;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingBottom, 7);
|
||||
view.yoga.paddingBottom = YGPointValue(13);
|
||||
XCTAssertEqual(view.yoga.paddingBottom.value, 13);
|
||||
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPoint);
|
||||
view.yoga.paddingBottom = YGPercentValue(14);
|
||||
XCTAssertEqual(view.yoga.paddingBottom.value, 14);
|
||||
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingStart = 8;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingStart, 8);
|
||||
view.yoga.paddingStart = YGPointValue(15);
|
||||
XCTAssertEqual(view.yoga.paddingStart.value, 15);
|
||||
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPoint);
|
||||
view.yoga.paddingStart = YGPercentValue(16);
|
||||
XCTAssertEqual(view.yoga.paddingStart.value, 16);
|
||||
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPercent);
|
||||
|
||||
view.yoga.paddingEnd = 9;
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9);
|
||||
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint);
|
||||
XCTAssertEqual(view.yoga.paddingEnd, 9);
|
||||
view.yoga.paddingEnd = YGPointValue(17);
|
||||
XCTAssertEqual(view.yoga.paddingEnd.value, 17);
|
||||
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPoint);
|
||||
view.yoga.paddingEnd = YGPercentValue(18);
|
||||
XCTAssertEqual(view.yoga.paddingEnd.value, 18);
|
||||
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
|
||||
}
|
||||
|
||||
- (void)testBorderWidthPropertiesWork
|
||||
@@ -630,12 +719,6 @@
|
||||
|
||||
view.yoga.borderWidth = 1;
|
||||
XCTAssertEqual(view.yoga.borderWidth, 1);
|
||||
XCTAssertTrue(isnan(view.yoga.borderLeftWidth));
|
||||
XCTAssertTrue(isnan(view.yoga.borderRightWidth));
|
||||
XCTAssertTrue(isnan(view.yoga.borderStartWidth));
|
||||
XCTAssertTrue(isnan(view.yoga.borderEndWidth));
|
||||
XCTAssertTrue(isnan(view.yoga.borderTopWidth));
|
||||
XCTAssertTrue(isnan(view.yoga.borderBottomWidth));
|
||||
|
||||
view.yoga.borderLeftWidth = 2;
|
||||
XCTAssertEqual(view.yoga.borderLeftWidth, 2);
|
||||
|
@@ -14,13 +14,13 @@ DEPENDENCIES:
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
YogaKit:
|
||||
:path: "../../YogaKit.podspec"
|
||||
:path: ../../YogaKit.podspec
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
|
||||
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
|
||||
YogaKit: cddeccc6a8d2aff563e4c738d3bddb290a6de4cb
|
||||
YogaKit: 31576530e8fcae3175469719ec3212397403330b
|
||||
|
||||
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
|
||||
|
||||
COCOAPODS: 1.2.0
|
||||
COCOAPODS: 1.1.1
|
||||
|
@@ -12,6 +12,11 @@ import YogaKit
|
||||
|
||||
struct DemoItem {
|
||||
let name: String
|
||||
root.backgroundColor = .red
|
||||
root.yoga.isEnabled = true
|
||||
root.yoga.width = YGValue(self.view.bounds.size.width)
|
||||
root.yoga.height = YGValue(self.view.bounds.size.height)
|
||||
root.yoga.alignItems = .center
|
||||
}
|
||||
|
||||
final class SwiftViewController: UIViewController, IGListAdapterDataSource {
|
||||
|
@@ -17,16 +17,16 @@
|
||||
UIView *root = self.view;
|
||||
root.backgroundColor = [UIColor redColor];
|
||||
root.yoga.isEnabled = YES;
|
||||
root.yoga.width = self.view.bounds.size.width;
|
||||
root.yoga.height = self.view.bounds.size.height;
|
||||
root.yoga.width = YGPointValue(self.view.bounds.size.width);
|
||||
root.yoga.height = YGPointValue(self.view.bounds.size.height);
|
||||
root.yoga.alignItems = YGAlignCenter;
|
||||
root.yoga.justifyContent = YGJustifyCenter;
|
||||
|
||||
UIView *child1 = [UIView new];
|
||||
child1.backgroundColor = [UIColor blueColor];
|
||||
child1.yoga.isEnabled = YES;
|
||||
child1.yoga.width = 100;
|
||||
child1.yoga.height = 100;
|
||||
child1.yoga.width = YGPointValue(100);
|
||||
child1.yoga.height = YGPointValue(100);
|
||||
|
||||
UIView *child2 = [UIView new];
|
||||
child2.backgroundColor = [UIColor greenColor];
|
||||
|
@@ -17,8 +17,8 @@ final class BasicViewController: UIViewController {
|
||||
root.backgroundColor = .white
|
||||
root.configureLayout { (layout) in
|
||||
layout.isEnabled = true
|
||||
layout.width = containerSize.width
|
||||
layout.height = containerSize.height
|
||||
layout.width = YGValue(containerSize.width)
|
||||
layout.height = YGValue(containerSize.height)
|
||||
layout.alignItems = .center
|
||||
layout.justifyContent = .center
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ final class LayoutInclusionViewController: UIViewController {
|
||||
contentView.configureLayout { (layout) in
|
||||
layout.isEnabled = true
|
||||
layout.height = 300
|
||||
layout.width = self.view.bounds.size.width
|
||||
layout.width = YGValue(self.view.bounds.size.width)
|
||||
layout.flexDirection = .row
|
||||
layout.justifyContent = .center
|
||||
layout.paddingHorizontal = 25
|
||||
|
@@ -30,7 +30,3 @@ android_resource(
|
||||
"PUBLIC",
|
||||
],
|
||||
)
|
||||
|
||||
project_config(
|
||||
src_target = ":android",
|
||||
)
|
||||
|
@@ -1,31 +1,28 @@
|
||||
apply plugin: "com.jfrog.bintray"
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
targetCompatibility = '1.7'
|
||||
sourceCompatibility = '1.7'
|
||||
|
||||
version = '1.3.0'
|
||||
group = 'com.facebook.yoga.android'
|
||||
version = VERSION_NAME
|
||||
group = GROUP
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.1.0"
|
||||
compileSdkVersion rootProject.compileSdkVersion
|
||||
buildToolsVersion rootProject.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 19
|
||||
minSdkVersion rootProject.minSdkVersion
|
||||
targetSdkVersion rootProject.targetSdkVersion
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility rootProject.targetCompatibilityVersion
|
||||
sourceCompatibility rootProject.sourceCompatibilityVersion
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.facebook.yoga:yoga:1.2.0'
|
||||
compile project(':yoga')
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
@@ -45,8 +42,4 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
ext {
|
||||
bintrayName = "com.facebook.yoga.android:yoga-layout"
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
|
||||
apply from: rootProject.file('gradle/release.gradle')
|
||||
|
5
android/gradle.properties
Normal file
5
android/gradle.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
GROUP=com.facebook.yoga.android
|
||||
POM_NAME=YogaLayout
|
||||
POM_DESCRIPTION=YogaLayout
|
||||
POM_ARTIFACT_ID=yoga-layout
|
||||
POM_PACKAGING=aar
|
@@ -33,7 +33,3 @@ keystore(
|
||||
properties = "debug.keystore.properties",
|
||||
store = "debug.keystore",
|
||||
)
|
||||
|
||||
project_config(
|
||||
src_target = ":sample",
|
||||
)
|
||||
|
@@ -4,7 +4,7 @@ package com.facebook.samples.yoga;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -19,7 +19,7 @@ import android.support.v7.app.ActionBar;
|
||||
import com.facebook.samples.yoga.R;
|
||||
import com.facebook.yoga.android.YogaViewLayoutFactory;
|
||||
|
||||
public class BenchmarkActivity extends ActionBarActivity {
|
||||
public class BenchmarkActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@@ -10,7 +10,7 @@ package com.facebook.samples.yoga;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -25,7 +25,7 @@ import com.facebook.yoga.android.YogaViewLayoutFactory;
|
||||
* {@code main_layout.xml}) that shows off the awesome functionality of the Yoga layout engine
|
||||
* as well as some optimisations on layout systems that it facilitates.
|
||||
*/
|
||||
public class MainActivity extends ActionBarActivity {
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@@ -37,7 +37,7 @@ import com.facebook.yoga.YogaMeasureFunction;
|
||||
import com.facebook.yoga.YogaMeasureMode;
|
||||
import com.facebook.yoga.YogaMeasureOutput;
|
||||
import com.facebook.yoga.YogaNode;
|
||||
import com.facebook.yoga.YogaNodeAPI;
|
||||
import com.facebook.yoga.YogaNode;
|
||||
import com.facebook.yoga.YogaOverflow;
|
||||
import com.facebook.yoga.YogaPositionType;
|
||||
import com.facebook.yoga.YogaWrap;
|
||||
@@ -789,7 +789,7 @@ public class YogaLayout extends ViewGroup {
|
||||
* @return A measurement output ({@code YogaMeasureOutput}) for the node
|
||||
*/
|
||||
public long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
17
build.gradle
17
build.gradle
@@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
|
||||
@@ -18,15 +18,18 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
flatDir {
|
||||
dirs "${rootDir}/lib/jsr-305"
|
||||
dirs "${rootDir}/lib/soloader"
|
||||
dirs "${rootDir}/lib/appcompat"
|
||||
dirs "${rootDir}/lib/android-support"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
minSdkVersion = 15
|
||||
targetSdkVersion = 25
|
||||
compileSdkVersion = 25
|
||||
buildToolsVersion = '25.0.2'
|
||||
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||
targetCompatibilityVersion = JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
@@ -10,9 +10,12 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BaselineFunction.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Logger.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)MeasureFunction.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)MeasureOutput.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)YGConfigHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)YGNodeHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)YogaConfig.cs" />
|
||||
|
17
csharp/Facebook.Yoga/Logger.cs
Normal file
17
csharp/Facebook.Yoga/Logger.cs
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.
|
||||
*/
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public delegate void Logger(
|
||||
YogaConfig config,
|
||||
YogaNode node,
|
||||
YogaLogLevel level,
|
||||
string message);
|
||||
}
|
@@ -26,96 +26,9 @@ namespace Facebook.Yoga
|
||||
private const string DllName = "yoga";
|
||||
#endif
|
||||
|
||||
internal class YGNodeHandle : SafeHandle
|
||||
{
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
private GCHandle _managed;
|
||||
#endif
|
||||
|
||||
private YGNodeHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
ReleaseManaged();
|
||||
#endif
|
||||
Native.YGNodeFree(this.handle);
|
||||
GC.KeepAlive(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
public void SetContext(YogaNode node)
|
||||
{
|
||||
if (!_managed.IsAllocated)
|
||||
{
|
||||
#if ENABLE_IL2CPP
|
||||
// Weak causes 'GCHandle value belongs to a different domain' error
|
||||
_managed = GCHandle.Alloc(node);
|
||||
#else
|
||||
_managed = GCHandle.Alloc(node, GCHandleType.Weak);
|
||||
#endif
|
||||
Native.YGNodeSetContext(this.handle, GCHandle.ToIntPtr(_managed));
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseManaged()
|
||||
{
|
||||
if (_managed.IsAllocated)
|
||||
{
|
||||
_managed.Free();
|
||||
}
|
||||
}
|
||||
|
||||
public static YogaNode GetManaged(IntPtr ygNodePtr)
|
||||
{
|
||||
var node =
|
||||
GCHandle.FromIntPtr(Native.YGNodeGetContext(ygNodePtr)).Target as YogaNode;
|
||||
if (node == null)
|
||||
{
|
||||
throw new InvalidOperationException("YogaNode is already deallocated");
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal class YGConfigHandle : SafeHandle
|
||||
{
|
||||
private YGConfigHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
Native.YGConfigFree(this.handle);
|
||||
GC.KeepAlive(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void YGInteropSetLogger(
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger logger);
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern YGNodeHandle YGNodeNew();
|
||||
@@ -129,6 +42,9 @@ namespace Facebook.Yoga
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void YGNodeReset(YGNodeHandle node);
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern YGConfigHandle YGConfigGetDefault();
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern YGConfigHandle YGConfigNew();
|
||||
|
||||
@@ -445,15 +361,19 @@ namespace Facebook.Yoga
|
||||
|
||||
#endregion
|
||||
|
||||
#region AOT
|
||||
#region Context
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr YGNodeGetContext(IntPtr node);
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void YGNodeSetContext(IntPtr node, IntPtr managed);
|
||||
#endif
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr YGConfigGetContext(IntPtr config);
|
||||
|
||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void YGConfigSetContext(IntPtr config, IntPtr managed);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
84
csharp/Facebook.Yoga/YGConfigHandle.cs
Normal file
84
csharp/Facebook.Yoga/YGConfigHandle.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
internal class YGConfigHandle : SafeHandle
|
||||
{
|
||||
internal static readonly YGConfigHandle Default = Native.YGConfigGetDefault();
|
||||
private GCHandle _managedConfigHandle;
|
||||
|
||||
private YGConfigHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
if (this.handle != Default.handle)
|
||||
{
|
||||
ReleaseManaged();
|
||||
if (!IsInvalid)
|
||||
{
|
||||
Native.YGConfigFree(this.handle);
|
||||
}
|
||||
}
|
||||
GC.KeepAlive(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetContext(YogaConfig config)
|
||||
{
|
||||
if (!_managedConfigHandle.IsAllocated)
|
||||
{
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
// Weak causes 'GCHandle value belongs to a different domain' error
|
||||
_managedConfigHandle = GCHandle.Alloc(config);
|
||||
#else
|
||||
_managedConfigHandle = GCHandle.Alloc(config, GCHandleType.Weak);
|
||||
#endif
|
||||
var managedConfigPtr = GCHandle.ToIntPtr(_managedConfigHandle);
|
||||
Native.YGConfigSetContext(this.handle, managedConfigPtr);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseManaged()
|
||||
{
|
||||
if (_managedConfigHandle.IsAllocated)
|
||||
{
|
||||
_managedConfigHandle.Free();
|
||||
}
|
||||
}
|
||||
|
||||
public static YogaConfig GetManaged(IntPtr unmanagedConfigPtr)
|
||||
{
|
||||
if (unmanagedConfigPtr != IntPtr.Zero)
|
||||
{
|
||||
var managedConfigPtr = Native.YGConfigGetContext(unmanagedConfigPtr);
|
||||
var config = GCHandle.FromIntPtr(managedConfigPtr).Target as YogaConfig;
|
||||
if (config == null)
|
||||
{
|
||||
throw new InvalidOperationException("YogaConfig is already deallocated");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
80
csharp/Facebook.Yoga/YGNodeHandle.cs
Normal file
80
csharp/Facebook.Yoga/YGNodeHandle.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
internal class YGNodeHandle : SafeHandle
|
||||
{
|
||||
private GCHandle _managedNodeHandle;
|
||||
|
||||
private YGNodeHandle() : base(IntPtr.Zero, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsInvalid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handle == IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
ReleaseManaged();
|
||||
if (!IsInvalid)
|
||||
{
|
||||
Native.YGNodeFree(this.handle);
|
||||
GC.KeepAlive(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetContext(YogaNode node)
|
||||
{
|
||||
if (!_managedNodeHandle.IsAllocated)
|
||||
{
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
// Weak causes 'GCHandle value belongs to a different domain' error
|
||||
_managedNodeHandle = GCHandle.Alloc(node);
|
||||
#else
|
||||
_managedNodeHandle = GCHandle.Alloc(node, GCHandleType.Weak);
|
||||
#endif
|
||||
var managedNodePtr = GCHandle.ToIntPtr(_managedNodeHandle);
|
||||
Native.YGNodeSetContext(this.handle, managedNodePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseManaged()
|
||||
{
|
||||
if (_managedNodeHandle.IsAllocated)
|
||||
{
|
||||
_managedNodeHandle.Free();
|
||||
}
|
||||
}
|
||||
|
||||
public static YogaNode GetManaged(IntPtr unmanagedNodePtr)
|
||||
{
|
||||
if (unmanagedNodePtr != IntPtr.Zero)
|
||||
{
|
||||
var managedNodePtr = Native.YGNodeGetContext(unmanagedNodePtr);
|
||||
var node = GCHandle.FromIntPtr(managedNodePtr).Target as YogaNode;
|
||||
if (node == null)
|
||||
{
|
||||
throw new InvalidOperationException("YogaNode is already deallocated");
|
||||
}
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,5 +13,5 @@ using System.Runtime.InteropServices;
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate float YogaBaselineFunc(IntPtr node, float width, float height);
|
||||
public delegate float YogaBaselineFunc(IntPtr unmanagedNodePtr, float width, float height);
|
||||
}
|
||||
|
@@ -8,29 +8,92 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if __IOS__
|
||||
using ObjCRuntime;
|
||||
#endif
|
||||
#if ENABLE_IL2CPP
|
||||
using AOT;
|
||||
#endif
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
public class YogaConfig
|
||||
{
|
||||
private Native.YGConfigHandle _ygConfig;
|
||||
internal static readonly YogaConfig Default = new YogaConfig(YGConfigHandle.Default);
|
||||
private static YogaLogger _managedLogger;
|
||||
|
||||
public YogaConfig()
|
||||
private YGConfigHandle _ygConfig;
|
||||
private Logger _logger;
|
||||
|
||||
private YogaConfig(YGConfigHandle ygConfig)
|
||||
{
|
||||
_ygConfig = Native.YGConfigNew();
|
||||
_ygConfig = ygConfig;
|
||||
if (_ygConfig.IsInvalid)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
|
||||
_ygConfig.SetContext(this);
|
||||
|
||||
if (_ygConfig == YGConfigHandle.Default)
|
||||
{
|
||||
_managedLogger = LoggerInternal;
|
||||
Native.YGInteropSetLogger(_managedLogger);
|
||||
}
|
||||
}
|
||||
|
||||
internal Native.YGConfigHandle Handle
|
||||
public YogaConfig()
|
||||
: this(Native.YGConfigNew())
|
||||
{
|
||||
}
|
||||
|
||||
internal YGConfigHandle Handle
|
||||
{
|
||||
get {
|
||||
return _ygConfig;
|
||||
}
|
||||
}
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
[MonoPInvokeCallback(typeof(YogaLogger))]
|
||||
#endif
|
||||
private static void LoggerInternal(
|
||||
IntPtr unmanagedConfigPtr,
|
||||
IntPtr unmanagedNodePtr,
|
||||
YogaLogLevel level,
|
||||
string message)
|
||||
{
|
||||
var config = YGConfigHandle.GetManaged(unmanagedConfigPtr);
|
||||
if (config == null || config._logger == null)
|
||||
{
|
||||
// Default logger
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
|
||||
config._logger(config, node, level, message);
|
||||
}
|
||||
|
||||
if (level == YogaLogLevel.Error || level == YogaLogLevel.Fatal)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public Logger Logger
|
||||
{
|
||||
get {
|
||||
return _logger;
|
||||
}
|
||||
|
||||
set {
|
||||
_logger = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetExperimentalFeatureEnabled(
|
||||
YogaExperimentalFeature feature,
|
||||
bool enabled)
|
||||
@@ -68,5 +131,10 @@ namespace Facebook.Yoga
|
||||
{
|
||||
return Native.YGConfigGetInstanceCount();
|
||||
}
|
||||
|
||||
public static void SetDefaultLogger(Logger logger)
|
||||
{
|
||||
Default.Logger = logger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,8 +11,6 @@ namespace Facebook.Yoga
|
||||
{
|
||||
public enum YogaExperimentalFeature
|
||||
{
|
||||
Rounding,
|
||||
WebFlexBasis,
|
||||
MinFlexFix,
|
||||
}
|
||||
}
|
||||
|
@@ -16,5 +16,6 @@ namespace Facebook.Yoga
|
||||
Info,
|
||||
Debug,
|
||||
Verbose,
|
||||
Fatal,
|
||||
}
|
||||
}
|
||||
|
@@ -10,48 +10,12 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if __IOS__
|
||||
using ObjCRuntime;
|
||||
#endif
|
||||
#if ENABLE_IL2CPP
|
||||
using AOT;
|
||||
#endif
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
internal static class YogaLogger
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Func(YogaLogLevel level, string message);
|
||||
|
||||
private static bool _initialized;
|
||||
private static Func _managedLogger = LoggerInternal;
|
||||
|
||||
public static Func Logger = null;
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
[MonoPInvokeCallback(typeof(Func))]
|
||||
#endif
|
||||
public static void LoggerInternal(YogaLogLevel level, string message)
|
||||
{
|
||||
if (Logger != null)
|
||||
{
|
||||
Logger(level, message);
|
||||
}
|
||||
|
||||
if (level == YogaLogLevel.Error)
|
||||
{
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
Native.YGInteropSetLogger(_managedLogger);
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public delegate void YogaLogger(
|
||||
IntPtr unmanagedConfigPtr,
|
||||
IntPtr unmanagedNotePtr,
|
||||
YogaLogLevel level,
|
||||
string message);
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ namespace Facebook.Yoga
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate YogaSize YogaMeasureFunc(
|
||||
IntPtr node,
|
||||
IntPtr unmanagedNodePtr,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
@@ -10,11 +10,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
#if __IOS__
|
||||
using ObjCRuntime;
|
||||
#endif
|
||||
@@ -26,49 +24,26 @@ namespace Facebook.Yoga
|
||||
{
|
||||
public partial class YogaNode : IEnumerable<YogaNode>
|
||||
{
|
||||
private Native.YGNodeHandle _ygNode;
|
||||
private YogaConfig _config;
|
||||
private readonly YGNodeHandle _ygNode;
|
||||
private readonly YogaConfig _config;
|
||||
private WeakReference _parent;
|
||||
private List<YogaNode> _children;
|
||||
private MeasureFunction _measureFunction;
|
||||
private BaselineFunction _baselineFunction;
|
||||
private object _data;
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
private static YogaMeasureFunc _managedMeasure;
|
||||
private static YogaBaselineFunc _managedBaseline;
|
||||
#else
|
||||
private YogaMeasureFunc _managedMeasure;
|
||||
private YogaBaselineFunc _managedBaseline;
|
||||
#endif
|
||||
private object _data;
|
||||
|
||||
public YogaNode()
|
||||
public YogaNode(YogaConfig config = null)
|
||||
{
|
||||
YogaLogger.Initialize();
|
||||
|
||||
_ygNode = Native.YGNodeNew();
|
||||
if (_ygNode.IsInvalid)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
public YogaNode(YogaConfig config)
|
||||
{
|
||||
YogaLogger.Initialize();
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
_config = config;
|
||||
_config = config == null ? YogaConfig.Default : config;
|
||||
_ygNode = Native.YGNodeNewWithConfig(_config.Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ygNode = Native.YGNodeNew();
|
||||
}
|
||||
if (_ygNode.IsInvalid)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to allocate native memory");
|
||||
}
|
||||
|
||||
_ygNode.SetContext(this);
|
||||
}
|
||||
|
||||
public YogaNode(YogaNode srcNode)
|
||||
@@ -83,10 +58,9 @@ namespace Facebook.Yoga
|
||||
_baselineFunction = null;
|
||||
_data = null;
|
||||
|
||||
Native.YGNodeReset(_ygNode);
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
_ygNode.ReleaseManaged();
|
||||
#endif
|
||||
Native.YGNodeReset(_ygNode);
|
||||
_ygNode.SetContext(this);
|
||||
}
|
||||
|
||||
public bool IsDirty
|
||||
@@ -447,7 +421,7 @@ namespace Facebook.Yoga
|
||||
}
|
||||
}
|
||||
|
||||
public float StyleAspectRatio
|
||||
public float AspectRatio
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -576,6 +550,20 @@ namespace Facebook.Yoga
|
||||
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
|
||||
}
|
||||
|
||||
public void AddChild(YogaNode child)
|
||||
{
|
||||
Insert(Count, child);
|
||||
}
|
||||
|
||||
public void RemoveChild(YogaNode child)
|
||||
{
|
||||
int index = IndexOf(child);
|
||||
if (index >= 0)
|
||||
{
|
||||
RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_children != null)
|
||||
@@ -595,38 +583,15 @@ namespace Facebook.Yoga
|
||||
public void SetMeasureFunction(MeasureFunction measureFunction)
|
||||
{
|
||||
_measureFunction = measureFunction;
|
||||
if (measureFunction != null)
|
||||
{
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
_managedMeasure = MeasureInternalAOT;
|
||||
_ygNode.SetContext(this);
|
||||
#else
|
||||
_managedMeasure = MeasureInternal;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
_managedMeasure = null;
|
||||
}
|
||||
_managedMeasure = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
|
||||
Native.YGNodeSetMeasureFunc(_ygNode, _managedMeasure);
|
||||
}
|
||||
|
||||
public void SetBaselineFunction(BaselineFunction baselineFunction)
|
||||
{
|
||||
_baselineFunction = baselineFunction;
|
||||
if (baselineFunction != null)
|
||||
{
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
_managedBaseline = BaselineInternalAOT;
|
||||
_ygNode.SetContext(this);
|
||||
#else
|
||||
_managedBaseline = BaselineInternal;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
_managedBaseline = null;
|
||||
}
|
||||
_managedBaseline =
|
||||
baselineFunction != null ? BaselineInternal : (YogaBaselineFunc)null;
|
||||
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
|
||||
}
|
||||
|
||||
@@ -641,63 +606,46 @@ namespace Facebook.Yoga
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
[MonoPInvokeCallback(typeof(YogaMeasureFunc))]
|
||||
private static YogaSize MeasureInternalAOT(
|
||||
IntPtr ygNodePtr,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode)
|
||||
{
|
||||
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
|
||||
return node.MeasureInternal(IntPtr.Zero, width, widthMode, height, heightMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
private YogaSize MeasureInternal(
|
||||
IntPtr node,
|
||||
private static YogaSize MeasureInternal(
|
||||
IntPtr unmanagedNodePtr,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode)
|
||||
{
|
||||
if (_measureFunction == null)
|
||||
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
|
||||
if (node == null || node._measureFunction == null)
|
||||
{
|
||||
throw new InvalidOperationException("Measure function is not defined.");
|
||||
}
|
||||
|
||||
return _measureFunction(this, width, widthMode, height, heightMode);
|
||||
return node._measureFunction(node, width, widthMode, height, heightMode);
|
||||
}
|
||||
|
||||
#if (UNITY_IOS && !UNITY_EDITOR) || ENABLE_IL2CPP || __IOS__
|
||||
[MonoPInvokeCallback(typeof(YogaBaselineFunc))]
|
||||
private static float BaselineInternalAOT(
|
||||
IntPtr ygNodePtr,
|
||||
#endif
|
||||
private static float BaselineInternal(
|
||||
IntPtr unmanagedNodePtr,
|
||||
float width,
|
||||
float height)
|
||||
{
|
||||
var node = Native.YGNodeHandle.GetManaged(ygNodePtr);
|
||||
return node.BaselineInternal(IntPtr.Zero, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
private float BaselineInternal(IntPtr node, float width, float height)
|
||||
{
|
||||
if (_baselineFunction == null)
|
||||
var node = YGNodeHandle.GetManaged(unmanagedNodePtr);
|
||||
if (node == null || node._baselineFunction == null)
|
||||
{
|
||||
throw new InvalidOperationException("Baseline function is not defined.");
|
||||
}
|
||||
|
||||
return _baselineFunction(this, width, height);
|
||||
return node._baselineFunction(node, width, height);
|
||||
}
|
||||
|
||||
public string Print(YogaPrintOptions options =
|
||||
YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
YogaLogger.Func orig = YogaLogger.Logger;
|
||||
YogaLogger.Logger = (level, message) => {sb.Append(message);};
|
||||
Logger orig = _config.Logger;
|
||||
_config.Logger = (config, node, level, message) => {sb.Append(message);};
|
||||
Native.YGNodePrint(_ygNode, options);
|
||||
YogaLogger.Logger = orig;
|
||||
_config.Logger = orig;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace Facebook.Yoga
|
||||
{
|
||||
[System.Flags]
|
||||
public enum YogaPrintOptions
|
||||
{
|
||||
Layout = 1,
|
||||
|
@@ -9,19 +9,23 @@
|
||||
|
||||
#include "YGInterop.h"
|
||||
|
||||
static YGInteropLoggerFunc gManagedFunc;
|
||||
static YGInteropLogger gManagedLogger;
|
||||
|
||||
static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) {
|
||||
static int unmanagedLogger(const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
const char *format,
|
||||
va_list args) {
|
||||
int result = 0;
|
||||
if (gManagedFunc) {
|
||||
char buffer[256];
|
||||
result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
(*gManagedFunc)(level, buffer);
|
||||
if (gManagedLogger) {
|
||||
char message[8192];
|
||||
result = vsnprintf(message, sizeof(message), format, args);
|
||||
(*gManagedLogger)(config, node, level, message);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) {
|
||||
gManagedFunc = managedFunc;
|
||||
YGSetLogger(&unmanagedLogger);
|
||||
void YGInteropSetLogger(YGInteropLogger managedLogger) {
|
||||
gManagedLogger = managedLogger;
|
||||
YGConfigSetLogger(YGConfigGetDefault(), &unmanagedLogger);
|
||||
}
|
||||
|
@@ -13,8 +13,13 @@
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message);
|
||||
typedef int (*YGInteropLogger)(const void *unmanagedConfigPtr,
|
||||
const void *unmanagedNodePtr,
|
||||
YGLogLevel level,
|
||||
const char *message);
|
||||
|
||||
WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc);
|
||||
WIN_EXPORT YGConfigRef YGConfigGetDefault();
|
||||
|
||||
WIN_EXPORT void YGInteropSetLogger(YGInteropLogger managedLogger);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
@@ -243,6 +243,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||
<ClInclude Include="..\..\yoga\YGEnums.c" />
|
||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
@@ -252,6 +253,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
||||
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
||||
<ClCompile Include="YGInterop.cpp" />
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
@@ -228,6 +228,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\yoga\Yoga.h" />
|
||||
<ClInclude Include="..\..\yoga\YGEnums.h" />
|
||||
<ClInclude Include="..\..\yoga\YGMacros.h" />
|
||||
<ClInclude Include="..\..\yoga\YGNodeList.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
@@ -237,6 +238,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\yoga\Yoga.c" />
|
||||
<ClCompile Include="..\..\yoga\YGEnums.c" />
|
||||
<ClCompile Include="..\..\yoga\YGNodeList.c" />
|
||||
<ClCompile Include="YGInterop.cpp" />
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
@@ -1815,5 +1815,148 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(72f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_center_should_size_based_on_content()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.MarginTop = 20;
|
||||
root.Width = 100;
|
||||
root.Height = 100;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.JustifyContent = YogaJustify.Center;
|
||||
root_child0.FlexShrink = 1;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0.FlexGrow = 1;
|
||||
root_child0_child0.FlexShrink = 1;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0_child0.Width = 20;
|
||||
root_child0_child0_child0.Height = 20;
|
||||
root_child0_child0.Insert(0, root_child0_child0_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(20f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(20f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(40f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_align_strech_should_size_based_on_parent()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.MarginTop = 20;
|
||||
root.Width = 100;
|
||||
root.Height = 100;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.JustifyContent = YogaJustify.Center;
|
||||
root_child0.FlexShrink = 1;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0.FlexGrow = 1;
|
||||
root_child0_child0.FlexShrink = 1;
|
||||
root_child0.Insert(0, root_child0_child0);
|
||||
|
||||
YogaNode root_child0_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0_child0.Width = 20;
|
||||
root_child0_child0_child0.Height = 20;
|
||||
root_child0_child0.Insert(0, root_child0_child0_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(20f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(20f, root.LayoutY);
|
||||
Assert.AreEqual(100f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(80f, root_child0_child0_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth);
|
||||
Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1381,5 +1381,169 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrapped_column_max_height()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.AlignContent = YogaAlign.Center;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 700;
|
||||
root.Height = 500;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.Width = 100;
|
||||
root_child0.Height = 500;
|
||||
root_child0.MaxHeight = 200;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.MarginLeft = 20;
|
||||
root_child1.MarginTop = 20;
|
||||
root_child1.MarginRight = 20;
|
||||
root_child1.MarginBottom = 20;
|
||||
root_child1.Width = 200;
|
||||
root_child1.Height = 200;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.Width = 100;
|
||||
root_child2.Height = 100;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(700f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(250f, root_child0.LayoutX);
|
||||
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(200f, root_child1.LayoutX);
|
||||
Assert.AreEqual(250f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(420f, root_child2.LayoutX);
|
||||
Assert.AreEqual(200f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(700f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(350f, root_child0.LayoutX);
|
||||
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(300f, root_child1.LayoutX);
|
||||
Assert.AreEqual(250f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(200f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(180f, root_child2.LayoutX);
|
||||
Assert.AreEqual(200f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_wrapped_column_max_height_flex()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
root.AlignContent = YogaAlign.Center;
|
||||
root.AlignItems = YogaAlign.Center;
|
||||
root.Wrap = YogaWrap.Wrap;
|
||||
root.Width = 700;
|
||||
root.Height = 500;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.FlexShrink = 1;
|
||||
root_child0.FlexBasis = 0.Percent();
|
||||
root_child0.Width = 100;
|
||||
root_child0.Height = 500;
|
||||
root_child0.MaxHeight = 200;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.FlexGrow = 1;
|
||||
root_child1.FlexShrink = 1;
|
||||
root_child1.FlexBasis = 0.Percent();
|
||||
root_child1.MarginLeft = 20;
|
||||
root_child1.MarginTop = 20;
|
||||
root_child1.MarginRight = 20;
|
||||
root_child1.MarginBottom = 20;
|
||||
root_child1.Width = 200;
|
||||
root_child1.Height = 200;
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.Width = 100;
|
||||
root_child2.Height = 100;
|
||||
root.Insert(2, root_child2);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(700f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(300f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(180f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(250f, root_child1.LayoutX);
|
||||
Assert.AreEqual(200f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(180f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(300f, root_child2.LayoutX);
|
||||
Assert.AreEqual(400f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(700f, root.LayoutWidth);
|
||||
Assert.AreEqual(500f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(300f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(180f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(250f, root_child1.LayoutX);
|
||||
Assert.AreEqual(200f, root_child1.LayoutY);
|
||||
Assert.AreEqual(200f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(180f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(300f, root_child2.LayoutX);
|
||||
Assert.AreEqual(400f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -366,7 +366,6 @@ namespace Facebook.Yoga
|
||||
public void Test_flex_grow_to_min()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 100;
|
||||
@@ -422,7 +421,6 @@ namespace Facebook.Yoga
|
||||
public void Test_flex_grow_in_at_most_container()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -475,6 +473,99 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_child()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.FlexGrow = 1;
|
||||
root_child0.FlexBasis = 0;
|
||||
root_child0.Height = 100;
|
||||
root.Insert(0, root_child0);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_constrained_min_max_column()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.MinHeight = 100;
|
||||
root.MaxHeight = 200;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.FlexGrow = 1;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.Height = 50;
|
||||
root.Insert(1, root_child1);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(0f, root.LayoutWidth);
|
||||
Assert.AreEqual(100f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(0f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(50f, root_child1.LayoutY);
|
||||
Assert.AreEqual(0f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_flex_grow_within_max_width()
|
||||
{
|
||||
@@ -957,113 +1048,5 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_min_width_in_flex_distribution()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
root.Width = 300;
|
||||
root.Height = 300;
|
||||
|
||||
YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.FlexGrow = 2;
|
||||
root_child0.FlexShrink = 1;
|
||||
root_child0.FlexBasis = 0.Percent();
|
||||
root_child0.MinWidth = 100;
|
||||
root_child0.MaxWidth = 200;
|
||||
root.Insert(0, root_child0);
|
||||
|
||||
YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.FlexGrow = 1;
|
||||
root_child1.FlexShrink = 1;
|
||||
root_child1.FlexBasis = 0.Percent();
|
||||
root.Insert(1, root_child1);
|
||||
|
||||
YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.FlexGrow = 1;
|
||||
root_child2.FlexShrink = 1;
|
||||
root_child2.FlexBasis = 0.Percent();
|
||||
root.Insert(2, root_child2);
|
||||
|
||||
YogaNode root_child3 = new YogaNode(config);
|
||||
root_child3.FlexGrow = 1;
|
||||
root_child3.FlexShrink = 1;
|
||||
root_child3.FlexBasis = 0.Percent();
|
||||
root.Insert(3, root_child3);
|
||||
|
||||
YogaNode root_child4 = new YogaNode(config);
|
||||
root_child4.FlexGrow = 1;
|
||||
root_child4.FlexShrink = 1;
|
||||
root_child4.FlexBasis = 0.Percent();
|
||||
root.Insert(4, root_child4);
|
||||
root.StyleDirection = YogaDirection.LTR;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(300f, root.LayoutWidth);
|
||||
Assert.AreEqual(300f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(100f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(150f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(200f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(250f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child4.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
|
||||
Assert.AreEqual(0f, root.LayoutX);
|
||||
Assert.AreEqual(0f, root.LayoutY);
|
||||
Assert.AreEqual(300f, root.LayoutWidth);
|
||||
Assert.AreEqual(300f, root.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(200f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(150f, root_child1.LayoutX);
|
||||
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||
Assert.AreEqual(50f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(100f, root_child2.LayoutX);
|
||||
Assert.AreEqual(0f, root_child2.LayoutY);
|
||||
Assert.AreEqual(50f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child2.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(50f, root_child3.LayoutX);
|
||||
Assert.AreEqual(0f, root_child3.LayoutY);
|
||||
Assert.AreEqual(50f, root_child3.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child3.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child4.LayoutX);
|
||||
Assert.AreEqual(0f, root_child4.LayoutY);
|
||||
Assert.AreEqual(50f, root_child4.LayoutWidth);
|
||||
Assert.AreEqual(300f, root_child4.LayoutHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_width_height()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -63,7 +62,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_position_left_top()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -107,7 +105,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_position_bottom_right()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -151,7 +148,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -208,7 +204,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_cross()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -264,7 +259,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_cross_min_height()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -320,7 +314,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_main_max_height()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -379,7 +372,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_cross_max_height()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -437,7 +429,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_main_max_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -496,7 +487,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_cross_max_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -554,7 +544,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_main_min_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -613,7 +602,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_flex_basis_cross_min_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -671,7 +659,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -781,7 +768,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_margin_should_calculate_based_only_on_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -840,7 +826,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_padding_should_calculate_based_only_on_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -899,7 +884,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_absolute_position()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 200;
|
||||
@@ -1063,7 +1047,6 @@ namespace Facebook.Yoga
|
||||
public void Test_percentage_container_in_wrapping_container()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.JustifyContent = YogaJustify.Center;
|
||||
|
@@ -21,7 +21,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -90,7 +89,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -187,7 +185,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_flex_basis_flex_shrink_row()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.FlexDirection = YogaFlexDirection.Row;
|
||||
@@ -257,7 +254,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_flex_basis_overrides_main_size()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 100;
|
||||
@@ -329,7 +325,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_total_fractial()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 87.4f;
|
||||
@@ -401,7 +396,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_total_fractial_nested()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 87.4f;
|
||||
@@ -507,7 +501,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_fractial_input_1()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 100;
|
||||
@@ -579,7 +572,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_fractial_input_2()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Width = 100;
|
||||
@@ -651,7 +643,6 @@ namespace Facebook.Yoga
|
||||
public void Test_rounding_fractial_input_3()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Top = 0.3f;
|
||||
@@ -684,17 +675,17 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
|
||||
root.StyleDirection = YogaDirection.RTL;
|
||||
root.CalculateLayout();
|
||||
@@ -707,24 +698,23 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||
Assert.AreEqual(100f, root_child0.LayoutWidth);
|
||||
Assert.AreEqual(64f, root_child0.LayoutHeight);
|
||||
Assert.AreEqual(65f, root_child0.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||
Assert.AreEqual(64f, root_child1.LayoutY);
|
||||
Assert.AreEqual(100f, root_child1.LayoutWidth);
|
||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||
Assert.AreEqual(24f, root_child1.LayoutHeight);
|
||||
|
||||
Assert.AreEqual(0f, root_child2.LayoutX);
|
||||
Assert.AreEqual(89f, root_child2.LayoutY);
|
||||
Assert.AreEqual(100f, root_child2.LayoutWidth);
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
Assert.AreEqual(25f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_fractial_input_4()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
|
||||
|
||||
YogaNode root = new YogaNode(config);
|
||||
root.Top = 0.7f;
|
||||
@@ -793,5 +783,305 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(24f, root_child2.LayoutHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_rounding_inner_node_controversy_horizontal()
|
||||
{
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -69,6 +69,7 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(YogaFlexDirection.Row, node1.FlexDirection);
|
||||
}
|
||||
|
||||
#if !UNITY_5_4_OR_NEWER
|
||||
public static void ForceGC()
|
||||
{
|
||||
YogaNodeTest.ForceGC();
|
||||
@@ -132,5 +133,6 @@ namespace Facebook.Yoga
|
||||
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -164,6 +164,14 @@ namespace Facebook.Yoga
|
||||
return MeasureOutput.Make(123.4f, 81.7f);
|
||||
});
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual(124.0f, node.LayoutWidth);
|
||||
Assert.AreEqual(82.0f, node.LayoutHeight);
|
||||
|
||||
node = new YogaNode(new YogaConfig{PointScaleFactor = 0});
|
||||
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||
return MeasureOutput.Make(123.4f, 81.7f);
|
||||
});
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual(123.4f, node.LayoutWidth);
|
||||
Assert.AreEqual(81.7f, node.LayoutHeight);
|
||||
}
|
||||
@@ -240,6 +248,26 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(0, child2.LayoutY);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrintOneNode()
|
||||
{
|
||||
YogaNode node = new YogaNode();
|
||||
node.Width = 100;
|
||||
node.Height = 120;
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual("<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" ></div>", node.Print());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrintWithLogger()
|
||||
{
|
||||
YogaNode node = new YogaNode(new YogaConfig{Logger = (c, n, l, m) => {}});
|
||||
node.Width = 110;
|
||||
node.Height = 105;
|
||||
node.CalculateLayout();
|
||||
Assert.AreEqual("<div layout=\"width: 110; height: 105; top: 0; left: 0;\" style=\"width: 110px; height: 105px; \" ></div>", node.Print());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPrint()
|
||||
{
|
||||
@@ -301,9 +329,10 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(90.Pt(), node4.MaxHeight);
|
||||
}
|
||||
|
||||
#if !UNITY_5_4_OR_NEWER
|
||||
public static void ForceGC()
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration);
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
@@ -430,6 +459,7 @@ namespace Facebook.Yoga
|
||||
return MeasureOutput.Make(120, 130);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void TestLayoutMargin() {
|
||||
|
@@ -24,5 +24,5 @@ ROOT=`buck root|tail -1`
|
||||
DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'`
|
||||
cp $ROOT/$DYLIB .
|
||||
|
||||
mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs
|
||||
mcs -debug -d:YOGA_ENABLE_GC_TEST -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs
|
||||
MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll
|
||||
|
@@ -140,6 +140,3 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages (~> 104)
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.6
|
||||
|
@@ -20,30 +20,30 @@ There is an easy interface to Yoga called `YogaLayout`. This is a view group th
|
||||
xmlns:yoga="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
yoga:align_items="stretch"
|
||||
yoga:yg_alignItems="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"
|
||||
yoga:yg_marginHorizontal="10dp"
|
||||
yoga:yg_marginTop="5dp"
|
||||
yoga:yg_flexDirection="row"
|
||||
yoga:yg_alignItems="center"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/ic_launcher"
|
||||
yoga:flex="0"
|
||||
yoga:yg_flex="0"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/child_1_text"
|
||||
android:textColor="@color/children_text"
|
||||
yoga:flex="1"
|
||||
yoga:margin_start="8dp"
|
||||
yoga:yg_flex="1"
|
||||
yoga:yg_marginStart="8dp"
|
||||
/>
|
||||
</YogaLayout>
|
||||
</YogaLayout>
|
||||
@@ -59,7 +59,7 @@ compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
|
||||
|
||||
## layout\_width and layout\_height
|
||||
|
||||
If either are set to an actual size (in px or dp etc) then this is taken as a default for `yoga:height` or `yoga:width`. Otherwise they are ignored.
|
||||
If either are set to an actual size (in px or dp etc) then this is taken as a default for `yoga:yg_height` or `yoga:ygWidth`. Otherwise they are ignored.
|
||||
|
||||
## VirtualYogaLayout
|
||||
|
||||
@@ -67,11 +67,11 @@ Sometimes you will nest `YogaLayout`s within `YogaLayout`s in order to get your
|
||||
|
||||
## RTL locales
|
||||
|
||||
RTL locales are supported by default. That is, unless you explicitly set the `yoga:direction="ltr|rtl|inherit"` attribute on a view, it will obtain the locale direction _at runtime_. This means that the layout will rearrange properly, even if the locale changes while your app is running!
|
||||
RTL locales are supported by default. That is, unless you explicitly set the `yoga:yg_direction="ltr|rtl|inherit"` attribute on a view, it will obtain the locale direction At runtime_. This means that the layout will rearrange properly, even if the locale changes while your app is running!
|
||||
|
||||
## Attributes
|
||||
|
||||
The list of all attributes can be found in [attrs.xml](https://github.com/facebook/yoga/blob/master/android/sample/res/com/facebook/samples/yoga/res/values/attrs.xml), but logically map from the Yoga properties.
|
||||
The list of all attributes can be found in [attrs.xml](https://github.com/facebook/yoga/blob/master/android/src/main/res/values/attrs.xml), but logically map from the Yoga properties.
|
||||
|
||||
## Auto margins
|
||||
|
||||
|
@@ -28,7 +28,7 @@ The following functions help manage the children of a node.
|
||||
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);
|
||||
uint32_t YGNodeGetChildCount(YGNodeRef node);
|
||||
```
|
||||
|
||||
### Style getters & setters
|
||||
|
@@ -188,7 +188,7 @@ enum YogaMeasureMode {
|
||||
|
||||
interface YogaMeasureFunction {
|
||||
long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
@@ -163,25 +163,25 @@ root.Insert(text, 1);
|
||||
<YogaLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
yoga:justify_content="stretch">
|
||||
yoga:yg_justifyContent="stretch">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
yoga:flex="1"/>
|
||||
yoga:yg_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">
|
||||
yoga:yg_paddingAll="20px"
|
||||
yoga:yg_flexDirection="row"
|
||||
yoga:yg_alignItems="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"/>
|
||||
yoga:yg_flex="1"
|
||||
yoga:yg_marginStart="20px"/>
|
||||
</VirtualYogaLayout>
|
||||
</YogaLayout>
|
||||
```
|
||||
|
5
enums.py
5
enums.py
@@ -90,12 +90,11 @@ ENUMS = {
|
||||
'Info',
|
||||
'Debug',
|
||||
'Verbose',
|
||||
'Fatal',
|
||||
],
|
||||
'ExperimentalFeature': [
|
||||
'Rounding',
|
||||
# Mimic web flex-basis behavior.
|
||||
'WebFlexBasis',
|
||||
'MinFlexFix'
|
||||
],
|
||||
'PrintOptions': [
|
||||
('Layout', 1),
|
||||
@@ -223,6 +222,8 @@ for name, values in sorted(ENUMS.items()):
|
||||
with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f:
|
||||
f.write(LICENSE)
|
||||
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)
|
||||
for value in values:
|
||||
if isinstance(value, tuple):
|
||||
|
@@ -167,3 +167,20 @@
|
||||
<div style="width: 72px; height: 72px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="align_center_should_size_based_on_content" style="width: 100px; height: 100px; align-items: center; margin-top: 20px;">
|
||||
<div style="flex-grow: 0; flex-shrink: 1; justify-content: center;">
|
||||
<div style="flex-grow: 1; flex-shrink: 1;">
|
||||
<div style="width: 20px; height: 20px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="align_strech_should_size_based_on_parent" style="width: 100px; height: 100px; align-items: strech; margin-top: 20px;">
|
||||
<div style="flex-grow: 0; flex-shrink: 1; justify-content: center;">
|
||||
<div style="flex-grow: 1; flex-shrink: 1;">
|
||||
<div style="width: 20px; height: 20px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -113,3 +113,15 @@
|
||||
<div style="width: 80px; height: 80px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrapped_column_max_height" style="height: 500px; width: 700px; flex-direction: column;align-items: center; justify-content: center; align-content: center; flex-wrap:wrap;">
|
||||
<div style="width: 100px; height: 500px; max-height: 200px;"></div>
|
||||
<div style="width: 200px; height: 200px; margin: 20px;"></div>
|
||||
<div style="width: 100px; height: 100px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrapped_column_max_height_flex" style="height: 500px; width: 700px; flex-direction: column;align-items: center; justify-content: center; align-content: center; flex-wrap:wrap;">
|
||||
<div style="width: 100px; height: 500px; max-height: 200px; flex: 1;"></div>
|
||||
<div style="width: 200px; height: 200px; margin: 20px; flex: 1"></div>
|
||||
<div style="width: 100px; height: 100px;"></div>
|
||||
</div>
|
@@ -30,17 +30,26 @@
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_grow_to_min" experiments="MinFlexFix" style="min-height: 100px; max-height: 500px; width: 100px;">
|
||||
<div id="flex_grow_to_min" style="min-height: 100px; max-height: 500px; width: 100px;">
|
||||
<div style="flex-grow: 1; flex-shrink: 1;"></div>
|
||||
<div style="height: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_grow_in_at_most_container" experiments="MinFlexFix" style="width: 100px; height: 100px; background-color: white; flex-direction: row; align-items: flex-start;">
|
||||
<div id="flex_grow_in_at_most_container" style="width: 100px; height: 100px; background-color: white; flex-direction: row; align-items: flex-start;">
|
||||
<div style="flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 0px;"></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 style="flex-direction: row; max-width: 100px;">
|
||||
<div style="height: 20px; flex-grow: 1;"></div>
|
||||
|
@@ -1,61 +1,61 @@
|
||||
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div id="percentage_width_height" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="width: 30%; height: 30%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_position_left_top" experiments="Rounding" style="width: 400px; height: 400px; flex-direction: row;">
|
||||
<div id="percentage_position_left_top" style="width: 400px; height: 400px; flex-direction: row;">
|
||||
<div style="width: 45%; height: 55%; left: 10%; top: 20%"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_position_bottom_right" experiments="Rounding" style="width: 500px; height: 500px; flex-direction: row;">
|
||||
<div id="percentage_position_bottom_right" style="width: 500px; height: 500px; flex-direction: row;">
|
||||
<div style="width: 55%; height: 15%; bottom: 10%; right: 20%"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div id="percentage_flex_basis" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 50%;"></div>
|
||||
<div style="flex-grow: 1; flex-basis: 25%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_flex_basis_cross" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 50%;"></div>
|
||||
<div style="flex-grow: 1; flex-basis: 25%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_min_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_flex_basis_cross_min_height" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; min-height: 60%;"></div>
|
||||
<div style="flex-grow: 2; min-height: 10%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_main_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div id="percentage_flex_basis_main_max_height" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_flex_basis_cross_max_height" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_main_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div id="percentage_flex_basis_main_max_width" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 15%; max-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; max-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_flex_basis_cross_max_width" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; max-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 15%; max-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_main_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div id="percentage_flex_basis_main_min_width" style="width: 200px; height: 200px; flex-direction: row;">
|
||||
<div style="flex-grow: 1; flex-basis: 15%; min-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 10%; min-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_flex_basis_cross_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_flex_basis_cross_min_width" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%;"></div>
|
||||
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_multiple_nested_with_padding_margin_and_percentage_values" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div id="percentage_multiple_nested_with_padding_margin_and_percentage_values" style="width: 200px; height: 200px; flex-direction: column;">
|
||||
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%; margin: 5px; padding: 3px;">
|
||||
<div style="width: 50%; margin: 5px; padding: 3%;">
|
||||
<div style="width: 45%; margin: 5%; padding: 3px;"></div>
|
||||
@@ -64,19 +64,19 @@
|
||||
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_margin_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
|
||||
<div id="percentage_margin_should_calculate_based_only_on_width" style="width: 200px; height: 100px;">
|
||||
<div style="flex-grow: 1; margin: 10%;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
|
||||
<div id="percentage_padding_should_calculate_based_only_on_width" style="width: 200px; height: 100px;">
|
||||
<div style="flex-grow: 1; padding: 10%;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_absolute_position" experiments="Rounding" style="width: 200px; height: 100px;">
|
||||
<div id="percentage_absolute_position" style="width: 200px; height: 100px;">
|
||||
<div style="position: absolute; top: 10%; left: 30%; width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<div style="width: 100px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="percentage_container_in_wrapping_container" experiments="MinFlexFix" style="align-items: center; width: 200px; height: 200px; justify-content: center;">
|
||||
<div id="percentage_container_in_wrapping_container" style="align-items: center; width: 200px; height: 200px; justify-content: center;">
|
||||
<div>
|
||||
<div style="alignItems: center; flex-direction: row; justify-content: center; width: 100%;">
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<div id="rounding_flex_basis_flex_grow_row_width_of_100" experiments="Rounding" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div id="rounding_flex_basis_flex_grow_row_width_of_100" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_flex_basis_flex_grow_row_prime_number_width" experiments="Rounding" style="width: 113px; height: 100px; flex-direction: row;">
|
||||
<div id="rounding_flex_basis_flex_grow_row_prime_number_width" style="width: 113px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
@@ -12,25 +12,25 @@
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_flex_basis_flex_shrink_row" experiments="Rounding" style="width: 101px; height: 100px; flex-direction: row;">
|
||||
<div id="rounding_flex_basis_flex_shrink_row" style="width: 101px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
<div style="flex-basis: 25px;"></div>
|
||||
<div style="flex-basis: 25px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_flex_basis_overrides_main_size" experiments="Rounding" style="height: 113px; width: 100px;">
|
||||
<div id="rounding_flex_basis_overrides_main_size" style="height: 113px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_total_fractial" experiments="Rounding" style="height: 113.4px; width: 87.4px;">
|
||||
<div id="rounding_total_fractial" style="height: 113.4px; width: 87.4px;">
|
||||
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;"></div>
|
||||
<div style="height: 10px; flex-grow:1.6;"></div>
|
||||
<div style="height: 10.7px; flex-grow:1.1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_total_fractial_nested" experiments="Rounding" style="height: 113.4px; width: 87.4px;">
|
||||
<div id="rounding_total_fractial_nested" style="height: 113.4px; width: 87.4px;">
|
||||
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;">
|
||||
<div style="bottom: 13.3px; height: 9.9px; flex-grow:1; flex-basis:0.3px;"></div>
|
||||
<div style="top: 13.3px; height: 1.1px; flex-grow:4; flex-basis:0.3px;"></div>
|
||||
@@ -39,26 +39,57 @@
|
||||
<div style="height: 10.7px; flex-grow:1.1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_1" experiments="Rounding" style="height: 113.4px; width: 100px;">
|
||||
<div id="rounding_fractial_input_1" style="height: 113.4px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_2" experiments="Rounding" style="height: 113.6px; width: 100px;">
|
||||
<div id="rounding_fractial_input_2" style="height: 113.6px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_3" experiments="Rounding" style="top: 0.3px; height: 113.4px; width: 100px;">
|
||||
<div id="rounding_fractial_input_3" style="top: 0.3px; height: 113.4px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_4" experiments="Rounding" style="top: 0.7px; height: 113.4px; width: 100px;">
|
||||
<div id="rounding_fractial_input_4" style="top: 0.7px; height: 113.4px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_inner_node_controversy_horizontal" 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" 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" 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>
|
||||
|
@@ -420,25 +420,39 @@ function getDefaultStyleValue(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 = [];
|
||||
|
||||
for (var i = 0; i < root.children.length; i++) {
|
||||
var child = root.children[i];
|
||||
rootLayout.push({
|
||||
var layout = {
|
||||
name: child.id !== '' ? child.id : 'INSERT_NAME_HERE',
|
||||
left: child.offsetLeft + child.parentNode.clientLeft,
|
||||
top: child.offsetTop + child.parentNode.clientTop,
|
||||
width: child.offsetWidth,
|
||||
height: child.offsetHeight,
|
||||
children: calculateTree(child),
|
||||
children: calculateTree(child, roundToPixelGrid),
|
||||
style: getYogaStyle(child),
|
||||
declaredStyle: child.style,
|
||||
rawStyle: child.getAttribute('style'),
|
||||
experiments: child.getAttribute('experiments')
|
||||
? child.getAttribute('experiments').split(' ')
|
||||
: [],
|
||||
});
|
||||
};
|
||||
|
||||
var size = getRoundedSize(child);
|
||||
layout.width = size.width;
|
||||
layout.height = size.height;
|
||||
|
||||
rootLayout.push(layout);
|
||||
}
|
||||
|
||||
return rootLayout;
|
||||
|
14
gradle.properties
Normal file
14
gradle.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
|
||||
VERSION_NAME=1.4.3-SNAPSHOT
|
||||
POM_URL=https://github.com/facebook/yoga
|
||||
POM_SCM_URL=https://github.com/facebook/yoga.git
|
||||
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
|
||||
POM_SCM_DEV_CONNECTION=scm:git:git@github.com:facebook/yoga.git
|
||||
POM_LICENSE_NAME=BSD License
|
||||
POM_LICENSE_URL=https://github.com/facebook/yoga/blob/master/LICENSE
|
||||
POM_LICENSE_DIST=repo
|
||||
POM_DEVELOPER_ID=facebook
|
||||
POM_DEVELOPER_NAME=facebook
|
@@ -1,92 +0,0 @@
|
||||
ext {
|
||||
bintrayUserOrg = 'facebook'
|
||||
bintrayRepo = 'maven'
|
||||
siteURL = "https://facebook.github.io/yoga/"
|
||||
projectLicenses = {
|
||||
license {
|
||||
name 'BSD License'
|
||||
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getBintrayUsername() {
|
||||
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
|
||||
}
|
||||
|
||||
def getBintrayApiKey() {
|
||||
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
||||
}
|
||||
|
||||
def getBintrayGpgPassword() {
|
||||
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
|
||||
}
|
||||
|
||||
def dryRunOnly() {
|
||||
return hasProperty('dryRun') ? property('dryRun').toBoolean() : false
|
||||
}
|
||||
|
||||
def pomConfig = {
|
||||
licenses {
|
||||
// TODO Can we grab this from above?
|
||||
license {
|
||||
name 'BSD License'
|
||||
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
primaryPublication(MavenPublication) {
|
||||
groupId group
|
||||
artifact(sourcesJar)
|
||||
artifact(javadocJar)
|
||||
pom.packaging='aar'
|
||||
pom.withXml {
|
||||
def root = asNode()
|
||||
root.appendNode('name', 'Yoga')
|
||||
root.appendNode('url', siteURL)
|
||||
root.children().last() + pomConfig
|
||||
def dependenciesNode = root.appendNode('dependencies')
|
||||
//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
|
||||
configurations.compile.allDependencies.each {
|
||||
if(it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null) {
|
||||
def dependencyNode = dependenciesNode.appendNode('dependency')
|
||||
dependencyNode.appendNode('groupId', it.group)
|
||||
dependencyNode.appendNode('artifactId', it.name)
|
||||
dependencyNode.appendNode('version', it.version)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bintray {
|
||||
user = getBintrayUsername()
|
||||
key = getBintrayApiKey()
|
||||
publications = ['primaryPublication']
|
||||
configurations = ['archives']
|
||||
pkg {
|
||||
repo = bintrayRepo
|
||||
userOrg = bintrayUserOrg
|
||||
name = project.bintrayName
|
||||
dryRun = dryRunOnly()
|
||||
licenses = projectLicenses
|
||||
override = true
|
||||
publish = true
|
||||
publicDownloadNumbers = true
|
||||
version {
|
||||
name = project.version
|
||||
released = new Date()
|
||||
gpg {
|
||||
sign = true
|
||||
passphrase = getBintrayGpgPassword()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
gradle/android-maven-install.gradle
Normal file
37
gradle/android-maven-install.gradle
Normal file
@@ -0,0 +1,37 @@
|
||||
// Configure the Android maven publication
|
||||
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
version = VERSION_NAME
|
||||
group = GROUP
|
||||
// Set the .aar / .jar base file name to match the artifact ID
|
||||
// in case the module has a different name
|
||||
project.archivesBaseName = POM_ARTIFACT_ID
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
// This generates POM.xml with proper parameters
|
||||
pom.project {
|
||||
name POM_NAME
|
||||
artifactId POM_ARTIFACT_ID
|
||||
packaging POM_PACKAGING
|
||||
description POM_DESCRIPTION
|
||||
url projectUrl
|
||||
|
||||
scm {
|
||||
url scmUrl
|
||||
connection scmConnection
|
||||
developerConnection scmDeveloperConnection
|
||||
}
|
||||
|
||||
licenses projectLicenses
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id developerId
|
||||
name developerName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
gradle/android-tasks.gradle
Normal file
47
gradle/android-tasks.gradle
Normal file
@@ -0,0 +1,47 @@
|
||||
// Android tasks for Javadoc and sources.jar generation
|
||||
|
||||
afterEvaluate { project ->
|
||||
if (POM_PACKAGING == 'aar') {
|
||||
task androidJavadoc(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.srcDirs
|
||||
exclude '**/pom.xml'
|
||||
exclude '**/proguard_annotations.pro'
|
||||
classpath += files(android.bootClasspath)
|
||||
}
|
||||
|
||||
task androidJavadocJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
from androidJavadoc.destinationDir
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
def name = variant.name.capitalize()
|
||||
task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
|
||||
from variant.javaCompile.destinationDir
|
||||
}
|
||||
}
|
||||
|
||||
artifacts.add('archives', androidJavadocJar)
|
||||
artifacts.add('archives', androidSourcesJar)
|
||||
}
|
||||
|
||||
if (POM_PACKAGING == 'jar') {
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
artifacts.add('archives', javadocJar)
|
||||
artifacts.add('archives', sourcesJar)
|
||||
}
|
||||
}
|
63
gradle/bintray.gradle
Normal file
63
gradle/bintray.gradle
Normal file
@@ -0,0 +1,63 @@
|
||||
// Upload to Bintray
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
def getBintrayUsername() {
|
||||
return project.hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
|
||||
}
|
||||
|
||||
def getBintrayApiKey() {
|
||||
return project.hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
||||
}
|
||||
|
||||
def getBintrayGpgPassword() {
|
||||
return project.hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
|
||||
}
|
||||
|
||||
def getMavenCentralUsername() {
|
||||
return project.hasProperty('mavenCentralUsername') ? property('mavenCentralUsername') : System.getenv('MAVEN_CENTRAL_USERNAME')
|
||||
}
|
||||
|
||||
def getMavenCentralPassword() {
|
||||
return project.hasProperty('mavenCentralPassword') ? property('mavenCentralPassword') : System.getenv('MAVEN_CENTRAL_PASSWORD')
|
||||
}
|
||||
|
||||
def shouldSyncWithMavenCentral() {
|
||||
return project.hasProperty('syncWithMavenCentral') ? property('syncWithMavenCentral').toBoolean() : false
|
||||
}
|
||||
|
||||
def dryRunOnly() {
|
||||
return project.hasProperty('dryRun') ? property('dryRun').toBoolean() : false
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = getBintrayUsername()
|
||||
key = getBintrayApiKey()
|
||||
configurations = ['archives']
|
||||
pkg {
|
||||
repo = bintrayRepo
|
||||
userOrg = bintrayUserOrg
|
||||
name = bintrayName
|
||||
desc = bintrayDescription
|
||||
websiteUrl = projectUrl
|
||||
issueTrackerUrl = issuesUrl
|
||||
vcsUrl = scmUrl
|
||||
licenses = projectLicenses
|
||||
dryRun = dryRunOnly()
|
||||
override = true
|
||||
publish = true
|
||||
publicDownloadNumbers = true
|
||||
version {
|
||||
desc = bintrayDescription
|
||||
gpg {
|
||||
sign = true
|
||||
passphrase = getBintrayGpgPassword()
|
||||
}
|
||||
mavenCentralSync {
|
||||
sync = shouldSyncWithMavenCentral()
|
||||
user = getMavenCentralUsername()
|
||||
password = getMavenCentralPassword()
|
||||
close = '1' // If set to 0, you have to manually click release
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
96
gradle/gradle-mvn-push.gradle
Normal file
96
gradle/gradle-mvn-push.gradle
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2013 Chris Banes
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'signing'
|
||||
|
||||
version = VERSION_NAME
|
||||
group = GROUP
|
||||
|
||||
def isReleaseBuild() {
|
||||
return VERSION_NAME.contains('SNAPSHOT') == false
|
||||
}
|
||||
|
||||
def getReleaseRepositoryUrl() {
|
||||
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
||||
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
}
|
||||
|
||||
def getSnapshotRepositoryUrl() {
|
||||
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
||||
: "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
|
||||
def getRepositoryUsername() {
|
||||
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
|
||||
}
|
||||
|
||||
def getRepositoryPassword() {
|
||||
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
|
||||
}
|
||||
|
||||
afterEvaluate { project ->
|
||||
uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||
|
||||
pom.groupId = GROUP
|
||||
pom.artifactId = POM_ARTIFACT_ID
|
||||
pom.version = VERSION_NAME
|
||||
|
||||
repository(url: getReleaseRepositoryUrl()) {
|
||||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
|
||||
}
|
||||
snapshotRepository(url: getSnapshotRepositoryUrl()) {
|
||||
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
|
||||
}
|
||||
|
||||
pom.project {
|
||||
name POM_NAME
|
||||
packaging POM_PACKAGING
|
||||
description POM_DESCRIPTION
|
||||
url POM_URL
|
||||
|
||||
scm {
|
||||
url POM_SCM_URL
|
||||
connection POM_SCM_CONNECTION
|
||||
developerConnection POM_SCM_DEV_CONNECTION
|
||||
}
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name POM_LICENSE_NAME
|
||||
url POM_LICENSE_URL
|
||||
distribution POM_LICENSE_DIST
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id POM_DEVELOPER_ID
|
||||
name POM_DEVELOPER_NAME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
|
||||
sign configurations.archives
|
||||
}
|
||||
}
|
33
gradle/release-bintray.gradle
Normal file
33
gradle/release-bintray.gradle
Normal file
@@ -0,0 +1,33 @@
|
||||
// Set up everything required for releasing on Bintray
|
||||
ext {
|
||||
bintrayRepo = 'maven'
|
||||
bintrayUserOrg = 'facebook'
|
||||
bintrayName = "${GROUP}:${POM_ARTIFACT_ID}"
|
||||
bintrayDescription = POM_DESCRIPTION
|
||||
projectUrl = POM_URL
|
||||
issuesUrl = 'https://github.com/facebook/yoga/issues'
|
||||
scmUrl = POM_SCM_URL
|
||||
scmConnection = POM_SCM_CONNECTION
|
||||
scmDeveloperConnection = POM_SCM_DEV_CONNECTION
|
||||
|
||||
publishedGroupId = GROUP
|
||||
libraryName = 'yoga'
|
||||
artifact = 'yoga'
|
||||
|
||||
developerId = POM_DEVELOPER_ID
|
||||
developerName = POM_DEVELOPER_NAME
|
||||
|
||||
projectLicenses = {
|
||||
license {
|
||||
name = POM_LICENSE_NAME
|
||||
url = POM_LICENSE_URL
|
||||
distribution = POM_LICENSE_DIST
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the Android Maven publication (POM etc.)
|
||||
apply from: rootProject.file('gradle/android-maven-install.gradle')
|
||||
|
||||
// Upload to Bintray
|
||||
apply from: rootProject.file('gradle/bintray.gradle')
|
8
gradle/release.gradle
Normal file
8
gradle/release.gradle
Normal file
@@ -0,0 +1,8 @@
|
||||
// Common Android tasks for all releases that generate Javadocs, sources, etc.
|
||||
apply from: rootProject.file('gradle/android-tasks.gradle')
|
||||
|
||||
// Upload to Bintray
|
||||
apply from: rootProject.file('gradle/release-bintray.gradle')
|
||||
|
||||
// Upload directly to standard Maven Central (for SNAPSHOTs)
|
||||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
|
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.github.dcendents.android-maven'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
targetCompatibility = '1.7'
|
||||
sourceCompatibility = '1.7'
|
||||
|
||||
version = '1.3.1'
|
||||
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'
|
||||
}
|
||||
group = GROUP
|
||||
version = VERSION_NAME
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.1.0"
|
||||
compileSdkVersion rootProject.compileSdkVersion
|
||||
buildToolsVersion rootProject.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 19
|
||||
minSdkVersion rootProject.minSdkVersion
|
||||
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 {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility rootProject.targetCompatibilityVersion
|
||||
sourceCompatibility rootProject.sourceCompatibilityVersion
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -39,12 +46,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
preBuild.dependsOn buckBuildAndCopy
|
||||
|
||||
dependencies {
|
||||
compile(name: 'jsr305')
|
||||
compile(name: 'soloader-0.1.0', ext: 'aar')
|
||||
provided(project(':yoga:proguard-annotations'))
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
||||
compile 'com.facebook.soloader:soloader:0.2.0'
|
||||
provided project(':yoga:proguard-annotations')
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
@@ -65,7 +70,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
}
|
||||
|
||||
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/release.gradle')
|
||||
|
@@ -18,5 +18,5 @@ public interface YogaBaselineFunction {
|
||||
* default to the computed height of the node.
|
||||
*/
|
||||
@DoNotStrip
|
||||
float baseline(YogaNodeAPI node, float width, float height);
|
||||
float baseline(YogaNode node, float width, float height);
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ public class YogaConfig {
|
||||
}
|
||||
|
||||
long mNativePointer;
|
||||
private YogaLogger mLogger;
|
||||
|
||||
private native long jni_YGConfigNew();
|
||||
public YogaConfig() {
|
||||
@@ -51,4 +52,30 @@ public class YogaConfig {
|
||||
public void setUseWebDefaults(boolean useWebDefaults) {
|
||||
jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
|
||||
public void setPointScaleFactor(float pixelsInPoint) {
|
||||
jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
|
||||
|
||||
/**
|
||||
* Yoga previously had an error where containers would take the maximum space possible instead of the minimum
|
||||
* like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch;
|
||||
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
|
||||
*/
|
||||
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
|
||||
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
||||
public void setLogger(YogaLogger logger) {
|
||||
mLogger = logger;
|
||||
jni_YGConfigSetLogger(mNativePointer, logger);
|
||||
}
|
||||
|
||||
public YogaLogger getLogger() {
|
||||
return mLogger;
|
||||
}
|
||||
}
|
||||
|
@@ -13,9 +13,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
@DoNotStrip
|
||||
public enum YogaExperimentalFeature {
|
||||
ROUNDING(0),
|
||||
WEB_FLEX_BASIS(1),
|
||||
MIN_FLEX_FIX(2);
|
||||
WEB_FLEX_BASIS(0);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
@@ -29,9 +27,7 @@ public enum YogaExperimentalFeature {
|
||||
|
||||
public static YogaExperimentalFeature fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0: return ROUNDING;
|
||||
case 1: return WEB_FLEX_BASIS;
|
||||
case 2: return MIN_FLEX_FIX;
|
||||
case 0: return WEB_FLEX_BASIS;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,8 @@ public enum YogaLogLevel {
|
||||
WARN(1),
|
||||
INFO(2),
|
||||
DEBUG(3),
|
||||
VERBOSE(4);
|
||||
VERBOSE(4),
|
||||
FATAL(5);
|
||||
|
||||
private int mIntValue;
|
||||
|
||||
@@ -36,6 +37,7 @@ public enum YogaLogLevel {
|
||||
case 2: return INFO;
|
||||
case 3: return DEBUG;
|
||||
case 4: return VERBOSE;
|
||||
case 5: return FATAL;
|
||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||
}
|
||||
}
|
||||
|
@@ -18,5 +18,5 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
@DoNotStrip
|
||||
public interface YogaLogger {
|
||||
@DoNotStrip
|
||||
void log(YogaLogLevel level, String message);
|
||||
void log(YogaNode node, YogaLogLevel level, String message);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ public interface YogaMeasureFunction {
|
||||
*/
|
||||
@DoNotStrip
|
||||
long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
|
@@ -18,7 +18,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
public class YogaNode {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("yoga");
|
||||
@@ -28,12 +28,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
* Get native instance count. Useful for testing only.
|
||||
*/
|
||||
static native int jni_YGNodeGetInstanceCount();
|
||||
static native void jni_YGLog(int level, String message);
|
||||
|
||||
private static native void jni_YGSetLogger(Object logger);
|
||||
public static void setLogger(YogaLogger logger) {
|
||||
jni_YGSetLogger(logger);
|
||||
}
|
||||
|
||||
private YogaNode mParent;
|
||||
private List<YogaNode> mChildren;
|
||||
@@ -106,7 +100,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeFree(long nativePointer);
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
jni_YGNodeFree(mNativePointer);
|
||||
@@ -116,7 +109,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeReset(long nativePointer);
|
||||
@Override
|
||||
public void reset() {
|
||||
mEdgeSetFlag = 0;
|
||||
mHasSetPosition = false;
|
||||
@@ -141,23 +133,21 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
mLayoutDirection = 0;
|
||||
|
||||
mMeasureFunction = null;
|
||||
mBaselineFunction = null;
|
||||
mData = null;
|
||||
|
||||
jni_YGNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount() {
|
||||
return mChildren == null ? 0 : mChildren.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaNode getChildAt(int i) {
|
||||
return mChildren.get(i);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
@Override
|
||||
public void addChildAt(YogaNode child, int i) {
|
||||
if (child.mParent != null) {
|
||||
throw new IllegalStateException("Child already has a parent, it must be removed first.");
|
||||
@@ -172,7 +162,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
||||
@Override
|
||||
public YogaNode removeChildAt(int i) {
|
||||
|
||||
final YogaNode child = mChildren.remove(i);
|
||||
@@ -181,221 +170,184 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
return child;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable
|
||||
YogaNode getParent() {
|
||||
return mParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(YogaNode child) {
|
||||
return mChildren == null ? -1 : mChildren.indexOf(child);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
|
||||
@Override
|
||||
public void calculateLayout(float width, float height) {
|
||||
jni_YGNodeCalculateLayout(mNativePointer, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNewLayout() {
|
||||
return mHasNewLayout;
|
||||
}
|
||||
|
||||
private native void jni_YGNodeMarkDirty(long nativePointer);
|
||||
@Override
|
||||
public void dirty() {
|
||||
jni_YGNodeMarkDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private native boolean jni_YGNodeIsDirty(long nativePointer);
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
@Override
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markLayoutSeen() {
|
||||
mHasNewLayout = false;
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaDirection getStyleDirection() {
|
||||
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
||||
@Override
|
||||
public void setDirection(YogaDirection direction) {
|
||||
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
||||
@Override
|
||||
public YogaFlexDirection getFlexDirection() {
|
||||
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
||||
@Override
|
||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
||||
@Override
|
||||
public YogaJustify getJustifyContent() {
|
||||
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
||||
@Override
|
||||
public void setJustifyContent(YogaJustify justifyContent) {
|
||||
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignItems() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
||||
@Override
|
||||
public void setAlignItems(YogaAlign alignItems) {
|
||||
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignSelf() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
||||
@Override
|
||||
public void setAlignSelf(YogaAlign alignSelf) {
|
||||
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
||||
@Override
|
||||
public YogaAlign getAlignContent() {
|
||||
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
||||
@Override
|
||||
public void setAlignContent(YogaAlign alignContent) {
|
||||
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
||||
@Override
|
||||
public YogaPositionType getPositionType() {
|
||||
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
||||
@Override
|
||||
public void setPositionType(YogaPositionType positionType) {
|
||||
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
||||
@Override
|
||||
public void setWrap(YogaWrap flexWrap) {
|
||||
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
||||
@Override
|
||||
public YogaOverflow getOverflow() {
|
||||
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
||||
@Override
|
||||
public void setOverflow(YogaOverflow overflow) {
|
||||
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
||||
}
|
||||
|
||||
private native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
||||
@Override
|
||||
public YogaDisplay getDisplay() {
|
||||
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
||||
@Override
|
||||
public void setDisplay(YogaDisplay display) {
|
||||
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
||||
@Override
|
||||
public void setFlex(float flex) {
|
||||
jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
|
||||
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
||||
@Override
|
||||
public float getFlexGrow() {
|
||||
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
||||
@Override
|
||||
public void setFlexGrow(float flexGrow) {
|
||||
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
||||
}
|
||||
|
||||
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
||||
@Override
|
||||
public float getFlexShrink() {
|
||||
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
||||
@Override
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getFlexBasis() {
|
||||
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
||||
@Override
|
||||
public void setFlexBasis(float flexBasis) {
|
||||
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setFlexBasisPercent(float percent) {
|
||||
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
||||
@Override
|
||||
public void setFlexBasisAuto() {
|
||||
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||
@Override
|
||||
public YogaValue getMargin(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & MARGIN) == MARGIN)) {
|
||||
return YogaValue.UNDEFINED;
|
||||
@@ -404,28 +356,24 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
@Override
|
||||
public void setMargin(YogaEdge edge, float margin) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
||||
@Override
|
||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
||||
@Override
|
||||
public void setMarginAuto(YogaEdge edge) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||
@Override
|
||||
public YogaValue getPadding(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & PADDING) == PADDING)) {
|
||||
return YogaValue.UNDEFINED;
|
||||
@@ -434,21 +382,18 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
@Override
|
||||
public void setPadding(YogaEdge edge, float padding) {
|
||||
mEdgeSetFlag |= PADDING;
|
||||
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
||||
@Override
|
||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||
mEdgeSetFlag |= PADDING;
|
||||
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getBorder(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & BORDER) == BORDER)) {
|
||||
return YogaConstants.UNDEFINED;
|
||||
@@ -457,14 +402,12 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
@Override
|
||||
public void setBorder(YogaEdge edge, float border) {
|
||||
mEdgeSetFlag |= BORDER;
|
||||
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||
@Override
|
||||
public YogaValue getPosition(YogaEdge edge) {
|
||||
if (!mHasSetPosition) {
|
||||
return YogaValue.UNDEFINED;
|
||||
@@ -473,135 +416,113 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
@Override
|
||||
public void setPosition(YogaEdge edge, float position) {
|
||||
mHasSetPosition = true;
|
||||
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
||||
@Override
|
||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||
mHasSetPosition = true;
|
||||
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
||||
@Override
|
||||
public void setWidth(float width) {
|
||||
jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
||||
@Override
|
||||
public void setWidthAuto() {
|
||||
jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
||||
@Override
|
||||
public void setHeight(float height) {
|
||||
jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
||||
@Override
|
||||
public void setHeightAuto() {
|
||||
jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getMinWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
||||
@Override
|
||||
public void setMinWidth(float minWidth) {
|
||||
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setMinWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getMinHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
||||
@Override
|
||||
public void setMinHeight(float minHeight) {
|
||||
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setMinHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getMaxWidth() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
||||
@Override
|
||||
public void setMaxWidth(float maxWidth) {
|
||||
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setMaxWidthPercent(float percent) {
|
||||
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
||||
@Override
|
||||
public YogaValue getMaxHeight() {
|
||||
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
||||
@Override
|
||||
public void setMaxHeight(float maxheight) {
|
||||
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
||||
@Override
|
||||
public void setMaxHeightPercent(float percent) {
|
||||
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
@@ -616,27 +537,22 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutX() {
|
||||
return mLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutY() {
|
||||
return mTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutHeight() {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutMargin(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
@@ -656,7 +572,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutPadding(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
@@ -676,7 +591,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutBorder(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
@@ -696,13 +610,11 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.fromInt(mLayoutDirection);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
@Override
|
||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||
mMeasureFunction = measureFunction;
|
||||
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||
@@ -728,7 +640,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
|
||||
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
@Override
|
||||
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
||||
mBaselineFunction = baselineFunction;
|
||||
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
||||
@@ -739,18 +650,25 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
return mBaselineFunction.baseline(this, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMeasureDefined() {
|
||||
return mMeasureFunction != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Object data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
private native void jni_YGNodePrint(long nativePointer);
|
||||
|
||||
/**
|
||||
* Use the set logger (defaults to adb log) to print out the styles, children, and computed
|
||||
* layout of the tree rooted at this node.
|
||||
*/
|
||||
public void print() {
|
||||
jni_YGNodePrint(mNativePointer);
|
||||
}
|
||||
}
|
||||
|
@@ -1,100 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.yoga;
|
||||
|
||||
// This only exists for legacy reasons. It will be removed sometime in the near future.
|
||||
public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
|
||||
int getChildCount();
|
||||
YogaNodeType getChildAt(int i);
|
||||
void addChildAt(YogaNodeType child, int i);
|
||||
YogaNodeType removeChildAt(int i);
|
||||
YogaNodeType getParent();
|
||||
int indexOf(YogaNodeType child);
|
||||
void setMeasureFunction(YogaMeasureFunction measureFunction);
|
||||
void setBaselineFunction(YogaBaselineFunction measureFunction);
|
||||
boolean isMeasureDefined();
|
||||
void calculateLayout(float width, float height);
|
||||
boolean isDirty();
|
||||
boolean hasNewLayout();
|
||||
void dirty();
|
||||
void markLayoutSeen();
|
||||
void copyStyle(YogaNodeType srcNode);
|
||||
YogaDirection getStyleDirection();
|
||||
void setDirection(YogaDirection direction);
|
||||
YogaFlexDirection getFlexDirection();
|
||||
void setFlexDirection(YogaFlexDirection flexDirection);
|
||||
YogaJustify getJustifyContent();
|
||||
void setJustifyContent(YogaJustify justifyContent);
|
||||
YogaAlign getAlignItems();
|
||||
void setAlignItems(YogaAlign alignItems);
|
||||
YogaAlign getAlignSelf();
|
||||
void setAlignSelf(YogaAlign alignSelf);
|
||||
YogaAlign getAlignContent();
|
||||
void setAlignContent(YogaAlign alignContent);
|
||||
YogaPositionType getPositionType();
|
||||
void setPositionType(YogaPositionType positionType);
|
||||
void setWrap(YogaWrap flexWrap);
|
||||
void setFlex(float flex);
|
||||
float getFlexGrow();
|
||||
void setFlexGrow(float flexGrow);
|
||||
float getFlexShrink();
|
||||
void setFlexShrink(float flexShrink);
|
||||
YogaValue getFlexBasis();
|
||||
void setFlexBasis(float flexBasis);
|
||||
void setFlexBasisPercent(float percent);
|
||||
void setFlexBasisAuto();
|
||||
YogaValue getMargin(YogaEdge edge);
|
||||
void setMargin(YogaEdge edge, float margin);
|
||||
void setMarginPercent(YogaEdge edge, float percent);
|
||||
void setMarginAuto(YogaEdge edge);
|
||||
YogaValue getPadding(YogaEdge edge);
|
||||
void setPadding(YogaEdge edge, float padding);
|
||||
void setPaddingPercent(YogaEdge edge, float percent);
|
||||
float getBorder(YogaEdge edge);
|
||||
void setBorder(YogaEdge edge, float border);
|
||||
YogaValue getPosition(YogaEdge edge);
|
||||
void setPosition(YogaEdge edge, float position);
|
||||
void setPositionPercent(YogaEdge edge, float percent);
|
||||
YogaValue getWidth();
|
||||
void setWidth(float width);
|
||||
void setWidthPercent(float percent);
|
||||
void setWidthAuto();
|
||||
YogaValue getHeight();
|
||||
void setHeight(float height);
|
||||
void setHeightPercent(float percent);
|
||||
void setHeightAuto();
|
||||
YogaValue getMaxWidth();
|
||||
void setMaxWidth(float maxWidth);
|
||||
void setMaxWidthPercent(float percent);
|
||||
YogaValue getMinWidth();
|
||||
void setMinWidth(float minWidth);
|
||||
void setMinWidthPercent(float percent);
|
||||
YogaValue getMaxHeight();
|
||||
void setMaxHeight(float maxHeight);
|
||||
void setMaxHeightPercent(float percent);
|
||||
YogaValue getMinHeight();
|
||||
void setMinHeight(float minHeight);
|
||||
void setMinHeightPercent(float percent);
|
||||
float getLayoutX();
|
||||
float getLayoutY();
|
||||
float getLayoutWidth();
|
||||
float getLayoutHeight();
|
||||
float getLayoutMargin(YogaEdge edge);
|
||||
float getLayoutPadding(YogaEdge edge);
|
||||
float getLayoutBorder(YogaEdge edge);
|
||||
YogaDirection getLayoutDirection();
|
||||
YogaOverflow getOverflow();
|
||||
void setOverflow(YogaOverflow overflow);
|
||||
YogaDisplay getDisplay();
|
||||
void setDisplay(YogaDisplay display);
|
||||
void setData(Object data);
|
||||
Object getData();
|
||||
void reset();
|
||||
}
|
5
java/gradle.properties
Normal file
5
java/gradle.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
GROUP=com.facebook.yoga
|
||||
POM_NAME=Yoga
|
||||
POM_DESCRIPTION=Java bindings to libyoga
|
||||
POM_ARTIFACT_ID=yoga
|
||||
POM_PACKAGING=aar
|
@@ -14,8 +14,12 @@
|
||||
using namespace facebook::jni;
|
||||
using namespace std;
|
||||
|
||||
static inline weak_ref<jobject> *YGNodeJobject(YGNodeRef node) {
|
||||
return reinterpret_cast<weak_ref<jobject> *>(YGNodeGetContext(node));
|
||||
struct JYogaNode : public JavaClass<JYogaNode> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNode;";
|
||||
};
|
||||
|
||||
static inline weak_ref<JYogaNode> *YGNodeJobject(YGNodeRef node) {
|
||||
return reinterpret_cast<weak_ref<JYogaNode> *>(YGNodeGetContext(node));
|
||||
}
|
||||
|
||||
static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNode) {
|
||||
@@ -24,7 +28,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNod
|
||||
}
|
||||
|
||||
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
if(YGNodeGetHasNewLayout(root)){
|
||||
if (YGNodeGetHasNewLayout(root)) {
|
||||
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||
@@ -54,28 +58,28 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
const int PADDING = 2;
|
||||
const int BORDER = 4;
|
||||
|
||||
int hasEdgeSetFlag = (int)obj->getFieldValue(edgeSetFlagField);
|
||||
int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField);
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||
|
||||
if((hasEdgeSetFlag & MARGIN) == MARGIN){
|
||||
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
||||
obj->setFieldValue(marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||
obj->setFieldValue(marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||
}
|
||||
|
||||
if((hasEdgeSetFlag & PADDING) == PADDING){
|
||||
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
||||
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
}
|
||||
|
||||
if((hasEdgeSetFlag & BORDER) == BORDER){
|
||||
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
||||
obj->setFieldValue(borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
@@ -90,7 +94,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
||||
}
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
YGLog(root, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +103,7 @@ static void YGPrint(YGNodeRef node) {
|
||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||
cout << obj->toString() << endl;
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
YGLog(node, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +140,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
|
||||
|
||||
return YGSize{*measuredWidth, *measuredHeight};
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
YGLog(node, YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
return YGSize{
|
||||
widthMode == YGMeasureModeUndefined ? 0 : width,
|
||||
heightMode == YGMeasureModeUndefined ? 0 : height,
|
||||
@@ -148,20 +152,28 @@ struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
|
||||
};
|
||||
|
||||
static global_ref<jobject> *jLogger;
|
||||
static int YGLog(YGLogLevel level, const char *format, va_list args) {
|
||||
static int YGJNILogFunc(const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
const char *format,
|
||||
va_list args) {
|
||||
char buffer[256];
|
||||
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
static auto logFunc = findClassStatic("com/facebook/yoga/YogaLogger")
|
||||
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
|
||||
static auto logFunc =
|
||||
findClassStatic("com/facebook/yoga/YogaLogger")
|
||||
->getMethod<void(local_ref<JYogaNode>, local_ref<JYogaLogLevel>, jstring)>("log");
|
||||
|
||||
static auto logLevelFromInt =
|
||||
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
|
||||
|
||||
logFunc(jLogger->get(),
|
||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||
auto jlogger = reinterpret_cast<global_ref<jobject> *>(YGConfigGetContext(config));
|
||||
logFunc(jlogger->get(),
|
||||
obj,
|
||||
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
|
||||
Environment::current()->NewStringUTF(buffer));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -174,27 +186,6 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
||||
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
||||
}
|
||||
|
||||
void jni_YGSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
|
||||
if (jLogger) {
|
||||
jLogger->releaseAlias();
|
||||
delete jLogger;
|
||||
}
|
||||
|
||||
if (logger) {
|
||||
jLogger = new global_ref<jobject>(make_global(logger));
|
||||
YGSetLogger(YGLog);
|
||||
} else {
|
||||
jLogger = NULL;
|
||||
YGSetLogger(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void jni_YGLog(alias_ref<jclass> clazz, jint level, jstring message) {
|
||||
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
|
||||
YGLog(static_cast<YGLogLevel>(level), "%s", nMessage);
|
||||
Environment::current()->ReleaseStringUTFChars(message, nMessage);
|
||||
}
|
||||
|
||||
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
||||
const YGNodeRef node = YGNodeNew();
|
||||
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
|
||||
@@ -223,6 +214,13 @@ void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
YGNodeSetPrintFunc(node, YGPrint);
|
||||
}
|
||||
|
||||
void jni_YGNodePrint(alias_ref<jobject> thiz, jlong nativePointer) {
|
||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||
YGNodePrint(node,
|
||||
(YGPrintOptions)(YGPrintOptionsStyle | YGPrintOptionsLayout |
|
||||
YGPrintOptionsChildren));
|
||||
}
|
||||
|
||||
void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer, jint index) {
|
||||
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
||||
}
|
||||
@@ -388,16 +386,56 @@ void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
|
||||
YGConfigFree(config);
|
||||
}
|
||||
|
||||
void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>, jlong nativePointer, jint feature, jboolean enabled) {
|
||||
void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jint feature,
|
||||
jboolean enabled) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetExperimentalFeatureEnabled(config, static_cast<YGExperimentalFeature>(feature), enabled);
|
||||
YGConfigSetExperimentalFeatureEnabled(config,
|
||||
static_cast<YGExperimentalFeature>(feature),
|
||||
enabled);
|
||||
}
|
||||
|
||||
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>, jlong nativePointer, jboolean useWebDefaults) {
|
||||
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jboolean useWebDefaults) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
||||
}
|
||||
|
||||
void jni_YGConfigSetPointScaleFactor(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jfloat pixelsInPoint) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetPointScaleFactor(config, pixelsInPoint);
|
||||
}
|
||||
|
||||
void jni_YGConfigSetUseLegacyStretchBehaviour(alias_ref<jobject>,
|
||||
jlong nativePointer,
|
||||
jboolean useLegacyStretchBehaviour) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
void jni_YGConfigSetLogger(alias_ref<jobject>, jlong nativePointer, alias_ref<jobject> logger) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
|
||||
auto context = YGConfigGetContext(config);
|
||||
if (context) {
|
||||
auto jlogger = reinterpret_cast<global_ref<jobject> *>(context);
|
||||
jlogger->releaseAlias();
|
||||
delete jlogger;
|
||||
}
|
||||
|
||||
if (logger) {
|
||||
YGConfigSetContext(config, new global_ref<jobject>(make_global(logger)));
|
||||
YGConfigSetLogger(config, YGJNILogFunc);
|
||||
} else {
|
||||
YGConfigSetContext(config, NULL);
|
||||
YGConfigSetLogger(config, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
|
||||
return YGNodeGetInstanceCount();
|
||||
}
|
||||
@@ -483,8 +521,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
||||
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
||||
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
||||
YGMakeNativeMethod(jni_YGSetLogger),
|
||||
YGMakeNativeMethod(jni_YGLog),
|
||||
YGMakeNativeMethod(jni_YGNodePrint),
|
||||
});
|
||||
registerNatives("com/facebook/yoga/YogaConfig",
|
||||
{
|
||||
@@ -492,6 +529,9 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
YGMakeNativeMethod(jni_YGConfigFree),
|
||||
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
|
||||
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults),
|
||||
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
|
||||
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
|
||||
YGMakeNativeMethod(jni_YGConfigSetLogger),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -1791,4 +1791,145 @@ public class YGAlignItemsTest {
|
||||
assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_center_should_size_based_on_content() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setAlignItems(YogaAlign.CENTER);
|
||||
root.setMargin(YogaEdge.TOP, 20f);
|
||||
root.setWidth(100f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setJustifyContent(YogaJustify.CENTER);
|
||||
root_child0.setFlexShrink(1f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0.setFlexGrow(1f);
|
||||
root_child0_child0.setFlexShrink(1f);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0_child0.setWidth(20f);
|
||||
root_child0_child0_child0.setHeight(20f);
|
||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_strech_should_size_based_on_parent() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setMargin(YogaEdge.TOP, 20f);
|
||||
root.setWidth(100f);
|
||||
root.setHeight(100f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setJustifyContent(YogaJustify.CENTER);
|
||||
root_child0.setFlexShrink(1f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0.setFlexGrow(1f);
|
||||
root_child0_child0.setFlexShrink(1f);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child0 = new YogaNode(config);
|
||||
root_child0_child0_child0.setWidth(20f);
|
||||
root_child0_child0_child0.setHeight(20f);
|
||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1364,4 +1364,166 @@ public class YGFlexWrapTest {
|
||||
assertEquals(80f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wrapped_column_max_height() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setJustifyContent(YogaJustify.CENTER);
|
||||
root.setAlignContent(YogaAlign.CENTER);
|
||||
root.setAlignItems(YogaAlign.CENTER);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(700f);
|
||||
root.setHeight(500f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setWidth(100f);
|
||||
root_child0.setHeight(500f);
|
||||
root_child0.setMaxHeight(200f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setMargin(YogaEdge.LEFT, 20f);
|
||||
root_child1.setMargin(YogaEdge.TOP, 20f);
|
||||
root_child1.setMargin(YogaEdge.RIGHT, 20f);
|
||||
root_child1.setMargin(YogaEdge.BOTTOM, 20f);
|
||||
root_child1.setWidth(200f);
|
||||
root_child1.setHeight(200f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setWidth(100f);
|
||||
root_child2.setHeight(100f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(700f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(200f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(250f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(420f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(700f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(350f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(300f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(250f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wrapped_column_max_height_flex() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setJustifyContent(YogaJustify.CENTER);
|
||||
root.setAlignContent(YogaAlign.CENTER);
|
||||
root.setAlignItems(YogaAlign.CENTER);
|
||||
root.setWrap(YogaWrap.WRAP);
|
||||
root.setWidth(700f);
|
||||
root.setHeight(500f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexShrink(1f);
|
||||
root_child0.setFlexBasisPercent(0f);
|
||||
root_child0.setWidth(100f);
|
||||
root_child0.setHeight(500f);
|
||||
root_child0.setMaxHeight(200f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setFlexShrink(1f);
|
||||
root_child1.setFlexBasisPercent(0f);
|
||||
root_child1.setMargin(YogaEdge.LEFT, 20f);
|
||||
root_child1.setMargin(YogaEdge.TOP, 20f);
|
||||
root_child1.setMargin(YogaEdge.RIGHT, 20f);
|
||||
root_child1.setMargin(YogaEdge.BOTTOM, 20f);
|
||||
root_child1.setWidth(200f);
|
||||
root_child1.setHeight(200f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setWidth(100f);
|
||||
root_child2.setHeight(100f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(700f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(300f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(180f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(180f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(300f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(400f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(700f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(500f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(300f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(180f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(180f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(300f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(400f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -357,7 +357,6 @@ public class YGMinMaxDimensionTest {
|
||||
@Test
|
||||
public void test_flex_grow_to_min() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(100f);
|
||||
@@ -412,7 +411,6 @@ public class YGMinMaxDimensionTest {
|
||||
@Test
|
||||
public void test_flex_grow_in_at_most_container() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -465,6 +463,97 @@ public class YGMinMaxDimensionTest {
|
||||
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_grow_child() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setFlexBasis(0f);
|
||||
root_child0.setHeight(100f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_grow_within_constrained_min_max_column() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setMinHeight(100f);
|
||||
root.setMaxHeight(200f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setHeight(50f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_grow_within_max_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
@@ -936,111 +1025,4 @@ public class YGMinMaxDimensionTest {
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_min_width_in_flex_distribution() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(300f);
|
||||
root.setHeight(300f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(2f);
|
||||
root_child0.setFlexShrink(1f);
|
||||
root_child0.setFlexBasisPercent(0f);
|
||||
root_child0.setMinWidth(100f);
|
||||
root_child0.setMaxWidth(200f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setFlexShrink(1f);
|
||||
root_child1.setFlexBasisPercent(0f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setFlexGrow(1f);
|
||||
root_child2.setFlexShrink(1f);
|
||||
root_child2.setFlexBasisPercent(0f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final YogaNode root_child3 = new YogaNode(config);
|
||||
root_child3.setFlexGrow(1f);
|
||||
root_child3.setFlexShrink(1f);
|
||||
root_child3.setFlexBasisPercent(0f);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final YogaNode root_child4 = new YogaNode(config);
|
||||
root_child4.setFlexGrow(1f);
|
||||
root_child4.setFlexShrink(1f);
|
||||
root_child4.setFlexBasisPercent(0f);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(300f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(150f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(200f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(250f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(300f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(200f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(300f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_width_height() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -60,7 +59,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_position_left_top() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -103,7 +101,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_position_bottom_right() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -146,7 +143,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -202,7 +198,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -257,7 +252,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_min_height() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -312,7 +306,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_max_height() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -370,7 +363,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_max_height() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -427,7 +419,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_max_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -485,7 +476,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_max_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -542,7 +532,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_main_min_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -600,7 +589,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_flex_basis_cross_min_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -657,7 +645,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -766,7 +753,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_margin_should_calculate_based_only_on_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -824,7 +810,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_padding_should_calculate_based_only_on_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -882,7 +867,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_absolute_position() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(200f);
|
||||
@@ -1043,7 +1027,6 @@ public class YGPercentageTest {
|
||||
@Test
|
||||
public void test_percentage_container_in_wrapping_container() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setJustifyContent(YogaJustify.CENTER);
|
||||
|
@@ -19,7 +19,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_flex_basis_flex_grow_row_width_of_100() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -87,7 +86,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_flex_basis_flex_grow_row_prime_number_width() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -183,7 +181,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_flex_basis_flex_shrink_row() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
@@ -252,7 +249,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_flex_basis_overrides_main_size() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(100f);
|
||||
@@ -323,7 +319,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_total_fractial() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(87.4f);
|
||||
@@ -394,7 +389,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_total_fractial_nested() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(87.4f);
|
||||
@@ -499,7 +493,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_fractial_input_1() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(100f);
|
||||
@@ -570,7 +563,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_fractial_input_2() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setWidth(100f);
|
||||
@@ -641,7 +633,6 @@ public class YGRoundingTest {
|
||||
@Test
|
||||
public void test_rounding_fractial_input_3() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setPosition(YogaEdge.TOP, 0.3f);
|
||||
@@ -674,17 +665,17 @@ public class YGRoundingTest {
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(64f, root_child0.getLayoutHeight(), 0.0f);
|
||||
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
||||
assertEquals(24f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
|
||||
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
@@ -697,23 +688,22 @@ public class YGRoundingTest {
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(64f, root_child0.getLayoutHeight(), 0.0f);
|
||||
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
||||
assertEquals(24f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
|
||||
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_rounding_fractial_input_4() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setPosition(YogaEdge.TOP, 0.7f);
|
||||
@@ -782,4 +772,301 @@ public class YGRoundingTest {
|
||||
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_rounding_inner_node_controversy_horizontal() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(320f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setHeight(10f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setHeight(10f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child1_child0 = new YogaNode(config);
|
||||
root_child1_child0.setFlexGrow(1f);
|
||||
root_child1_child0.setHeight(10f);
|
||||
root_child1.addChildAt(root_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setFlexGrow(1f);
|
||||
root_child2.setHeight(10f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(107f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(107f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(106f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(106f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(213f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(107f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(213f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(107f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(107f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(106f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(106f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(107f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_rounding_inner_node_controversy_vertical() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setHeight(320f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setWidth(10f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setWidth(10f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child1_child0 = new YogaNode(config);
|
||||
root_child1_child0.setFlexGrow(1f);
|
||||
root_child1_child0.setWidth(10f);
|
||||
root_child1.addChildAt(root_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setFlexGrow(1f);
|
||||
root_child2.setWidth(10f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(107f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(107f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_rounding_inner_node_controversy_combined() {
|
||||
YogaConfig config = new YogaConfig();
|
||||
|
||||
final YogaNode root = new YogaNode(config);
|
||||
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root.setWidth(640f);
|
||||
root.setHeight(320f);
|
||||
|
||||
final YogaNode root_child0 = new YogaNode(config);
|
||||
root_child0.setFlexGrow(1f);
|
||||
root_child0.setHeightPercent(100f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child1 = new YogaNode(config);
|
||||
root_child1.setFlexGrow(1f);
|
||||
root_child1.setHeightPercent(100f);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final YogaNode root_child1_child0 = new YogaNode(config);
|
||||
root_child1_child0.setFlexGrow(1f);
|
||||
root_child1_child0.setWidthPercent(100f);
|
||||
root_child1.addChildAt(root_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child1_child1 = new YogaNode(config);
|
||||
root_child1_child1.setFlexGrow(1f);
|
||||
root_child1_child1.setWidthPercent(100f);
|
||||
root_child1.addChildAt(root_child1_child1, 1);
|
||||
|
||||
final YogaNode root_child1_child1_child0 = new YogaNode(config);
|
||||
root_child1_child1_child0.setFlexGrow(1f);
|
||||
root_child1_child1_child0.setWidthPercent(100f);
|
||||
root_child1_child1.addChildAt(root_child1_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child1_child2 = new YogaNode(config);
|
||||
root_child1_child2.setFlexGrow(1f);
|
||||
root_child1_child2.setWidthPercent(100f);
|
||||
root_child1.addChildAt(root_child1_child2, 2);
|
||||
|
||||
final YogaNode root_child2 = new YogaNode(config);
|
||||
root_child2.setFlexGrow(1f);
|
||||
root_child2.setHeightPercent(100f);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(640f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(213f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(213f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(107f, root_child1_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(213f, root_child1_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child1_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(427f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(213f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(640f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(427f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(213f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(213f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(107f, root_child1_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(106f, root_child1_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(213f, root_child1_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(214f, root_child1_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(107f, root_child1_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(213f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(320f, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class YogaNodeTest {
|
||||
child2.setWidth(40);
|
||||
child2.setHeight(40);
|
||||
child2.setBaselineFunction(new YogaBaselineFunction() {
|
||||
public float baseline(YogaNodeAPI node, float width, float height) {
|
||||
public float baseline(YogaNode node, float width, float height) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
@@ -57,7 +57,7 @@ public class YogaNodeTest {
|
||||
final YogaNode node = new YogaNode();
|
||||
node.setMeasureFunction(new YogaMeasureFunction() {
|
||||
public long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
@@ -75,7 +75,7 @@ public class YogaNodeTest {
|
||||
final YogaNode node = new YogaNode();
|
||||
node.setMeasureFunction(new YogaMeasureFunction() {
|
||||
public long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
@@ -84,8 +84,8 @@ public class YogaNodeTest {
|
||||
}
|
||||
});
|
||||
node.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
assertEquals(100.5f, node.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100.5f, node.getLayoutHeight(), 0.0f);
|
||||
assertEquals(101f, node.getLayoutWidth(), 0.01f);
|
||||
assertEquals(101f, node.getLayoutHeight(), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class YogaNodeTest {
|
||||
final YogaNode node = new YogaNode();
|
||||
node.setMeasureFunction(new YogaMeasureFunction() {
|
||||
public long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
@@ -102,8 +102,8 @@ public class YogaNodeTest {
|
||||
}
|
||||
});
|
||||
node.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
assertEquals(Float.MIN_VALUE, node.getLayoutWidth(), 0.0f);
|
||||
assertEquals(Float.MIN_VALUE, node.getLayoutHeight(), 0.0f);
|
||||
assertEquals(Float.MIN_VALUE, node.getLayoutWidth(), 0.01f);
|
||||
assertEquals(Float.MIN_VALUE, node.getLayoutHeight(), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,7 +111,7 @@ public class YogaNodeTest {
|
||||
final YogaNode node = new YogaNode();
|
||||
node.setMeasureFunction(new YogaMeasureFunction() {
|
||||
public long measure(
|
||||
YogaNodeAPI node,
|
||||
YogaNode node,
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
@@ -120,40 +120,8 @@ public class YogaNodeTest {
|
||||
}
|
||||
});
|
||||
node.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
assertEquals(Float.MAX_VALUE, node.getLayoutWidth(), 0.0f);
|
||||
assertEquals(Float.MAX_VALUE, node.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
private YogaLogLevel mLogLevel;
|
||||
private String mLogMessage;
|
||||
|
||||
@Test
|
||||
public void testLogger() {
|
||||
YogaNode.setLogger(new YogaLogger() {
|
||||
public void log(YogaLogLevel level, String message) {
|
||||
mLogLevel = level;
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
YogaNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello");
|
||||
assertEquals(YogaLogLevel.DEBUG, mLogLevel);
|
||||
assertEquals("Hello", mLogMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLogger() {
|
||||
YogaNode.setLogger(new YogaLogger() {
|
||||
public void log(YogaLogLevel level, String message) {}
|
||||
});
|
||||
YogaNode.setLogger(new YogaLogger() {
|
||||
public void log(YogaLogLevel level, String message) {
|
||||
mLogLevel = level;
|
||||
mLogMessage = message;
|
||||
}
|
||||
});
|
||||
YogaNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox");
|
||||
assertEquals(YogaLogLevel.VERBOSE, mLogLevel);
|
||||
assertEquals("Flexbox", mLogMessage);
|
||||
assertEquals(Float.MAX_VALUE, node.getLayoutWidth(), 0.01f);
|
||||
assertEquals(Float.MAX_VALUE, node.getLayoutHeight(), 0.01f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -43,10 +43,8 @@ module.exports = {
|
||||
EDGE_VERTICAL: 7,
|
||||
EDGE_ALL: 8,
|
||||
|
||||
EXPERIMENTAL_FEATURE_COUNT: 3,
|
||||
EXPERIMENTAL_FEATURE_ROUNDING: 0,
|
||||
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 1,
|
||||
EXPERIMENTAL_FEATURE_MIN_FLEX_FIX: 2,
|
||||
EXPERIMENTAL_FEATURE_COUNT: 1,
|
||||
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 0,
|
||||
|
||||
FLEX_DIRECTION_COUNT: 4,
|
||||
FLEX_DIRECTION_COLUMN: 0,
|
||||
@@ -61,12 +59,13 @@ module.exports = {
|
||||
JUSTIFY_SPACE_BETWEEN: 3,
|
||||
JUSTIFY_SPACE_AROUND: 4,
|
||||
|
||||
LOG_LEVEL_COUNT: 5,
|
||||
LOG_LEVEL_COUNT: 6,
|
||||
LOG_LEVEL_ERROR: 0,
|
||||
LOG_LEVEL_WARN: 1,
|
||||
LOG_LEVEL_INFO: 2,
|
||||
LOG_LEVEL_DEBUG: 3,
|
||||
LOG_LEVEL_VERBOSE: 4,
|
||||
LOG_LEVEL_FATAL: 5,
|
||||
|
||||
MEASURE_MODE_COUNT: 3,
|
||||
MEASURE_MODE_UNDEFINED: 0,
|
||||
|
@@ -23,7 +23,7 @@ module.exports = function (bind, lib) {
|
||||
|
||||
UNDEFINED: NaN
|
||||
|
||||
}, require(`./YGEnums`));
|
||||
}, require('./YGEnums'));
|
||||
|
||||
class Layout {
|
||||
|
||||
|
@@ -1878,3 +1878,152 @@ it("align_items_flex_end_child_without_margin_bigger_than_parent", function () {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_center_should_size_based_on_content", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setMargin(Yoga.EDGE_TOP, 20);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root_child0.setFlexShrink(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setFlexShrink(1);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setWidth(20);
|
||||
root_child0_child0_child0.setHeight(20);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedWidth(), "20 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedWidth(), "20 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("align_strech_should_size_based_on_parent", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setMargin(Yoga.EDGE_TOP, 20);
|
||||
root.setWidth(100);
|
||||
root.setHeight(100);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root_child0.setFlexShrink(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setFlexShrink(1);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
|
||||
var root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setWidth(20);
|
||||
root_child0_child0_child0.setHeight(20);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(80 === root_child0_child0_child0.getComputedLeft(), "80 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
|
||||
console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
@@ -1423,3 +1423,173 @@ it("wrapped_row_within_align_items_flex_end", function () {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("wrapped_column_max_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root.setAlignContent(Yoga.ALIGN_CENTER);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setFlexWrap(Yoga.WRAP_WRAP);
|
||||
root.setWidth(700);
|
||||
root.setHeight(500);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(500);
|
||||
root_child0.setMaxHeight(200);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setMargin(Yoga.EDGE_LEFT, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_TOP, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_RIGHT, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_BOTTOM, 20);
|
||||
root_child1.setWidth(200);
|
||||
root_child1.setHeight(200);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(100);
|
||||
root_child2.setHeight(100);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(700 === root.getComputedWidth(), "700 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(200 === root_child1.getComputedLeft(), "200 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(250 === root_child1.getComputedTop(), "250 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child1.getComputedHeight(), "200 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(420 === root_child2.getComputedLeft(), "420 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(200 === root_child2.getComputedTop(), "200 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(700 === root.getComputedWidth(), "700 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(350 === root_child0.getComputedLeft(), "350 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(300 === root_child1.getComputedLeft(), "300 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(250 === root_child1.getComputedTop(), "250 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(200 === root_child1.getComputedHeight(), "200 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(180 === root_child2.getComputedLeft(), "180 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(200 === root_child2.getComputedTop(), "200 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("wrapped_column_max_height_flex", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
root.setAlignContent(Yoga.ALIGN_CENTER);
|
||||
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||
root.setFlexWrap(Yoga.WRAP_WRAP);
|
||||
root.setWidth(700);
|
||||
root.setHeight(500);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis("0%");
|
||||
root_child0.setWidth(100);
|
||||
root_child0.setHeight(500);
|
||||
root_child0.setMaxHeight(200);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setFlexBasis("0%");
|
||||
root_child1.setMargin(Yoga.EDGE_LEFT, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_TOP, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_RIGHT, 20);
|
||||
root_child1.setMargin(Yoga.EDGE_BOTTOM, 20);
|
||||
root_child1.setWidth(200);
|
||||
root_child1.setHeight(200);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setWidth(100);
|
||||
root_child2.setHeight(100);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(700 === root.getComputedWidth(), "700 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(300 === root_child0.getComputedLeft(), "300 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(180 === root_child0.getComputedHeight(), "180 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(200 === root_child1.getComputedTop(), "200 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(180 === root_child1.getComputedHeight(), "180 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(300 === root_child2.getComputedLeft(), "300 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(400 === root_child2.getComputedTop(), "400 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(700 === root.getComputedWidth(), "700 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(300 === root_child0.getComputedLeft(), "300 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(180 === root_child0.getComputedHeight(), "180 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(200 === root_child1.getComputedTop(), "200 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(200 === root_child1.getComputedWidth(), "200 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(180 === root_child1.getComputedHeight(), "180 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(300 === root_child2.getComputedLeft(), "300 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(400 === root_child2.getComputedTop(), "400 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
@@ -380,8 +380,6 @@ it("justify_content_overflow_min_max", function () {
|
||||
it("flex_grow_to_min", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
@@ -440,8 +438,6 @@ it("flex_grow_to_min", function () {
|
||||
it("flex_grow_in_at_most_container", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -498,6 +494,105 @@ it("flex_grow_in_at_most_container", function () {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_grow_child", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(0);
|
||||
root_child0.setHeight(100);
|
||||
root.insertChild(root_child0, 0);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_grow_within_constrained_min_max_column", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setMinHeight(100);
|
||||
root.setMaxHeight(200);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setHeight(50);
|
||||
root.insertChild(root_child1, 1);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("flex_grow_within_max_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
@@ -1013,114 +1108,3 @@ it("min_max_percent_no_width_height", function () {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("min_width_in_flex_distribution", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(300);
|
||||
root.setHeight(300);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(2);
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis("0%");
|
||||
root_child0.setMinWidth(100);
|
||||
root_child0.setMaxWidth(200);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setFlexBasis("0%");
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setFlexShrink(1);
|
||||
root_child2.setFlexBasis("0%");
|
||||
root.insertChild(root_child2, 2);
|
||||
|
||||
var root_child3 = Yoga.Node.create(config);
|
||||
root_child3.setFlexGrow(1);
|
||||
root_child3.setFlexShrink(1);
|
||||
root_child3.setFlexBasis("0%");
|
||||
root.insertChild(root_child3, 3);
|
||||
|
||||
var root_child4 = Yoga.Node.create(config);
|
||||
root_child4.setFlexGrow(1);
|
||||
root_child4.setFlexShrink(1);
|
||||
root_child4.setFlexBasis("0%");
|
||||
root.insertChild(root_child4, 4);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(100 === root_child1.getComputedLeft(), "100 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(150 === root_child2.getComputedLeft(), "150 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
console.assert(200 === root_child3.getComputedLeft(), "200 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
|
||||
console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
|
||||
|
||||
console.assert(250 === root_child4.getComputedLeft(), "250 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
|
||||
console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(200 === root_child0.getComputedLeft(), "200 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(150 === root_child1.getComputedLeft(), "150 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(100 === root_child2.getComputedLeft(), "100 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
console.assert(50 === root_child3.getComputedLeft(), "50 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
|
||||
console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child4.getComputedLeft(), "0 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
|
||||
console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
|
||||
console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
@@ -14,8 +14,6 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
it("percentage_width_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -60,8 +58,6 @@ it("percentage_width_height", function () {
|
||||
it("percentage_position_left_top", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -108,8 +104,6 @@ it("percentage_position_left_top", function () {
|
||||
it("percentage_position_bottom_right", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -156,8 +150,6 @@ it("percentage_position_bottom_right", function () {
|
||||
it("percentage_flex_basis", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -217,8 +209,6 @@ it("percentage_flex_basis", function () {
|
||||
it("percentage_flex_basis_cross", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -277,8 +267,6 @@ it("percentage_flex_basis_cross", function () {
|
||||
it("percentage_flex_basis_cross_min_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -337,8 +325,6 @@ it("percentage_flex_basis_cross_min_height", function () {
|
||||
it("percentage_flex_basis_main_max_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -400,8 +386,6 @@ it("percentage_flex_basis_main_max_height", function () {
|
||||
it("percentage_flex_basis_cross_max_height", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -462,8 +446,6 @@ it("percentage_flex_basis_cross_max_height", function () {
|
||||
it("percentage_flex_basis_main_max_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -525,8 +507,6 @@ it("percentage_flex_basis_main_max_width", function () {
|
||||
it("percentage_flex_basis_cross_max_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -587,8 +567,6 @@ it("percentage_flex_basis_cross_max_width", function () {
|
||||
it("percentage_flex_basis_main_min_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -650,8 +628,6 @@ it("percentage_flex_basis_main_min_width", function () {
|
||||
it("percentage_flex_basis_cross_min_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -712,8 +688,6 @@ it("percentage_flex_basis_cross_min_width", function () {
|
||||
it("percentage_multiple_nested_with_padding_margin_and_percentage_values", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -826,8 +800,6 @@ it("percentage_multiple_nested_with_padding_margin_and_percentage_values", funct
|
||||
it("percentage_margin_should_calculate_based_only_on_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -889,8 +861,6 @@ it("percentage_margin_should_calculate_based_only_on_width", function () {
|
||||
it("percentage_padding_should_calculate_based_only_on_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -952,8 +922,6 @@ it("percentage_padding_should_calculate_based_only_on_width", function () {
|
||||
it("percentage_absolute_position", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(200);
|
||||
@@ -1126,8 +1094,6 @@ it("percent_within_flex_grow", function () {
|
||||
it("percentage_container_in_wrapping_container", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||
|
@@ -14,8 +14,6 @@ var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||
it("rounding_flex_basis_flex_grow_row_width_of_100", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -87,8 +85,6 @@ it("rounding_flex_basis_flex_grow_row_width_of_100", function () {
|
||||
it("rounding_flex_basis_flex_grow_row_prime_number_width", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -188,8 +184,6 @@ it("rounding_flex_basis_flex_grow_row_prime_number_width", function () {
|
||||
it("rounding_flex_basis_flex_shrink_row", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
@@ -262,8 +256,6 @@ it("rounding_flex_basis_flex_shrink_row", function () {
|
||||
it("rounding_flex_basis_overrides_main_size", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
@@ -338,8 +330,6 @@ it("rounding_flex_basis_overrides_main_size", function () {
|
||||
it("rounding_total_fractial", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(87.4);
|
||||
@@ -414,8 +404,6 @@ it("rounding_total_fractial", function () {
|
||||
it("rounding_total_fractial_nested", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(87.4);
|
||||
@@ -524,8 +512,6 @@ it("rounding_total_fractial_nested", function () {
|
||||
it("rounding_fractial_input_1", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
@@ -600,8 +586,6 @@ it("rounding_fractial_input_1", function () {
|
||||
it("rounding_fractial_input_2", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setWidth(100);
|
||||
@@ -676,8 +660,6 @@ it("rounding_fractial_input_2", function () {
|
||||
it("rounding_fractial_input_3", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPosition(Yoga.EDGE_TOP, 0.3);
|
||||
@@ -709,17 +691,17 @@ it("rounding_fractial_input_3", function () {
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(64 === root_child0.getComputedHeight(), "64 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
console.assert(65 === root_child0.getComputedHeight(), "65 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(64 === root_child1.getComputedTop(), "64 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(25 === root_child1.getComputedHeight(), "25 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
console.assert(24 === root_child1.getComputedHeight(), "24 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(89 === root_child2.getComputedTop(), "89 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(24 === root_child2.getComputedHeight(), "24 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
console.assert(25 === root_child2.getComputedHeight(), "25 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
@@ -731,17 +713,17 @@ it("rounding_fractial_input_3", function () {
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(64 === root_child0.getComputedHeight(), "64 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
console.assert(65 === root_child0.getComputedHeight(), "65 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(64 === root_child1.getComputedTop(), "64 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(25 === root_child1.getComputedHeight(), "25 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
console.assert(24 === root_child1.getComputedHeight(), "24 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(89 === root_child2.getComputedTop(), "89 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(24 === root_child2.getComputedHeight(), "24 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
console.assert(25 === root_child2.getComputedHeight(), "25 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
@@ -753,8 +735,6 @@ it("rounding_fractial_input_3", function () {
|
||||
it("rounding_fractial_input_4", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_ROUNDING, true);
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setPosition(Yoga.EDGE_TOP, 0.7);
|
||||
@@ -827,3 +807,312 @@ it("rounding_fractial_input_4", function () {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("rounding_inner_node_controversy_horizontal", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(320);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexGrow(1);
|
||||
root_child1_child0.setHeight(10);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(320 === root.getComputedWidth(), "320 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(10 === root.getComputedHeight(), "10 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(107 === root_child0.getComputedWidth(), "107 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(107 === root_child1.getComputedLeft(), "107 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(106 === root_child1.getComputedWidth(), "106 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(106 === root_child1_child0.getComputedWidth(), "106 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(213 === root_child2.getComputedLeft(), "213 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(107 === root_child2.getComputedWidth(), "107 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(320 === root.getComputedWidth(), "320 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(10 === root.getComputedHeight(), "10 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(213 === root_child0.getComputedLeft(), "213 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(107 === root_child0.getComputedWidth(), "107 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(107 === root_child1.getComputedLeft(), "107 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(106 === root_child1.getComputedWidth(), "106 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(106 === root_child1_child0.getComputedWidth(), "106 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(107 === root_child2.getComputedWidth(), "107 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("rounding_inner_node_controversy_vertical", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setHeight(320);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexGrow(1);
|
||||
root_child1_child0.setWidth(10);
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(10 === root.getComputedWidth(), "10 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(320 === root.getComputedHeight(), "320 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child0.getComputedHeight(), "107 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(107 === root_child1.getComputedTop(), "107 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1.getComputedHeight(), "106 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedWidth(), "10 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child0.getComputedHeight(), "106 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(213 === root_child2.getComputedTop(), "213 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child2.getComputedHeight(), "107 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(10 === root.getComputedWidth(), "10 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(320 === root.getComputedHeight(), "320 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child0.getComputedHeight(), "107 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(107 === root_child1.getComputedTop(), "107 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1.getComputedWidth(), "10 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1.getComputedHeight(), "106 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(10 === root_child1_child0.getComputedWidth(), "10 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child0.getComputedHeight(), "106 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(213 === root_child2.getComputedTop(), "213 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(10 === root_child2.getComputedWidth(), "10 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child2.getComputedHeight(), "107 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
it("rounding_inner_node_controversy_combined", function () {
|
||||
var config = Yoga.Config.create();
|
||||
|
||||
try {
|
||||
var root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||
root.setWidth(640);
|
||||
root.setHeight(320);
|
||||
|
||||
var root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setHeight("100%");
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
var root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setHeight("100%");
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
var root_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child0.setFlexGrow(1);
|
||||
root_child1_child0.setWidth("100%");
|
||||
root_child1.insertChild(root_child1_child0, 0);
|
||||
|
||||
var root_child1_child1 = Yoga.Node.create(config);
|
||||
root_child1_child1.setFlexGrow(1);
|
||||
root_child1_child1.setWidth("100%");
|
||||
root_child1.insertChild(root_child1_child1, 1);
|
||||
|
||||
var root_child1_child1_child0 = Yoga.Node.create(config);
|
||||
root_child1_child1_child0.setFlexGrow(1);
|
||||
root_child1_child1_child0.setWidth("100%");
|
||||
root_child1_child1.insertChild(root_child1_child1_child0, 0);
|
||||
|
||||
var root_child1_child2 = Yoga.Node.create(config);
|
||||
root_child1_child2.setFlexGrow(1);
|
||||
root_child1_child2.setWidth("100%");
|
||||
root_child1.insertChild(root_child1_child2, 2);
|
||||
|
||||
var root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setHeight("100%");
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(640 === root.getComputedWidth(), "640 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(320 === root.getComputedHeight(), "320 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(213 === root_child0.getComputedWidth(), "213 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child0.getComputedHeight(), "320 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(213 === root_child1.getComputedLeft(), "213 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1.getComputedWidth(), "214 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child1.getComputedHeight(), "320 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child0.getComputedWidth(), "214 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child1_child0.getComputedHeight(), "107 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child1.getComputedLeft(), "0 === root_child1_child1.getComputedLeft() (" + root_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(107 === root_child1_child1.getComputedTop(), "107 === root_child1_child1.getComputedTop() (" + root_child1_child1.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child1.getComputedWidth(), "214 === root_child1_child1.getComputedWidth() (" + root_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child1.getComputedHeight(), "106 === root_child1_child1.getComputedHeight() (" + root_child1_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child1_child0.getComputedLeft(), "0 === root_child1_child1_child0.getComputedLeft() (" + root_child1_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child1_child0.getComputedTop(), "0 === root_child1_child1_child0.getComputedTop() (" + root_child1_child1_child0.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child1_child0.getComputedWidth(), "214 === root_child1_child1_child0.getComputedWidth() (" + root_child1_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child1_child0.getComputedHeight(), "106 === root_child1_child1_child0.getComputedHeight() (" + root_child1_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child2.getComputedLeft(), "0 === root_child1_child2.getComputedLeft() (" + root_child1_child2.getComputedLeft() + ")");
|
||||
console.assert(213 === root_child1_child2.getComputedTop(), "213 === root_child1_child2.getComputedTop() (" + root_child1_child2.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child2.getComputedWidth(), "214 === root_child1_child2.getComputedWidth() (" + root_child1_child2.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child1_child2.getComputedHeight(), "107 === root_child1_child2.getComputedHeight() (" + root_child1_child2.getComputedHeight() + ")");
|
||||
|
||||
console.assert(427 === root_child2.getComputedLeft(), "427 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(213 === root_child2.getComputedWidth(), "213 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child2.getComputedHeight(), "320 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
|
||||
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||
|
||||
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||
console.assert(640 === root.getComputedWidth(), "640 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||
console.assert(320 === root.getComputedHeight(), "320 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||
|
||||
console.assert(427 === root_child0.getComputedLeft(), "427 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||
console.assert(213 === root_child0.getComputedWidth(), "213 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child0.getComputedHeight(), "320 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(213 === root_child1.getComputedLeft(), "213 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1.getComputedWidth(), "214 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child1.getComputedHeight(), "320 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child0.getComputedWidth(), "214 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child1_child0.getComputedHeight(), "107 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child1.getComputedLeft(), "0 === root_child1_child1.getComputedLeft() (" + root_child1_child1.getComputedLeft() + ")");
|
||||
console.assert(107 === root_child1_child1.getComputedTop(), "107 === root_child1_child1.getComputedTop() (" + root_child1_child1.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child1.getComputedWidth(), "214 === root_child1_child1.getComputedWidth() (" + root_child1_child1.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child1.getComputedHeight(), "106 === root_child1_child1.getComputedHeight() (" + root_child1_child1.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child1_child0.getComputedLeft(), "0 === root_child1_child1_child0.getComputedLeft() (" + root_child1_child1_child0.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child1_child1_child0.getComputedTop(), "0 === root_child1_child1_child0.getComputedTop() (" + root_child1_child1_child0.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child1_child0.getComputedWidth(), "214 === root_child1_child1_child0.getComputedWidth() (" + root_child1_child1_child0.getComputedWidth() + ")");
|
||||
console.assert(106 === root_child1_child1_child0.getComputedHeight(), "106 === root_child1_child1_child0.getComputedHeight() (" + root_child1_child1_child0.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child1_child2.getComputedLeft(), "0 === root_child1_child2.getComputedLeft() (" + root_child1_child2.getComputedLeft() + ")");
|
||||
console.assert(213 === root_child1_child2.getComputedTop(), "213 === root_child1_child2.getComputedTop() (" + root_child1_child2.getComputedTop() + ")");
|
||||
console.assert(214 === root_child1_child2.getComputedWidth(), "214 === root_child1_child2.getComputedWidth() (" + root_child1_child2.getComputedWidth() + ")");
|
||||
console.assert(107 === root_child1_child2.getComputedHeight(), "107 === root_child1_child2.getComputedHeight() (" + root_child1_child2.getComputedHeight() + ")");
|
||||
|
||||
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
||||
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
||||
console.assert(213 === root_child2.getComputedWidth(), "213 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
||||
console.assert(320 === root_child2.getComputedHeight(), "320 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
||||
} finally {
|
||||
if (typeof root !== "undefined") {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
@@ -21,7 +21,7 @@ prebuilt_cxx_library(
|
||||
|
||||
cxx_library(
|
||||
name = "fbjni",
|
||||
srcs = glob(["**/*.cpp"]),
|
||||
srcs = glob(["src/main/cpp/**/*.cpp"]),
|
||||
compiler_flags = [
|
||||
"-DLOG_TAG=\"libfb\"",
|
||||
"-DDISABLE_CPUCAP",
|
||||
@@ -35,11 +35,12 @@ cxx_library(
|
||||
"-Wno-unused-parameter",
|
||||
"-std=c++11",
|
||||
],
|
||||
exported_headers = subdir_glob([("include", "**/*.h")]),
|
||||
exported_headers = subdir_glob([("src/main/cpp/include", "**/*.h")]),
|
||||
header_namespace = "",
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
":ndklog",
|
||||
FBJNI_JAVA_TARGET,
|
||||
JNI_TARGET,
|
||||
],
|
||||
)
|
||||
|
33
lib/fb/build.gradle
Normal file
33
lib/fb/build.gradle
Normal file
@@ -0,0 +1,33 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.compileSdkVersion
|
||||
buildToolsVersion rootProject.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.minSdkVersion
|
||||
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 'src/main/cpp/CMakeLists.txt'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.facebook.soloader:soloader:0.2.0'
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.1'
|
||||
compile project(':yoga:proguard-annotations')
|
||||
}
|
||||
}
|
14
lib/fb/src/main/AndroidManifest.xml
Normal file
14
lib/fb/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
This source code is licensed under the BSD-style license found in the
|
||||
LICENSE file in the root directory of this source tree. An additional grant
|
||||
of patent rights can be found in the PATENTS file in the same directory.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.facebook.libfb">
|
||||
</manifest>
|
33
lib/fb/src/main/cpp/CMakeLists.txt
Normal file
33
lib/fb/src/main/cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# 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)
|
||||
|
||||
add_compile_options(
|
||||
-fno-omit-frame-pointer
|
||||
-fexceptions
|
||||
-Wall
|
||||
-std=c++11
|
||||
-DDISABLE_CPUCAP
|
||||
-DDISABLE_XPLAT)
|
||||
|
||||
file(GLOB fb_SRC
|
||||
*.cpp
|
||||
jni/*.cpp
|
||||
lyra/*.cpp)
|
||||
|
||||
add_library(fb SHARED
|
||||
${fb_SRC})
|
||||
|
||||
target_include_directories(fb PRIVATE
|
||||
include)
|
||||
|
||||
target_link_libraries(fb android log)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user