RE: Transparency? SOLVED
RE: Transparency? SOLVED
- Subject: RE: Transparency? SOLVED
- From: "Huyler, Christopher M" <email@hidden>
- Date: Wed, 21 Apr 2004 12:10:16 -0400
- Thread-topic: Transparency? SOLVED
Thanks! I would have run into the isOpaque problem sooner or later and
the it hadn't even crossed my mind...
Good news, I found a solution...
NSRectFill() apparently ignores the alpha value. A work around is to
use a NSBeizerPath like so:
NSBezierPath *bp = [NSBeizerPath bezierPathWithRect:rect];
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.5] set];
[bp fill];
Thanks everyone for your help.
-----Original Message-----
From: Nicko van Someren [
mailto:email@hidden]
Sent: Wednesday, April 21, 2004 12:00 PM
To: Huyler, Christopher M
Cc: J Nozzi; email@hidden
Subject: Re: Transparency?
Have you remembered to override -(BOOL)isOpaque in the NSBox subclass?
The default version returns YES but if you want anything behind your
view to be drawn reliably you'll need to override it to return NO so
that items lower down in the stack of views (such as the window
background) get drawn.
Nicko
On 21 Apr 2004, at 16:27, Huyler, Christopher M wrote:
>
At this point, nothing is in the NSBox. If I remove the NSRectFill
>
call, I end up with an invisible box.
>
>
I just tried the following which also didn't work. The color of the
box
>
is still gray instead of being completely white.
>
>
[[NSColor whiteColor] set];
>
NSRecFill(rect);
>
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] set];
>
NSRectFill(rect);
>
>
Installer uses a Custom View so everything appears to be programmatic.
>
>
-----Original Message-----
>
From: Nicko van Someren [mailto:email@hidden]
>
Sent: Wednesday, April 21, 2004 11:01 AM
>
To: Huyler, Christopher M
>
Cc: J Nozzi; email@hidden
>
Subject: Re: Transparency?
>
>
You are right that alpha of 1.0 is opaque and 0.0 is transparent.
>
>
What's in the content view of the NSBox? Also, what happens if you
>
remove the NSRectFill call? If the content is black then you'd get
the
>
behaviour you are seeing.
>
>
Nicko
>
>
>
On 21 Apr 2004, at 15:32, Huyler, Christopher M wrote:
>
>
> When I lower the alpha number, the rectangle gets darker. An alpha
>
> value of 0.0 (which should be completely transparent right?) comes
out
>
> as a black square.
>
>
>
> -----Original Message-----
>
> From: J Nozzi [mailto:email@hidden]
>
> Sent: Wednesday, April 21, 2004 10:26 AM
>
> To: Huyler, Christopher M
>
> Subject: Re: Transparency?
>
>
>
>
>
> Try a lower alpha. Like 0.5 ... Your screen may not be calibrated
>
> correctly (or close enough) to actually show any transparency with
>
such
>
> a slight transparency setting. The lower the alpha number, the more
>
> transparency.
>
>
>
> - J
>
>
>
>
>
> On Apr 21, 2004, at 10:19 AM, Huyler, Christopher M wrote:
>
>
>
>> The Installer.app program has a cool looking transparency effect
>
where
>
>> it has a slightly transparent white box, then the background image,
>
>> then
>
>> finally the striped background of the window. How do I do this in
>
>> cocoa?
>
>>
>
>> I started by sub-classing an NSBox and rewriting the drawRect
>
> function:
>
>>
>
>> - (void) drawRect:(NSRect) frame
>
>> {
>
>> NSRect rect=[self frame];
>
>> [super drawRect:frame];
>
>> rect.origin=NSMakePoint(1,1);
>
>> rect.size.width-=2;
>
>> rect.size.height-=2;
>
>>
>
>> [[NSColor colorWithCalibratedWhite:1.0 alpha:0.9] set ];
>
>> NSRectFill(rect);
>
>> }
>
>>
>
>> However, the box does not end up being transparent. Instead it is
>
just
>
>> off-white. Can someone point me in the right direction?
>
>>
>
>> --
>
>> Christopher Huyler
>
>> Computer Associates Intl.
>
>> _______________________________________________
>
>> cocoa-dev mailing list | email@hidden
>
>> Help/Unsubscribe/Archives:
>
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>> Do not post admin requests to the list. They will be ignored.
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.