Re: I am Completly Stumped, NSTableView
Re: I am Completly Stumped, NSTableView
- Subject: Re: I am Completly Stumped, NSTableView
- From: Guy English <email@hidden>
- Date: Tue, 22 Mar 2005 01:31:52 -0500
Ben Rhodes <email@hidden> wrote:
> I would really like to see a proof of concept for a transparent
> NSTableView.
Yeah, that sounds kinda interesting. I've just hacked around a bit and
here's what I came up with:
// in your NSTableView subclass:
- (BOOL) isOpaque
{
// need this so that our opaque ancestor will be drawn
return NO;
}
- (void)drawBackgroundInClipRect:(NSRect)clipRect
{
// do nothing - calling super here will fill the rect which we
don't want to do - the opaque ancestor will do its thing for us and
the background will get cleared.
}
// in the controller or where-ever you setup your views:
[[listView enclosingScrollView] setFrameOrigin: NSMakePoint( 0, 0 )];
[[listView enclosingScrollView] setDrawsBackground: NO];
[imageView addSubview: [listView enclosingScrollView]];
That's it. Requires 10.3 for drawBackgroundInClipRect.
Here's the theory behind it:
Youd need to set the table view to not be opaque so that the rendering
code will keep faulting up the view hierarchy until it hits an
ancestor - the firstOpaqueAncestor - that will make sure all the
pixels have been drawn. Now, if you just place your table view over an
NSImageView you've got a problem - because despite it being "below"
the NSTableView it's really just a sibling. So ... we need to make
sure the table view is a subview of the image view we want to use as a
background.
One gotcha is that you don't actually want to move the NSTableView -
it's enclosed in an NSScrollView and you probably don't have an IB
outlet to that. So we get the scroll view from the table view and set
it not to draw it's background ( so it doesn't interfere with the
effect we're going for ). We then set our NSScrollView frame to be the
origin because it's going to be inserted as a subview of the
NSImageView we're using as the background. You don't need to use the
origin - you can inset it if you want. Finally we add the enclosing
scroll view ( and thus the table it contains ) as a subview of the
NSImageView. Now it should just all work. Happy?
Don't be. :) You'll find you're probably still SOL because I don't
think the same trick will work for an NSMovieView. Check the archives
- I seem to remember something from last week complaining that
subviews get clobbered by the movie. The suggestion then, and it's a
good one, was to look into overlay windows. Position your table view
on an overlay window over the location of your NSMovieView and let
Quartz Compositor do it's magic. In this case in
drawBackgroundInClipRect you'll probably want to clear to:
[[NSColor clearColor] set]; NSRectFill( clipRect ); But that's just a
guess I haven't tried it.
Hope that helped a bit and good luck with it.
Take care,
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden