From 8f0bac54a3bffbd3e796f88e3885b4cb1fd8b822 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 12 Jun 2016 12:31:44 -0400 Subject: [PATCH] Took an alternate route through the constraints in the grid. This should be a bit easier... --- darwin/grid.m | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/darwin/grid.m b/darwin/grid.m index d019d9df..c0cb4d3a 100644 --- a/darwin/grid.m +++ b/darwin/grid.m @@ -133,6 +133,7 @@ struct uiGrid { NSNumber *number; NSLayoutConstraint *c; NSView **colviews, **rowviews; + NSView *firstView; [self removeOurConstraints]; if ([self->children count] == 0) @@ -237,7 +238,57 @@ struct uiGrid { [self addConstraint:c]; [self->edges addObject:c]; } - [set release]; + + // now put all the views in the same row and column together + for (x = 0; x < xcount; x++) { + [set removeAllObjects]; + for (y = 0; y < ycount; y++) + [set addObject:[NSNumber numberWithInt:gg[y][x]]]; + first = YES; + for (number in set) { + if ([number intValue] == -1) + continue; + gc = (gridChild *) [self->children objectAtIndex:[number intValue]]; + if (first) { + firstView = [gc view]; + first = NO; + continue; + } + c = mkConstraint([gc view], NSLayoutAttributeLeading, + NSLayoutRelationEqual, + firstView, NSLayoutAttributeLeading, + 1, 0, + @"uiGrid column left edge constraint"); + [self addConstraint:c]; + [self->edges addObject:c]; + } + } + for (y = 0; y < ycount; y++) { + [set removeAllObjects]; + for (x = 0; x < xcount; x++) + [set addObject:[NSNumber numberWithInt:gg[y][x]]]; + first = YES; + for (number in set) { + if ([number intValue] == -1) + continue; + gc = (gridChild *) [self->children objectAtIndex:[number intValue]]; + if (first) { + firstView = [gc view]; + first = NO; + continue; + } + c = mkConstraint([gc view], NSLayoutAttributeTop, + NSLayoutRelationEqual, + firstView, NSLayoutAttributeTop, + 1, 0, + @"uiGrid row top edge constraint"); + [self addConstraint:c]; + [self->edges addObject:c]; + } + } + +// TODO +return; // now go through every row and column and extract SOME view from that row and column for the inner constraints // if it turns out that a row or column is totally empty, duplicate the one to the left (this has the effect of collapsing empty rows) @@ -310,6 +361,7 @@ struct uiGrid { // and finally clean up uiFree(colviews); uiFree(rowviews); + [set release]; for (y = 0; y < ycount; y++) uiFree(gg[y]); uiFree(gg);