Tried to do lateral dimension tuning. Didn't work -_- Recursive tBoxes might have to be individual NSViews as well :|
Psy in #macdev said things which confirm that Auto Layout does NOT give me Interface Builder metrics for free. This destroys the whole point...
This commit is contained in:
parent
2fe193563e
commit
f1b372569a
|
@ -52,7 +52,7 @@
|
|||
NSMutableArray *subhorz, *subvert;
|
||||
NSMutableArray *subhorzleft, *subhorzright;
|
||||
NSMutableArray *subverttop, *subvertbottom;
|
||||
uintmax_t *first;
|
||||
__block uintmax_t *first;
|
||||
NSUInteger i;
|
||||
tAutoLayoutParams pp;
|
||||
void (^buildPrimary)(NSMutableArray *in, BOOL first, BOOL last,
|
||||
|
@ -149,6 +149,33 @@
|
|||
[p->vertAttachBottom addObjectsFromArray:subvertbottom];
|
||||
}
|
||||
|
||||
// now constrain the lateral dimension
|
||||
// all children of item i must be next to the first child of item i+1
|
||||
// this is so sub-boxes are on the same "line"
|
||||
// TODO move this declaration above
|
||||
void (^lateral)(NSMutableArray *, BOOL, BOOL, NSMutableArray *, NSMutableArray *) = ^(NSMutableArray *out, BOOL xfirst, BOOL last, NSMutableArray *outstart, NSMutableArray *outend) {
|
||||
NSUInteger i;
|
||||
uintmax_t j;
|
||||
|
||||
for (i = 0; i < [self->children count] - 1; i++)
|
||||
for (j = first[i]; j < first[i + 1]; j++) {
|
||||
NSString *c1, *c2;
|
||||
NSString *constraint;
|
||||
|
||||
c1 = tAutoLayoutKey(j);
|
||||
c2 = tAutoLayoutKey(first[i + 1]);
|
||||
constraint = [NSString stringWithFormat:@"[%@][%@]", c1, c2];
|
||||
[out addObject:constraint];
|
||||
[outstart addObject:[NSNumber numberWithBool:xfirst]];
|
||||
[outend addObject:[NSNumber numberWithBool:last]];
|
||||
}
|
||||
};
|
||||
|
||||
if (self->vertical)
|
||||
lateral(p->vert, p->vertFirst, p->vertLast, p->vertAttachTop, p->vertAttachBottom);
|
||||
else
|
||||
lateral(p->horz, p->horzFirst, p->horzLast, p->horzAttachLeft, p->horzAttachRight);
|
||||
|
||||
[subhorz release];
|
||||
[subhorzleft release];
|
||||
[subhorzright release];
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
// #qo LDFLAGS: -framework Foundation -framework AppKit
|
||||
|
||||
BOOL margined = NO;
|
||||
BOOL spaced = NO;
|
||||
BOOL firstvert = YES;
|
||||
|
||||
@interface appDelegate : NSObject<NSApplicationDelegate>
|
||||
@end
|
||||
|
@ -18,23 +19,23 @@ BOOL margined = NO;
|
|||
tSpinbox *spinbox;
|
||||
|
||||
mainwin = [[tWindow alloc] init];
|
||||
[mainwin tSetMargined:margined];
|
||||
[mainwin tSetMargined:spaced];
|
||||
|
||||
box = [[tBox alloc] tInitVertical:YES];
|
||||
box = [[tBox alloc] tInitVertical:firstvert];
|
||||
|
||||
spinbox = [[tSpinbox alloc] init];
|
||||
[box tAddControl:spinbox stretchy:NO];
|
||||
|
||||
[mainwin tSetControl:box];
|
||||
|
||||
hbox = [[tBox alloc] tInitVertical:NO];
|
||||
hbox = [[tBox alloc] tInitVertical:!firstvert];
|
||||
button = [[tButton alloc] tInitWithText:@"Button"];
|
||||
[hbox tAddControl:button stretchy:YES];
|
||||
button = [[tButton alloc] tInitWithText:@"Button"];
|
||||
[hbox tAddControl:button stretchy:YES];
|
||||
[box tAddControl:hbox stretchy:NO];
|
||||
|
||||
hbox = [[tBox alloc] tInitVertical:NO];
|
||||
hbox = [[tBox alloc] tInitVertical:!firstvert];
|
||||
button = [[tButton alloc] tInitWithText:@"Button"];
|
||||
[hbox tAddControl:button stretchy:YES];
|
||||
button = [[tButton alloc] tInitWithText:@"Button"];
|
||||
|
@ -55,7 +56,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
NSApplication *app;
|
||||
|
||||
margined = argc > 1;
|
||||
spaced = argc > 1;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
|
|
Loading…
Reference in New Issue