Restored the test program to its full glory. Also removed the whole NSTabViewDelegate song and dance; that seemed to actually introduce bugs (like the tab view going partially offscreen at the top on first ppage switch to Page 2).
This commit is contained in:
parent
2aeccf4444
commit
0fd453fa91
|
@ -12,60 +12,6 @@ struct uiTab {
|
||||||
NSMutableArray *margined; // []NSNumber
|
NSMutableArray *margined; // []NSNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
// NSTabView handles tab switching interestingly: it /removes the old tab from the view hierarchy outright/
|
|
||||||
// for some reason that I don't know (TODO), this casues problems for our auto layout, even if we do a depth first recomputation of all of our fitting sizes
|
|
||||||
// therefore, we have to only update the current tab page
|
|
||||||
// TODO this doesn't really work...
|
|
||||||
@interface tabDelegateClass : NSObject<NSTabViewDelegate> {
|
|
||||||
NSMapTable *tabs;
|
|
||||||
}
|
|
||||||
- (void)tabView:(NSTabView *)tv didSelectTabViewItem:(NSTabViewItem *)item;
|
|
||||||
- (void)registerTab:(uiTab *)b;
|
|
||||||
- (void)unregisterTab:(uiTab *)b;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation tabDelegateClass
|
|
||||||
|
|
||||||
- (id)init
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
if (self)
|
|
||||||
self->tabs = newMap();
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
if ([self->tabs count] != 0)
|
|
||||||
complain("attempt to destroy shared tab delegate but tabs are still registered to it");
|
|
||||||
[self->tabs release];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tabView:(NSTabView *)tv didSelectTabViewItem:(NSTabViewItem *)item
|
|
||||||
{
|
|
||||||
uiTab *t;
|
|
||||||
|
|
||||||
t = (uiTab *) mapGet(self->tabs, tv);
|
|
||||||
uiDarwinControlTriggerRelayout(uiDarwinControl(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)registerTab:(uiTab *)t
|
|
||||||
{
|
|
||||||
mapSet(self->tabs, t->tabview, t);
|
|
||||||
[t->tabview setDelegate:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)unregisterTab:(uiTab *)t
|
|
||||||
{
|
|
||||||
[t->tabview setDelegate:nil];
|
|
||||||
[self->tabs removeObjectForKey:t->tabview];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
static tabDelegateClass *tabDelegate = nil;
|
|
||||||
|
|
||||||
static void onDestroy(uiTab *);
|
static void onDestroy(uiTab *);
|
||||||
|
|
||||||
uiDarwinDefineControlWithOnDestroy(
|
uiDarwinDefineControlWithOnDestroy(
|
||||||
|
@ -97,20 +43,20 @@ static void onDestroy(uiTab *t)
|
||||||
|
|
||||||
// TODO container update
|
// TODO container update
|
||||||
|
|
||||||
// TODO document our updating all pages here
|
|
||||||
static void tabRelayout(uiDarwinControl *c)
|
static void tabRelayout(uiDarwinControl *c)
|
||||||
{
|
{
|
||||||
uiTab *t = uiTab(c);
|
uiTab *t = uiTab(c);
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
NSValue *v;
|
|
||||||
uiControl *child;
|
|
||||||
uiDarwinControl *cc;
|
|
||||||
NSView *view, *childView;
|
|
||||||
NSNumber *margined;
|
|
||||||
|
|
||||||
if ([t->pages count] == 0)
|
if ([t->pages count] == 0)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < [t->pages count]; i++) {
|
for (i = 0; i < [t->pages count]; i++) {
|
||||||
|
NSValue *v;
|
||||||
|
uiControl *child;
|
||||||
|
uiDarwinControl *cc;
|
||||||
|
NSView *view, *childView;
|
||||||
|
NSNumber *margined;
|
||||||
|
|
||||||
v = (NSValue *) [t->pages objectAtIndex:i];
|
v = (NSValue *) [t->pages objectAtIndex:i];
|
||||||
child = (uiControl *) [v pointerValue];
|
child = (uiControl *) [v pointerValue];
|
||||||
view = (NSView *) [t->views objectAtIndex:i];
|
view = (NSView *) [t->views objectAtIndex:i];
|
||||||
|
@ -211,12 +157,6 @@ uiTab *uiNewTab(void)
|
||||||
t->views = [NSMutableArray new];
|
t->views = [NSMutableArray new];
|
||||||
t->margined = [NSMutableArray new];
|
t->margined = [NSMutableArray new];
|
||||||
|
|
||||||
if (tabDelegate == nil) {
|
|
||||||
tabDelegate = [tabDelegateClass new];
|
|
||||||
[delegates addObject:tabDelegate];
|
|
||||||
}
|
|
||||||
[tabDelegate registerTab:t];
|
|
||||||
|
|
||||||
uiDarwinFinishNewControl(t, uiTab);
|
uiDarwinFinishNewControl(t, uiTab);
|
||||||
uiDarwinControl(t)->Relayout = tabRelayout;
|
uiDarwinControl(t)->Relayout = tabRelayout;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||||
uiOnShouldQuit(onShouldQuit, w);
|
uiOnShouldQuit(onShouldQuit, w);
|
||||||
|
|
||||||
mainBox = newHorizontalBox();
|
mainBox = newHorizontalBox();
|
||||||
// uiWindowSetChild(w, uiControl(mainBox));
|
uiWindowSetChild(w, uiControl(mainBox));
|
||||||
|
|
||||||
mainTab = newTab();
|
mainTab = newTab();
|
||||||
uiBoxAppend(mainBox, uiControl(mainTab), 1);
|
uiBoxAppend(mainBox, uiControl(mainTab), 1);
|
||||||
|
@ -88,8 +88,7 @@ int main(int argc, char *argv[])
|
||||||
makePage1(w);
|
makePage1(w);
|
||||||
uiTabAppend(mainTab, "Page 1", uiControl(page1));
|
uiTabAppend(mainTab, "Page 1", uiControl(page1));
|
||||||
|
|
||||||
// uiTabAppend(mainTab, "Page 2", uiControl(page2));
|
uiTabAppend(mainTab, "Page 2", uiControl(page2));
|
||||||
uiWindowSetChild(w, uiControl(page2));
|
|
||||||
|
|
||||||
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
|
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue