Drag image creation for NSView with CALayer in NSCollectionView calls drawRect:?

2011-03-14 Thread Lee Ann Rucker
I have an NSCollectionView with NSCollectionViewItems that have, amongst other 
things, a layer-hosting NSView with CALayers. The collectionView has 
wantsLayers set, and everything there is working nicely - draw, scroll, reorder 
animation.

The trouble comes when I try to drag them. The collectionView builds the drag 
image for me, and all the collectionViewItem's children draw except the one 
with the CALayers. Some digging and logging revealed that the drag image 
creation code is calling drawRect: on my layer-hosting NSView.

I can work around it by implementing a drawRect: that creates a placeholder 
drag image, but the question I have is:

Is there something I'm missing that would cause it to create the right drag 
image for me?

Or is this an Apple bug?
If so, is my workaround good or bad? Is there a case where it will call 
drawRect: for some other legit reason, or should it just never call it and so 
when it's fixed my drawRect: will be 
ignored?___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Re: Drag image creation for NSView with CALayer in NSCollectionView calls drawRect:?

2011-03-14 Thread Kyle Sluder
On Mon, Mar 14, 2011 at 1:15 PM, Lee Ann Rucker lruc...@vmware.com wrote:
 Is there something I'm missing that would cause it to create the right drag 
 image for me?

If you think about it, you pretty much have to use the old raster
drawing path to generate drag images. Even if you don't call
-drawRect: (which NSCollectionView presumably does to insulate you
from its implementation details), the drag image is a static bitmap. I
suppose you could use a CARenderer to produce a static bitmap from
within -drawRect:.

I believe we've determined that the window update machinery does not
call -drawRect: if you have set up your layer-hosting view correctly.
Printing, and apparently NSCollectionView, will call it directly.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Re: Drag image creation for NSView with CALayer in NSCollectionView calls drawRect:?

2011-03-14 Thread Lee Ann Rucker

On Mar 14, 2011, at 1:29 PM, Kyle Sluder wrote:

 On Mon, Mar 14, 2011 at 1:15 PM, Lee Ann Rucker lruc...@vmware.com wrote:
 Is there something I'm missing that would cause it to create the right drag 
 image for me?
 
 If you think about it, you pretty much have to use the old raster
 drawing path to generate drag images. Even if you don't call
 -drawRect: (which NSCollectionView presumably does to insulate you
 from its implementation details), the drag image is a static bitmap. I
 suppose you could use a CARenderer to produce a static bitmap from
 within -drawRect:.

It's a CAOpenGLLayer, so as far as I can tell CARenderer is not going to help. 
But I'm fine with having a placeholder image, I just wanted to be sure I was 
making it in the right place. The first thing I thought looked promising was 
cacheDisplayInRect:toBitmapImageRep: which is called by NSCollectionView's 
drag, but that just calls drawRect on the top level view.

 
 I believe we've determined that the window update machinery does not
 call -drawRect: if you have set up your layer-hosting view correctly.
 Printing, and apparently NSCollectionView, will call it directly.
 
 --Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com