PDA

View Full Version : Custom Cocoa Windows?




simX
Jan 5, 2006, 06:34 AM
I'd like to figure out a way to create those cool black-looking style floating palettes that Apple often creates, like the transparent black palette in iPhoto 5 that allows you to adjust brightness, contrast, color levels, etc. I believe these are also used in Motion as well.

Basically it's like those bezel "windows" that come up when you increase or decrease the volume via the keyboard -- they come up for about 3 seconds and are transparent, and they fade away after about a second or so. The "windows" for my Xcode project are going to act similarly and look similar (i.e.: black/gray, partially transparent, all four corners are rounded), except that the delay to fade is going to be different -- on the order of 10 seconds.

Ideally these windows would also be easily accessible via Cocoa methods (and not Carbon, because I'm not entirely familiar with Carbon).

Anyone have any ideas? Thanks in advance.



Catfish_Man
Jan 5, 2006, 07:15 AM
Apple's developer page has sample code for a round transparent window. You can probably work from there, although it might be somewhat tricky to duplicate the black Motion/Aperture/iPhoto style windows.

satans_banjo
Jan 5, 2006, 07:44 AM
quicksilver have done it. maybe you could e-mail the developers and see how they did it

caveman_uk
Jan 5, 2006, 08:28 AM
I haven't looked at the source code (I'm on windows at the mo :( ) but this seems applicable from the description.

http://developer.apple.com/samplecode/FunkyOverlayWindow/FunkyOverlayWindow.html

whooleytoo
Jan 5, 2006, 09:16 AM
Apple's developer page has sample code for a round transparent window. You can probably work from there, although it might be somewhat tricky to duplicate the black Motion/Aperture/iPhoto style windows.

Yup, work from this example to create a custom window with no title bar or border, then you can use


// Make the window translucent
NSColor* translucent = [NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:0.6] ;
[myWindow setBackgroundColor:translucent];


To set the window's colour and degree of translucency (tinker with the alpha parameter to suit your needs).

simX
Jan 7, 2006, 03:50 PM
Apple's developer page has sample code for a round transparent window. You can probably work from there, although it might be somewhat tricky to duplicate the black Motion/Aperture/iPhoto style windows.

Can you give me a URL? The FunkyOverlayWindow example doesn't show how to modify the shape of a window -- the "funky overlay window" is still rectangular in shape. The cited example of the round window seems to be exactly the thing I need, but I can't find it.

[UPDATE: Found it! (http://developer.apple.com/samplecode/RoundTransparentWindow/RoundTransparentWindow.html)]