Updates darwin to work with upstream changes
This commit is contained in:
parent
b817a16c05
commit
831fe1e73b
|
@ -23,7 +23,6 @@
|
||||||
uiForm *f;
|
uiForm *f;
|
||||||
NSMutableArray *children;
|
NSMutableArray *children;
|
||||||
int padded;
|
int padded;
|
||||||
int nStretchy;
|
|
||||||
|
|
||||||
NSLayoutConstraint *first;
|
NSLayoutConstraint *first;
|
||||||
NSMutableArray *inBetweens;
|
NSMutableArray *inBetweens;
|
||||||
|
@ -45,6 +44,7 @@
|
||||||
- (void)setPadded:(int)p;
|
- (void)setPadded:(int)p;
|
||||||
- (BOOL)hugsTrailing;
|
- (BOOL)hugsTrailing;
|
||||||
- (BOOL)hugsBottom;
|
- (BOOL)hugsBottom;
|
||||||
|
- (int)nStretchy;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
struct uiForm {
|
struct uiForm {
|
||||||
|
@ -123,7 +123,6 @@ struct uiForm {
|
||||||
self->f = ff;
|
self->f = ff;
|
||||||
self->padded = 0;
|
self->padded = 0;
|
||||||
self->children = [NSMutableArray new];
|
self->children = [NSMutableArray new];
|
||||||
self->nStretchy = 0;
|
|
||||||
|
|
||||||
self->inBetweens = [NSMutableArray new];
|
self->inBetweens = [NSMutableArray new];
|
||||||
self->widths = [NSMutableArray new];
|
self->widths = [NSMutableArray new];
|
||||||
|
@ -221,6 +220,9 @@ struct uiForm {
|
||||||
// first arrange the children vertically and make them the same width
|
// first arrange the children vertically and make them the same width
|
||||||
prev = nil;
|
prev = nil;
|
||||||
for (fc in self->children) {
|
for (fc in self->children) {
|
||||||
|
[fc setHidden:!uiControlVisible(fc.c)];
|
||||||
|
if (!uiControlVisible(fc.c))
|
||||||
|
continue;
|
||||||
if (prev == nil) { // first view
|
if (prev == nil) { // first view
|
||||||
self->first = mkConstraint(self, NSLayoutAttributeTop,
|
self->first = mkConstraint(self, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
|
@ -259,6 +261,8 @@ struct uiForm {
|
||||||
prev = [fc view];
|
prev = [fc view];
|
||||||
prevlabel = fc;
|
prevlabel = fc;
|
||||||
}
|
}
|
||||||
|
if (prev == nil) // all hidden; act as if nothing there
|
||||||
|
return;
|
||||||
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
|
@ -269,6 +273,8 @@ struct uiForm {
|
||||||
|
|
||||||
// now arrange the controls horizontally
|
// now arrange the controls horizontally
|
||||||
for (fc in self->children) {
|
for (fc in self->children) {
|
||||||
|
if (!uiControlVisible(fc.c))
|
||||||
|
continue;
|
||||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
c = mkConstraint(self, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
fc, NSLayoutAttributeLeading,
|
fc, NSLayoutAttributeLeading,
|
||||||
|
@ -313,6 +319,8 @@ struct uiForm {
|
||||||
// and make all stretchy controls have the same height
|
// and make all stretchy controls have the same height
|
||||||
prev = nil;
|
prev = nil;
|
||||||
for (fc in self->children) {
|
for (fc in self->children) {
|
||||||
|
if (!uiControlVisible(fc.c))
|
||||||
|
continue;
|
||||||
if (!fc.stretchy)
|
if (!fc.stretchy)
|
||||||
continue;
|
continue;
|
||||||
if (prev == nil) {
|
if (prev == nil) {
|
||||||
|
@ -375,15 +383,13 @@ struct uiForm {
|
||||||
@"uiForm baseline constraint");
|
@"uiForm baseline constraint");
|
||||||
[self addConstraint:fc.baseline];
|
[self addConstraint:fc.baseline];
|
||||||
|
|
||||||
|
oldnStretchy = [self nStretchy];
|
||||||
[self->children addObject:fc];
|
[self->children addObject:fc];
|
||||||
|
|
||||||
[self establishOurConstraints];
|
[self establishOurConstraints];
|
||||||
if (fc.stretchy) {
|
if (fc.stretchy)
|
||||||
oldnStretchy = self->nStretchy;
|
|
||||||
self->nStretchy++;
|
|
||||||
if (oldnStretchy == 0)
|
if (oldnStretchy == 0)
|
||||||
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f));
|
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f));
|
||||||
}
|
|
||||||
|
|
||||||
[fc release]; // we don't need the initial reference now
|
[fc release]; // we don't need the initial reference now
|
||||||
}
|
}
|
||||||
|
@ -408,8 +414,7 @@ struct uiForm {
|
||||||
|
|
||||||
[self establishOurConstraints];
|
[self establishOurConstraints];
|
||||||
if (stretchy) {
|
if (stretchy) {
|
||||||
self->nStretchy--;
|
if ([self nStretchy] == 0)
|
||||||
if (self->nStretchy == 0)
|
|
||||||
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f));
|
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +445,22 @@ struct uiForm {
|
||||||
- (BOOL)hugsBottom
|
- (BOOL)hugsBottom
|
||||||
{
|
{
|
||||||
// only hug if we have stretchy
|
// only hug if we have stretchy
|
||||||
return self->nStretchy != 0;
|
return [self nStretchy] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)nStretchy
|
||||||
|
{
|
||||||
|
formChild *fc;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
for (fc in self->children) {
|
||||||
|
if (!uiControlVisible(fc.c))
|
||||||
|
continue;
|
||||||
|
if (fc.stretchy)
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -500,6 +520,13 @@ static void uiFormChildEdgeHuggingChanged(uiDarwinControl *c)
|
||||||
uiDarwinControlDefaultHuggingPriority(uiForm, view)
|
uiDarwinControlDefaultHuggingPriority(uiForm, view)
|
||||||
uiDarwinControlDefaultSetHuggingPriority(uiForm, view)
|
uiDarwinControlDefaultSetHuggingPriority(uiForm, view)
|
||||||
|
|
||||||
|
static void uiFormChildVisibilityChanged(uiDarwinControl *c)
|
||||||
|
{
|
||||||
|
uiForm *f = uiForm(c);
|
||||||
|
|
||||||
|
[f->view establishOurConstraints];
|
||||||
|
}
|
||||||
|
|
||||||
void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||||
{
|
{
|
||||||
// LONGTERM on other platforms
|
// LONGTERM on other platforms
|
||||||
|
|
Loading…
Reference in New Issue