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: David Duncan <email@hidden>
- Date: Thu, 30 Oct 2014 15:40:43 -0700
> On Oct 30, 2014, at 2:09 PM, Bill Cheeseman <email@hidden> wrote:
>
>
>> 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.
Every view (and its subviews) contained in an NSVisualEffectView that returns YES from allowsVibrancy is made vibrant. If a given view returns NO from allowsVibrant, and none of its superviews returns YES, than that view will not be 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
And that is where you go off the rails. That icon image cannot be a subview of a view that returns YES from allowsVibrancy if you want it to not be vibrant. But it can be a subview of the NSVisualEffectView.
> , 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.
If you position the icon view such that it is rendered in the same position, but not in the same hierarchy as the view hierarchy that does allow vibrancy, you should get what you are looking for. The transparent regions of the icon will show the vibrancy (because the view draws over) without the non-transperant regions turning vibrant.
> 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
--
David Duncan
_______________________________________________
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