[YogaKit] support macOS, tvOS, Carthage; auto apply layout like AutoLayout. #1026

Closed
cntrump wants to merge 38 commits from yogakit_autoapplylayout_patch into main
13 changed files with 206 additions and 78 deletions
Showing only changes of commit aa11f6a4db - Show all commits

View File

@@ -503,7 +503,12 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
topLeft.y + YGNodeLayoutGetHeight(node),
};
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
// use bounds/center and not frame if non-identity transform.
const CGPoint origin = preserveOrigin ? (CGPoint) {
.x = view.center.x - CGRectGetWidth(view.bounds) * 0.5,
.y = view.center.y - CGRectGetHeight(view.bounds) * 0.5
}
: CGPointZero;
CGRect frame = (CGRect){
.origin =
{
@@ -519,7 +524,6 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
},
};
// use bounds/center and not frame if non-identity transform.
view.bounds = (CGRect) {
.origin = view.bounds.origin,
.size = frame.size