Judging from the video, your images are not square. It looks like they're only as large as they need to be to contain the drawn item, and are getting stretched to fit your square NSDraggingItem icon.
toggle quoted messageShow quoted text
Any chance you changed the image rendering code inside of [dv imageRectForItemAtIndex:dragItemIndex] as well?
On Nov 5, 2019, at 9:42 PM, Graham Cox <graham@...> wrote:
I’m modernising some old code that does drag and drop the old, simple and perfectly functional (but deprecated) way.
The new way seems twice as complicated to me, but hey-ho.
Anyway, I’m creating NSDraggingItems for each item to be dragged, and I’m setting the image and frame to sane values. When I start to drag the items however, the images are slightly resized - they expand widthways a small amount, but vertically a somewhat larger amount, making each item appear to stretch vertically. It looks like crap.
The images are actually square - and I set the image size to match the frame size, which has the same width and height.
for( DKOLibraryItem* libItem in itemsToDrag )
NSDraggingItem* dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:libItem];
NSRect libItemRect = [dv imageRectForItemAtIndex:dragItemIndex]; // this rect is square, width = height
NSImage* icon = [libItem.previewImage copy];
icon.size = libItemRect.size;
[dragItem setDraggingFrame:libItemRect contents:icon];
//…. other stuff
Has anyone some clue what’s going on here?
Here’s a short video showing what I’m seeing. http://s3.amazonaws.com/Mapdiva/Video/Screen%20Recording%202019-11-06%20at%203.40.09%20pm.mov