heres what I came up with. the last two methods, - (float)fraction; and - (void)setFraction:(float)newFract; I found in OmniFrameworks.
@implementation lokiSplitViewHorizontal
- (void) mouseDown: (NSEvent *) theEvent {
if ([theEvent clickCount]==2) {
if (!(NSPointInRect([self convertPoint:[theEvent locationInWindow] fromView:nil], [[[self subviews] objectAtIndex:(0 || 1)] frame])) ) {
if ([[[self subviews] objectAtIndex:0] frame].size.height) {
theOldSize = [self fraction];
[self setFraction:1.0];
} else [self setFraction:(theOldSize == nil) ? .6 : theOldSize];
}
} else [super mouseDown:theEvent];
}
- (float)fraction {
NSRect topFrame, bottomFrame;
if ([[self subviews] count] < 2)
return 0.0;
topFrame = [[[self subviews] objectAtIndex:0] frame];
bottomFrame = [[[self subviews] objectAtIndex:1] frame];
return bottomFrame.size.height / (bottomFrame.size.height + topFrame.size.height);
}
- (void)setFraction:(float)newFract {
NSRect topFrame, bottomFrame;
NSView *topSubView;
NSView *bottomSubView;
float totalHeight;
if ([[self subviews] count] < 2)
return;
topSubView = [[self subviews] objectAtIndex:0];
bottomSubView = [[self subviews] objectAtIndex:1];
topFrame = [topSubView frame];
bottomFrame = [bottomSubView frame];
totalHeight = bottomFrame.size.height + topFrame.size.height;
bottomFrame.size.height = newFract * totalHeight;
topFrame.size.height = totalHeight - bottomFrame.size.height;
[topSubView setFrame:topFrame];
[bottomSubView setFrame:bottomFrame];
[self adjustSubviews];
[self setNeedsDisplay: YES];
}
@end
Anyone see any ways to make this mo' better? =)