Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > OmniOutliner's collapsing subViews

OmniOutliner's collapsing subViews
Thread Tools
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Oct 31, 2002, 03:22 PM
 
I have noticed that Omni Outliner has the very tasty feature of allowing a subview to collapse on double click of the splitter. Does anyone have a code snippet which does this? Or perhaps know of an open source app which does this? Im guessing I need to overide mouse down or something, but thats about all this n00b knows.
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Nov 2, 2002, 02:17 PM
 
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? =)
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Nov 3, 2002, 12:01 AM
 
Ive discovered a problem with my subclass of NSSpliView. Inside one of my subViews resides a tableView. Everything collapses and uncollapses nicely and this table view resizes correctly but, the scrollBar track is not changing length to match the tableView. I can cause it to redraw itself by resizing the window. How can I fix this?
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Nov 3, 2002, 12:25 PM
 
Whenever you modify (move, resize, add/remove views, etc.) a splitview you have to call -adjustSubviews afterwards.

It's not exactly documented but it's come up a lot. If that's not your problem, well..I tried!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2