2015-08-15 22:32:34 -05:00
|
|
|
// 15 august 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2015-08-17 00:58:23 -05:00
|
|
|
// TODOs:
|
2016-05-01 15:25:05 -05:00
|
|
|
// - tab on page 2 is glitched initially
|
2015-08-23 22:10:17 -05:00
|
|
|
// - 10.8: if we switch to page 4, then switch back to page 1, check Spaced, and go back to page 4, some controls (progress bar, popup button) are clipped on the sides
|
2016-05-01 10:43:34 -05:00
|
|
|
// - calling layoutSubtreeIfNeeded on a superview of the box will cause the following intrinsic content size thing to not work until the window is resized in the primary direction; this is bad if we ever add a Splitter...
|
2016-05-01 15:25:05 -05:00
|
|
|
// - moving around randomly through the tabs does this too
|
2016-05-01 10:25:35 -05:00
|
|
|
|
2016-05-06 22:27:46 -05:00
|
|
|
@interface boxChild : NSObject
|
|
|
|
@property uiControl *c;
|
2016-05-06 19:34:02 -05:00
|
|
|
@property BOOL stretchy;
|
2016-05-06 22:27:46 -05:00
|
|
|
@property NSLayoutPriority oldHorzHuggingPri;
|
|
|
|
@property NSLayoutPriority oldVertHuggingPri;
|
2016-05-07 00:11:58 -05:00
|
|
|
- (NSView *)view;
|
2016-05-06 18:21:41 -05:00
|
|
|
@end
|
|
|
|
|
2016-05-06 22:27:46 -05:00
|
|
|
@interface boxView : NSView {
|
|
|
|
uiBox *b;
|
2016-05-07 00:11:58 -05:00
|
|
|
NSMutableArray *children;
|
2015-08-15 22:32:34 -05:00
|
|
|
BOOL vertical;
|
|
|
|
int padded;
|
2016-05-06 22:27:46 -05:00
|
|
|
|
|
|
|
NSLayoutConstraint *first;
|
2016-05-07 00:11:58 -05:00
|
|
|
NSMutableArray *inBetweens;
|
2016-05-06 22:27:46 -05:00
|
|
|
NSLayoutConstraint *last;
|
2016-05-07 00:11:58 -05:00
|
|
|
NSMutableArray *otherConstraints;
|
2016-05-06 22:27:46 -05:00
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutAttribute primaryStart;
|
|
|
|
NSLayoutAttribute primaryEnd;
|
|
|
|
NSLayoutAttribute secondaryStart;
|
|
|
|
NSLayoutAttribute secondaryEnd;
|
|
|
|
NSLayoutAttribute primarySize;
|
2015-08-15 22:32:34 -05:00
|
|
|
NSLayoutConstraintOrientation primaryOrientation;
|
|
|
|
NSLayoutConstraintOrientation secondaryOrientation;
|
2016-05-06 22:27:46 -05:00
|
|
|
}
|
2016-05-07 00:11:58 -05:00
|
|
|
- (id)initWithVertical:(BOOL)vertical b:(uiBox *)b;
|
|
|
|
- (void)onDestroy;
|
|
|
|
- (void)removeOurConstraints;
|
|
|
|
- (void)forAll:(void (^)(uintmax_t i, boxChild *b))closure;
|
|
|
|
- (boxChild *)child:(uintmax_t)i;
|
|
|
|
- (BOOL)isVertical;
|
|
|
|
- (void)recreateConstraints;
|
|
|
|
- (BOOL)isStretchy;
|
|
|
|
- (void)append:(uiControl *)c stretchy:(int)stretchy;
|
|
|
|
- (void)delete:(uintmax_t)n;
|
|
|
|
- (int)isPadded;
|
|
|
|
- (void)setPadded:(int)padded;
|
2016-05-06 22:27:46 -05:00
|
|
|
@end
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
struct uiBox {
|
|
|
|
uiDarwinControl c;
|
|
|
|
boxView *view;
|
|
|
|
};
|
|
|
|
|
|
|
|
@implementation boxChild
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (NSView *)view
|
|
|
|
{
|
|
|
|
return (NSView *) uiControlHandle(self.c);
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation boxView
|
|
|
|
|
|
|
|
- (id)initWithVertical:(BOOL)vertical b:(uiBox *)b
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
self = [super initWithFrame:NSZeroRect];
|
|
|
|
if (self != nil) {
|
|
|
|
self->b = b;
|
|
|
|
self->vertical = vertical;
|
|
|
|
self->children = [NSMutableArray new];
|
|
|
|
self->inBetweens = [NSMutableArray new];
|
|
|
|
self->otherConstraints = [NSMutableArray new];
|
|
|
|
|
|
|
|
if (self->vertical) {
|
|
|
|
self->primaryStart = NSLayoutAttributeTop;
|
|
|
|
self->primaryEnd = NSLayoutAttributeBottom;
|
|
|
|
self->secondaryStart = NSLayoutAttributeLeading;
|
|
|
|
self->secondaryEnd = NSLayoutAttributeTrailing;
|
|
|
|
self->primarySize = NSLayoutAttributeHeight;
|
|
|
|
self->primaryOrientation = NSLayoutConstraintOrientationVertical;
|
|
|
|
self->secondaryOrientation = NSLayoutConstraintOrientationHorizontal;
|
|
|
|
} else {
|
|
|
|
self->primaryStart = NSLayoutAttributeLeading;
|
|
|
|
self->primaryEnd = NSLayoutAttributeTrailing;
|
|
|
|
self->secondaryStart = NSLayoutAttributeTop;
|
|
|
|
self->secondaryEnd = NSLayoutAttributeBottom;
|
|
|
|
self->primarySize = NSLayoutAttributeWidth;
|
|
|
|
self->primaryOrientation = NSLayoutConstraintOrientationHorizontal;
|
|
|
|
self->secondaryOrientation = NSLayoutConstraintOrientationVertical;
|
|
|
|
}
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
2016-05-07 00:11:58 -05:00
|
|
|
return self;
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)onDestroy
|
2015-08-21 00:09:07 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
|
|
|
uintmax_t i, n;
|
2015-08-21 00:09:07 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
[self removeOurConstraints];
|
|
|
|
[self->first release];
|
|
|
|
[self->inBetweens release];
|
|
|
|
[self->last release];
|
|
|
|
[self->otherConstraints release];
|
|
|
|
|
|
|
|
n = [self->children count];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
bc = [self child:i];
|
|
|
|
uiControlSetParent(bc.c, NULL);
|
|
|
|
uiDarwinControlSetSuperview(uiDarwinControl(bc.c), nil);
|
|
|
|
uiControlDestroy(bc.c);
|
2015-08-21 00:09:07 -05:00
|
|
|
}
|
2016-05-07 00:11:58 -05:00
|
|
|
[self->children release];
|
2015-08-21 00:09:07 -05:00
|
|
|
}
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)removeOurConstraints
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
[self removeConstraint:self->first];
|
|
|
|
[self removeConstraints:self->inBetweens];
|
|
|
|
[self removeConstraint:self->last];
|
|
|
|
[self removeConstraints:self->otherConstraints];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)forAll:(void (^)(uintmax_t i, boxChild *b))closure
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
|
|
|
uintmax_t i, n;
|
2016-04-30 16:45:44 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
n = [self->children count];
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
closure(i, [self child:i]);
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (boxChild *)child:(uintmax_t)i
|
|
|
|
{
|
|
|
|
return (boxChild *) [self->children objectAtIndex:i];
|
|
|
|
}
|
2016-05-06 18:21:41 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (BOOL)isVertical
|
2016-05-06 19:34:02 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
return self->vertical;
|
2016-05-06 19:34:02 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
// TODO something about spinbox hugging
|
|
|
|
// TODO should this be in updateConstraints?
|
2016-05-06 19:34:02 -05:00
|
|
|
- (void)recreateConstraints
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
|
|
|
uintmax_t i, n;
|
|
|
|
BOOL hasStretchy;
|
2016-04-30 16:45:44 -05:00
|
|
|
NSView *firstStretchy = nil;
|
|
|
|
CGFloat padding;
|
|
|
|
NSView *prev, *next;
|
2016-05-07 00:11:58 -05:00
|
|
|
NSLayoutConstraint *c;
|
|
|
|
NSLayoutRelation relation;
|
|
|
|
|
|
|
|
[self removeOurConstraints];
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
n = [self->children count];
|
2016-04-30 17:07:36 -05:00
|
|
|
if (n == 0)
|
2015-08-15 22:32:34 -05:00
|
|
|
return;
|
2016-04-30 16:45:44 -05:00
|
|
|
padding = 0;
|
2016-05-07 00:11:58 -05:00
|
|
|
if (self->padded)
|
2016-04-30 16:45:44 -05:00
|
|
|
padding = 8.0; // TODO named constant
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
// first, attach the first view to the leading
|
2016-05-07 00:11:58 -05:00
|
|
|
prev = [[self child:0] view];
|
|
|
|
self->first = mkConstraint(prev, self->primaryStart,
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-07 00:11:58 -05:00
|
|
|
self, self->primaryStart,
|
2016-04-30 16:45:44 -05:00
|
|
|
1, 0,
|
2016-05-07 00:11:58 -05:00
|
|
|
@"uiBox first primary constraint");
|
|
|
|
[self addConstraint:self->first];
|
|
|
|
[self->first retain];
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
// next, assemble the views in the primary direction
|
|
|
|
// they all go in a straight line
|
|
|
|
// also figure out whether we have stretchy controls, and which is the first
|
2016-05-07 00:11:58 -05:00
|
|
|
if ([self child:0].stretchy) {
|
2016-04-30 16:45:44 -05:00
|
|
|
hasStretchy = YES;
|
|
|
|
firstStretchy = prev;
|
|
|
|
} else
|
|
|
|
hasStretchy = NO;
|
|
|
|
for (i = 1; i < n; i++) {
|
2016-05-07 00:11:58 -05:00
|
|
|
next = [[self child:i] view];
|
|
|
|
if (!hasStretchy && [self child:i].stretchy) {
|
2015-08-15 22:32:34 -05:00
|
|
|
hasStretchy = YES;
|
2016-04-30 16:45:44 -05:00
|
|
|
firstStretchy = next;
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
2016-05-07 00:11:58 -05:00
|
|
|
c = mkConstraint(next, self->primaryStart,
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-07 00:11:58 -05:00
|
|
|
prev, self->primaryEnd,
|
2016-04-30 16:45:44 -05:00
|
|
|
1, padding,
|
2016-05-07 00:11:58 -05:00
|
|
|
@"uiBox later primary constraint");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->inBetweens addObject:c];
|
2016-04-30 16:45:44 -05:00
|
|
|
prev = next;
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
// if there is a stretchy control, add the no-stretchy view
|
2016-05-07 00:11:58 -05:00
|
|
|
relation = NSLayoutRelationEqual;
|
2016-05-06 19:34:02 -05:00
|
|
|
if (!hasStretchy)
|
|
|
|
relation = NSLayoutRelationLessThanOrEqual;
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
// and finally end the primary direction
|
2016-05-07 00:11:58 -05:00
|
|
|
self->last = mkConstraint(prev, self->primaryEnd,
|
|
|
|
relation,
|
|
|
|
self, self->primaryEnd,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox last primary constraint");
|
|
|
|
[self addConstraint:self->last];
|
|
|
|
[self->last retain];
|
2015-08-15 22:32:34 -05:00
|
|
|
|
|
|
|
// next: assemble the views in the secondary direction
|
|
|
|
// each of them will span the secondary direction
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-05-07 00:11:58 -05:00
|
|
|
prev = [[self child:i] view];
|
|
|
|
c = mkConstraint(prev, self->secondaryStart,
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-07 00:11:58 -05:00
|
|
|
self, self->secondaryStart,
|
2016-04-30 16:45:44 -05:00
|
|
|
1, 0,
|
2016-05-07 00:11:58 -05:00
|
|
|
@"uiBox start secondary constraint");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->otherConstraints addObject:c];
|
|
|
|
c = mkConstraint(prev, self->secondaryEnd,
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-07 00:11:58 -05:00
|
|
|
self, self->secondaryEnd,
|
2016-04-30 16:45:44 -05:00
|
|
|
1, 0,
|
2016-05-07 00:11:58 -05:00
|
|
|
@"uiBox start secondary constraint");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->otherConstraints addObject:c];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-04-30 16:45:44 -05:00
|
|
|
// finally, set sizes for stretchy controls
|
|
|
|
if (hasStretchy)
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-05-07 00:11:58 -05:00
|
|
|
if (![self child:i].stretchy)
|
2016-04-30 16:45:44 -05:00
|
|
|
continue;
|
2016-05-07 00:11:58 -05:00
|
|
|
prev = [[self child:i] view];
|
2016-04-30 16:45:44 -05:00
|
|
|
if (prev == firstStretchy)
|
|
|
|
continue;
|
2016-05-07 00:11:58 -05:00
|
|
|
c = mkConstraint(prev, self->primarySize,
|
2016-04-30 16:45:44 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-07 00:11:58 -05:00
|
|
|
firstStretchy, self->primarySize,
|
2016-04-30 16:45:44 -05:00
|
|
|
1, 0,
|
2016-05-07 00:11:58 -05:00
|
|
|
@"uiBox stretchy sizing");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->otherConstraints addObject:c];
|
2016-04-30 16:45:44 -05:00
|
|
|
}
|
2015-08-17 18:11:35 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (BOOL)isStretchy
|
2016-05-06 19:34:02 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
|
|
|
uintmax_t i, n;
|
2016-05-06 19:34:02 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
n = [self->children count];
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
if ([b child:i].stretchy)
|
2016-05-06 19:55:33 -05:00
|
|
|
return YES;
|
2016-05-07 00:11:58 -05:00
|
|
|
return NO;
|
2016-05-06 19:34:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)layout
|
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
uiControl *parent;
|
|
|
|
BOOL shouldExpand;
|
|
|
|
NSView *lastView;
|
|
|
|
|
2016-05-06 19:34:02 -05:00
|
|
|
[super layout];
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
if ([self->children count] == 0)
|
|
|
|
return;
|
|
|
|
if ([self isStretchy])
|
|
|
|
return;
|
|
|
|
parent = uiControlParent(uiControl(self->b));
|
|
|
|
if (parent == NULL) // do nothing if no parent
|
|
|
|
return; // TODO what happens if parents change?
|
|
|
|
if (self->vertical)
|
|
|
|
shouldExpand = uiDarwinControlChildrenShouldAllowSpaceAtBottom(uiDarwinControl(parent));
|
|
|
|
else
|
|
|
|
shouldExpand = uiDarwinControlChildrenShouldAllowSpaceAtTrailingEdge(uiDarwinControl(parent));
|
|
|
|
if (shouldExpand)
|
|
|
|
return;
|
2016-05-06 18:21:41 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
// okay, so we need to redo self->last to not expand
|
|
|
|
[self removeConstraint:self->last];
|
|
|
|
lastView = (NSView *) [self->last firstItem];
|
|
|
|
[self->last release];
|
|
|
|
self->last = mkConstraint(prev, self->primaryEnd,
|
|
|
|
NSLayoutRelationEqual,
|
|
|
|
self, self->primaryEnd,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox last primary constraint");
|
|
|
|
[self addConstraint:self->last];
|
|
|
|
[self->last retain];
|
|
|
|
[self updateConstraintsForSubtreeIfNeeded];
|
|
|
|
[super layout];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)append:(uiControl *)c stretchy:(int)stretchy
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
bc = [boxChild new];
|
|
|
|
bc.c = c;
|
|
|
|
bc.stretchy = stretchy;
|
|
|
|
bc.oldHorzHuggingPri = horzHuggingPri(childView);
|
|
|
|
bc.oldVertHuggingPri = vertHuggingPri(childView);
|
|
|
|
childView = [bc view];
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
uiControlSetParent(bc.c, uiControl(self->b));
|
|
|
|
uiDarwinControlSetSuperview(uiDarwinControl(bc.c), self);
|
|
|
|
uiDarwinControlSyncEnableState(uiDarwinControl(bc.c), uiControlEnabledToUser(uiControl(self->b)));
|
2015-08-17 00:52:06 -05:00
|
|
|
|
2015-08-15 22:32:34 -05:00
|
|
|
// if a control is stretchy, it should not hug in the primary direction
|
|
|
|
// otherwise, it should *forcibly* hug
|
|
|
|
if (stretchy)
|
|
|
|
setHuggingPri(childView, NSLayoutPriorityDefaultLow, b->primaryOrientation);
|
|
|
|
else
|
|
|
|
// TODO will default high work?
|
2015-08-16 22:16:42 -05:00
|
|
|
setHuggingPri(childView, NSLayoutPriorityRequired, b->primaryOrientation);
|
2015-08-15 22:32:34 -05:00
|
|
|
// make sure controls don't hug their secondary direction so they fill the width of the view
|
2015-08-16 22:16:42 -05:00
|
|
|
setHuggingPri(childView, NSLayoutPriorityDefaultLow, b->secondaryOrientation);
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
[b->children addObject:bc];
|
|
|
|
[bc release]; // we don't need the initial reference now
|
|
|
|
|
2016-05-06 19:34:02 -05:00
|
|
|
[b->view recreateConstraints];
|
2016-05-06 18:21:41 -05:00
|
|
|
[b->view setNeedsUpdateConstraints:YES];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)delete:(uintmax_t)n
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
2015-08-17 00:52:06 -05:00
|
|
|
NSView *removedView;
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
bc = [self child:n];
|
|
|
|
removedView = [bc view];
|
|
|
|
|
|
|
|
uiControlSetParent(bc.c, NULL);
|
|
|
|
uiDarwinControlSetSuperview(uiDarwinControl(bc.c), nil);
|
|
|
|
|
|
|
|
setHorzHuggingPri(removedView, bc.oldHorzHuggingPri);
|
|
|
|
setVertHuggingPri(removedView, bc.oldVertHuggingPri);
|
|
|
|
|
2015-08-15 22:32:34 -05:00
|
|
|
[b->children removeObjectAtIndex:n];
|
2016-05-07 00:11:58 -05:00
|
|
|
|
2016-05-06 19:34:02 -05:00
|
|
|
[b->view recreateConstraints];
|
2016-05-06 18:21:41 -05:00
|
|
|
[b->view setNeedsUpdateConstraints:YES];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (int)isPadded
|
|
|
|
{
|
|
|
|
return self->padded;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setPadded:(int)padded
|
|
|
|
{
|
|
|
|
CGFloat padding;
|
|
|
|
uintmax_t i, n;
|
|
|
|
NSLayoutConstraint *c;
|
|
|
|
|
|
|
|
self->padded = padded
|
|
|
|
|
|
|
|
// TODO split into method (using above code)
|
|
|
|
padding = 0;
|
|
|
|
if (self->padded)
|
|
|
|
padding = 8.0;
|
|
|
|
n = [self->inBetweens count];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
c = (NSLayoutConstraint *) [self->inBetweens objectAtIndex:i];
|
|
|
|
[c setConstant:padding];
|
|
|
|
}
|
|
|
|
// TODO call anything?
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
static void uiBoxDestroy(uiControl *c)
|
|
|
|
{
|
|
|
|
[b->view onDestroy];
|
|
|
|
[b->view release];
|
|
|
|
uiFreeControl(uiControl(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
uiDarwinControlDefaultHandle(uiBox, view)
|
|
|
|
uiDarwinControlDefaultParent(uiBox, view)
|
|
|
|
uiDarwinControlDefaultSetParent(uiBox, view)
|
|
|
|
uiDarwinControlDefaultToplevel(uiBox, view)
|
|
|
|
uiDarwinControlDefaultVisible(uiBox, view)
|
|
|
|
uiDarwinControlDefaultShow(uiBox, view)
|
|
|
|
uiDarwinControlDefaultHide(uiBox, view)
|
|
|
|
uiDarwinControlDefaultEnabled(uiBox, view)
|
|
|
|
uiDarwinControlDefaultEnable(uiBox, view)
|
|
|
|
uiDarwinControlDefaultDisable(uiBox, view)
|
|
|
|
|
|
|
|
static void uiBoxSyncEnableState(uiDarwinControl *c, int enabled)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
if (uiDarwinShouldStopSyncEnableState(uiDarwinControl(b), enabled))
|
|
|
|
return;
|
|
|
|
[b->view forAll:^(uintmax_t i, boxChild *bc) {
|
|
|
|
uiDarwinControlSyncEnableState(uiDarwinControl(bc.c), enabled);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
uiDarwinControlDefaultSetSuperview(uiBox, view)
|
|
|
|
|
|
|
|
static BOOL uiBoxChildrenShouldAllowSpaceAtTrailingEdge(uiDarwinControl *c)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
return ![b->view isVertical];
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL uiBoxChildrenShouldAllowSpaceAtBottom(uiDarwinControl *c)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
return [b->view isVertical];
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
|
|
|
{
|
|
|
|
[b->view append:c stretchy:stretchy];
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiBoxDelete(uiBox *b, uintmax_t n)
|
|
|
|
{
|
|
|
|
[b->view delete:n];
|
|
|
|
}
|
|
|
|
|
2015-08-15 22:32:34 -05:00
|
|
|
int uiBoxPadded(uiBox *b)
|
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
return [b->view isPadded];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2015-08-16 22:16:42 -05:00
|
|
|
void uiBoxSetPadded(uiBox *b, int padded)
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
[b->view setPadded:padded];
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2015-08-16 22:08:00 -05:00
|
|
|
static uiBox *finishNewBox(BOOL vertical)
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
|
|
|
uiBox *b;
|
|
|
|
|
2016-04-25 11:35:01 -05:00
|
|
|
uiDarwinNewControl(uiBox, b);
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
b->view = [[boxView alloc] initWithVertical:vertical b:b];
|
2015-08-15 22:32:34 -05:00
|
|
|
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiBox *uiNewHorizontalBox(void)
|
|
|
|
{
|
|
|
|
return finishNewBox(NO);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiBox *uiNewVerticalBox(void)
|
|
|
|
{
|
|
|
|
return finishNewBox(YES);
|
|
|
|
}
|