mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a method DragAndDropContainer::setCurrentDragImage
This commit is contained in:
parent
d474af1e11
commit
062f136dd4
2 changed files with 22 additions and 1 deletions
|
|
@ -43,7 +43,7 @@ public:
|
|||
imageOffset (offset),
|
||||
hasCheckedForExternalDrag (false)
|
||||
{
|
||||
setSize (im.getWidth(), im.getHeight());
|
||||
updateSize();
|
||||
|
||||
if (mouseDragSource == nullptr)
|
||||
mouseDragSource = sourceComponent;
|
||||
|
|
@ -160,6 +160,13 @@ public:
|
|||
forceMouseCursorUpdate();
|
||||
}
|
||||
|
||||
void updateImage (const Image& newImage)
|
||||
{
|
||||
image = newImage;
|
||||
updateSize();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
forceMouseCursorUpdate();
|
||||
|
|
@ -207,6 +214,11 @@ private:
|
|||
bool hasCheckedForExternalDrag;
|
||||
Time lastTimeOverTarget;
|
||||
|
||||
void updateSize()
|
||||
{
|
||||
setSize (image.getWidth(), image.getHeight());
|
||||
}
|
||||
|
||||
void forceMouseCursorUpdate()
|
||||
{
|
||||
Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate();
|
||||
|
|
@ -472,6 +484,12 @@ var DragAndDropContainer::getCurrentDragDescription() const
|
|||
: var();
|
||||
}
|
||||
|
||||
void DragAndDropContainer::setCurrentDragImage (const Image& newImage)
|
||||
{
|
||||
if (dragImageComponent != nullptr)
|
||||
dragImageComponent->updateImage (newImage);
|
||||
}
|
||||
|
||||
DragAndDropContainer* DragAndDropContainer::findParentDragContainerFor (Component* c)
|
||||
{
|
||||
return c != nullptr ? c->findParentComponentOfClass<DragAndDropContainer>() : nullptr;
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ public:
|
|||
*/
|
||||
var getCurrentDragDescription() const;
|
||||
|
||||
/** If a drag is in progress, this allows the image being shown to be dynamically updated. */
|
||||
void setCurrentDragImage (const Image& newImage);
|
||||
|
||||
/** Utility to find the DragAndDropContainer for a given Component.
|
||||
|
||||
This will search up this component's parent hierarchy looking for the first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue