Browse Source

Added a method DragAndDropContainer::setCurrentDragImage

tags/2021-05-28
jules 10 years ago
parent
commit
062f136dd4
2 changed files with 22 additions and 1 deletions
  1. +19
    -1
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  2. +3
    -0
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h

+ 19
- 1
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -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;


+ 3
- 0
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h View File

@@ -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…
Cancel
Save