> Don't think so.. NSRectFill does and always has filled in copy mode. Er, to be clear though, unless you have layer backed views on, every view draws into the same flat buffer of color.
So if you do this: [[NSColor clearColor] set]; NSRectFill(rect); then you are clearing out all the color in that rect and introducing a hole in your window. If that's desirable, cool, go for it, but you also need to call [window setOpaque:NO]. To draw on top of existing color rather than replacing it, you don't want NSRectFill. There you want NSRectFillUsingOperation with the NSCompositeSourceOver operation. That should be considered the 'normal' drawing mode, so it's somewhat unfortunate that the nice convenient looking NSRectFill uses copy mode. -Ken Cocoa Frameworks On Mon, Jul 28, 2008 at 7:54 PM, Ken Ferry <[EMAIL PROTECTED]> wrote: > On Mon, Jul 28, 2008 at 7:46 PM, Graham Cox <[EMAIL PROTECTED]> wrote: >> >> On 29 Jul 2008, at 12:31 pm, Dale Miller wrote: >> >>> I cannot get transparent colors to work. I have tried two cases: >>> 1) I have a view which returns YES to "isTransparent". The log shows the >>> method has been called and responded YES. If I do a NSRectFill after >>> [[NSColor clearColor] set] the view displays as black. > > You probably needs to set your window to non-opaque. See -[NSWindow > setOpaque:]. By default the window server assumes that the content of > your window is opaque (outside of the corners), and therefore it > doesn't need to necessarily draw anything behind it. > >> -isTransparent only applies to certain controls, not to views in general. >> Did you mean -isOpaque instead? > > Yes- isTransparent isn't something that you'd normally override. For > buttons and boxes, setTransparent:YES just makes them return from > drawRect: without drawing anything. > >> I think there is a bug that seemed to get introduced in Leopard. The >> NSRectFill methods now seem to do something different from what they did on >> Tiger, using a different composition mode that stops transparency working >> quite right. I'm not completely sure though - I just noticed some drawing >> problems in my code when I went to Leopard and didn't investigate them - I >> just switched to using a different technique. > > Don't think so.. NSRectFill does and always has filled in copy mode. > >> You can avoid the problem by using NSBezierPath instead (e.g. [NSBezierPath >> fillRect:]) >> >> >>> >>> 2) If i do a "drawInRect" with the attribute >>> NSBackgroundColorAttributeName set to [NSColor clearColor] (or to a color >>> with an alpha of 0. regardless of the red/green/blue components) the >>> background of the text draws as black. What is it that I don't understand? >> >> I believe this is a known bug - transparent text backgrounds aren't >> supported. You can achieve the equivalent just by rendering the text atop >> the background in the usual way (i.e. no background attribute set at all) - >> the only place this bug causes a problem is with editing text using >> NSTextView with a transparent background. So this might be related to your >> (mis)use of isTransparent? > > The black would be the window server assuming that the window is > opaque. In SnowLeopard you'd actually see garbage there. > > Text should be able to draw okay into transparency, though it breaks > subpixel rendering. For best results, turn off font smoothing > (CGContextSetShouldSmoothFonts) when rendering text into a transparent > context. > > -Ken > Cocoa frameworks > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
