CocoaDev

Edit AllPages

This is irrelevant in 10.5+ and not worth a topic since it’s a simply an option in IB.


Note that in Leopard, this effect can be achieved by setting the NSSplitView to use a thin divider (in Interface Builder) and the additional grabber can be made by implementing the

- (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex

delegate method. -BB

(More information on this in NSSplitViewWithResizeControl)


I am trying to design a splitview like it mail, the one that seperates the mail boxs from the message. I’ve managed to get the one pixel splitter to look right, but i haven’t had any luck when it comes to the grabber. Any suggestions?


Take a look at ResizeCustomViewOnDrag to see how to get the drag and drop to work right. You need this in a custom view that draws the grip however you wish and defines a “grip rect”, a rectangle defining your grip’s area. In the example, “GRIPRECT” could be a macro or even just a function like [self gripRect] that calculates and returns the grip rectangle. The mouseDown method in the example will check to see if the grip rect is being dragged and reacts accordingly.


RBSplitView can do this also. You can get the Mail grab image/look from RSControls [http://blogs.roguesheep.com/2006/10/23/for-your-ui-pleasurerscontrols]


Here is my solution, which I basically stole from Colloquy but slimmed down and added the autosave function listed on another page here. It relies on three classes: a subclass of NSSplitview, a view class for the background, and a view class for the slider portion. You also will need to rob the slider image from Mail.app and dissect a 1-pixel-wide shot of the part that expands. Basically, you configure it like so:

http://idisk.mac.com/omnius/Public/MailSplitView.tiff

MySplitView

#import <Cocoa/Cocoa.h>

@interface MySplitView : NSSplitView { IBOutlet id leftView; IBOutlet id resizeSlider;

IBOutlet id outlineView;  //You have to make this in your IB
IBOutlet id actionButon;  //You have to make this in your IB
IBOutlet id favoritesButton; //You have to make this in your IB

BOOL inResizeMode; }

@end

#import “MySplitView.h”

@implementation MySplitView

#pragma mark - #pragma mark Original Methods

#pragma mark - #pragma mark Overridden from NSSplitView

#pragma mark - #pragma mark NSSplitView delegate methods

#pragma mark - #pragma mark Sidebar resize area

#pragma mark - #pragma mark Position save support

@end

[[MailStyleFunctionBarBackground

#import <Cocoa/Cocoa.h>

@interface MailStyleFunctioBarBackgroundView : NSView { NSImage *backgroundImageForSelectedStyle; }

@end

#import “MailStyleFunctioBarBackgroundView.h”

@implementation MailStyleFunctioBarBackgroundView

#pragma mark - #pragma mark Display

@end

SDSliderImageView

#import <Cocoa/Cocoa.h>

@interface SDSliderImageView : NSImageView { } @end

#import “SDSliderImageView.h”

@implementation SDSliderImageView

@end


I’ve posted a sample project that demonstrates some good techniques for creating this type of layout:

[http://www.mere-mortal-software.com/blog/details.php?d=2006-12-21]

http://www.mere-mortal-software.com/blog/blogimages/2006/12/21/[[FinalWindow.jpg


Any chance to see this palette compatible with the new Interface Builder 3?


What the heck doesn’t somebody make an open source cocoa framework with all of this stuff in it. I’ve still very new to Cocoa and all this stuff is what I want in my app, but I really shouldn’t have to keep copy-n-pasting this stuff all of the place.


If it’s an issue for you, it’s open-source: release your own framework. We don’t get paid to put this code out and we don’t charge you anything for it. You get what you pay for.