Fixed the last remaining edge cases. We're done! Auto Layout works~ ♫
This commit is contained in:
parent
8f55b7e331
commit
8d5442b83f
|
@ -1,10 +1,6 @@
|
||||||
// 15 august 2015
|
// 15 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODOs:
|
|
||||||
// - tab on page 2 doesn't grow (groupbox does instead)
|
|
||||||
// - page 3 doesn't work right; probably due to our shouldExpand logic being applied incorrectly
|
|
||||||
|
|
||||||
// TODOs to confirm
|
// TODOs to confirm
|
||||||
// - 10.8: if we switch to page 4, then switch back to page 1, check Spaced, and go back to page 4, some controls (progress bar, popup button) are clipped on the sides
|
// - 10.8: if we switch to page 4, then switch back to page 1, check Spaced, and go back to page 4, some controls (progress bar, popup button) are clipped on the sides
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ struct uiGroup {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
NSBox *box;
|
NSBox *box;
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
|
NSLayoutPriority oldHorzHuggingPri;
|
||||||
|
NSLayoutPriority oldVertHuggingPri;
|
||||||
int margined;
|
int margined;
|
||||||
struct singleChildConstraints constraints;
|
struct singleChildConstraints constraints;
|
||||||
NSLayoutPriority horzHuggingPri;
|
NSLayoutPriority horzHuggingPri;
|
||||||
|
@ -135,9 +137,10 @@ void uiGroupSetChild(uiGroup *g, uiControl *child)
|
||||||
|
|
||||||
if (g->child != NULL) {
|
if (g->child != NULL) {
|
||||||
removeConstraints(g);
|
removeConstraints(g);
|
||||||
childView = (NSView *) uiControlHandle(g->child);
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(g->child), g->oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
||||||
[childView removeFromSuperview];
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(g->child), g->oldVertHuggingPri, NSLayoutConstraintOrientationVertical);
|
||||||
uiControlSetParent(g->child, NULL);
|
uiControlSetParent(g->child, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(g->child), nil);
|
||||||
}
|
}
|
||||||
g->child = child;
|
g->child = child;
|
||||||
if (g->child != NULL) {
|
if (g->child != NULL) {
|
||||||
|
@ -145,6 +148,11 @@ void uiGroupSetChild(uiGroup *g, uiControl *child)
|
||||||
uiControlSetParent(g->child, uiControl(g));
|
uiControlSetParent(g->child, uiControl(g));
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(g->child), [g->box contentView]);
|
uiDarwinControlSetSuperview(uiDarwinControl(g->child), [g->box contentView]);
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(g->child), uiControlEnabledToUser(uiControl(g)));
|
uiDarwinControlSyncEnableState(uiDarwinControl(g->child), uiControlEnabledToUser(uiControl(g)));
|
||||||
|
// don't hug, just in case we're a stretchy group
|
||||||
|
g->oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(g->child), NSLayoutConstraintOrientationHorizontal);
|
||||||
|
g->oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(g->child), NSLayoutConstraintOrientationVertical);
|
||||||
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(g->child), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
|
||||||
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(g->child), NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
||||||
}
|
}
|
||||||
groupRelayout(g);
|
groupRelayout(g);
|
||||||
}
|
}
|
||||||
|
|
16
darwin/tab.m
16
darwin/tab.m
|
@ -1,6 +1,9 @@
|
||||||
// 15 august 2015
|
// 15 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
|
// TODOs
|
||||||
|
// - page 2 tab doesn't lay out properly at first; need to jiggle on page change too :S
|
||||||
|
|
||||||
@interface tabPage : NSObject {
|
@interface tabPage : NSObject {
|
||||||
struct singleChildConstraints constraints;
|
struct singleChildConstraints constraints;
|
||||||
int margined;
|
int margined;
|
||||||
|
@ -8,6 +11,8 @@
|
||||||
NSObject *pageID;
|
NSObject *pageID;
|
||||||
}
|
}
|
||||||
@property uiControl *c;
|
@property uiControl *c;
|
||||||
|
@property NSLayoutPriority oldHorzHuggingPri;
|
||||||
|
@property NSLayoutPriority oldVertHuggingPri;
|
||||||
- (id)initWithView:(NSView *)v pageID:(NSObject *)o;
|
- (id)initWithView:(NSView *)v pageID:(NSObject *)o;
|
||||||
- (NSView *)childView;
|
- (NSView *)childView;
|
||||||
- (void)establishChildConstraints;
|
- (void)establishChildConstraints;
|
||||||
|
@ -193,6 +198,13 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
||||||
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
|
||||||
|
page.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), NSLayoutConstraintOrientationHorizontal);
|
||||||
|
page.oldVertHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(page.c), 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
|
||||||
|
|
||||||
|
@ -215,6 +227,10 @@ void uiTabDelete(uiTab *t, uintmax_t n)
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
|
|
||||||
page = (tabPage *) [t->pages objectAtIndex:n];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
|
|
||||||
|
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];
|
||||||
|
|
Loading…
Reference in New Issue