• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
transparency weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

transparency weirdness


  • Subject: transparency weirdness
  • From: Michael Link <email@hidden>
  • Date: Wed, 12 Apr 2006 18:16:07 -0500

I have this code for a subclass of NSBox.

@implementation MXMetalBox

- (void)drawRect:(NSRect)rect
{
	if ([self boxType] == NSBoxSeparator) {
		NSRect __rect;
		float* __c = NULL;
		BOOL __increment = NO;

		if (rect.size.width < rect.size.height) {
			__rect = NSInsetRect(rect, 2.0, 0.0);
			__c = &__rect.origin.x;
			__increment = YES;
		}
		else {
			__rect = NSInsetRect(rect, 0.0, 2.0);
			__c = &__rect.origin.y;
		}

		[[NSColor colorWithCalibratedWhite:0.55 alpha:0.85] set];
		NSRectFill(__rect);

		if (__increment) {
			(*__c)++;
			[[NSColor colorWithCalibratedWhite:0.9 alpha:0.90] set];
		}
		else {
			(*__c)--;
			[[NSColor colorWithCalibratedWhite:1.0 alpha:0.90] set];
		}

		NSRectFill(__rect);
	}
	else {
		[super drawRect:rect];
	}
}

- (BOOL)isOpaque
{
	return NO;
}

@end

The problem is that when I draw in the main window view the alpha draws correctly, but when the drawing takes place in a modal sheet the alpha does not draw at all. I have tried replacing NSRectFill with NSBezierPath fill and NSRectFillUsingOperation and neither of those draw with alpha at all in any window... I've also tried setting [[NSGraphicsContext currentContext] setCompositingOperation:NSCompositeSourceOver]; but that doesn't seem to help either. What is so special about NSRectFill() that it works sometimes?

--
Michael

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Prev by Date: Re: Cocoa Books
  • Next by Date: Re: Double precision drawing in Cocoa
  • Previous by thread: Re: Double precision drawing in Cocoa
  • Next by thread: Drag and Drop: Strange behavior with propertyListForType
  • Index(es):
    • Date
    • Thread