Reverted the uiTab changes to allow NULL. Still debating whether to allow NULL or not.
This commit is contained in:
parent
717486b7a2
commit
2f2db46109
44
darwin/tab.m
44
darwin/tab.m
|
@ -58,7 +58,6 @@ struct uiTab {
|
||||||
{
|
{
|
||||||
[self removeChildConstraints];
|
[self removeChildConstraints];
|
||||||
if (self.c == NULL)
|
if (self.c == NULL)
|
||||||
// TODO make sure we need the margins
|
|
||||||
return;
|
return;
|
||||||
singleChildConstraintsEstablish(&(self->constraints),
|
singleChildConstraintsEstablish(&(self->constraints),
|
||||||
self->view, [self childView],
|
self->view, [self childView],
|
||||||
|
@ -98,11 +97,9 @@ static void uiTabDestroy(uiControl *c)
|
||||||
// then destroy all the children
|
// then destroy all the children
|
||||||
for (page in t->pages) {
|
for (page in t->pages) {
|
||||||
[page removeChildConstraints];
|
[page removeChildConstraints];
|
||||||
if (page.c != NULL) {
|
uiControlSetParent(page.c, NULL);
|
||||||
uiControlSetParent(page.c, NULL);
|
uiDarwinControlSetSuperview(uiDarwinControl(page.c), nil);
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(page.c), nil);
|
uiControlDestroy(page.c);
|
||||||
uiControlDestroy(page.c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// and finally destroy ourselves
|
// and finally destroy ourselves
|
||||||
[t->pages release];
|
[t->pages release];
|
||||||
|
@ -190,26 +187,23 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
NSObject *pageID;
|
NSObject *pageID;
|
||||||
|
|
||||||
|
uiControlSetParent(child, uiControl(t));
|
||||||
|
|
||||||
view = [[NSView alloc] initWithFrame:NSZeroRect];
|
view = [[NSView alloc] initWithFrame:NSZeroRect];
|
||||||
// don't turn off the autoresizing mask on view; if we do, nothing shows up
|
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
|
||||||
if (child != NULL) {
|
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
||||||
uiControlSetParent(child, uiControl(t));
|
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// the documentation says these can be nil but the headers say these must not be; let's be safe and make them non-nil anyway
|
// the documentation says these can be nil but the headers say these must not be; let's be safe and make them non-nil anyway
|
||||||
pageID = [NSObject new];
|
pageID = [NSObject new];
|
||||||
page = [[tabPage alloc] initWithView:view pageID:pageID];
|
page = [[tabPage alloc] initWithView:view pageID:pageID];
|
||||||
page.c = child;
|
page.c = child;
|
||||||
|
|
||||||
if (page.c != NULL) {
|
// don't hug, just in case we're a stretchy tab
|
||||||
// don't hug, just in case we're a stretchy tab
|
page.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationHorizontal);
|
||||||
page.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationHorizontal);
|
page.oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationVertical);
|
||||||
page.oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationVertical);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
|
||||||
}
|
|
||||||
|
|
||||||
[t->pages insertObject:page atIndex:n];
|
[t->pages insertObject:page atIndex:n];
|
||||||
[page release]; // no need for initial reference
|
[page release]; // no need for initial reference
|
||||||
|
@ -234,19 +228,15 @@ void uiTabDelete(uiTab *t, uintmax_t n)
|
||||||
|
|
||||||
page = (tabPage *) [t->pages objectAtIndex:n];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
|
|
||||||
if (page.c != NULL) {
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldVertHuggingPri, NSLayoutConstraintOrientationVertical);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldVertHuggingPri, NSLayoutConstraintOrientationVertical);
|
|
||||||
}
|
|
||||||
|
|
||||||
child = page.c;
|
child = page.c;
|
||||||
[page removeChildConstraints];
|
[page removeChildConstraints];
|
||||||
[t->pages removeObjectAtIndex:n];
|
[t->pages removeObjectAtIndex:n];
|
||||||
|
|
||||||
if (child != NULL) {
|
uiControlSetParent(child, NULL);
|
||||||
uiControlSetParent(child, NULL);
|
uiDarwinControlSetSuperview(uiDarwinControl(child), nil);
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(child), nil);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = [t->tabview tabViewItemAtIndex:n];
|
i = [t->tabview tabViewItemAtIndex:n];
|
||||||
[t->tabview removeTabViewItem:i];
|
[t->tabview removeTabViewItem:i];
|
||||||
|
|
Loading…
Reference in New Issue