Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4f37cde043 | ||
|
7df60376ff | ||
|
7fa4adb0d9 | ||
|
abb91ae77b | ||
|
a4b1ac83f4 | ||
|
8775cdc13f | ||
|
db732ce9fa | ||
|
7c09244c39 | ||
|
2cc2a5f2ff | ||
|
e4b50f2a8d | ||
|
a2a84532ff | ||
|
d391323129 | ||
|
ab28ecf31b | ||
|
a4bab68802 | ||
|
e3cfacf0cb |
1
.swift-version
Normal file
1
.swift-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0
|
@@ -6,7 +6,7 @@
|
|||||||
# of patent rights can be found in the PATENTS file in the same directory.
|
# of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode7.3
|
osx_image: xcode8.2
|
||||||
language: cpp
|
language: cpp
|
||||||
compiler: clang
|
compiler: clang
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ install:
|
|||||||
script:
|
script:
|
||||||
- buck test //:yoga
|
- buck test //:yoga
|
||||||
- buck test //java:java
|
- buck test //java:java
|
||||||
- buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
|
- buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64
|
||||||
- sh csharp/tests/Facebook.Yoga/test_macos.sh
|
- sh csharp/tests/Facebook.Yoga/test_macos.sh
|
||||||
|
|
||||||
- cd javascript
|
- cd javascript
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Yoga [](https://travis-ci.org/facebook/yoga)
|
# Yoga [](https://travis-ci.org/facebook/yoga) [](http://cocoapods.org/pods/Yoga)
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
|
||||||
|
27
Yoga.podspec
Normal file
27
Yoga.podspec
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'Yoga'
|
||||||
|
s.version = '1.0.0'
|
||||||
|
s.summary = 'A cross-platform layout engine.'
|
||||||
|
s.homepage = 'https://github.com/facebook/yoga'
|
||||||
|
s.documentation_url = 'https://facebook.github.io/yoga'
|
||||||
|
s.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
|
||||||
|
|
||||||
|
s.license = { :type => 'BSD', :file => "LICENSE" }
|
||||||
|
s.authors = 'Facebook'
|
||||||
|
s.social_media_url = 'https://twitter.com/fbOpenSource'
|
||||||
|
s.source = {
|
||||||
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
|
:tag => 'v2017.01.23.00',
|
||||||
|
}
|
||||||
|
s.module_name = 'yoga'
|
||||||
|
s.requires_arc = false
|
||||||
|
s.compiler_flags = [
|
||||||
|
'-fno-omit-frame-pointer',
|
||||||
|
'-fexceptions',
|
||||||
|
'-Wall',
|
||||||
|
'-Werror',
|
||||||
|
'-std=c11',
|
||||||
|
'-fPIC'
|
||||||
|
]
|
||||||
|
s.source_files = 'yoga/**/*.{c,h}'
|
||||||
|
end
|
1
YogaKit/.swift-version
Normal file
1
YogaKit/.swift-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0.2
|
@@ -30,8 +30,8 @@ COMPILER_FLAGS = [
|
|||||||
apple_library(
|
apple_library(
|
||||||
name = 'YogaKit',
|
name = 'YogaKit',
|
||||||
compiler_flags = COMPILER_FLAGS,
|
compiler_flags = COMPILER_FLAGS,
|
||||||
srcs = glob(['*.m']),
|
srcs = glob(['Source/**/*.m']),
|
||||||
exported_headers = glob(['*.h']),
|
exported_headers = glob(['Source/**/*.h']),
|
||||||
frameworks = [
|
frameworks = [
|
||||||
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
|
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
|
||||||
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
|
||||||
|
@@ -18,40 +18,44 @@
|
|||||||
|
|
||||||
@implementation YogaKitTests
|
@implementation YogaKitTests
|
||||||
|
|
||||||
#ifndef TRAVIS_CI
|
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedWithSingleView
|
- (void)testNodesAreDeallocedWithSingleView
|
||||||
{
|
{
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
__weak YGLayout *layoutRef = nil;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
@autoreleasepool {
|
||||||
view.yoga.flexBasis = 1;
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertEqual(1, YGNodeGetInstanceCount());
|
view.yoga.flexBasis = 1;
|
||||||
view = nil;
|
|
||||||
|
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
layoutRef = view.yoga;
|
||||||
|
XCTAssertNotNil(layoutRef);
|
||||||
|
|
||||||
|
view = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertNil(layoutRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testNodesAreDeallocedCascade
|
- (void)testNodesAreDeallocedCascade
|
||||||
{
|
{
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
__weak YGLayout *topLayout = nil;
|
||||||
|
__weak YGLayout *subviewLayout = nil;
|
||||||
|
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
@autoreleasepool {
|
||||||
view.yoga.flexBasis = 1;
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
topLayout = view.yoga;
|
||||||
|
topLayout.flexBasis = 1;
|
||||||
|
|
||||||
for (int i=0; i<10; i++) {
|
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
subview.yoga.flexBasis = 1;
|
subviewLayout = subview.yoga;
|
||||||
[view addSubview:subview];
|
subviewLayout.flexBasis = 1;
|
||||||
|
|
||||||
|
view = nil;
|
||||||
}
|
}
|
||||||
XCTAssertEqual(11, YGNodeGetInstanceCount());
|
|
||||||
view = nil;
|
|
||||||
|
|
||||||
XCTAssertEqual(0, YGNodeGetInstanceCount());
|
XCTAssertNil(topLayout);
|
||||||
|
XCTAssertNil(subviewLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
- (void)testIsEnabled
|
- (void)testIsEnabled
|
||||||
{
|
{
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
@@ -89,13 +93,20 @@
|
|||||||
|
|
||||||
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
textBadgeView.yoga.isEnabled = YES;
|
textBadgeView.yoga.isEnabled = YES;
|
||||||
textBadgeView.yoga.marginLeft = 3.0;
|
textBadgeView.yoga.margin = 0;
|
||||||
textBadgeView.yoga.width = 10;
|
textBadgeView.yoga.width = 10;
|
||||||
textBadgeView.yoga.height = 10;
|
textBadgeView.yoga.height = 10;
|
||||||
[container addSubview:textBadgeView];
|
[container addSubview:textBadgeView];
|
||||||
|
|
||||||
|
const CGSize textBadgeViewSize = textBadgeView.yoga.intrinsicSize;
|
||||||
|
XCTAssertEqual(textBadgeViewSize.height, 10);
|
||||||
|
XCTAssertEqual(textBadgeViewSize.width, 10);
|
||||||
|
|
||||||
const CGSize containerSize = container.yoga.intrinsicSize;
|
const CGSize containerSize = container.yoga.intrinsicSize;
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
|
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
|
||||||
|
|
||||||
|
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
|
||||||
|
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
|
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
|
||||||
@@ -112,13 +123,15 @@
|
|||||||
[container addSubview:label];
|
[container addSubview:label];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(146,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
|
CGSize const labelSizeAfterFirstPass = label.frame.size;
|
||||||
|
|
||||||
label.text = @"This is a slightly longer text.";
|
label.text = @"This is a slightly longer text.";
|
||||||
|
XCTAssertTrue(CGSizeEqualToSize(label.frame.size, labelSizeAfterFirstPass));
|
||||||
|
|
||||||
[label.yoga markDirty];
|
[label.yoga markDirty];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(213,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
|
XCTAssertFalse(CGSizeEqualToSize(label.frame.size, labelSizeAfterFirstPass));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testFrameAndOriginPlacement
|
- (void)testFrameAndOriginPlacement
|
||||||
@@ -129,18 +142,25 @@
|
|||||||
container.yoga.isEnabled = YES;
|
container.yoga.isEnabled = YES;
|
||||||
container.yoga.flexDirection = YGFlexDirectionRow;
|
container.yoga.flexDirection = YGFlexDirectionRow;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
subview1.yoga.isEnabled = YES;
|
||||||
subview.yoga.isEnabled = YES;
|
subview1.yoga.flexGrow = 1;
|
||||||
subview.yoga.flexGrow = 1;
|
[container addSubview:subview1];
|
||||||
|
|
||||||
|
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview2.yoga.isEnabled = YES;
|
||||||
|
subview2.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:subview2];
|
||||||
|
|
||||||
|
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
subview3.yoga.isEnabled = YES;
|
||||||
|
subview3.yoga.flexGrow = 1;
|
||||||
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container addSubview:subview];
|
|
||||||
}
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
|
XCTAssertEqualWithAccuracy(subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
|
XCTAssertEqualWithAccuracy(subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
|
||||||
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
|
|
||||||
|
|
||||||
CGFloat totalWidth = 0;
|
CGFloat totalWidth = 0;
|
||||||
for (UIView *view in container.subviews) {
|
for (UIView *view in container.subviews) {
|
||||||
@@ -176,7 +196,7 @@
|
|||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame));
|
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
|
||||||
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
|
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
|
||||||
|
|
||||||
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
|
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
|
||||||
@@ -215,18 +235,18 @@
|
|||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
for (UIView *view in container.subviews) {
|
for (UIView *subview in container.subviews) {
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
XCTAssertEqual(subview.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
subview3.yoga.isIncludedInLayout = NO;
|
subview3.yoga.isIncludedInLayout = NO;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
|
|
||||||
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
// We don't set the frame to zero, so, it should be set to what it was previously at.
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
|
||||||
@@ -251,11 +271,11 @@
|
|||||||
[container addSubview:subview3];
|
[container addSubview:subview3];
|
||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
XCTAssertEqual(1, container.yoga.numberOfChildren);
|
XCTAssertEqual(container.yoga.numberOfChildren, 1);
|
||||||
|
|
||||||
subview2.yoga.isIncludedInLayout = YES;
|
subview2.yoga.isIncludedInLayout = YES;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
XCTAssertEqual(2, container.yoga.numberOfChildren);
|
XCTAssertEqual(container.yoga.numberOfChildren, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
|
||||||
@@ -282,18 +302,19 @@
|
|||||||
|
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
|
XCTAssertEqual(subview3.bounds.size.width, 0);
|
||||||
|
|
||||||
subview3.yoga.isIncludedInLayout = YES;
|
subview3.yoga.isIncludedInLayout = YES;
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
for (UIView *view in container.subviews) {
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
}
|
XCTAssertEqual(subview2.bounds.size.width, 100);
|
||||||
|
XCTAssertEqual(subview3.bounds.size.width, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testyg_isLeafFlag
|
- (void)testIsLeafFlag
|
||||||
{
|
{
|
||||||
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
XCTAssertTrue(view.yoga.isLeaf);
|
XCTAssertTrue(view.yoga.isLeaf);
|
||||||
@@ -351,18 +372,22 @@
|
|||||||
}
|
}
|
||||||
[container.yoga applyLayout];
|
[container.yoga applyLayout];
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
|
XCTAssertEqual(subview1.bounds.size.width, 100);
|
||||||
|
XCTAssertEqual(subview1.bounds.size.height, 25);
|
||||||
for (UIView *subview in subview1.subviews) {
|
for (UIView *subview in subview1.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize));
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
XCTAssertFalse(isnan(subviewSize.height));
|
XCTAssertFalse(isnan(subviewSize.height));
|
||||||
XCTAssertFalse(isnan(subviewSize.width));
|
XCTAssertFalse(isnan(subviewSize.width));
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
|
XCTAssertEqual(subview2.bounds.size.width, 150);
|
||||||
|
XCTAssertEqual(subview2.bounds.size.height, 25);
|
||||||
for (UIView *subview in subview2.subviews) {
|
for (UIView *subview in subview2.subviews) {
|
||||||
const CGSize subviewSize = subview.bounds.size;
|
const CGSize subviewSize = subview.bounds.size;
|
||||||
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size));
|
XCTAssertNotEqual(subviewSize.width, 0);
|
||||||
|
XCTAssertNotEqual(subviewSize.height, 0);
|
||||||
XCTAssertFalse(isnan(subviewSize.height));
|
XCTAssertFalse(isnan(subviewSize.height));
|
||||||
XCTAssertFalse(isnan(subviewSize.width));
|
XCTAssertFalse(isnan(subviewSize.width));
|
||||||
}
|
}
|
||||||
|
30
YogaKit/YogaKit.podspec
Normal file
30
YogaKit/YogaKit.podspec
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
Pod::Spec.new do |spec|
|
||||||
|
spec.name = 'YogaKit'
|
||||||
|
spec.version = '1.0.0'
|
||||||
|
spec.license = { :type => 'BSD-3-Clause', :file => '../LICENSE' }
|
||||||
|
spec.homepage = 'https://facebook.github.io/yoga'
|
||||||
|
spec.authors = {
|
||||||
|
'Emil Sjölander' => 'sjolander.emil@gmail.com',
|
||||||
|
'Dustin Shahidehpour' => 'dshahidehpour@gmail.com'
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
|
||||||
|
spec.description = <<-DESC
|
||||||
|
Yoga is a cross-platform layout engine which implements Flexbox.
|
||||||
|
It enables maximum collaboration within your team by implementing an API familiar to
|
||||||
|
many designers and opening it up to developers across different platforms.
|
||||||
|
DESC
|
||||||
|
|
||||||
|
spec.documentation_url = 'https://facebook.github.io/yoga/docs/getting-started/'
|
||||||
|
spec.source = {
|
||||||
|
:git => 'https://github.com/facebook/yoga.git',
|
||||||
|
:tag => 'v2017.01.23.00'
|
||||||
|
}
|
||||||
|
spec.platform = :ios
|
||||||
|
|
||||||
|
spec.dependency 'Yoga', '~> 1.0'
|
||||||
|
spec.source_files = 'Source/*.{h,m}',
|
||||||
|
spec.public_header_files = 'Source/{YGLayout,UIView+Yoga}.h'
|
||||||
|
spec.private_header_files = 'Source/YGLayout+Private.h'
|
||||||
|
|
||||||
|
end
|
@@ -1,32 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
|
||||||
{
|
|
||||||
[System.Obsolete]
|
|
||||||
public class Border
|
|
||||||
{
|
|
||||||
public float? Top;
|
|
||||||
public float? Bottom;
|
|
||||||
public float? Left;
|
|
||||||
public float? Right;
|
|
||||||
|
|
||||||
public Border(
|
|
||||||
float? top = null,
|
|
||||||
float? bottom = null,
|
|
||||||
float? left = null,
|
|
||||||
float? right = null)
|
|
||||||
{
|
|
||||||
Top = top;
|
|
||||||
Bottom = bottom;
|
|
||||||
Left = left;
|
|
||||||
Right = right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,11 +10,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)BaselineFunction.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)BaselineFunction.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Border.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)MeasureFunction.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)MeasureFunction.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)MeasureOutput.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)MeasureOutput.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Spacing.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
|
||||||
@@ -28,7 +26,6 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaLogLevel.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaLogLevel.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureFunc.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureFunc.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureMode.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureMode.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.Create.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.Spacing.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.Spacing.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)YogaOverflow.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)YogaOverflow.cs" />
|
||||||
|
@@ -1,32 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
|
||||||
{
|
|
||||||
[System.Obsolete]
|
|
||||||
public class Spacing
|
|
||||||
{
|
|
||||||
public YogaValue? Top;
|
|
||||||
public YogaValue? Bottom;
|
|
||||||
public YogaValue? Left;
|
|
||||||
public YogaValue? Right;
|
|
||||||
|
|
||||||
public Spacing(
|
|
||||||
YogaValue? top = null,
|
|
||||||
YogaValue? bottom = null,
|
|
||||||
YogaValue? left = null,
|
|
||||||
YogaValue? right = null)
|
|
||||||
{
|
|
||||||
Top = top;
|
|
||||||
Bottom = bottom;
|
|
||||||
Left = left;
|
|
||||||
Right = right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,234 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Facebook.Yoga
|
|
||||||
{
|
|
||||||
public partial class YogaNode
|
|
||||||
{
|
|
||||||
[Obsolete("use Object Initializer")]
|
|
||||||
public static YogaNode Create(
|
|
||||||
YogaDirection? styleDirection = null,
|
|
||||||
YogaFlexDirection? flexDirection = null,
|
|
||||||
YogaJustify? justifyContent = null,
|
|
||||||
YogaAlign? alignContent = null,
|
|
||||||
YogaAlign? alignItems = null,
|
|
||||||
YogaAlign? alignSelf = null,
|
|
||||||
YogaPositionType? positionType = null,
|
|
||||||
YogaWrap? wrap = null,
|
|
||||||
YogaOverflow? overflow = null,
|
|
||||||
float? flex = null,
|
|
||||||
float? flexGrow = null,
|
|
||||||
float? flexShrink = null,
|
|
||||||
YogaValue? flexBasis = null,
|
|
||||||
Spacing position = null,
|
|
||||||
Spacing margin = null,
|
|
||||||
Spacing padding = null,
|
|
||||||
Border border = null,
|
|
||||||
YogaValue? width = null,
|
|
||||||
YogaValue? height = null,
|
|
||||||
YogaValue? maxWidth = null,
|
|
||||||
YogaValue? maxHeight = null,
|
|
||||||
YogaValue? minWidth = null,
|
|
||||||
YogaValue? minHeight = null)
|
|
||||||
{
|
|
||||||
YogaNode node = new YogaNode();
|
|
||||||
|
|
||||||
if (styleDirection.HasValue)
|
|
||||||
{
|
|
||||||
node.StyleDirection = styleDirection.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flexDirection.HasValue)
|
|
||||||
{
|
|
||||||
node.FlexDirection = flexDirection.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (justifyContent.HasValue)
|
|
||||||
{
|
|
||||||
node.JustifyContent = justifyContent.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alignContent.HasValue)
|
|
||||||
{
|
|
||||||
node.AlignContent = alignContent.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alignItems.HasValue)
|
|
||||||
{
|
|
||||||
node.AlignItems = alignItems.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alignSelf.HasValue)
|
|
||||||
{
|
|
||||||
node.AlignSelf = alignSelf.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (positionType.HasValue)
|
|
||||||
{
|
|
||||||
node.PositionType = positionType.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wrap.HasValue)
|
|
||||||
{
|
|
||||||
node.Wrap = wrap.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overflow.HasValue)
|
|
||||||
{
|
|
||||||
node.Overflow = overflow.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flex.HasValue)
|
|
||||||
{
|
|
||||||
node.Flex = flex.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flexGrow.HasValue)
|
|
||||||
{
|
|
||||||
node.FlexGrow = flexGrow.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flexShrink.HasValue)
|
|
||||||
{
|
|
||||||
node.FlexShrink = flexShrink.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flexBasis.HasValue)
|
|
||||||
{
|
|
||||||
node.FlexBasis = flexBasis.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position != null)
|
|
||||||
{
|
|
||||||
if (position.Top.HasValue)
|
|
||||||
{
|
|
||||||
node.Top = position.Top.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position.Bottom.HasValue)
|
|
||||||
{
|
|
||||||
node.Bottom = position.Bottom.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position.Left.HasValue)
|
|
||||||
{
|
|
||||||
node.Left = position.Left.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position.Right.HasValue)
|
|
||||||
{
|
|
||||||
node.Right = position.Right.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (margin != null)
|
|
||||||
{
|
|
||||||
if (margin.Top.HasValue)
|
|
||||||
{
|
|
||||||
node.MarginTop = margin.Top.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (margin.Bottom.HasValue)
|
|
||||||
{
|
|
||||||
node.MarginBottom = margin.Bottom.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (margin.Left.HasValue)
|
|
||||||
{
|
|
||||||
node.MarginLeft = margin.Left.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (margin.Right.HasValue)
|
|
||||||
{
|
|
||||||
node.MarginRight = margin.Right.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (padding != null)
|
|
||||||
{
|
|
||||||
if (padding.Top.HasValue)
|
|
||||||
{
|
|
||||||
node.PaddingTop = padding.Top.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (padding.Bottom.HasValue)
|
|
||||||
{
|
|
||||||
node.PaddingBottom = padding.Bottom.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (padding.Left.HasValue)
|
|
||||||
{
|
|
||||||
node.PaddingLeft = padding.Left.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (padding.Right.HasValue)
|
|
||||||
{
|
|
||||||
node.PaddingRight = padding.Right.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (border != null)
|
|
||||||
{
|
|
||||||
if (border.Top.HasValue)
|
|
||||||
{
|
|
||||||
node.BorderTopWidth = border.Top.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (border.Bottom.HasValue)
|
|
||||||
{
|
|
||||||
node.BorderBottomWidth = border.Bottom.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (border.Left.HasValue)
|
|
||||||
{
|
|
||||||
node.BorderLeftWidth = border.Left.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (border.Right.HasValue)
|
|
||||||
{
|
|
||||||
node.BorderRightWidth = border.Right.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (width.HasValue)
|
|
||||||
{
|
|
||||||
node.Width = width.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (height.HasValue)
|
|
||||||
{
|
|
||||||
node.Height = height.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minWidth.HasValue)
|
|
||||||
{
|
|
||||||
node.MinWidth = minWidth.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minHeight.HasValue)
|
|
||||||
{
|
|
||||||
node.MinHeight = minHeight.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxWidth.HasValue)
|
|
||||||
{
|
|
||||||
node.MaxWidth = maxWidth.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxHeight.HasValue)
|
|
||||||
{
|
|
||||||
node.MaxHeight = maxHeight.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -264,81 +264,6 @@ namespace Facebook.Yoga
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("use Margin properties")]
|
|
||||||
public YogaValue GetMargin(YogaEdge edge)
|
|
||||||
{
|
|
||||||
return Native.YGNodeStyleGetMargin(_ygNode, edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use Margin properties")]
|
|
||||||
public void SetMargin(YogaEdge edge, YogaValue value)
|
|
||||||
{
|
|
||||||
if (value.Unit == YogaUnit.Percent)
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use Padding properties")]
|
|
||||||
public YogaValue GetPadding(YogaEdge edge)
|
|
||||||
{
|
|
||||||
return Native.YGNodeStyleGetPadding(_ygNode, edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use Padding properties")]
|
|
||||||
public void SetPadding(YogaEdge edge, YogaValue value)
|
|
||||||
{
|
|
||||||
if (value.Unit == YogaUnit.Percent)
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use BorderWidth properties")]
|
|
||||||
public float GetBorder(YogaEdge edge)
|
|
||||||
{
|
|
||||||
return Native.YGNodeStyleGetBorder(_ygNode, edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use BorderWidth properties")]
|
|
||||||
public void SetBorder(YogaEdge edge, float border)
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetBorder(_ygNode, edge, border);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use Position properties")]
|
|
||||||
public YogaValue GetPosition(YogaEdge edge)
|
|
||||||
{
|
|
||||||
return Native.YGNodeStyleGetPosition(_ygNode, edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use Position properties")]
|
|
||||||
public void SetPosition(YogaEdge edge, YogaValue value)
|
|
||||||
{
|
|
||||||
if (value.Unit == YogaUnit.Percent)
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("use LayoutPadding properties")]
|
|
||||||
public float GetLayoutPadding(YogaEdge edge)
|
|
||||||
{
|
|
||||||
return Native.YGNodeLayoutGetPadding(_ygNode, edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
public YogaValue Width
|
public YogaValue Width
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@@ -310,5 +310,384 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_center()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_flex_end()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.FlexEnd;
|
||||||
|
root.AlignItems = YogaAlign.FlexEnd;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_justify_content_center()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_center()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_center_on_child_only()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.AlignSelf = YogaAlign.Center;
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_center_and_top_position()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Top = 10;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_center_and_bottom_position()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Bottom = 10;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(25f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(50f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_center_and_left_position()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Left = 5;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(5f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(5f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_absolute_layout_align_items_and_justify_content_center_and_right_position()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.FlexGrow = 1;
|
||||||
|
root.Width = 110;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.PositionType = YogaPositionType.Absolute;
|
||||||
|
root_child0.Right = 5;
|
||||||
|
root_child0.Width = 60;
|
||||||
|
root_child0.Height = 40;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(45f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(110f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(45f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(60f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(40f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,3 +24,39 @@
|
|||||||
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
|
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
|
||||||
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
|
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_flex_end" style="height: 100px; width: 110px; flex-grow: 1; align-items: flex-end; justify-content: flex-end;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_justify_content_center" style="height: 100px; width: 110px; flex-grow: 1; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_center" style="height: 100px; width: 110px; flex-grow: 1; align-items: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_center_on_child_only" style="height: 100px; width: 110px; flex-grow: 1;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;align-self: center;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_center_and_top_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;top:10px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_center_and_bottom_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;bottom:10px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_center_and_left_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;left:5px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="absolute_layout_align_items_and_justify_content_center_and_right_position" style="height: 100px; width: 110px; flex-grow: 1; align-items: center; justify-content: center;">
|
||||||
|
<div style="position: absolute; width: 60px; height: 40px;right:5px;"></div>
|
||||||
|
</div>
|
@@ -75,7 +75,9 @@ static void YGPrint(YGNodeRef node) {
|
|||||||
|
|
||||||
static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
|
static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) {
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
return findClassLocal("com/facebook/yoga/YogaNode")->getMethod<jfloat(jfloat, jfloat)>("baseline")(obj, width, height);
|
static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
|
->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
||||||
|
return baselineFunc(obj, width, height);
|
||||||
} else {
|
} else {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
@@ -87,7 +89,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
|
|||||||
float height,
|
float height,
|
||||||
YGMeasureMode heightMode) {
|
YGMeasureMode heightMode) {
|
||||||
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
if (auto obj = YGNodeJobject(node)->lockLocal()) {
|
||||||
static auto measureFunc = findClassLocal("com/facebook/yoga/YogaNode")
|
static auto measureFunc = findClassStatic("com/facebook/yoga/YogaNode")
|
||||||
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
||||||
|
|
||||||
YGTransferLayoutDirection(node, obj);
|
YGTransferLayoutDirection(node, obj);
|
||||||
@@ -121,7 +123,7 @@ static int YGLog(YGLogLevel level, const char *format, va_list args) {
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||||
|
|
||||||
static auto logFunc = findClassLocal("com/facebook/yoga/YogaLogger")
|
static auto logFunc = findClassStatic("com/facebook/yoga/YogaLogger")
|
||||||
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
|
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
|
||||||
|
|
||||||
static auto logLevelFromInt =
|
static auto logLevelFromInt =
|
||||||
@@ -221,8 +223,11 @@ void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboole
|
|||||||
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
|
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jni_YGNodeSetHasBaselineFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasBaselineFunc) {
|
void jni_YGNodeSetHasBaselineFunc(alias_ref<jobject>,
|
||||||
YGNodeSetBaselineFunc(_jlong2YGNodeRef(nativePointer), hasBaselineFunc ? YGJNIBaselineFunc : NULL);
|
jlong nativePointer,
|
||||||
|
jboolean hasBaselineFunc) {
|
||||||
|
YGNodeSetBaselineFunc(_jlong2YGNodeRef(nativePointer),
|
||||||
|
hasBaselineFunc ? YGJNIBaselineFunc : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean jni_YGNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
|
jboolean jni_YGNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
|
||||||
|
@@ -303,4 +303,374 @@ public class YGAbsolutePositionTest {
|
|||||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_center() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_flex_end() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.FLEX_END);
|
||||||
|
root.setAlignItems(YogaAlign.FLEX_END);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_justify_content_center() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_center() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_center_on_child_only() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setAlignSelf(YogaAlign.CENTER);
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_center_and_top_position() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setPosition(YogaEdge.TOP, 10f);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_center_and_bottom_position() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setPosition(YogaEdge.BOTTOM, 10f);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(50f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_center_and_left_position() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setPosition(YogaEdge.LEFT, 5f);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_absolute_layout_align_items_and_justify_content_center_and_right_position() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setFlexGrow(1f);
|
||||||
|
root.setWidth(110f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||||
|
root_child0.setPosition(YogaEdge.RIGHT, 5f);
|
||||||
|
root_child0.setWidth(60f);
|
||||||
|
root_child0.setHeight(40f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(45f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout();
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(45f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -459,6 +459,11 @@ double Node::getComputedMargin(int edge) const
|
|||||||
return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge));
|
return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Node::getComputedBorder(int edge) const
|
||||||
|
{
|
||||||
|
return YGNodeLayoutGetBorder(m_node, static_cast<YGEdge>(edge));
|
||||||
|
}
|
||||||
|
|
||||||
double Node::getComputedPadding(int edge) const
|
double Node::getComputedPadding(int edge) const
|
||||||
{
|
{
|
||||||
return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge));
|
return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge));
|
||||||
|
@@ -177,6 +177,7 @@ class Node {
|
|||||||
Layout getComputedLayout(void) const;
|
Layout getComputedLayout(void) const;
|
||||||
|
|
||||||
double getComputedMargin(int edge) const;
|
double getComputedMargin(int edge) const;
|
||||||
|
double getComputedBorder(int edge) const;
|
||||||
double getComputedPadding(int edge) const;
|
double getComputedPadding(int edge) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -155,5 +155,6 @@ NBIND_CLASS(Node)
|
|||||||
method(getComputedLayout);
|
method(getComputedLayout);
|
||||||
|
|
||||||
method(getComputedMargin);
|
method(getComputedMargin);
|
||||||
|
method(getComputedBorder);
|
||||||
method(getComputedPadding);
|
method(getComputedPadding);
|
||||||
}
|
}
|
||||||
|
@@ -310,3 +310,391 @@ it("absolute_layout_within_border", function () {
|
|||||||
(typeof gc !== "undefined") && gc();
|
(typeof gc !== "undefined") && gc();
|
||||||
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
});
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_center", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_flex_end", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_FLEX_END);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_FLEX_END);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedTop(), "60 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === 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(60 === root_child0.getComputedTop(), "60 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_justify_content_center", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === 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(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_center", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_center_on_child_only", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setAlignSelf(Yoga.ALIGN_CENTER);
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_center_and_top_position", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setPosition(Yoga.EDGE_TOP, 10);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedTop(), "10 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_center_and_bottom_position", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setPosition(Yoga.EDGE_BOTTOM, 10);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(50 === root_child0.getComputedTop(), "50 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(25 === root_child0.getComputedLeft(), "25 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(50 === root_child0.getComputedTop(), "50 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_center_and_left_position", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setPosition(Yoga.EDGE_LEFT, 5);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(5 === root_child0.getComputedLeft(), "5 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(5 === root_child0.getComputedLeft(), "5 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("absolute_layout_align_items_and_justify_content_center_and_right_position", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setFlexGrow(1);
|
||||||
|
root.setWidth(110);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
|
||||||
|
root_child0.setPosition(Yoga.EDGE_RIGHT, 5);
|
||||||
|
root_child0.setWidth(60);
|
||||||
|
root_child0.setHeight(40);
|
||||||
|
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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(45 === root_child0.getComputedLeft(), "45 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === 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(110 === root.getComputedWidth(), "110 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(45 === root_child0.getComputedLeft(), "45 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(40 === root_child0.getComputedHeight(), "40 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -172,3 +172,75 @@ it("align_self_flex_end_override_flex_start", function () {
|
|||||||
(typeof gc !== "undefined") && gc();
|
(typeof gc !== "undefined") && gc();
|
||||||
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
});
|
});
|
||||||
|
it("align_self_baseline", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||||
|
root_child0.setWidth(50);
|
||||||
|
root_child0.setHeight(50);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child1 = Yoga.Node.create();
|
||||||
|
root_child1.setAlignSelf(Yoga.ALIGN_BASELINE);
|
||||||
|
root_child1.setWidth(50);
|
||||||
|
root_child1.setHeight(20);
|
||||||
|
root.insertChild(root_child1, 1);
|
||||||
|
|
||||||
|
var root_child1_child0 = Yoga.Node.create();
|
||||||
|
root_child1_child0.setWidth(50);
|
||||||
|
root_child1_child0.setHeight(10);
|
||||||
|
root_child1.insertChild(root_child1_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(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(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(40 === root_child1.getComputedTop(), "40 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child1.getComputedHeight(), "20 === 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(50 === root_child1_child0.getComputedWidth(), "50 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(50 === root_child0.getComputedWidth(), "50 === 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(40 === root_child1.getComputedTop(), "40 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child1.getComputedHeight(), "20 === 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(50 === root_child1_child0.getComputedWidth(), "50 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(10 === root_child1_child0.getComputedHeight(), "10 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
33
javascript/tests/Facebook.Yoga/YGComputedBorderTest.js
Normal file
33
javascript/tests/Facebook.Yoga/YGComputedBorderTest.js
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
||||||
|
|
||||||
|
it("border_start", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
root.setBorder(Yoga.EDGE_START, 10);
|
||||||
|
|
||||||
|
root.calculateLayout(100, 100, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(10 === root.getComputedBorder(Yoga.EDGE_LEFT), "10 === root.getComputedBorder(Yoga.EDGE_LEFT)");
|
||||||
|
console.assert(0 === root.getComputedBorder(Yoga.EDGE_RIGHT), "0 === root.getComputedBorder(Yoga.EDGE_RIGHT)");
|
||||||
|
|
||||||
|
root.calculateLayout(100, 100, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedBorder(Yoga.EDGE_LEFT), "0 === root.getComputedBorder(Yoga.EDGE_LEFT)");
|
||||||
|
console.assert(10 === root.getComputedBorder(Yoga.EDGE_RIGHT), "10 === root.getComputedBorder(Yoga.EDGE_RIGHT)");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
@@ -292,3 +292,364 @@ TEST(YogaTest, absolute_layout_within_border) {
|
|||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_flex_end) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_justify_content_center) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_center) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_center_on_child_only) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter);
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_top_position) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_bottom_position) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_left_position) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, absolute_layout_align_items_and_justify_content_center_and_right_position) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetFlexGrow(root, 1);
|
||||||
|
YGNodeStyleSetWidth(root, 110);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeStyleSetPosition(root_child0, YGEdgeRight, 5);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 60);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 40);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
@@ -697,3 +697,53 @@ TEST(YogaTest, aspect_ratio_allow_child_overflow_parent_size) {
|
|||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, aspect_ratio_defined_main_with_margin) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetHeight(root_child0, 50);
|
||||||
|
YGNodeStyleSetAspectRatio(root_child0, 1);
|
||||||
|
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
|
||||||
|
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, aspect_ratio_defined_cross_with_margin) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0, 50);
|
||||||
|
YGNodeStyleSetAspectRatio(root_child0, 1);
|
||||||
|
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
|
||||||
|
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
@@ -39,6 +39,22 @@ static YGSize _measureMin(YGNodeRef node,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static YGSize _measure_84_49(YGNodeRef node,
|
||||||
|
float width,
|
||||||
|
YGMeasureMode widthMode,
|
||||||
|
float height,
|
||||||
|
YGMeasureMode heightMode) {
|
||||||
|
int *measureCount = (int*) YGNodeGetContext(node);
|
||||||
|
if (measureCount) {
|
||||||
|
(*measureCount)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YGSize {
|
||||||
|
.width = 84.f,
|
||||||
|
.height = 49.f,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
TEST(YogaTest, measure_once_single_flexible_child) {
|
TEST(YogaTest, measure_once_single_flexible_child) {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
@@ -131,3 +147,28 @@ TEST(YogaTest, remeasure_with_atmost_computed_width_undefined_height) {
|
|||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, remeasure_with_already_measured_value_smaller_but_still_float_equal) {
|
||||||
|
int measureCount = 0;
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 288.f);
|
||||||
|
YGNodeStyleSetHeight(root, 288.f);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPadding(root_child0, YGEdgeAll, 2.88f);
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeSetContext(root_child0_child0, &measureCount);
|
||||||
|
YGNodeSetMeasureFunc(root_child0_child0, _measure_84_49);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
ASSERT_EQ(1, measureCount);
|
||||||
|
}
|
||||||
|
@@ -47,6 +47,27 @@ TEST(YogaTest, dont_measure_single_grow_shrink_child) {
|
|||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, measure_absolute_child_with_no_constraints) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
int measureCount = 0;
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
YGNodeSetContext(root_child0_child0, &measureCount);
|
||||||
|
YGNodeSetMeasureFunc(root_child0_child0, _measure);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_EQ(1, measureCount);
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
TEST(YogaTest, cannot_add_child_to_node_with_measure_func) {
|
TEST(YogaTest, cannot_add_child_to_node_with_measure_func) {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
111
yoga/YGEnums.h
111
yoga/YGEnums.h
@@ -15,110 +15,89 @@ YG_EXTERN_C_BEGIN
|
|||||||
|
|
||||||
#define YGFlexDirectionCount 4
|
#define YGFlexDirectionCount 4
|
||||||
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow,
|
||||||
YGFlexDirectionColumnReverse,
|
YGFlexDirectionRowReverse,
|
||||||
YGFlexDirectionRow,
|
}
|
||||||
YGFlexDirectionRowReverse,
|
YG_ENUM_END(YGFlexDirection);
|
||||||
} YG_ENUM_END(YGFlexDirection);
|
|
||||||
|
|
||||||
#define YGMeasureModeCount 3
|
#define YGMeasureModeCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
||||||
YGMeasureModeUndefined,
|
YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost,
|
||||||
YGMeasureModeExactly,
|
}
|
||||||
YGMeasureModeAtMost,
|
YG_ENUM_END(YGMeasureMode);
|
||||||
} YG_ENUM_END(YGMeasureMode);
|
|
||||||
|
|
||||||
#define YGPrintOptionsCount 3
|
#define YGPrintOptionsCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
||||||
YGPrintOptionsLayout = 1,
|
YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4,
|
||||||
YGPrintOptionsStyle = 2,
|
}
|
||||||
YGPrintOptionsChildren = 4,
|
YG_ENUM_END(YGPrintOptions);
|
||||||
} YG_ENUM_END(YGPrintOptions);
|
|
||||||
|
|
||||||
#define YGEdgeCount 9
|
#define YGEdgeCount 9
|
||||||
typedef YG_ENUM_BEGIN(YGEdge) {
|
typedef YG_ENUM_BEGIN(YGEdge) {
|
||||||
YGEdgeLeft,
|
YGEdgeLeft, YGEdgeTop, YGEdgeRight, YGEdgeBottom, YGEdgeStart, YGEdgeEnd, YGEdgeHorizontal,
|
||||||
YGEdgeTop,
|
YGEdgeVertical, YGEdgeAll,
|
||||||
YGEdgeRight,
|
}
|
||||||
YGEdgeBottom,
|
YG_ENUM_END(YGEdge);
|
||||||
YGEdgeStart,
|
|
||||||
YGEdgeEnd,
|
|
||||||
YGEdgeHorizontal,
|
|
||||||
YGEdgeVertical,
|
|
||||||
YGEdgeAll,
|
|
||||||
} YG_ENUM_END(YGEdge);
|
|
||||||
|
|
||||||
#define YGPositionTypeCount 2
|
#define YGPositionTypeCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGPositionType) {
|
typedef YG_ENUM_BEGIN(YGPositionType) {
|
||||||
YGPositionTypeRelative,
|
YGPositionTypeRelative, YGPositionTypeAbsolute,
|
||||||
YGPositionTypeAbsolute,
|
}
|
||||||
} YG_ENUM_END(YGPositionType);
|
YG_ENUM_END(YGPositionType);
|
||||||
|
|
||||||
#define YGDimensionCount 2
|
#define YGDimensionCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDimension) {
|
typedef YG_ENUM_BEGIN(YGDimension) {
|
||||||
YGDimensionWidth,
|
YGDimensionWidth, YGDimensionHeight,
|
||||||
YGDimensionHeight,
|
}
|
||||||
} YG_ENUM_END(YGDimension);
|
YG_ENUM_END(YGDimension);
|
||||||
|
|
||||||
#define YGJustifyCount 5
|
#define YGJustifyCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGJustify) {
|
typedef YG_ENUM_BEGIN(YGJustify) {
|
||||||
YGJustifyFlexStart,
|
YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween,
|
||||||
YGJustifyCenter,
|
YGJustifySpaceAround,
|
||||||
YGJustifyFlexEnd,
|
}
|
||||||
YGJustifySpaceBetween,
|
YG_ENUM_END(YGJustify);
|
||||||
YGJustifySpaceAround,
|
|
||||||
} YG_ENUM_END(YGJustify);
|
|
||||||
|
|
||||||
#define YGDirectionCount 3
|
#define YGDirectionCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGDirection) {
|
typedef YG_ENUM_BEGIN(YGDirection) {
|
||||||
YGDirectionInherit,
|
YGDirectionInherit, YGDirectionLTR, YGDirectionRTL,
|
||||||
YGDirectionLTR,
|
}
|
||||||
YGDirectionRTL,
|
YG_ENUM_END(YGDirection);
|
||||||
} YG_ENUM_END(YGDirection);
|
|
||||||
|
|
||||||
#define YGLogLevelCount 5
|
#define YGLogLevelCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
||||||
YGLogLevelError,
|
YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose,
|
||||||
YGLogLevelWarn,
|
}
|
||||||
YGLogLevelInfo,
|
YG_ENUM_END(YGLogLevel);
|
||||||
YGLogLevelDebug,
|
|
||||||
YGLogLevelVerbose,
|
|
||||||
} YG_ENUM_END(YGLogLevel);
|
|
||||||
|
|
||||||
#define YGWrapCount 2
|
#define YGWrapCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGWrap) {
|
typedef YG_ENUM_BEGIN(YGWrap) {
|
||||||
YGWrapNoWrap,
|
YGWrapNoWrap, YGWrapWrap,
|
||||||
YGWrapWrap,
|
}
|
||||||
} YG_ENUM_END(YGWrap);
|
YG_ENUM_END(YGWrap);
|
||||||
|
|
||||||
#define YGOverflowCount 3
|
#define YGOverflowCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGOverflow) {
|
typedef YG_ENUM_BEGIN(YGOverflow) {
|
||||||
YGOverflowVisible,
|
YGOverflowVisible, YGOverflowHidden, YGOverflowScroll,
|
||||||
YGOverflowHidden,
|
}
|
||||||
YGOverflowScroll,
|
YG_ENUM_END(YGOverflow);
|
||||||
} YG_ENUM_END(YGOverflow);
|
|
||||||
|
|
||||||
#define YGExperimentalFeatureCount 2
|
#define YGExperimentalFeatureCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
||||||
YGExperimentalFeatureRounding,
|
YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis,
|
||||||
YGExperimentalFeatureWebFlexBasis,
|
}
|
||||||
} YG_ENUM_END(YGExperimentalFeature);
|
YG_ENUM_END(YGExperimentalFeature);
|
||||||
|
|
||||||
#define YGAlignCount 6
|
#define YGAlignCount 6
|
||||||
typedef YG_ENUM_BEGIN(YGAlign) {
|
typedef YG_ENUM_BEGIN(YGAlign) {
|
||||||
YGAlignAuto,
|
YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, YGAlignBaseline,
|
||||||
YGAlignFlexStart,
|
}
|
||||||
YGAlignCenter,
|
YG_ENUM_END(YGAlign);
|
||||||
YGAlignFlexEnd,
|
|
||||||
YGAlignStretch,
|
|
||||||
YGAlignBaseline,
|
|
||||||
} YG_ENUM_END(YGAlign);
|
|
||||||
|
|
||||||
#define YGUnitCount 3
|
#define YGUnitCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGUnit) {
|
typedef YG_ENUM_BEGIN(YGUnit) {
|
||||||
YGUnitUndefined,
|
YGUnitUndefined, YGUnitPixel, YGUnitPercent,
|
||||||
YGUnitPixel,
|
}
|
||||||
YGUnitPercent,
|
YG_ENUM_END(YGUnit);
|
||||||
} YG_ENUM_END(YGUnit);
|
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
@@ -42,7 +42,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NS_ENUM
|
#ifdef NS_ENUM
|
||||||
// Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a enum).
|
// Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a
|
||||||
|
// enum).
|
||||||
// Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI.
|
// Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI.
|
||||||
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
|
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
|
||||||
#define YG_ENUM_END(name)
|
#define YG_ENUM_END(name)
|
||||||
|
191
yoga/Yoga.c
191
yoga/Yoga.c
@@ -48,6 +48,7 @@ typedef struct YGLayout {
|
|||||||
float position[4];
|
float position[4];
|
||||||
float dimensions[2];
|
float dimensions[2];
|
||||||
float margin[6];
|
float margin[6];
|
||||||
|
float border[6];
|
||||||
float padding[6];
|
float padding[6];
|
||||||
YGDirection direction;
|
YGDirection direction;
|
||||||
|
|
||||||
@@ -531,7 +532,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
|||||||
return node->layout.instanceName; \
|
return node->layout.instanceName; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
|
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
|
||||||
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
|
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
|
||||||
YG_ASSERT(edge <= YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \
|
YG_ASSERT(edge <= YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \
|
||||||
\
|
\
|
||||||
@@ -596,6 +597,7 @@ YG_NODE_LAYOUT_PROPERTY_IMPL(float, Height, dimensions[YGDimensionHeight]);
|
|||||||
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
YG_NODE_LAYOUT_PROPERTY_IMPL(YGDirection, Direction, direction);
|
||||||
|
|
||||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin);
|
||||||
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border);
|
||||||
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
|
YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding);
|
||||||
|
|
||||||
uint32_t gCurrentGenerationCount = 0;
|
uint32_t gCurrentGenerationCount = 0;
|
||||||
@@ -1272,14 +1274,17 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node,
|
|||||||
childWidthMeasureMode = YGMeasureModeUndefined;
|
childWidthMeasureMode = YGMeasureModeUndefined;
|
||||||
childHeightMeasureMode = YGMeasureModeUndefined;
|
childHeightMeasureMode = YGMeasureModeUndefined;
|
||||||
|
|
||||||
|
const float marginRow = YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth);
|
||||||
|
const float marginColumn = YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth);
|
||||||
|
|
||||||
if (isRowStyleDimDefined) {
|
if (isRowStyleDimDefined) {
|
||||||
childWidth = YGValueResolve(&child->style.dimensions[YGDimensionWidth], parentWidth) +
|
childWidth =
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionRow, parentWidth);
|
YGValueResolve(&child->style.dimensions[YGDimensionWidth], parentWidth) + marginRow;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
if (isColumnStyleDimDefined) {
|
if (isColumnStyleDimDefined) {
|
||||||
childHeight = YGValueResolve(&child->style.dimensions[YGDimensionHeight], parentHeight) +
|
childHeight =
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionColumn, parentWidth);
|
YGValueResolve(&child->style.dimensions[YGDimensionHeight], parentHeight) + marginColumn;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1318,12 +1323,12 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node,
|
|||||||
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
||||||
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
||||||
child->layout.computedFlexBasis =
|
child->layout.computedFlexBasis =
|
||||||
fmaxf(childWidth / child->style.aspectRatio,
|
fmaxf((childWidth - marginRow) / child->style.aspectRatio,
|
||||||
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth));
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, parentWidth));
|
||||||
return;
|
return;
|
||||||
} else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
} else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
||||||
child->layout.computedFlexBasis =
|
child->layout.computedFlexBasis =
|
||||||
fmaxf(childHeight * child->style.aspectRatio,
|
fmaxf((childHeight - marginColumn) * child->style.aspectRatio,
|
||||||
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth));
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, parentWidth));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1374,9 +1379,11 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
|
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
|
||||||
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
||||||
|
|
||||||
|
const float marginRow = YGNodeMarginForAxis(child, YGFlexDirectionRow, width);
|
||||||
|
const float marginColumn = YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
|
||||||
|
|
||||||
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) {
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow)) {
|
||||||
childWidth = YGValueResolve(&child->style.dimensions[YGDimensionWidth], width) +
|
childWidth = YGValueResolve(&child->style.dimensions[YGDimensionWidth], width) + marginRow;
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionRow, width);
|
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified width, compute the width based
|
// If the child doesn't have a specified width, compute the width based
|
||||||
// on the left/right
|
// on the left/right
|
||||||
@@ -1393,8 +1400,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) {
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn)) {
|
||||||
childHeight = YGValueResolve(&child->style.dimensions[YGDimensionHeight], height) +
|
childHeight =
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
|
YGValueResolve(&child->style.dimensions[YGDimensionHeight], height) + marginColumn;
|
||||||
} else {
|
} else {
|
||||||
// If the child doesn't have a specified height, compute the height
|
// If the child doesn't have a specified height, compute the height
|
||||||
// based on the top/bottom
|
// based on the top/bottom
|
||||||
@@ -1415,11 +1422,13 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
|
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
|
||||||
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
||||||
if (YGFloatIsUndefined(childWidth)) {
|
if (YGFloatIsUndefined(childWidth)) {
|
||||||
childWidth = fmaxf(childHeight * child->style.aspectRatio,
|
childWidth =
|
||||||
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width));
|
marginRow + fmaxf((childHeight - marginColumn) * child->style.aspectRatio,
|
||||||
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionColumn, width));
|
||||||
} else if (YGFloatIsUndefined(childHeight)) {
|
} else if (YGFloatIsUndefined(childHeight)) {
|
||||||
childHeight = fmaxf(childWidth / child->style.aspectRatio,
|
childHeight =
|
||||||
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width));
|
marginColumn + fmaxf((childWidth - marginRow) / child->style.aspectRatio,
|
||||||
|
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, width));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1431,11 +1440,11 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
childHeightMeasureMode =
|
childHeightMeasureMode =
|
||||||
YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
||||||
|
|
||||||
// According to the spec, if the main size is not definite and the
|
// If the size of the parent is defined then try to constrain the absolute child to that size
|
||||||
// child's inline axis is parallel to the main axis (i.e. it's
|
// as well. This allows text within the absolute child to wrap to the size of its parent.
|
||||||
// horizontal), the child should be sized using "UNDEFINED" in
|
// This is the same behavior as many browsers implement.
|
||||||
// the main size. Otherwise use "AT_MOST" in the cross axis.
|
if (!isMainAxisRow && YGFloatIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined &&
|
||||||
if (!isMainAxisRow && YGFloatIsUndefined(childWidth) && widthMode != YGMeasureModeUndefined) {
|
width > 0) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeAtMost;
|
childWidthMeasureMode = YGMeasureModeAtMost;
|
||||||
}
|
}
|
||||||
@@ -1472,6 +1481,15 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
child->layout.measuredDimensions[dim[mainAxis]] -
|
child->layout.measuredDimensions[dim[mainAxis]] -
|
||||||
YGNodeTrailingBorder(node, mainAxis) -
|
YGNodeTrailingBorder(node, mainAxis) -
|
||||||
YGNodeTrailingPosition(child, mainAxis, width);
|
YGNodeTrailingPosition(child, mainAxis, width);
|
||||||
|
} else if (!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
||||||
|
node->style.justifyContent == YGJustifyCenter) {
|
||||||
|
child->layout.position[leading[mainAxis]] = (node->layout.measuredDimensions[dim[mainAxis]] -
|
||||||
|
child->layout.measuredDimensions[dim[mainAxis]]) /
|
||||||
|
2.0f;
|
||||||
|
} else if (!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
||||||
|
node->style.justifyContent == YGJustifyFlexEnd) {
|
||||||
|
child->layout.position[leading[mainAxis]] = (node->layout.measuredDimensions[dim[mainAxis]] -
|
||||||
|
child->layout.measuredDimensions[dim[mainAxis]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (YGNodeIsTrailingPosDefined(child, crossAxis) &&
|
if (YGNodeIsTrailingPosDefined(child, crossAxis) &&
|
||||||
@@ -1480,6 +1498,16 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
child->layout.measuredDimensions[dim[crossAxis]] -
|
child->layout.measuredDimensions[dim[crossAxis]] -
|
||||||
YGNodeTrailingBorder(node, crossAxis) -
|
YGNodeTrailingBorder(node, crossAxis) -
|
||||||
YGNodeTrailingPosition(child, crossAxis, width);
|
YGNodeTrailingPosition(child, crossAxis, width);
|
||||||
|
} else if (!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
||||||
|
YGNodeAlignItem(node, child) == YGAlignCenter) {
|
||||||
|
child->layout.position[leading[crossAxis]] =
|
||||||
|
(node->layout.measuredDimensions[dim[crossAxis]] -
|
||||||
|
child->layout.measuredDimensions[dim[crossAxis]]) /
|
||||||
|
2.0f;
|
||||||
|
} else if (!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
||||||
|
YGNodeAlignItem(node, child) == YGAlignFlexEnd) {
|
||||||
|
child->layout.position[leading[crossAxis]] = (node->layout.measuredDimensions[dim[crossAxis]] -
|
||||||
|
child->layout.measuredDimensions[dim[crossAxis]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1749,39 +1777,25 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
|
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
|
||||||
node->layout.direction = direction;
|
node->layout.direction = direction;
|
||||||
|
|
||||||
node->layout.margin[YGEdgeStart] =
|
const YGFlexDirection flexRowDirection = YGFlexDirectionResolve(YGFlexDirectionRow, direction);
|
||||||
YGNodeLeadingMargin(node,
|
const YGFlexDirection flexColumnDirection =
|
||||||
YGFlexDirectionResolve(YGFlexDirectionRow, direction),
|
YGFlexDirectionResolve(YGFlexDirectionColumn, direction);
|
||||||
parentWidth);
|
|
||||||
node->layout.margin[YGEdgeEnd] =
|
|
||||||
YGNodeTrailingMargin(node,
|
|
||||||
YGFlexDirectionResolve(YGFlexDirectionRow, direction),
|
|
||||||
parentWidth);
|
|
||||||
node->layout.margin[YGEdgeTop] =
|
|
||||||
YGNodeLeadingMargin(node,
|
|
||||||
YGFlexDirectionResolve(YGFlexDirectionColumn, direction),
|
|
||||||
parentWidth);
|
|
||||||
node->layout.margin[YGEdgeBottom] =
|
|
||||||
YGNodeTrailingMargin(node,
|
|
||||||
YGFlexDirectionResolve(YGFlexDirectionColumn, direction),
|
|
||||||
parentWidth);
|
|
||||||
|
|
||||||
node->layout.padding[YGEdgeStart] =
|
node->layout.margin[YGEdgeStart] = YGNodeLeadingMargin(node, flexRowDirection, parentWidth);
|
||||||
YGNodeLeadingPadding(node,
|
node->layout.margin[YGEdgeEnd] = YGNodeTrailingMargin(node, flexRowDirection, parentWidth);
|
||||||
YGFlexDirectionResolve(YGFlexDirectionRow, direction),
|
node->layout.margin[YGEdgeTop] = YGNodeLeadingMargin(node, flexColumnDirection, parentWidth);
|
||||||
parentWidth);
|
node->layout.margin[YGEdgeBottom] = YGNodeTrailingMargin(node, flexColumnDirection, parentWidth);
|
||||||
node->layout.padding[YGEdgeEnd] =
|
|
||||||
YGNodeTrailingPadding(node,
|
node->layout.border[YGEdgeStart] = YGNodeLeadingBorder(node, flexRowDirection);
|
||||||
YGFlexDirectionResolve(YGFlexDirectionRow, direction),
|
node->layout.border[YGEdgeEnd] = YGNodeTrailingBorder(node, flexRowDirection);
|
||||||
parentWidth);
|
node->layout.border[YGEdgeTop] = YGNodeLeadingBorder(node, flexColumnDirection);
|
||||||
node->layout.padding[YGEdgeTop] =
|
node->layout.border[YGEdgeBottom] = YGNodeTrailingBorder(node, flexColumnDirection);
|
||||||
YGNodeLeadingPadding(node,
|
|
||||||
YGFlexDirectionResolve(YGFlexDirectionColumn, direction),
|
node->layout.padding[YGEdgeStart] = YGNodeLeadingPadding(node, flexRowDirection, parentWidth);
|
||||||
parentWidth);
|
node->layout.padding[YGEdgeEnd] = YGNodeTrailingPadding(node, flexRowDirection, parentWidth);
|
||||||
|
node->layout.padding[YGEdgeTop] = YGNodeLeadingPadding(node, flexColumnDirection, parentWidth);
|
||||||
node->layout.padding[YGEdgeBottom] =
|
node->layout.padding[YGEdgeBottom] =
|
||||||
YGNodeTrailingPadding(node,
|
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
||||||
YGFlexDirectionResolve(YGFlexDirectionColumn, direction),
|
|
||||||
parentWidth);
|
|
||||||
|
|
||||||
if (node->measure) {
|
if (node->measure) {
|
||||||
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||||
@@ -1985,8 +1999,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
if (child->style.positionType != YGPositionTypeAbsolute) {
|
if (child->style.positionType != YGPositionTypeAbsolute) {
|
||||||
const float outerFlexBasis =
|
const float outerFlexBasis =
|
||||||
fmaxf(YGValueResolve(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize), child->layout.computedFlexBasis) +
|
fmaxf(YGValueResolve(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
|
||||||
YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
child->layout.computedFlexBasis) +
|
||||||
|
YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
|
||||||
|
|
||||||
// If this is a multi-line flow and this item pushes us over the
|
// If this is a multi-line flow and this item pushes us over the
|
||||||
// available size, we've
|
// available size, we've
|
||||||
@@ -2205,10 +2220,13 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGMeasureMode childWidthMeasureMode;
|
YGMeasureMode childWidthMeasureMode;
|
||||||
YGMeasureMode childHeightMeasureMode;
|
YGMeasureMode childHeightMeasureMode;
|
||||||
|
|
||||||
|
const float marginRow =
|
||||||
|
YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth);
|
||||||
|
const float marginColumn =
|
||||||
|
YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth);
|
||||||
|
|
||||||
if (isMainAxisRow) {
|
if (isMainAxisRow) {
|
||||||
childWidth =
|
childWidth = updatedMainSize + marginRow;
|
||||||
updatedMainSize +
|
|
||||||
YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth);
|
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(availableInnerCrossDim) &&
|
if (!YGFloatIsUndefined(availableInnerCrossDim) &&
|
||||||
@@ -2224,15 +2242,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
} else {
|
} else {
|
||||||
childHeight = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionHeight],
|
childHeight = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionHeight],
|
||||||
availableInnerHeight) +
|
availableInnerHeight) +
|
||||||
YGNodeMarginForAxis(currentRelativeChild,
|
marginColumn;
|
||||||
YGFlexDirectionColumn,
|
|
||||||
availableInnerWidth);
|
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
childHeight =
|
childHeight = updatedMainSize + marginColumn;
|
||||||
updatedMainSize +
|
|
||||||
YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionColumn, availableInnerWidth);
|
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(availableInnerCrossDim) &&
|
if (!YGFloatIsUndefined(availableInnerCrossDim) &&
|
||||||
@@ -2246,17 +2260,16 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
childWidthMeasureMode =
|
childWidthMeasureMode =
|
||||||
YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost;
|
YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeAtMost;
|
||||||
} else {
|
} else {
|
||||||
childWidth =
|
childWidth = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionWidth],
|
||||||
YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionWidth],
|
availableInnerWidth) +
|
||||||
availableInnerWidth) +
|
marginRow;
|
||||||
YGNodeMarginForAxis(currentRelativeChild, YGFlexDirectionRow, availableInnerWidth);
|
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(currentRelativeChild->style.aspectRatio)) {
|
if (!YGFloatIsUndefined(currentRelativeChild->style.aspectRatio)) {
|
||||||
if (isMainAxisRow) {
|
if (isMainAxisRow) {
|
||||||
childHeight = fmaxf(childWidth / currentRelativeChild->style.aspectRatio,
|
childHeight = fmaxf((childWidth - marginRow) / currentRelativeChild->style.aspectRatio,
|
||||||
YGNodePaddingAndBorderForAxis(currentRelativeChild,
|
YGNodePaddingAndBorderForAxis(currentRelativeChild,
|
||||||
YGFlexDirectionColumn,
|
YGFlexDirectionColumn,
|
||||||
availableInnerWidth));
|
availableInnerWidth));
|
||||||
@@ -2264,21 +2277,26 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
// Parent size constraint should have higher priority than flex
|
// Parent size constraint should have higher priority than flex
|
||||||
if (YGNodeIsFlex(currentRelativeChild)) {
|
if (YGNodeIsFlex(currentRelativeChild)) {
|
||||||
childHeight = fminf(childHeight, availableInnerHeight);
|
childHeight = fminf((childHeight - marginColumn), availableInnerHeight);
|
||||||
childWidth = childHeight * currentRelativeChild->style.aspectRatio;
|
childWidth = marginRow + childHeight * currentRelativeChild->style.aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childHeight += marginColumn;
|
||||||
} else {
|
} else {
|
||||||
childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio,
|
childWidth =
|
||||||
YGNodePaddingAndBorderForAxis(currentRelativeChild,
|
fmaxf((childHeight - marginColumn) * currentRelativeChild->style.aspectRatio,
|
||||||
YGFlexDirectionRow,
|
YGNodePaddingAndBorderForAxis(currentRelativeChild,
|
||||||
availableInnerWidth));
|
YGFlexDirectionRow,
|
||||||
|
availableInnerWidth));
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
// Parent size constraint should have higher priority than flex
|
// Parent size constraint should have higher priority than flex
|
||||||
if (YGNodeIsFlex(currentRelativeChild)) {
|
if (YGNodeIsFlex(currentRelativeChild)) {
|
||||||
childWidth = fminf(childWidth, availableInnerWidth);
|
childWidth = fminf((childWidth - marginRow), availableInnerWidth);
|
||||||
childHeight = childWidth / currentRelativeChild->style.aspectRatio;
|
childHeight = marginColumn + childWidth / currentRelativeChild->style.aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childWidth += marginRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2487,24 +2505,31 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGMeasureMode childWidthMeasureMode = YGMeasureModeExactly;
|
YGMeasureMode childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
YGMeasureMode childHeightMeasureMode = YGMeasureModeExactly;
|
YGMeasureMode childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
|
const float marginRow =
|
||||||
|
YGNodeMarginForAxis(child, YGFlexDirectionRow, availableInnerWidth);
|
||||||
|
const float marginColumn =
|
||||||
|
YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth);
|
||||||
|
|
||||||
if (isMainAxisRow) {
|
if (isMainAxisRow) {
|
||||||
childWidth = child->layout.measuredDimensions[YGDimensionWidth] +
|
childWidth = child->layout.measuredDimensions[YGDimensionWidth];
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionRow, availableInnerWidth);
|
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
||||||
childHeight = childWidth / child->style.aspectRatio;
|
childHeight = marginColumn + childWidth / child->style.aspectRatio;
|
||||||
} else {
|
} else {
|
||||||
childHeight = crossDim;
|
childHeight = crossDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childWidth += marginRow;
|
||||||
} else {
|
} else {
|
||||||
childHeight = child->layout.measuredDimensions[YGDimensionHeight] +
|
childHeight = child->layout.measuredDimensions[YGDimensionHeight];
|
||||||
YGNodeMarginForAxis(child, YGFlexDirectionColumn, availableInnerWidth);
|
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
if (!YGFloatIsUndefined(child->style.aspectRatio)) {
|
||||||
childWidth = childHeight * child->style.aspectRatio;
|
childWidth = marginRow + childHeight * child->style.aspectRatio;
|
||||||
} else {
|
} else {
|
||||||
childWidth = crossDim;
|
childWidth = crossDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childHeight += marginColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionWidth],
|
YGConstrainMaxSizeForMode(YGValueResolve(&child->style.maxDimensions[YGDimensionWidth],
|
||||||
@@ -2786,7 +2811,7 @@ static inline bool YGMeasureModeOldSizeIsUnspecifiedAndStillFits(YGMeasureMode s
|
|||||||
YGMeasureMode lastSizeMode,
|
YGMeasureMode lastSizeMode,
|
||||||
float lastComputedSize) {
|
float lastComputedSize) {
|
||||||
return sizeMode == YGMeasureModeAtMost && lastSizeMode == YGMeasureModeUndefined &&
|
return sizeMode == YGMeasureModeAtMost && lastSizeMode == YGMeasureModeUndefined &&
|
||||||
size >= lastComputedSize;
|
(size >= lastComputedSize || YGFloatsEqual(size, lastComputedSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode,
|
static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(YGMeasureMode sizeMode,
|
||||||
@@ -2795,7 +2820,7 @@ static inline bool YGMeasureModeNewMeasureSizeIsStricterAndStillValid(YGMeasureM
|
|||||||
float lastSize,
|
float lastSize,
|
||||||
float lastComputedSize) {
|
float lastComputedSize) {
|
||||||
return lastSizeMode == YGMeasureModeAtMost && sizeMode == YGMeasureModeAtMost &&
|
return lastSizeMode == YGMeasureModeAtMost && sizeMode == YGMeasureModeAtMost &&
|
||||||
lastSize > size && lastComputedSize <= size;
|
lastSize > size && (lastComputedSize <= size || YGFloatsEqual(size, lastComputedSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
|
bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
|
||||||
|
16
yoga/Yoga.h
16
yoga/Yoga.h
@@ -43,7 +43,7 @@ typedef struct YGValue {
|
|||||||
YGUnit unit;
|
YGUnit unit;
|
||||||
} YGValue;
|
} YGValue;
|
||||||
|
|
||||||
static const YGValue YGValueUndefined = { YGUndefined, YGUnitUndefined };
|
static const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined};
|
||||||
|
|
||||||
typedef struct YGNode *YGNodeRef;
|
typedef struct YGNode *YGNodeRef;
|
||||||
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
|
||||||
@@ -139,6 +139,9 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
|
|||||||
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
|
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
|
||||||
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
|
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
|
||||||
|
|
||||||
|
#define YG_NODE_LAYOUT_EDGE_PROPERTY(type, name) \
|
||||||
|
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge);
|
||||||
|
|
||||||
YG_NODE_PROPERTY(void *, Context, context);
|
YG_NODE_PROPERTY(void *, Context, context);
|
||||||
YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc);
|
YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc);
|
||||||
YG_NODE_PROPERTY(YGBaselineFunc, BaselineFunc, baselineFunc)
|
YG_NODE_PROPERTY(YGBaselineFunc, BaselineFunc, baselineFunc)
|
||||||
@@ -195,12 +198,13 @@ YG_NODE_LAYOUT_PROPERTY(float, Width);
|
|||||||
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
YG_NODE_LAYOUT_PROPERTY(float, Height);
|
||||||
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
|
||||||
|
|
||||||
// Get the computed padding for this node after performing layout. If padding was set using
|
// Get the computed values for these nodes after performing layout. If they were set using
|
||||||
// pixel values then the returned value will be the same as YGNodeStyleGetPadding. However if
|
// pixel values then the returned value will be the same as YGNodeStyleGetXXX. However if
|
||||||
// padding was set using a percentage value then the returned value is the computed value used
|
// they were set using a percentage value then the returned value is the computed value used
|
||||||
// during layout.
|
// during layout.
|
||||||
WIN_EXPORT float YGNodeLayoutGetMargin(const YGNodeRef node, const YGEdge edge);
|
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin);
|
||||||
WIN_EXPORT float YGNodeLayoutGetPadding(const YGNodeRef node, const YGEdge edge);
|
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Border);
|
||||||
|
YG_NODE_LAYOUT_EDGE_PROPERTY(float, Padding);
|
||||||
|
|
||||||
WIN_EXPORT void YGSetLogger(YGLogger logger);
|
WIN_EXPORT void YGSetLogger(YGLogger logger);
|
||||||
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
|
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
|
||||||
|
Reference in New Issue
Block a user