I’m just relating what I’m observing in the video. Each icon is getting stretched vertically not by a uniform factor, but so that the drawn elements exactly fit the given bounds. Honestly, it looks like NSImage is ignoring the pdf media box and setting its size based on the drawn content.
toggle quoted messageShow quoted text
Humor me here for a minute: What happens if one of the icons is a square? It’s a simple test, anyway.
Sent from my iPhone
On Nov 5, 2019, at 11:27 PM, Graham Cox <email@example.com> wrote:
The images are square - the rect returned by -imageRectForItemAtIndex is used to render them in the view as well as supplying the frame to the NSDraggingItem. That’s why it seems odd to me that the drag changes it.
The original image is actually a PDF Representation with a size of 93, 93. The image frame for drawing (and dragging) is 76, 76. This size depends on the ‘icon size’ the user chooses for that interface - small, medium or large. 76 is the medium size. While the images themselves may not always look square, whatever is rendered has a media box that is square, and the icon is rendered centred in that square, scaled to the longer side. What that means is that no matter what overall shape the image is, the icon that results is square - it just contains some extra transparent background if needed.
In any case, the same rect is always used for rendering the image in the view and for the dragging frame. So even if it wasn’t square, they should agree.
On 6 Nov 2019, at 4:13 pm, Jon Gotow <firstname.lastname@example.org> wrote:
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.
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 <email@example.com> 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.