Changed the single-view containers to break their layouts before calling their childrens's Relayout()s. This is part of what I hope will fix uiRadioButtons.

This commit is contained in:
Pietro Gagliardi 2015-08-22 21:29:22 -04:00
parent 9216013e55
commit f6d10e4194
4 changed files with 7 additions and 3 deletions

View File

@ -27,13 +27,12 @@ void setHuggingPri(NSView *view, NSLayoutPriority priority, NSLayoutConstraintOr
[view setContentHuggingPriority:priority forOrientation:orientation]; [view setContentHuggingPriority:priority forOrientation:orientation];
} }
// precondition: constraints must have been removed from superview already
void layoutSingleView(NSView *superview, NSView *subview, int margined) void layoutSingleView(NSView *superview, NSView *subview, int margined)
{ {
NSDictionary *views; NSDictionary *views;
NSString *constraint; NSString *constraint;
[superview removeConstraints:[superview constraints]];
views = NSDictionaryOfVariableBindings(subview); views = NSDictionaryOfVariableBindings(subview);
constraint = @"H:|[subview]|"; constraint = @"H:|[subview]|";

View File

@ -41,6 +41,7 @@ static void groupRelayout(uiDarwinControl *c)
if (g->child == NULL) if (g->child == NULL)
return; return;
[g->box removeConstraints:[g->box constraints]];
cc = uiDarwinControl(g->child); cc = uiDarwinControl(g->child);
childView = (NSView *) uiControlHandle(g->child); childView = (NSView *) uiControlHandle(g->child);
// first relayout the child // first relayout the child

View File

@ -61,6 +61,7 @@ static void tabRelayout(uiDarwinControl *c)
child = (uiControl *) [v pointerValue]; child = (uiControl *) [v pointerValue];
view = (NSView *) [t->views objectAtIndex:i]; view = (NSView *) [t->views objectAtIndex:i];
childView = (NSView *) uiControlHandle(child); childView = (NSView *) uiControlHandle(child);
[view removeConstraints:[view constraints]];
margined = (NSNumber *) [t->margined objectAtIndex:i]; margined = (NSNumber *) [t->margined objectAtIndex:i];
// first lay out the child // first lay out the child
cc = uiDarwinControl(child); cc = uiDarwinControl(child);

View File

@ -125,15 +125,18 @@ static void windowRelayout(uiDarwinControl *c)
uiWindow *w = uiWindow(c); uiWindow *w = uiWindow(c);
uiDarwinControl *cc; uiDarwinControl *cc;
NSView *childView; NSView *childView;
NSView *contentView;
if (w->child == NULL) if (w->child == NULL)
return; return;
cc = uiDarwinControl(w->child); cc = uiDarwinControl(w->child);
childView = (NSView *) uiControlHandle(w->child); childView = (NSView *) uiControlHandle(w->child);
contentView = [w->window contentView];
[contentView removeConstraints:[contentView constraints]];
// first relayout the child // first relayout the child
(*(cc->Relayout))(cc); (*(cc->Relayout))(cc);
// now relayout ourselves // now relayout ourselves
layoutSingleView([w->window contentView], childView, w->margined); layoutSingleView(contentView, childView, w->margined);
} }
char *uiWindowTitle(uiWindow *w) char *uiWindowTitle(uiWindow *w)