Settled the SetParent stuff. NOW we can test.

This commit is contained in:
Pietro Gagliardi 2016-04-25 12:59:45 -04:00
parent 23c2998040
commit 3ca4a28bb3
5 changed files with 9 additions and 5 deletions

View File

@ -228,7 +228,8 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
[b->stretchy addObject:[NSNumber numberWithInt:stretchy]];
uiControlSetParent(c, uiControl(b));
[b->view addSubview:childView];
uiControlSetSuperview(c, b->view);
uiControlSyncEnableState(c, uiControlEnabledToUser(uiControl(b)));
// TODO save the old hugging priorities
// if a control is stretchy, it should not hug in the primary direction

View File

@ -89,7 +89,8 @@ void uiGroupSetChild(uiGroup *g, uiControl *child)
// we have to add controls to the box itself NOT the content view
// otherwise, things get really glitchy
// we also need to call -sizeToFit, but we'll do that in the relayout that's triggered below (see above)
[g->box addSubview:childView];
uiControlSetSuperview(c, g->box);
uiControlSyncEnableState(c, uiControlEnabledToUser(uiControl(g)));
}
groupRelayout(g);
}

View File

@ -98,7 +98,8 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
childView = (NSView *) uiControlHandle(child);
view = [[NSView alloc] initWithFrame:NSZeroRect];
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
[view addSubview:childView];
uiControlSetSuperview(child, view);
uiControlSyncEnableState(child, uiControlEnabledToUser(uiControl(t)));
[t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n];
[t->views insertObject:view atIndex:n];

View File

@ -187,7 +187,8 @@ void uiWindowSetChild(uiWindow *w, uiControl *child)
if (w->child != NULL) {
uiControlSetParent(w->child, uiControl(w));
childView = (NSView *) uiControlHandle(w->child);
[[w->window contentView] addSubview:childView];
uiControlSetSuperview(child, [w->window contentView]);
uiControlSyncEnableState(child, uiControlEnabledToUser(uiControl(w)));
}
windowRelayout(w);
}

View File

@ -1,4 +1,4 @@
every rule in ui_darwin.h
SetParent must be followed by SetSuperview
SetParent must be followed by SetSuperview and SyncEnableState
TODO can child cache it?
adding a child must be followed by a call to SyncEnableState