I’m trying to re-create the look of apps such as Mail and iTunes where the entire background of the window has a nice gradient of grey. I can get pretty close to this by enabling the ‘has texture’ checkbox in interface builder and using the following code:
on will open theObject
set background color of window "main" to {53199, 53199, 53199}
tell window "main" to update
end will open
… but I really want to get that gradient…
I’m also trying to customise a vertical split view so the handle is embedded in an image at the bottom and the split itself is more of a hairline. For a better representation; in Mail.app, it’s the part between the mailboxes (left hand column) and the mail viewer (right hand side) that I’m trying to mimick.
for a convenient gradient window solution you can try matt gemmel’s open source NSWindow subclass (TunesWindow); http://mattgemmell.com/source/
for a custom split view also use a subclass …
in your NSSplitView subclass you should at least overwrite ‘- (float)dividerThickness’ and return a small value. Probably it’s necessary to overwrite a second method ‘- (void) drawDividerInRect:(NSRect)aRect’ and modify thumbRect/add some custom drawing there.
(void) drawDividerInRect:(NSRect)aRect{
// if you want different behaviour for vert/hor you can test: if ([self isVertical]) {
NSRect thumbRect = aRect;
NSBezierPath *thumb = [NSBezierPath bezierPathWithRect:thumbRect];
[[NSColor blackColor] set];
[thumb fill];
}
you can try matt gemmel’s open source NSWindow subclass (TunesWindow);
That’s brilliant, thanks very much.
in your NSSplitView subclass you should at least overwrite…
I don’t fully understand Cocoa, but I appreciate the answer. I guess I need to get stuck into Cocoa, then apply your thinking.
the example I posted above should be working and give something similar to the iTunes version:
add two files to your project: “SmallSplitView.h” and “SmallSplitView.m”:
in “SmallSplitView.h” paste:
[code]#import <Cocoa/Cocoa.h>
@interface SmallSplitView : NSSplitView{} @end[/code]
in “SmallSplitView.m” paste:
[code]#import “SmallSplitView.h”
@implementation SmallSplitView
(float)dividerThickness{
return 1.0;
}
(void) drawDividerInRect:(NSRect)aRect{
NSRect thumbRect = aRect;
NSBezierPath *thumb = [NSBezierPath bezierPathWithRect:thumbRect];
[[NSColor clearColor] set]; // clearColor or some grey is probably closer to iTunes than black
[thumb fill];
}
@end[/code]
Then save and drop “SmallSplitView.h” on your nib in interface builder, select the split view and set the subclass as custom class (Apple + 5).
Now you can try it …