Saved some experiments.
This commit is contained in:
parent
6496de0fb2
commit
a2e5dbc94c
|
@ -0,0 +1,40 @@
|
||||||
|
// now find all horizontally adjacent views and string them together
|
||||||
|
for (y = 0; y < ycount; y++)
|
||||||
|
for (x = 0; x < xcount - 1; x++) {
|
||||||
|
if (gg[y][x] == -1)
|
||||||
|
continue;
|
||||||
|
if (gg[y][x + 1] == -1)
|
||||||
|
continue;
|
||||||
|
if (gg[y][x] == gg[y][x + 1]) // spanning
|
||||||
|
continue;
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y][x]];
|
||||||
|
firstView = [gc view];
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y][x + 1]];
|
||||||
|
c = mkConstraint(firstView, NSLayoutAttributeTrailing,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
[gc view], NSLayoutAttributeLeading,
|
||||||
|
1, -padding,
|
||||||
|
@"uiGrid inside trailing attribute");
|
||||||
|
[self addConstraint:c];
|
||||||
|
[self->inBetweens addObject:c];
|
||||||
|
}
|
||||||
|
// and same for vertically adjacent
|
||||||
|
for (x = 0; x < xcount; x++)
|
||||||
|
for (y = 0; y < ycount - 1; y++) {
|
||||||
|
if (gg[y][x] == -1)
|
||||||
|
continue;
|
||||||
|
if (gg[y + 1][x] == -1)
|
||||||
|
continue;
|
||||||
|
if (gg[y][x] == gg[y + 1][x]) // spanning
|
||||||
|
continue;
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y][x]];
|
||||||
|
firstView = [gc view];
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y + 1][x]];
|
||||||
|
c = mkConstraint(firstView, NSLayoutAttributeBottom,
|
||||||
|
NSLayoutRelationEqual,
|
||||||
|
[gc view], NSLayoutAttributeTop,
|
||||||
|
1, -padding,
|
||||||
|
@"uiGrid inside bottom attribute");
|
||||||
|
[self addConstraint:c];
|
||||||
|
[self->inBetweens addObject:c];
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
// if a row or column only contains emptys and spanning cells of a opposite-direction spannings, remove it by duplicating the previous row or column
|
||||||
|
BOOL onlyEmptyAndSpanning;
|
||||||
|
for (y = 0; y < ycount; y++) {
|
||||||
|
onlyEmptyAndSpanning = YES;
|
||||||
|
for (x = 0; x < xcount; x++)
|
||||||
|
if (gg[y][x] != -1) {
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y][x]];
|
||||||
|
if (gc.yspan == 1 || gc.top - ymin == y) {
|
||||||
|
onlyEmptyAndSpanning = NO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (onlyEmptyAndSpanning)
|
||||||
|
for (x = 0; x < xcount; x++)
|
||||||
|
gg[y][x] = gg[y - 1][x];
|
||||||
|
}
|
||||||
|
for (x = 0; x < xcount; x++) {
|
||||||
|
onlyEmptyAndSpanning = YES;
|
||||||
|
for (y = 0; y < ycount; y++)
|
||||||
|
if (gg[y][x] != -1) {
|
||||||
|
gc = (gridChild *) [self->children objectAtIndex:gg[y][x]];
|
||||||
|
if (gc.xspan == 1 || gc.left - xmin == x) {
|
||||||
|
onlyEmptyAndSpanning = NO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (onlyEmptyAndSpanning)
|
||||||
|
for (y = 0; y < ycount; y++)
|
||||||
|
gg[y][x] = gg[y][x - 1];
|
||||||
|
}
|
Loading…
Reference in New Issue