Re: How make image nonvibrant in Yosemite NSVisualEffectView
Re: How make image nonvibrant in Yosemite NSVisualEffectView
- Subject: Re: How make image nonvibrant in Yosemite NSVisualEffectView
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 30 Oct 2014 17:09:02 -0400
> On Oct 30, 2014, at 4:04 PM, David Duncan <email@hidden> wrote:
>
> Then you just move your single vibrant background as necessary to be behind the right icon view. It sounds like you are putting the icon view inside the vibrant background.
According to the AppKit Release Note, at least as I understand it, vibrancy only works if the NSVisualEffectView comes first and views that are to be vibrant are made containment subviews of NSVisualEffectView. That is, every view in front of the NSVisualEffectView is automatically made vibrant. It stands to reason that any view that is placed behind the NSVisualEffectView will not be vibrant.
My window content's background colors -- everything except the nontransparent portions of the icon image -- must be vibrant. To accomplish that, I make the NSVisualEffectView the window's contentView, and I insert a view that I call bubbleView as a subview of NSVisualEffectView. bubbleView contains the background colors. That way, NSVisualEffectView lies behind the background colors, and the background colors become vibrant as promised by the Release Note. So far, so good.
I then put the icon image into bubbleView, precisely because I want the background colors that show through the transparent areas of the icon image to be vibrant. In other words, I don't want a rectangular area of background colors surrounding the icon image to be nonvibrant. Unfortunately, putting the icon image in bubbleview, in front of NSVisualEffectView, makes the nontransparent areas of the icon image vibrant, too, and I don't want that to happen.
Are you suggesting that I should create another view -- call it iconView -- give it a transparent background color, put the icon image in it, make it the contentView of the window, and then make NSVisualEffectView a subview of iconView? Then bubbleView (without the icon image) could remain a subview of NSVisualEffectView so that bubbleView's background colors would be vibrant, as I require, or maybe I could just give NSVisualEffectView itself the background colors and dispense with bubbleView. Then the icon image would not be vibrant because it is not in front of NSVisualEffectView and is therefore outside of its influence.
What I'm not sure of is how I will prevent the background colors in bubbleView or NSVisualEffectView from obscuring the icon image in iconView behind them. After all, they are supposed to be "background" colors lying behind the icon image, not foreground colors in front of it. It seems to me that doing it my way with a rectangular maskImage the size of the window, but containing a hole in the shape of the nontransparent parts of the icon image to block the vibrancy effects, is more in keeping with the way vibrancy is designed, and more likely to work.
But I don't know how to create the hole in the right shape. I am researching CGImageRef routines that supposedly can do it.
--
Bill Cheeseman - email@hidden
_______________________________________________
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