Allowed uiGroups and uiTabs to have no and NULL controls with defined behavior on OS X. Actually added the test code this time.
This commit is contained in:
parent
0e785d886b
commit
fd9f6cea6a
44
darwin/tab.m
44
darwin/tab.m
|
@ -58,6 +58,7 @@ 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],
|
||||||
|
@ -97,9 +98,11 @@ 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];
|
||||||
uiControlSetParent(page.c, NULL);
|
if (page.c != NULL) {
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(page.c), nil);
|
uiControlSetParent(page.c, NULL);
|
||||||
uiControlDestroy(page.c);
|
uiDarwinControlSetSuperview(uiDarwinControl(page.c), nil);
|
||||||
|
uiControlDestroy(page.c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// and finally destroy ourselves
|
// and finally destroy ourselves
|
||||||
[t->pages release];
|
[t->pages release];
|
||||||
|
@ -187,23 +190,26 @@ 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];
|
||||||
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
|
// don't turn off the autoresizing mask on view; if we do, nothing shows up
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
if (child != NULL) {
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
uiControlSetParent(child, 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;
|
||||||
|
|
||||||
// don't hug, just in case we're a stretchy tab
|
if (page.c != NULL) {
|
||||||
page.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationHorizontal);
|
// don't hug, just in case we're a stretchy tab
|
||||||
page.oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationVertical);
|
page.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationHorizontal);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
|
page.oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationVertical);
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
|
||||||
|
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
|
||||||
|
@ -228,15 +234,19 @@ void uiTabDelete(uiTab *t, uintmax_t n)
|
||||||
|
|
||||||
page = (tabPage *) [t->pages objectAtIndex:n];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
|
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
if (page.c != NULL) {
|
||||||
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldVertHuggingPri, NSLayoutConstraintOrientationVertical);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(page.c), page.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
||||||
|
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];
|
||||||
|
|
||||||
uiControlSetParent(child, NULL);
|
if (child != NULL) {
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(child), nil);
|
uiControlSetParent(child, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(child), nil);
|
||||||
|
}
|
||||||
|
|
||||||
i = [t->tabview tabViewItemAtIndex:n];
|
i = [t->tabview tabViewItemAtIndex:n];
|
||||||
[t->tabview removeTabViewItem:i];
|
[t->tabview removeTabViewItem:i];
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
// 14 may 2016
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
// TODO add a test for childless windows
|
||||||
|
|
||||||
|
static uiGroup *newg(const char *n, int s)
|
||||||
|
{
|
||||||
|
uiGroup *g;
|
||||||
|
|
||||||
|
g = uiNewGroup(n);
|
||||||
|
if (s)
|
||||||
|
uiGroupSetChild(g, NULL);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uiTab *newt(int tt)
|
||||||
|
{
|
||||||
|
uiTab *t;
|
||||||
|
|
||||||
|
t = uiNewTab();
|
||||||
|
if (tt)
|
||||||
|
uiTabAppend(t, "Test", NULL);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
uiBox *makePage11(void)
|
||||||
|
{
|
||||||
|
uiBox *page11;
|
||||||
|
uiBox *ns;
|
||||||
|
uiBox *s;
|
||||||
|
|
||||||
|
page11 = newHorizontalBox();
|
||||||
|
|
||||||
|
ns = newVerticalBox();
|
||||||
|
uiBoxAppend(ns, uiControl(newg("", 0)), 0);
|
||||||
|
uiBoxAppend(ns, uiControl(newg("", 1)), 0);
|
||||||
|
uiBoxAppend(ns, uiControl(newg("Group", 0)), 0);
|
||||||
|
uiBoxAppend(ns, uiControl(newg("Group", 1)), 0);
|
||||||
|
uiBoxAppend(ns, uiControl(newt(0)), 0);
|
||||||
|
uiBoxAppend(ns, uiControl(newt(1)), 0);
|
||||||
|
uiBoxAppend(page11, uiControl(ns), 1);
|
||||||
|
|
||||||
|
s = newVerticalBox();
|
||||||
|
uiBoxAppend(s, uiControl(newg("", 0)), 1);
|
||||||
|
uiBoxAppend(s, uiControl(newg("", 1)), 1);
|
||||||
|
uiBoxAppend(s, uiControl(newg("Group", 0)), 1);
|
||||||
|
uiBoxAppend(s, uiControl(newg("Group", 1)), 1);
|
||||||
|
uiBoxAppend(s, uiControl(newt(0)), 1);
|
||||||
|
uiBoxAppend(s, uiControl(newt(1)), 1);
|
||||||
|
uiBoxAppend(page11, uiControl(s), 1);
|
||||||
|
|
||||||
|
return page11;
|
||||||
|
}
|
Loading…
Reference in New Issue