Re: Semi-transparent, blurred NSWindow background?
Re: Semi-transparent, blurred NSWindow background?
- Subject: Re: Semi-transparent, blurred NSWindow background?
- From: Rob Keniger <email@hidden>
- Date: Mon, 25 Aug 2008 14:13:02 +1000
On 25/08/2008, at 2:45 AM, Tim Andersson wrote:
Is there any way of creating a NSWindow that has a semi-transparent,
blurred background? With "blurred background" I mean that whatever
you see through the window/background is distorted (blurred).
In 10.5 you can add any core image filter to a window using the
private function 'CGSAddWindowFilter'.
typedef void * CGSConnectionID;
extern OSStatus CGSNewConnection(const void **attr, CGSConnectionID
*id);
- (void)enableBlurForWindow:(NSWindow *)window
{
CGSConnectionID _myConnection;
uint32_t __compositingFilter;
int __compositingType = 1; // Apply filter to contents underneath the
window, then draw window normally on top
/* Make a new connection to CoreGraphics, alternatively you could use
the main connection*/
CGSNewConnection(NULL , &_myConnection);
/* The following creates a new CoreImage filter, then sets its options
with a dictionary of values*/
CGSNewCIFilterByName (_myConnection, (CFStringRef)@"CIGaussianBlur",
&__compositingFilter);
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:
[NSNumber numberWithFloat:3.0] forKey:@"inputRadius"];
CGSSetCIFilterValuesFromDictionary(_myConnection, __compositingFilter,
(CFDictionaryRef)optionsDict);
/* Now just switch on the filter for the window */
CGSAddWindowFilter(_myConnection, [window windowNumber],
__compositingFilter, __compositingType );
}
Insert standard disclaimer about using private Apple APIs here.
--
Rob Keniger
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden