Some more uiBox work. We've ALMOST got it; just a few more tweaks to get groupboxes and tabs right and to fix page 3...
This commit is contained in:
parent
b564d578ba
commit
60c988100a
24
darwin/box.m
24
darwin/box.m
|
@ -41,6 +41,7 @@
|
||||||
- (void)removeOurConstraints;
|
- (void)removeOurConstraints;
|
||||||
- (void)syncEnableStates:(int)enabled;
|
- (void)syncEnableStates:(int)enabled;
|
||||||
- (CGFloat)paddingAmount;
|
- (CGFloat)paddingAmount;
|
||||||
|
- (void)establishOurConstraints;
|
||||||
- (void)append:(uiControl *)c stretchy:(int)stretchy;
|
- (void)append:(uiControl *)c stretchy:(int)stretchy;
|
||||||
- (void)delete:(uintmax_t)n;
|
- (void)delete:(uintmax_t)n;
|
||||||
- (int)isPadded;
|
- (int)isPadded;
|
||||||
|
@ -154,14 +155,16 @@ struct uiBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO something about spinbox hugging
|
// TODO something about spinbox hugging
|
||||||
- (void)updateConstraints
|
- (void)establishOurConstraints
|
||||||
{
|
{
|
||||||
boxChild *bc;
|
boxChild *bc;
|
||||||
CGFloat padding;
|
CGFloat padding;
|
||||||
NSView *prev;
|
NSView *prev;
|
||||||
NSLayoutConstraint *c;
|
NSLayoutConstraint *c;
|
||||||
|
NSLayoutRelation relation;
|
||||||
|
BOOL (*hugsSecondary)(uiDarwinControl *);
|
||||||
|
|
||||||
[super updateConstraints];
|
[self removeOurConstraints];
|
||||||
if ([self->children count] == 0)
|
if ([self->children count] == 0)
|
||||||
return;
|
return;
|
||||||
padding = [self paddingAmount];
|
padding = [self paddingAmount];
|
||||||
|
@ -199,6 +202,9 @@ struct uiBox {
|
||||||
[self->last retain];
|
[self->last retain];
|
||||||
|
|
||||||
// then arrange in the secondary direction
|
// then arrange in the secondary direction
|
||||||
|
hugsSecondary = uiDarwinControlHugsTrailingEdge;
|
||||||
|
if (!self->vertical)
|
||||||
|
hugsSecondary = uiDarwinControlHugsBottom;
|
||||||
for (bc in self->children) {
|
for (bc in self->children) {
|
||||||
c = mkConstraint(self, self->secondaryStart,
|
c = mkConstraint(self, self->secondaryStart,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
|
@ -207,8 +213,11 @@ struct uiBox {
|
||||||
@"uiBox secondary start constraint");
|
@"uiBox secondary start constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->otherConstraints addObject:c];
|
[self->otherConstraints addObject:c];
|
||||||
|
relation = NSLayoutRelationLessThanOrEqual;
|
||||||
|
if ((*hugsSecondary)(uiDarwinControl(bc.c)))
|
||||||
|
relation = NSLayoutRelationEqual;
|
||||||
c = mkConstraint([bc view], self->secondaryEnd,
|
c = mkConstraint([bc view], self->secondaryEnd,
|
||||||
NSLayoutRelationEqual,
|
relation,
|
||||||
self, self->secondaryEnd,
|
self, self->secondaryEnd,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiBox secondary end constraint");
|
@"uiBox secondary end constraint");
|
||||||
|
@ -268,8 +277,7 @@ struct uiBox {
|
||||||
|
|
||||||
[self->children addObject:bc];
|
[self->children addObject:bc];
|
||||||
|
|
||||||
[self removeOurConstraints];
|
[self establishOurConstraints];
|
||||||
[self setNeedsUpdateConstraints:YES];
|
|
||||||
if (bc.stretchy) {
|
if (bc.stretchy) {
|
||||||
oldnStretchy = self->nStretchy;
|
oldnStretchy = self->nStretchy;
|
||||||
self->nStretchy++;
|
self->nStretchy++;
|
||||||
|
@ -305,8 +313,7 @@ struct uiBox {
|
||||||
|
|
||||||
[self->children removeObjectAtIndex:n];
|
[self->children removeObjectAtIndex:n];
|
||||||
|
|
||||||
[self removeOurConstraints];
|
[self establishOurConstraints];
|
||||||
[self setNeedsUpdateConstraints:YES];
|
|
||||||
if (stretchy) {
|
if (stretchy) {
|
||||||
self->nStretchy--;
|
self->nStretchy--;
|
||||||
if (self->nStretchy == 0) {
|
if (self->nStretchy == 0) {
|
||||||
|
@ -402,8 +409,7 @@ static void uiBoxChildEdgeHuggingChanged(uiDarwinControl *c)
|
||||||
{
|
{
|
||||||
uiBox *b = uiBox(c);
|
uiBox *b = uiBox(c);
|
||||||
|
|
||||||
[b->view removeOurConstraints];
|
[b->view establishOurConstraints];
|
||||||
[b->view setNeedsUpdateConstraints:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
||||||
|
|
Loading…
Reference in New Issue