AffinedTransformed scaled Component & drag&drop

It’s a AffinedTransformed scaled plugin gui (smaller than the original size),
When startDragging, the dragged component (image snapshot) size is the original size without the scaling.
I’ve tried set setCurrentDragImage(ScaledSnapshotImage), but the dragged component size doesn’t change its size, then I get a bigger dragged component with the scaled image aligned to the left, so the behavior when clicking a draggable component becomes weird.

Any Suggestions?

The setCurrentDragImage() method is used for dynamically updating the drag image whilst a drag is in progress. If you only want to display a static, scaled snapshot of your plugin GUI then you can create a snapshot Image of your Component and scale it yourself before passing it to the startDragging() method. For example, if your GUI is scaled by a factor of 0.5 then in your mouseDown() callback you can do something like this:

Image componentSnapshot = createComponentSnapshot (getLocalBounds());

if (MainContentComponent* c = dynamic_cast<MainContentComponent*> (getParentComponent()))
            c->startDragging ("", this, componentSnapshot.rescaled (componentSnapshot.getWidth() / 2,
                                                                    componentSnapshot.getHeight() / 2));


1 Like

Hi Ed, I had to set imageOffset parameter to get it work fine
dragC->startDragging (dragDescriptor, this, dragImage, true, &imageOffset);