2015-08-15 22:32:34 -05:00
|
|
|
// 15 august 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2016-06-14 09:54:16 -05:00
|
|
|
// TODO hiding all stretchy controls still hugs trailing edge
|
|
|
|
|
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-12 00:23:55 -05:00
|
|
|
@property NSLayoutPriority oldPrimaryHuggingPri;
|
|
|
|
@property NSLayoutPriority oldSecondaryHuggingPri;
|
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-12 00:23:55 -05:00
|
|
|
|
|
|
|
NSLayoutConstraint *first;
|
|
|
|
NSMutableArray *inBetweens;
|
|
|
|
NSLayoutConstraint *last;
|
|
|
|
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:25:32 -05:00
|
|
|
- (id)initWithVertical:(BOOL)vert b:(uiBox *)bb;
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)onDestroy;
|
|
|
|
- (void)removeOurConstraints;
|
2016-05-11 15:46:42 -05:00
|
|
|
- (void)syncEnableStates:(int)enabled;
|
|
|
|
- (CGFloat)paddingAmount;
|
2016-05-12 10:57:32 -05:00
|
|
|
- (void)establishOurConstraints;
|
2016-05-07 00:11:58 -05:00
|
|
|
- (void)append:(uiControl *)c stretchy:(int)stretchy;
|
2016-06-13 19:46:11 -05:00
|
|
|
- (void)delete:(int)n;
|
2016-05-07 00:11:58 -05:00
|
|
|
- (int)isPadded;
|
2016-05-07 00:25:32 -05:00
|
|
|
- (void)setPadded:(int)p;
|
2016-05-12 00:23:55 -05:00
|
|
|
- (BOOL)hugsTrailing;
|
|
|
|
- (BOOL)hugsBottom;
|
2016-06-14 09:54:16 -05:00
|
|
|
- (int)nStretchy;
|
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
|
|
|
|
|
2016-05-07 00:25:32 -05:00
|
|
|
- (id)initWithVertical:(BOOL)vert b:(uiBox *)bb
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
self = [super initWithFrame:NSZeroRect];
|
|
|
|
if (self != nil) {
|
2016-05-07 00:25:32 -05:00
|
|
|
// the weird names vert and bb are to shut the compiler up about shadowing because implicit this/self is stupid
|
|
|
|
self->b = bb;
|
|
|
|
self->vertical = vert;
|
2016-05-12 01:03:23 -05:00
|
|
|
self->padded = 0;
|
2016-05-07 00:11:58 -05:00
|
|
|
self->children = [NSMutableArray new];
|
|
|
|
|
2016-05-12 01:03:23 -05:00
|
|
|
self->inBetweens = [NSMutableArray new];
|
|
|
|
self->otherConstraints = [NSMutableArray new];
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
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;
|
2015-08-21 00:09:07 -05:00
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
[self removeOurConstraints];
|
2016-05-12 00:23:55 -05:00
|
|
|
[self->inBetweens release];
|
|
|
|
[self->otherConstraints release];
|
2016-05-11 15:46:42 -05:00
|
|
|
|
|
|
|
for (bc in self->children) {
|
2016-05-07 00:11:58 -05:00
|
|
|
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-12 00:23:55 -05:00
|
|
|
if (self->first != nil) {
|
|
|
|
[self removeConstraint:self->first];
|
|
|
|
[self->first release];
|
|
|
|
self->first = nil;
|
|
|
|
}
|
|
|
|
if ([self->inBetweens count] != 0) {
|
|
|
|
[self removeConstraints:self->inBetweens];
|
|
|
|
[self->inBetweens removeAllObjects];
|
|
|
|
}
|
|
|
|
if (self->last != nil) {
|
|
|
|
[self removeConstraint:self->last];
|
|
|
|
[self->last release];
|
|
|
|
self->last = nil;
|
|
|
|
}
|
|
|
|
if ([self->otherConstraints count] != 0) {
|
|
|
|
[self removeConstraints:self->otherConstraints];
|
|
|
|
[self->otherConstraints removeAllObjects];
|
|
|
|
}
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-11 15:46:42 -05:00
|
|
|
- (void)syncEnableStates:(int)enabled
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-11 15:46:42 -05:00
|
|
|
boxChild *bc;
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-11 15:46:42 -05:00
|
|
|
for (bc in self->children)
|
|
|
|
uiDarwinControlSyncEnableState(uiDarwinControl(bc.c), enabled);
|
2016-05-07 00:11:58 -05:00
|
|
|
}
|
2016-05-06 18:21:41 -05:00
|
|
|
|
2016-05-11 15:46:42 -05:00
|
|
|
- (CGFloat)paddingAmount
|
2016-05-06 19:34:02 -05:00
|
|
|
{
|
2016-05-11 15:46:42 -05:00
|
|
|
if (!self->padded)
|
|
|
|
return 0.0;
|
2016-05-26 20:25:32 -05:00
|
|
|
return uiDarwinPaddingAmount(NULL);
|
2016-05-06 19:34:02 -05:00
|
|
|
}
|
|
|
|
|
2016-05-12 10:57:32 -05:00
|
|
|
- (void)establishOurConstraints
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-12 00:23:55 -05:00
|
|
|
boxChild *bc;
|
|
|
|
CGFloat padding;
|
|
|
|
NSView *prev;
|
|
|
|
NSLayoutConstraint *c;
|
2016-05-12 10:57:32 -05:00
|
|
|
BOOL (*hugsSecondary)(uiDarwinControl *);
|
2016-05-12 00:23:55 -05:00
|
|
|
|
2016-05-12 10:57:32 -05:00
|
|
|
[self removeOurConstraints];
|
2016-05-12 00:23:55 -05:00
|
|
|
if ([self->children count] == 0)
|
|
|
|
return;
|
|
|
|
padding = [self paddingAmount];
|
|
|
|
|
|
|
|
// first arrange in the primary direction
|
|
|
|
prev = nil;
|
|
|
|
for (bc in self->children) {
|
2016-06-14 09:54:16 -05:00
|
|
|
if (!uiControlVisible(bc.c))
|
|
|
|
continue;
|
2016-05-12 00:23:55 -05:00
|
|
|
if (prev == nil) { // first view
|
2018-05-05 19:15:32 -05:00
|
|
|
self->first = uiprivMkConstraint(self, self->primaryStart,
|
2016-05-12 00:23:55 -05:00
|
|
|
NSLayoutRelationEqual,
|
|
|
|
[bc view], self->primaryStart,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox first primary constraint");
|
|
|
|
[self addConstraint:self->first];
|
|
|
|
[self->first retain];
|
|
|
|
prev = [bc view];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// not the first; link it
|
2018-05-05 19:15:32 -05:00
|
|
|
c = uiprivMkConstraint(prev, self->primaryEnd,
|
2016-05-12 00:23:55 -05:00
|
|
|
NSLayoutRelationEqual,
|
|
|
|
[bc view], self->primaryStart,
|
2016-05-12 00:49:00 -05:00
|
|
|
1, -padding,
|
2016-05-12 00:23:55 -05:00
|
|
|
@"uiBox in-between primary constraint");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->inBetweens addObject:c];
|
|
|
|
prev = [bc view];
|
|
|
|
}
|
2016-06-14 09:54:16 -05:00
|
|
|
if (prev == nil) // no control visible; act as if no controls
|
|
|
|
return;
|
2018-05-05 19:15:32 -05:00
|
|
|
self->last = uiprivMkConstraint(prev, self->primaryEnd,
|
2016-05-12 00:23:55 -05:00
|
|
|
NSLayoutRelationEqual,
|
|
|
|
self, self->primaryEnd,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox last primary constraint");
|
|
|
|
[self addConstraint:self->last];
|
|
|
|
[self->last retain];
|
|
|
|
|
|
|
|
// then arrange in the secondary direction
|
2016-05-12 10:57:32 -05:00
|
|
|
hugsSecondary = uiDarwinControlHugsTrailingEdge;
|
|
|
|
if (!self->vertical)
|
|
|
|
hugsSecondary = uiDarwinControlHugsBottom;
|
2016-05-12 00:23:55 -05:00
|
|
|
for (bc in self->children) {
|
2016-06-14 09:54:16 -05:00
|
|
|
if (!uiControlVisible(bc.c))
|
|
|
|
continue;
|
2018-05-05 19:15:32 -05:00
|
|
|
c = uiprivMkConstraint(self, self->secondaryStart,
|
2016-05-12 00:23:55 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-12 00:31:47 -05:00
|
|
|
[bc view], self->secondaryStart,
|
2016-05-12 00:23:55 -05:00
|
|
|
1, 0,
|
|
|
|
@"uiBox secondary start constraint");
|
2016-05-12 00:49:00 -05:00
|
|
|
[self addConstraint:c];
|
2016-05-12 00:23:55 -05:00
|
|
|
[self->otherConstraints addObject:c];
|
2018-05-05 19:15:32 -05:00
|
|
|
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
2016-05-13 11:54:05 -05:00
|
|
|
NSLayoutRelationLessThanOrEqual,
|
|
|
|
self, self->secondaryEnd,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox secondary end <= constraint");
|
2016-05-12 10:57:32 -05:00
|
|
|
if ((*hugsSecondary)(uiDarwinControl(bc.c)))
|
2016-05-13 11:54:05 -05:00
|
|
|
[c setPriority:NSLayoutPriorityDefaultLow];
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->otherConstraints addObject:c];
|
2018-05-05 19:15:32 -05:00
|
|
|
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
2016-05-13 11:54:05 -05:00
|
|
|
NSLayoutRelationEqual,
|
2016-05-12 00:31:47 -05:00
|
|
|
self, self->secondaryEnd,
|
2016-05-12 00:23:55 -05:00
|
|
|
1, 0,
|
2016-05-13 11:54:05 -05:00
|
|
|
@"uiBox secondary end == constraint");
|
|
|
|
if (!(*hugsSecondary)(uiDarwinControl(bc.c)))
|
|
|
|
[c setPriority:NSLayoutPriorityDefaultLow];
|
2016-05-12 00:49:00 -05:00
|
|
|
[self addConstraint:c];
|
2016-05-12 00:23:55 -05:00
|
|
|
[self->otherConstraints addObject:c];
|
|
|
|
}
|
|
|
|
|
2016-05-12 00:49:00 -05:00
|
|
|
// and make all stretchy controls the same size
|
2016-06-14 09:54:16 -05:00
|
|
|
if ([self nStretchy] == 0)
|
2016-05-12 00:49:00 -05:00
|
|
|
return;
|
|
|
|
prev = nil; // first stretchy view
|
|
|
|
for (bc in self->children) {
|
2016-06-14 09:54:16 -05:00
|
|
|
if (!uiControlVisible(bc.c))
|
|
|
|
continue;
|
2016-05-12 00:49:00 -05:00
|
|
|
if (!bc.stretchy)
|
|
|
|
continue;
|
|
|
|
if (prev == nil) {
|
|
|
|
prev = [bc view];
|
|
|
|
continue;
|
|
|
|
}
|
2018-05-05 19:15:32 -05:00
|
|
|
c = uiprivMkConstraint(prev, self->primarySize,
|
2016-05-12 00:49:00 -05:00
|
|
|
NSLayoutRelationEqual,
|
|
|
|
[bc view], self->primarySize,
|
|
|
|
1, 0,
|
|
|
|
@"uiBox stretchy size constraint");
|
|
|
|
[self addConstraint:c];
|
|
|
|
[self->otherConstraints addObject:c];
|
|
|
|
}
|
2015-08-17 18:11:35 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (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;
|
2016-05-12 00:23:55 -05:00
|
|
|
NSLayoutPriority priority;
|
2016-06-13 19:46:11 -05:00
|
|
|
int oldnStretchy;
|
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;
|
2016-05-12 11:26:43 -05:00
|
|
|
bc.oldPrimaryHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(bc.c), self->primaryOrientation);
|
|
|
|
bc.oldSecondaryHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(bc.c), self->secondaryOrientation);
|
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
|
2016-05-12 00:23:55 -05:00
|
|
|
if (bc.stretchy)
|
|
|
|
priority = NSLayoutPriorityDefaultLow;
|
2015-08-15 22:32:34 -05:00
|
|
|
else
|
2016-05-28 17:01:25 -05:00
|
|
|
// LONGTERM will default high work?
|
2016-05-12 00:23:55 -05:00
|
|
|
priority = NSLayoutPriorityRequired;
|
2016-05-12 11:26:43 -05:00
|
|
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(bc.c), priority, self->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
|
2016-05-12 11:26:43 -05:00
|
|
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(bc.c), NSLayoutPriorityDefaultLow, self->secondaryOrientation);
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-06-14 09:54:16 -05:00
|
|
|
oldnStretchy = [self nStretchy];
|
2016-05-07 00:25:32 -05:00
|
|
|
[self->children addObject:bc];
|
2016-05-07 00:11:58 -05:00
|
|
|
|
2016-05-12 10:57:32 -05:00
|
|
|
[self establishOurConstraints];
|
2016-06-14 09:54:16 -05:00
|
|
|
if (bc.stretchy)
|
2016-05-12 11:26:43 -05:00
|
|
|
if (oldnStretchy == 0)
|
|
|
|
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->b));
|
2016-05-12 00:23:55 -05:00
|
|
|
|
|
|
|
[bc release]; // we don't need the initial reference now
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-06-13 19:46:11 -05:00
|
|
|
- (void)delete:(int)n
|
2015-08-15 22:32:34 -05:00
|
|
|
{
|
2016-05-07 00:11:58 -05:00
|
|
|
boxChild *bc;
|
2016-05-12 00:23:55 -05:00
|
|
|
int stretchy;
|
2015-08-15 22:32:34 -05:00
|
|
|
|
2016-05-11 15:46:42 -05:00
|
|
|
bc = (boxChild *) [self->children objectAtIndex:n];
|
2016-05-12 00:23:55 -05:00
|
|
|
stretchy = bc.stretchy;
|
2016-05-07 00:11:58 -05:00
|
|
|
|
|
|
|
uiControlSetParent(bc.c, NULL);
|
|
|
|
uiDarwinControlSetSuperview(uiDarwinControl(bc.c), nil);
|
|
|
|
|
2016-05-12 11:26:43 -05:00
|
|
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(bc.c), bc.oldPrimaryHuggingPri, self->primaryOrientation);
|
|
|
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(bc.c), bc.oldSecondaryHuggingPri, self->secondaryOrientation);
|
2016-05-08 10:29:09 -05:00
|
|
|
|
2016-05-07 00:25:32 -05:00
|
|
|
[self->children removeObjectAtIndex:n];
|
2016-05-07 00:11:58 -05:00
|
|
|
|
2016-05-12 10:57:32 -05:00
|
|
|
[self establishOurConstraints];
|
2016-06-14 09:54:16 -05:00
|
|
|
if (stretchy)
|
|
|
|
if ([self nStretchy] == 0)
|
2016-05-12 11:26:43 -05:00
|
|
|
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->b));
|
2015-08-15 22:32:34 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
- (int)isPadded
|
|
|
|
{
|
|
|
|
return self->padded;
|
|
|
|
}
|
|
|
|
|
2016-05-07 00:25:32 -05:00
|
|
|
- (void)setPadded:(int)p
|
2016-05-07 00:11:58 -05:00
|
|
|
{
|
|
|
|
CGFloat padding;
|
|
|
|
NSLayoutConstraint *c;
|
|
|
|
|
2016-05-07 00:25:32 -05:00
|
|
|
self->padded = p;
|
2016-05-11 15:46:42 -05:00
|
|
|
padding = [self paddingAmount];
|
|
|
|
for (c in self->inBetweens)
|
2016-05-12 00:49:00 -05:00
|
|
|
[c setConstant:-padding];
|
2016-05-07 00:11:58 -05:00
|
|
|
}
|
|
|
|
|
2016-05-12 00:23:55 -05:00
|
|
|
- (BOOL)hugsTrailing
|
|
|
|
{
|
|
|
|
if (self->vertical) // always hug if vertical
|
|
|
|
return YES;
|
2016-06-14 09:54:16 -05:00
|
|
|
return [self nStretchy] != 0;
|
2016-05-12 00:23:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)hugsBottom
|
|
|
|
{
|
|
|
|
if (!self->vertical) // always hug if horizontal
|
|
|
|
return YES;
|
2016-06-14 09:54:16 -05:00
|
|
|
return [self nStretchy] != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)nStretchy
|
|
|
|
{
|
|
|
|
boxChild *bc;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (bc in self->children) {
|
|
|
|
if (!uiControlVisible(bc.c))
|
|
|
|
continue;
|
|
|
|
if (bc.stretchy)
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return n;
|
2016-05-12 00:23:55 -05:00
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
@end
|
|
|
|
|
|
|
|
static void uiBoxDestroy(uiControl *c)
|
|
|
|
{
|
2016-05-07 00:25:32 -05:00
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
[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;
|
2016-05-11 15:46:42 -05:00
|
|
|
[b->view syncEnableStates:enabled];
|
2016-05-07 00:11:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uiDarwinControlDefaultSetSuperview(uiBox, view)
|
|
|
|
|
2016-05-12 00:31:47 -05:00
|
|
|
static BOOL uiBoxHugsTrailingEdge(uiDarwinControl *c)
|
2016-05-12 00:23:55 -05:00
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
return [b->view hugsTrailing];
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL uiBoxHugsBottom(uiDarwinControl *c)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
return [b->view hugsBottom];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uiBoxChildEdgeHuggingChanged(uiDarwinControl *c)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
2016-05-12 10:57:32 -05:00
|
|
|
[b->view establishOurConstraints];
|
2016-05-12 00:23:55 -05:00
|
|
|
}
|
|
|
|
|
2016-05-12 11:26:43 -05:00
|
|
|
uiDarwinControlDefaultHuggingPriority(uiBox, view)
|
|
|
|
uiDarwinControlDefaultSetHuggingPriority(uiBox, view)
|
|
|
|
|
2016-06-14 09:37:19 -05:00
|
|
|
static void uiBoxChildVisibilityChanged(uiDarwinControl *c)
|
|
|
|
{
|
|
|
|
uiBox *b = uiBox(c);
|
|
|
|
|
|
|
|
[b->view establishOurConstraints];
|
|
|
|
}
|
|
|
|
|
2016-05-07 00:11:58 -05:00
|
|
|
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
|
|
|
{
|
2016-05-28 17:01:25 -05:00
|
|
|
// LONGTERM on other platforms
|
|
|
|
// or at leat allow this and implicitly turn it into a spacer
|
2016-05-14 20:53:24 -05:00
|
|
|
if (c == NULL)
|
2018-04-15 20:46:08 -05:00
|
|
|
uiprivUserBug("You cannot add NULL to a uiBox.");
|
2016-05-07 00:11:58 -05:00
|
|
|
[b->view append:c stretchy:stretchy];
|
|
|
|
}
|
|
|
|
|
2016-06-13 19:46:11 -05:00
|
|
|
void uiBoxDelete(uiBox *b, int n)
|
2016-05-07 00:11:58 -05:00
|
|
|
{
|
|
|
|
[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);
|
|
|
|
}
|