Browse Source

Refactored the DragAndDropTarget callback methods, to replace the parameters with a structure. This also affects the TreeViewItem drag-and-drop callback methods.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
f4c4f310e1
22 changed files with 452 additions and 355 deletions
  1. +5
    -5
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp
  2. +2
    -2
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h
  3. +6
    -6
      extras/JuceDemo/Source/demos/DragAndDropDemo.cpp
  4. +136
    -116
      juce_amalgamated.cpp
  5. +81
    -53
      juce_amalgamated.h
  6. +1
    -1
      src/application/juce_ApplicationCommandManager.cpp
  7. +1
    -1
      src/application/juce_ApplicationCommandTarget.cpp
  8. +1
    -1
      src/containers/juce_Variant.cpp
  9. +1
    -1
      src/core/juce_StandardHeader.h
  10. +12
    -12
      src/gui/components/controls/juce_Toolbar.cpp
  11. +4
    -4
      src/gui/components/controls/juce_Toolbar.h
  12. +27
    -25
      src/gui/components/controls/juce_TreeView.cpp
  13. +16
    -11
      src/gui/components/controls/juce_TreeView.h
  14. +2
    -2
      src/gui/components/layout/juce_MultiDocumentPanel.cpp
  15. +1
    -1
      src/gui/components/menus/juce_PopupMenu.cpp
  16. +69
    -66
      src/gui/components/mouse/juce_DragAndDropContainer.cpp
  17. +11
    -7
      src/gui/components/mouse/juce_DragAndDropContainer.h
  18. +52
    -30
      src/gui/components/mouse/juce_DragAndDropTarget.h
  19. +1
    -1
      src/gui/components/properties/juce_PropertyPanel.cpp
  20. +2
    -2
      src/gui/components/windows/juce_DialogWindow.h
  21. +20
    -7
      src/gui/components/windows/juce_TooltipWindow.cpp
  22. +1
    -1
      src/gui/components/windows/juce_TopLevelWindow.cpp

+ 5
- 5
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp View File

@@ -336,21 +336,21 @@ void ProjectTreeViewBase::getAllSelectedNodesInTree (Component* componentInTree,
} }
} }
bool ProjectTreeViewBase::isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent)
bool ProjectTreeViewBase::isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails)
{ {
if (sourceDescription != projectItemDragType)
if (dragSourceDetails.description != projectItemDragType)
return false; return false;
OwnedArray <Project::Item> selectedNodes; OwnedArray <Project::Item> selectedNodes;
getAllSelectedNodesInTree (sourceComponent, selectedNodes);
getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes);
return selectedNodes.size() > 0 && acceptsDragItems (selectedNodes); return selectedNodes.size() > 0 && acceptsDragItems (selectedNodes);
} }
void ProjectTreeViewBase::itemDropped (const String& sourceDescription, Component* sourceComponent, int insertIndex)
void ProjectTreeViewBase::itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex)
{ {
OwnedArray <Project::Item> selectedNodes; OwnedArray <Project::Item> selectedNodes;
getAllSelectedNodesInTree (sourceComponent, selectedNodes);
getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes);
if (selectedNodes.size() > 0) if (selectedNodes.size() > 0)
{ {


+ 2
- 2
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h View File

@@ -92,8 +92,8 @@ public:
// Drag-and-drop stuff.. // Drag-and-drop stuff..
bool isInterestedInFileDrag (const StringArray& files); bool isInterestedInFileDrag (const StringArray& files);
void filesDropped (const StringArray& files, int insertIndex); void filesDropped (const StringArray& files, int insertIndex);
bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent);
void itemDropped (const String& sourceDescription, Component* sourceComponent, int insertIndex);
bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);
void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);
static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes); static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes);


+ 6
- 6
extras/JuceDemo/Source/demos/DragAndDropDemo.cpp View File

@@ -133,7 +133,7 @@ public:
// These methods implement the DragAndDropTarget interface, and allow our component // These methods implement the DragAndDropTarget interface, and allow our component
// to accept drag-and-drop of objects from other Juce components.. // to accept drag-and-drop of objects from other Juce components..
bool isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
bool isInterestedInDragSource (const SourceDetails& /*dragSourceDetails*/)
{ {
// normally you'd check the sourceDescription value to see if it's the // normally you'd check the sourceDescription value to see if it's the
// sort of object that you're interested in before returning true, but for // sort of object that you're interested in before returning true, but for
@@ -141,25 +141,25 @@ public:
return true; return true;
} }
void itemDragEnter (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
void itemDragEnter (const SourceDetails& /*dragSourceDetails*/)
{ {
somethingIsBeingDraggedOver = true; somethingIsBeingDraggedOver = true;
repaint(); repaint();
} }
void itemDragMove (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
void itemDragMove (const SourceDetails& /*dragSourceDetails*/)
{ {
} }
void itemDragExit (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
void itemDragExit (const SourceDetails& /*dragSourceDetails*/)
{ {
somethingIsBeingDraggedOver = false; somethingIsBeingDraggedOver = false;
repaint(); repaint();
} }
void itemDropped (const String& sourceDescription, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
void itemDropped (const SourceDetails& dragSourceDetails)
{ {
message = "last rows dropped: " + sourceDescription;
message = "last rows dropped: " + dragSourceDetails.description;
somethingIsBeingDraggedOver = false; somethingIsBeingDraggedOver = false;
repaint(); repaint();


+ 136
- 116
juce_amalgamated.cpp View File

@@ -4576,7 +4576,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg


const var var::call (const Identifier& method) const const var var::call (const Identifier& method) const
{ {
return invoke (method, 0, 0);
return invoke (method, nullptr, 0);
} }


const var var::call (const Identifier& method, const var& arg1) const const var var::call (const Identifier& method, const var& arg1) const
@@ -18682,7 +18682,7 @@ ApplicationCommandTarget* ApplicationCommandManager::findTargetForComponent (Com


if (target == nullptr && c != nullptr) if (target == nullptr && c != nullptr)
// (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug)
target = c->findParentComponentOfClass ((ApplicationCommandTarget*) 0);
target = c->findParentComponentOfClass ((ApplicationCommandTarget*) nullptr);


return target; return target;
} }
@@ -18811,7 +18811,7 @@ ApplicationCommandTarget* ApplicationCommandTarget::findFirstTargetParentCompone


if (c != nullptr) if (c != nullptr)
// (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug)
return c->findParentComponentOfClass ((ApplicationCommandTarget*) 0);
return c->findParentComponentOfClass ((ApplicationCommandTarget*) nullptr);


return nullptr; return nullptr;
} }
@@ -55836,15 +55836,14 @@ void Toolbar::buttonClicked (Button*)
} }
} }


bool Toolbar::isInterestedInDragSource (const String& sourceDescription,
Component* /*sourceComponent*/)
bool Toolbar::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
{ {
return sourceDescription == toolbarDragDescriptor && isEditingActive;
return dragSourceDetails.description == toolbarDragDescriptor && isEditingActive;
} }


void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, int y)
void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());


if (tc != nullptr) if (tc != nullptr)
{ {
@@ -55852,7 +55851,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
{ {
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette) if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
{ {
ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) 0);
ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) nullptr);


if (palette != nullptr) if (palette != nullptr)
palette->replaceComponent (tc); palette->replaceComponent (tc);
@@ -55872,7 +55871,8 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
const int currentIndex = items.indexOf (tc); const int currentIndex = items.indexOf (tc);
int newIndex = currentIndex; int newIndex = currentIndex;


const int dragObjectLeft = vertical ? (y - tc->dragOffsetY) : (x - tc->dragOffsetX);
const int dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth()); const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());


const Rectangle<int> current (Desktop::getInstance().getAnimator() const Rectangle<int> current (Desktop::getInstance().getAnimator()
@@ -55914,9 +55914,9 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
} }
} }


void Toolbar::itemDragExit (const String&, Component* sourceComponent)
void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());


if (tc != nullptr && isParentOf (tc)) if (tc != nullptr && isParentOf (tc))
{ {
@@ -55926,9 +55926,9 @@ void Toolbar::itemDragExit (const String&, Component* sourceComponent)
} }
} }


void Toolbar::itemDropped (const String&, Component* sourceComponent, int, int)
void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());


if (tc != nullptr) if (tc != nullptr)
tc->setState (Button::buttonNormal); tc->setState (Button::buttonNormal);
@@ -56076,7 +56076,7 @@ private:
{ {
Colour background; Colour background;


DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) 0);
DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) nullptr);


if (dw != nullptr) if (dw != nullptr)
background = dw->getBackgroundColour(); background = dw->getBackgroundColour();
@@ -57333,9 +57333,10 @@ void TreeView::hideDragHighlight() noexcept
} }


TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
const StringArray& files, const String& sourceDescription,
Component* sourceComponent) const noexcept
const StringArray& files, const SourceDetails& dragSourceDetails) const noexcept
{ {
x = dragSourceDetails.localPosition.getX();
y = dragSourceDetails.localPosition.getY();
insertIndex = 0; insertIndex = 0;
TreeViewItem* item = getItemAt (y); TreeViewItem* item = getItemAt (y);


@@ -57350,7 +57351,7 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
if (item->getNumSubItems() == 0 || ! item->isOpen()) if (item->getNumSubItems() == 0 || ! item->isOpen())
{ {
if (files.size() > 0 ? item->isInterestedInFileDrag (files) if (files.size() > 0 ? item->isInterestedInFileDrag (files)
: item->isInterestedInDragSource (sourceDescription, sourceComponent))
: item->isInterestedInDragSource (dragSourceDetails))
{ {
// Check if we're trying to drag into an empty group item.. // Check if we're trying to drag into an empty group item..
if (oldY > itemPos.getY() + itemPos.getHeight() / 4 if (oldY > itemPos.getY() + itemPos.getHeight() / 4
@@ -57386,12 +57387,13 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
return item->parentItem; return item->parentItem;
} }


void TreeView::handleDrag (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::handleDrag (const StringArray& files, const SourceDetails& dragSourceDetails)
{ {
const bool scrolled = viewport->autoScroll (x, y, 20, 10);
const bool scrolled = viewport->autoScroll (dragSourceDetails.localPosition.getX(),
dragSourceDetails.localPosition.getY(), 20, 10);


int insertIndex;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, sourceDescription, sourceComponent);
int insertIndex, x, y;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, dragSourceDetails);


if (item != nullptr) if (item != nullptr)
{ {
@@ -57400,7 +57402,7 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip
|| dragInsertPointHighlight->lastIndex != insertIndex) || dragInsertPointHighlight->lastIndex != insertIndex)
{ {
if (files.size() > 0 ? item->isInterestedInFileDrag (files) if (files.size() > 0 ? item->isInterestedInFileDrag (files)
: item->isInterestedInDragSource (sourceDescription, sourceComponent))
: item->isInterestedInDragSource (dragSourceDetails))
showDragHighlight (item, insertIndex, x, y); showDragHighlight (item, insertIndex, x, y);
else else
hideDragHighlight(); hideDragHighlight();
@@ -57412,12 +57414,12 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip
} }
} }


void TreeView::handleDrop (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::handleDrop (const StringArray& files, const SourceDetails& dragSourceDetails)
{ {
hideDragHighlight(); hideDragHighlight();


int insertIndex;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, sourceDescription, sourceComponent);
int insertIndex, x, y;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, dragSourceDetails);


if (item != nullptr) if (item != nullptr)
{ {
@@ -57428,8 +57430,8 @@ void TreeView::handleDrop (const StringArray& files, const String& sourceDescrip
} }
else else
{ {
if (item->isInterestedInDragSource (sourceDescription, sourceComponent))
item->itemDropped (sourceDescription, sourceComponent, insertIndex);
if (item->isInterestedInDragSource (dragSourceDetails))
item->itemDropped (dragSourceDetails, insertIndex);
} }
} }
} }
@@ -57446,7 +57448,7 @@ void TreeView::fileDragEnter (const StringArray& files, int x, int y)


void TreeView::fileDragMove (const StringArray& files, int x, int y) void TreeView::fileDragMove (const StringArray& files, int x, int y)
{ {
handleDrag (files, String::empty, 0, x, y);
handleDrag (files, SourceDetails (String::empty, 0, Point<int> (x, y)));
} }


void TreeView::fileDragExit (const StringArray&) void TreeView::fileDragExit (const StringArray&)
@@ -57456,32 +57458,32 @@ void TreeView::fileDragExit (const StringArray&)


void TreeView::filesDropped (const StringArray& files, int x, int y) void TreeView::filesDropped (const StringArray& files, int x, int y)
{ {
handleDrop (files, String::empty, 0, x, y);
handleDrop (files, SourceDetails (String::empty, 0, Point<int> (x, y)));
} }


bool TreeView::isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
bool TreeView::isInterestedInDragSource (const SourceDetails& /*dragSourceDetails*/)
{ {
return true; return true;
} }


void TreeView::itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDragEnter (const SourceDetails& dragSourceDetails)
{ {
itemDragMove (sourceDescription, sourceComponent, x, y);
itemDragMove (dragSourceDetails);
} }


void TreeView::itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDragMove (const SourceDetails& dragSourceDetails)
{ {
handleDrag (StringArray(), sourceDescription, sourceComponent, x, y);
handleDrag (StringArray(), dragSourceDetails);
} }


void TreeView::itemDragExit (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
void TreeView::itemDragExit (const SourceDetails& /*dragSourceDetails*/)
{ {
hideDragHighlight(); hideDragHighlight();
} }


void TreeView::itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDropped (const SourceDetails& dragSourceDetails)
{ {
handleDrop (StringArray(), sourceDescription, sourceComponent, x, y);
handleDrop (StringArray(), dragSourceDetails);
} }


enum TreeViewOpenness enum TreeViewOpenness
@@ -57691,12 +57693,12 @@ void TreeViewItem::filesDropped (const StringArray& /*files*/, int /*insertIndex
{ {
} }


bool TreeViewItem::isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
bool TreeViewItem::isInterestedInDragSource (const DragAndDropTarget::SourceDetails& /*dragSourceDetails*/)
{ {
return false; return false;
} }


void TreeViewItem::itemDropped (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*insertIndex*/)
void TreeViewItem::itemDropped (const DragAndDropTarget::SourceDetails& /*dragSourceDetails*/, int /*insertIndex*/)
{ {
} }


@@ -62956,7 +62958,7 @@ void MultiDocumentPanelWindow::updateOrder()
MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept
{ {
// (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug)
return findParentComponentOfClass ((MultiDocumentPanel*) 0);
return findParentComponentOfClass ((MultiDocumentPanel*) nullptr);
} }


class MDITabbedComponentInternal : public TabbedComponent class MDITabbedComponentInternal : public TabbedComponent
@@ -62974,7 +62976,7 @@ public:
void currentTabChanged (int, const String&) void currentTabChanged (int, const String&)
{ {
// (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug)
MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) 0);
MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) nullptr);


if (owner != nullptr) if (owner != nullptr)
owner->updateOrder(); owner->updateOrder();
@@ -70854,7 +70856,7 @@ private:
PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c); PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c);


if (mic == nullptr && c != nullptr) if (mic == nullptr && c != nullptr)
mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) 0);
mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) nullptr);


if (mic != currentChild if (mic != currentChild
&& (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible())) && (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible()))
@@ -71541,12 +71543,12 @@ public:
Component* const sourceComponent, Component* const sourceComponent,
Component* const mouseDragSource_, Component* const mouseDragSource_,
DragAndDropContainer* const o, DragAndDropContainer* const o,
const Point<int>& imageOffset_)
: image (im),
source (sourceComponent),
const Point<int>& imageOffset_,
ReferenceCountedObject* const customDataObject)
: sourceDetails (desc, sourceComponent, Point<int>(), customDataObject),
image (im),
mouseDragSource (mouseDragSource_), mouseDragSource (mouseDragSource_),
owner (o), owner (o),
dragDesc (desc),
imageOffset (imageOffset_), imageOffset (imageOffset_),
hasCheckedForExternalDrag (false), hasCheckedForExternalDrag (false),
drawImage (true) drawImage (true)
@@ -71554,7 +71556,7 @@ public:
setSize (im.getWidth(), im.getHeight()); setSize (im.getWidth(), im.getHeight());


if (mouseDragSource == nullptr) if (mouseDragSource == nullptr)
mouseDragSource = source;
mouseDragSource = sourceComponent;


mouseDragSource->addMouseListener (this, false); mouseDragSource->addMouseListener (this, false);


@@ -71573,8 +71575,10 @@ public:
{ {
mouseDragSource->removeMouseListener (this); mouseDragSource->removeMouseListener (this);


if (getCurrentlyOver() != nullptr && getCurrentlyOver()->isInterestedInDragSource (dragDesc, source))
getCurrentlyOver()->itemDragExit (dragDesc, source);
DragAndDropTarget* const current = getCurrentlyOver();

if (current != nullptr && current->isInterestedInDragSource (sourceDetails))
current->itemDragExit (sourceDetails);
} }
} }


@@ -71604,15 +71608,15 @@ public:
hit = hit->getComponentAt (relPos.getX(), relPos.getY()); hit = hit->getComponentAt (relPos.getX(), relPos.getY());
} }


// (note: use a local copy of the dragDesc member in case the callback runs
// (note: use a local copy of this in case the callback runs
// a modal loop and deletes this object before the method completes) // a modal loop and deletes this object before the method completes)
const String dragDescLocal (dragDesc);
const DragAndDropTarget::SourceDetails details (sourceDetails);


while (hit != nullptr) while (hit != nullptr)
{ {
DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit); DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit);


if (ddt != nullptr && ddt->isInterestedInDragSource (dragDescLocal, source))
if (ddt != nullptr && ddt->isInterestedInDragSource (details))
{ {
relativePos = hit->getLocalPoint (nullptr, screenPos); relativePos = hit->getLocalPoint (nullptr, screenPos);
return ddt; return ddt;
@@ -71646,13 +71650,13 @@ public:


setVisible (true); setVisible (true);


if (dropAccepted || source == nullptr)
if (dropAccepted || sourceDetails.sourceComponent == nullptr)
{ {
Desktop::getInstance().getAnimator().fadeOut (this, 120); Desktop::getInstance().getAnimator().fadeOut (this, 120);
} }
else else
{ {
const Point<int> target (source->localPointToGlobal (source->getLocalBounds().getCentre()));
const Point<int> target (sourceDetails.sourceComponent->localPointToGlobal (sourceDetails.sourceComponent->getLocalBounds().getCentre()));
const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre())); const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre()));


Desktop::getInstance().getAnimator().animateComponent (this, Desktop::getInstance().getAnimator().animateComponent (this,
@@ -71667,13 +71671,14 @@ public:


if (dropAccepted && ddt != nullptr) if (dropAccepted && ddt != nullptr)
{ {
// (note: use a local copy of the dragDesc member in case the callback runs
// (note: use a local copy of this in case the callback runs
// a modal loop and deletes this object before the method completes) // a modal loop and deletes this object before the method completes)
const String dragDescLocal (dragDesc);
DragAndDropTarget::SourceDetails details (sourceDetails);
details.localPosition = relPos;


currentlyOverComp = nullptr; currentlyOverComp = nullptr;


ddt->itemDropped (dragDescLocal, source, relPos.getX(), relPos.getY());
ddt->itemDropped (details);
} }


// careful - this object could now be deleted.. // careful - this object could now be deleted..
@@ -71682,9 +71687,9 @@ public:


void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos) void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos)
{ {
// (note: use a local copy of the dragDesc member in case the callback runs
// a modal loop and deletes this object before it returns)
const String dragDescLocal (dragDesc);
// (note: use a local copy of this in case a callback runs a modal loop and deletes
// this object before it returns)
DragAndDropTarget::SourceDetails details (sourceDetails);


Point<int> newPos (screenPos + imageOffset); Point<int> newPos (screenPos + imageOffset);


@@ -71696,29 +71701,41 @@ public:
setTopLeftPosition (newPos.getX(), newPos.getY()); setTopLeftPosition (newPos.getX(), newPos.getY());


Point<int> relPos; Point<int> relPos;
DragAndDropTarget* const ddt = findTarget (screenPos, relPos);
Component* ddtComp = dynamic_cast <Component*> (ddt);
DragAndDropTarget* const newTarget = findTarget (screenPos, relPos);
Component* newTargetComp = dynamic_cast <Component*> (newTarget);


drawImage = (ddt == nullptr) || ddt->shouldDrawDragImageWhenOver();
drawImage = (newTarget == nullptr) || newTarget->shouldDrawDragImageWhenOver();


if (ddtComp != currentlyOverComp)
if (newTargetComp != currentlyOverComp)
{ {
if (currentlyOverComp != nullptr && source != nullptr
&& getCurrentlyOver()->isInterestedInDragSource (dragDescLocal, source))
DragAndDropTarget* const lastTarget = getCurrentlyOver();

if (lastTarget != nullptr && details.sourceComponent != nullptr
&& lastTarget->isInterestedInDragSource (details))
lastTarget->itemDragExit (details);

currentlyOverComp = newTargetComp;

if (newTarget != nullptr)
{ {
getCurrentlyOver()->itemDragExit (dragDescLocal, source);
details.localPosition = relPos;

if (newTarget->isInterestedInDragSource (details))
newTarget->itemDragEnter (details);
} }
}


currentlyOverComp = ddtComp;
{
DragAndDropTarget* const target = getCurrentlyOver();
if (target != nullptr)
{
details.localPosition = relPos;


if (ddt != nullptr && ddt->isInterestedInDragSource (dragDescLocal, source))
ddt->itemDragEnter (dragDescLocal, source, relPos.getX(), relPos.getY());
if (target->isInterestedInDragSource (details))
target->itemDragMove (details);
}
} }


DragAndDropTarget* target = getCurrentlyOver();
if (target != nullptr && target->isInterestedInDragSource (dragDescLocal, source))
target->itemDragMove (dragDescLocal, source, relPos.getX(), relPos.getY());

if (getCurrentlyOver() == nullptr && canDoExternalDrag && ! hasCheckedForExternalDrag) if (getCurrentlyOver() == nullptr && canDoExternalDrag && ! hasCheckedForExternalDrag)
{ {
if (Desktop::getInstance().findComponentAt (screenPos) == nullptr) if (Desktop::getInstance().findComponentAt (screenPos) == nullptr)
@@ -71727,7 +71744,7 @@ public:
StringArray files; StringArray files;
bool canMoveFiles = false; bool canMoveFiles = false;


if (owner->shouldDropFilesWhenDraggedExternally (dragDescLocal, source, files, canMoveFiles)
if (owner->shouldDropFilesWhenDraggedExternally (details, files, canMoveFiles)
&& files.size() > 0) && files.size() > 0)
{ {
WeakReference<Component> thisWeakRef (this); WeakReference<Component> thisWeakRef (this);
@@ -71752,7 +71769,7 @@ public:


void timerCallback() void timerCallback()
{ {
if (source == nullptr)
if (sourceDetails.sourceComponent == nullptr)
{ {
delete this; delete this;
} }
@@ -71766,8 +71783,8 @@ public:
} }


private: private:
DragAndDropTarget::SourceDetails sourceDetails;
Image image; Image image;
WeakReference<Component> source;
WeakReference<Component> mouseDragSource; WeakReference<Component> mouseDragSource;
DragAndDropContainer* const owner; DragAndDropContainer* const owner;


@@ -71777,7 +71794,6 @@ private:
return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get());
} }


String dragDesc;
const Point<int> imageOffset; const Point<int> imageOffset;
bool hasCheckedForExternalDrag, drawImage; bool hasCheckedForExternalDrag, drawImage;


@@ -71797,7 +71813,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
Component* sourceComponent, Component* sourceComponent,
const Image& dragImage_, const Image& dragImage_,
const bool allowDraggingToExternalWindows, const bool allowDraggingToExternalWindows,
const Point<int>* imageOffsetFromMouse)
const Point<int>* imageOffsetFromMouse,
ReferenceCountedObject* customDataObject)
{ {
Image dragImage (dragImage_); Image dragImage (dragImage_);


@@ -71866,7 +71883,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
} }


dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent, dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent,
draggingSource->getComponentUnderMouse(), this, imageOffset);
draggingSource->getComponentUnderMouse(), this,
imageOffset, customDataObject);


currentDragDesc = sourceDescription; currentDragDesc = sourceDescription;


@@ -71908,42 +71926,31 @@ const String DragAndDropContainer::getCurrentDragDescription() const


DragAndDropContainer* DragAndDropContainer::findParentDragContainerFor (Component* c) DragAndDropContainer* DragAndDropContainer::findParentDragContainerFor (Component* c)
{ {
return c == nullptr ? nullptr : c->findParentComponentOfClass ((DragAndDropContainer*) 0);
return c == nullptr ? nullptr : c->findParentComponentOfClass ((DragAndDropContainer*) nullptr);
} }


bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)
bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails&, StringArray&, bool&)
{ {
return false; return false;
} }


void DragAndDropTarget::itemDragEnter (const String&, Component*, int, int)
{
}

void DragAndDropTarget::itemDragMove (const String&, Component*, int, int)
{
}

void DragAndDropTarget::itemDragExit (const String&, Component*)
DragAndDropTarget::SourceDetails::SourceDetails (const String& description_, Component* sourceComponent_,
const Point<int>& localPosition_, ReferenceCountedObject* const customDataObject_) noexcept
: description (description_),
sourceComponent (sourceComponent_),
localPosition (localPosition_),
customDataObject (customDataObject_)
{ {
} }


bool DragAndDropTarget::shouldDrawDragImageWhenOver()
{
return true;
}

void FileDragAndDropTarget::fileDragEnter (const StringArray&, int, int)
{
}

void FileDragAndDropTarget::fileDragMove (const StringArray&, int, int)
{
}
void DragAndDropTarget::itemDragEnter (const SourceDetails&) {}
void DragAndDropTarget::itemDragMove (const SourceDetails&) {}
void DragAndDropTarget::itemDragExit (const SourceDetails&) {}
bool DragAndDropTarget::shouldDrawDragImageWhenOver() { return true; }


void FileDragAndDropTarget::fileDragExit (const StringArray&)
{
}
void FileDragAndDropTarget::fileDragEnter (const StringArray&, int, int) {}
void FileDragAndDropTarget::fileDragMove (const StringArray&, int, int) {}
void FileDragAndDropTarget::fileDragExit (const StringArray&) {}


END_JUCE_NAMESPACE END_JUCE_NAMESPACE
/*** End of inlined file: juce_DragAndDropContainer.cpp ***/ /*** End of inlined file: juce_DragAndDropContainer.cpp ***/
@@ -73115,7 +73122,7 @@ public:
for (int i = propertyComps.size(); --i >= 0;) for (int i = propertyComps.size(); --i >= 0;)
propertyComps.getUnchecked(i)->setVisible (open); propertyComps.getUnchecked(i)->setVisible (open);


PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) 0);
PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) nullptr);


if (pp != nullptr) if (pp != nullptr)
pp->resized(); pp->resized();
@@ -79771,22 +79778,35 @@ void TooltipWindow::showFor (const String& tip)
tipShowing = tip; tipShowing = tip;


Point<int> mousePos (Desktop::getMousePosition()); Point<int> mousePos (Desktop::getMousePosition());
Rectangle<int> parentArea;


if (getParentComponent() != nullptr) if (getParentComponent() != nullptr)
{
mousePos = getParentComponent()->getLocalPoint (nullptr, mousePos); mousePos = getParentComponent()->getLocalPoint (nullptr, mousePos);
parentArea = getParentComponent()->getLocalBounds();
}
else
{
parentArea = Desktop::getInstance().getMonitorAreaContaining (mousePos);
}


int x, y, w, h;
int w, h;
getLookAndFeel().getTooltipSize (tip, w, h); getLookAndFeel().getTooltipSize (tip, w, h);


if (mousePos.getX() > getParentWidth() / 2)
x = mousePos.getX() - (w + 12);
int x = mousePos.getX();
if (x > parentArea.getCentreX())
x -= (w + 12);
else else
x = mousePos.getX() + 24;
x += 24;


if (mousePos.getY() > getParentHeight() / 2)
y = mousePos.getY() - (h + 6);
int y = mousePos.getY();
if (y > parentArea.getCentreY())
y -= (h + 6);
else else
y = mousePos.getY() + 6;
y += 6;

x = jlimit (parentArea.getX(), parentArea.getRight() - w, x);
y = jlimit (parentArea.getY(), parentArea.getBottom() - h, y);


setBounds (x, y, w, h); setBounds (x, y, w, h);
setVisible (true); setVisible (true);
@@ -79915,7 +79935,7 @@ public:


if (tlw == nullptr && c != nullptr) if (tlw == nullptr && c != nullptr)
// (unable to use the syntax findParentComponentOfClass <TopLevelWindow> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <TopLevelWindow> () because of a VC6 compiler bug)
tlw = c->findParentComponentOfClass ((TopLevelWindow*) 0);
tlw = c->findParentComponentOfClass ((TopLevelWindow*) nullptr);


if (tlw != nullptr) if (tlw != nullptr)
active = tlw; active = tlw;


+ 81
- 53
juce_amalgamated.h View File

@@ -50619,16 +50619,42 @@ public:
/** Destructor. */ /** Destructor. */
virtual ~DragAndDropTarget() {} virtual ~DragAndDropTarget() {}


/** Contains details about the source of a drag-and-drop operation.
The contents of this
*/
class JUCE_API SourceDetails
{
public:
/** Creates a SourceDetails object from its various settings. */
SourceDetails (const String& description, Component* sourceComponent,
const Point<int>& localPosition, ReferenceCountedObject* customDataObject = nullptr) noexcept;

/** A descriptor string - this is set DragAndDropContainer::startDragging(). */
String description;

/** The component from the drag operation was started. */
WeakReference<Component> sourceComponent;

/** The local position of the mouse, relative to the target component.
Note that for calls such as isInterestedInDragSource(), this may be a null position.
*/
Point<int> localPosition;

/** A pointer to a user-supplied object which contains some kind of data which is relevant to
the specific classes which are being used. Make sure that you check the type of this object,
and safely dynamic_cast it to your required type.
*/
ReferenceCountedObjectPtr<ReferenceCountedObject> customDataObject;
};

/** Callback to check whether this target is interested in the type of object being /** Callback to check whether this target is interested in the type of object being
dragged. dragged.


@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param dragSourceDetails contains information about the source of the drag operation.
@returns true if this component wants to receive the other callbacks regarging this @returns true if this component wants to receive the other callbacks regarging this
type of object; if it returns false, no other callbacks will be made. type of object; if it returns false, no other callbacks will be made.
*/ */
virtual bool isInterestedInDragSource (const String& sourceDescription,
Component* sourceComponent) = 0;
virtual bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) = 0;


/** Callback to indicate that something is being dragged over this component. /** Callback to indicate that something is being dragged over this component.


@@ -50638,15 +50664,10 @@ public:
Use this callback as a trigger to make your component repaint itself to give the Use this callback as a trigger to make your component repaint itself to give the
user feedback about whether the item can be dropped here or not. user feedback about whether the item can be dropped here or not.


@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
@see itemDragExit @see itemDragExit
*/ */
virtual void itemDragEnter (const String& sourceDescription,
Component* sourceComponent,
int x, int y);
virtual void itemDragEnter (const SourceDetails& dragSourceDetails);


/** Callback to indicate that the user is dragging something over this component. /** Callback to indicate that the user is dragging something over this component.


@@ -50654,14 +50675,9 @@ public:
something. Normally overriding itemDragEnter() and itemDragExit() are enough, but something. Normally overriding itemDragEnter() and itemDragExit() are enough, but
this lets you know what happens in-between. this lets you know what happens in-between.


@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
*/ */
virtual void itemDragMove (const String& sourceDescription,
Component* sourceComponent,
int x, int y);
virtual void itemDragMove (const SourceDetails& dragSourceDetails);


/** Callback to indicate that something has been dragged off the edge of this component. /** Callback to indicate that something has been dragged off the edge of this component.


@@ -50671,12 +50687,10 @@ public:
If you've used itemDragEnter() to repaint your component and give feedback, use this If you've used itemDragEnter() to repaint your component and give feedback, use this
as a signal to repaint it in its normal state. as a signal to repaint it in its normal state.


@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param dragSourceDetails contains information about the source of the drag operation.
@see itemDragEnter @see itemDragEnter
*/ */
virtual void itemDragExit (const String& sourceDescription,
Component* sourceComponent);
virtual void itemDragExit (const SourceDetails& dragSourceDetails);


/** Callback to indicate that the user has dropped something onto this component. /** Callback to indicate that the user has dropped something onto this component.


@@ -50686,14 +50700,9 @@ public:
Note that after this is called, the itemDragExit method may not be called, so you should Note that after this is called, the itemDragExit method may not be called, so you should
clean up in here if there's anything you need to do when the drag finishes. clean up in here if there's anything you need to do when the drag finishes.


@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
*/ */
virtual void itemDropped (const String& sourceDescription,
Component* sourceComponent,
int x, int y) = 0;
virtual void itemDropped (const SourceDetails& dragSourceDetails) = 0;


/** Overriding this allows the target to tell the drag container whether to /** Overriding this allows the target to tell the drag container whether to
draw the drag image while the cursor is over it. draw the drag image while the cursor is over it.
@@ -50702,6 +50711,16 @@ public:
image will not be shown when the cursor is over this target. image will not be shown when the cursor is over this target.
*/ */
virtual bool shouldDrawDragImageWhenOver(); virtual bool shouldDrawDragImageWhenOver();

private:
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code!
virtual void isInterestedInDragSource (const String&, Component*) {}
virtual int itemDragEnter (const String&, Component*, int, int) { return 0; }
virtual int itemDragMove (const String&, Component*, int, int) { return 0; }
virtual int itemDragExit (const String&, Component*) { return 0; }
virtual int itemDropped (const String&, Component*, int, int) { return 0; }
#endif
}; };


#endif // __JUCE_DRAGANDDROPTARGET_JUCEHEADER__ #endif // __JUCE_DRAGANDDROPTARGET_JUCEHEADER__
@@ -50749,10 +50768,9 @@ public:
findParentDragContainerFor() is a handy method to call to find the findParentDragContainerFor() is a handy method to call to find the
drag container to use for a component. drag container to use for a component.


@param sourceDescription a string to use as the description of the thing being
dragged - this will be passed to the objects that might be
dropped-onto so they can decide if they want to handle it or
not
@param sourceDescription a string to use as the description of the thing being dragged - this
will be passed to the objects that might be dropped-onto so they can
decide whether they want to handle it
@param sourceComponent the component that is being dragged @param sourceComponent the component that is being dragged
@param dragImage the image to drag around underneath the mouse. If this is a null image, @param dragImage the image to drag around underneath the mouse. If this is a null image,
a snapshot of the sourceComponent will be used instead. a snapshot of the sourceComponent will be used instead.
@@ -50763,12 +50781,16 @@ public:
at which the image should be drawn from the mouse. If it isn't at which the image should be drawn from the mouse. If it isn't
specified, then the image will be centred around the mouse. If specified, then the image will be centred around the mouse. If
an image hasn't been passed-in, this will be ignored. an image hasn't been passed-in, this will be ignored.
@param customDataObject Any kind of reference-counted object which you want to have passed to
the target component. A pointer to this object will be made available
to the targets in the DragAndDropTarget::SourceDetails class.
*/ */
void startDragging (const String& sourceDescription, void startDragging (const String& sourceDescription,
Component* sourceComponent, Component* sourceComponent,
const Image& dragImage = Image::null, const Image& dragImage = Image::null,
bool allowDraggingToOtherJuceWindows = false, bool allowDraggingToOtherJuceWindows = false,
const Point<int>* imageOffsetFromMouse = nullptr);
const Point<int>* imageOffsetFromMouse = nullptr,
ReferenceCountedObject* customDataObject = nullptr);


/** Returns true if something is currently being dragged. */ /** Returns true if something is currently being dragged. */
bool isDragAndDropActive() const; bool isDragAndDropActive() const;
@@ -50842,8 +50864,7 @@ protected:
method) method)
@see performExternalDragDropOfFiles @see performExternalDragDropOfFiles
*/ */
virtual bool shouldDropFilesWhenDraggedExternally (const String& dragSourceDescription,
Component* dragSourceComponent,
virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
StringArray& files, StringArray& files,
bool& canMoveFiles); bool& canMoveFiles);


@@ -50853,6 +50874,8 @@ private:
ScopedPointer <Component> dragImageComponent; ScopedPointer <Component> dragImageComponent;
String currentDragDesc; String currentDragDesc;


JUCE_DEPRECATED (virtual bool shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)) { return false; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer);
}; };


@@ -51100,13 +51123,13 @@ public:
/** @internal */ /** @internal */
void mouseDown (const MouseEvent&); void mouseDown (const MouseEvent&);
/** @internal */ /** @internal */
bool isInterestedInDragSource (const String&, Component*);
bool isInterestedInDragSource (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragMove (const String&, Component*, int, int);
void itemDragMove (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragExit (const String&, Component*);
void itemDragExit (const SourceDetails&);
/** @internal */ /** @internal */
void itemDropped (const String&, Component*, int, int);
void itemDropped (const SourceDetails&);
/** @internal */ /** @internal */
void updateAllItemPositions (bool animate); void updateAllItemPositions (bool animate);
/** @internal */ /** @internal */
@@ -54388,7 +54411,7 @@ public:
To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag(). To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag().
@see DragAndDropTarget::isInterestedInDragSource, itemDropped @see DragAndDropTarget::isInterestedInDragSource, itemDropped
*/ */
virtual bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent);
virtual bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);


/** When a things are dropped into this item, this callback is invoked. /** When a things are dropped into this item, this callback is invoked.


@@ -54396,7 +54419,7 @@ public:
The insertIndex value indicates where in the list of sub-items the new items should be placed. The insertIndex value indicates where in the list of sub-items the new items should be placed.
@see isInterestedInDragSource, DragAndDropTarget::itemDropped @see isInterestedInDragSource, DragAndDropTarget::itemDropped
*/ */
virtual void itemDropped (const String& sourceDescription, Component* sourceComponent, int insertIndex);
virtual void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);


/** Sets a flag to indicate that the item wants to be allowed /** Sets a flag to indicate that the item wants to be allowed
to draw all the way across to the left edge of the treeview. to draw all the way across to the left edge of the treeview.
@@ -54523,6 +54546,12 @@ private:
TreeViewItem* getNextVisibleItem (bool recurse) const noexcept; TreeViewItem* getNextVisibleItem (bool recurse) const noexcept;
TreeViewItem* findItemFromIdentifierString (const String& identifierString); TreeViewItem* findItemFromIdentifierString (const String& identifierString);


#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code!
virtual void isInterestedInDragSource (const String&, Component*) {}
virtual int itemDropped (const String&, Component*, int) { return 0; }
#endif

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeViewItem); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeViewItem);
}; };


@@ -54761,15 +54790,15 @@ public:
/** @internal */ /** @internal */
void filesDropped (const StringArray& files, int x, int y); void filesDropped (const StringArray& files, int x, int y);
/** @internal */ /** @internal */
bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent);
bool isInterestedInDragSource (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDragEnter (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDragMove (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragExit (const String& sourceDescription, Component* sourceComponent);
void itemDragExit (const SourceDetails&);
/** @internal */ /** @internal */
void itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDropped (const SourceDetails&);


private: private:
friend class TreeViewItem; friend class TreeViewItem;
@@ -54798,11 +54827,10 @@ private:
void updateButtonUnderMouse (const MouseEvent& e); void updateButtonUnderMouse (const MouseEvent& e);
void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) noexcept; void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) noexcept;
void hideDragHighlight() noexcept; void hideDragHighlight() noexcept;
void handleDrag (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y);
void handleDrop (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y);
void handleDrag (const StringArray& files, const SourceDetails&);
void handleDrop (const StringArray& files, const SourceDetails&);
TreeViewItem* getInsertPosition (int& x, int& y, int& insertIndex, TreeViewItem* getInsertPosition (int& x, int& y, int& insertIndex,
const StringArray& files, const String& sourceDescription,
Component* sourceComponent) const noexcept;
const StringArray& files, const SourceDetails&) const noexcept;


JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView);
}; };
@@ -64832,7 +64860,7 @@ public:
the DialogWindow that is created. To find a pointer to this window from your the DialogWindow that is created. To find a pointer to this window from your
contentComponent, you can do something like this: contentComponent, you can do something like this:
@code @code
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0);
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr);


if (dw != nullptr) if (dw != nullptr)
dw->exitModalState (1234); dw->exitModalState (1234);
@@ -64875,7 +64903,7 @@ public:
the DialogWindow that is created. To find a pointer to this window from your the DialogWindow that is created. To find a pointer to this window from your
contentComponent, you can do something like this: contentComponent, you can do something like this:
@code @code
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0);
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr);


if (dw != nullptr) if (dw != nullptr)
dw->exitModalState (1234); dw->exitModalState (1234);


+ 1
- 1
src/application/juce_ApplicationCommandManager.cpp View File

@@ -244,7 +244,7 @@ ApplicationCommandTarget* ApplicationCommandManager::findTargetForComponent (Com
if (target == nullptr && c != nullptr) if (target == nullptr && c != nullptr)
// (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug)
target = c->findParentComponentOfClass ((ApplicationCommandTarget*) 0);
target = c->findParentComponentOfClass ((ApplicationCommandTarget*) nullptr);
return target; return target;
} }


+ 1
- 1
src/application/juce_ApplicationCommandTarget.cpp View File

@@ -74,7 +74,7 @@ ApplicationCommandTarget* ApplicationCommandTarget::findFirstTargetParentCompone
if (c != nullptr) if (c != nullptr)
// (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <ApplicationCommandTarget> () because of a VC6 compiler bug)
return c->findParentComponentOfClass ((ApplicationCommandTarget*) 0);
return c->findParentComponentOfClass ((ApplicationCommandTarget*) nullptr);
return nullptr; return nullptr;
} }


+ 1
- 1
src/containers/juce_Variant.cpp View File

@@ -464,7 +464,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg
const var var::call (const Identifier& method) const const var var::call (const Identifier& method) const
{ {
return invoke (method, 0, 0);
return invoke (method, nullptr, 0);
} }
const var var::call (const Identifier& method, const var& arg1) const const var var::call (const Identifier& method, const var& arg1) const


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53 #define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 73
#define JUCE_BUILDNUMBER 74
/** Current Juce version number. /** Current Juce version number.


+ 12
- 12
src/gui/components/controls/juce_Toolbar.cpp View File

@@ -563,15 +563,14 @@ void Toolbar::buttonClicked (Button*)
} }
//============================================================================== //==============================================================================
bool Toolbar::isInterestedInDragSource (const String& sourceDescription,
Component* /*sourceComponent*/)
bool Toolbar::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
{ {
return sourceDescription == toolbarDragDescriptor && isEditingActive;
return dragSourceDetails.description == toolbarDragDescriptor && isEditingActive;
} }
void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, int y)
void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr) if (tc != nullptr)
{ {
@@ -579,7 +578,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
{ {
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette) if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
{ {
ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) 0);
ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) nullptr);
if (palette != nullptr) if (palette != nullptr)
palette->replaceComponent (tc); palette->replaceComponent (tc);
@@ -599,7 +598,8 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
const int currentIndex = items.indexOf (tc); const int currentIndex = items.indexOf (tc);
int newIndex = currentIndex; int newIndex = currentIndex;
const int dragObjectLeft = vertical ? (y - tc->dragOffsetY) : (x - tc->dragOffsetX);
const int dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth()); const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
const Rectangle<int> current (Desktop::getInstance().getAnimator() const Rectangle<int> current (Desktop::getInstance().getAnimator()
@@ -641,9 +641,9 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in
} }
} }
void Toolbar::itemDragExit (const String&, Component* sourceComponent)
void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr && isParentOf (tc)) if (tc != nullptr && isParentOf (tc))
{ {
@@ -653,9 +653,9 @@ void Toolbar::itemDragExit (const String&, Component* sourceComponent)
} }
} }
void Toolbar::itemDropped (const String&, Component* sourceComponent, int, int)
void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
{ {
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (sourceComponent);
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr) if (tc != nullptr)
tc->setState (Button::buttonNormal); tc->setState (Button::buttonNormal);
@@ -806,7 +806,7 @@ private:
{ {
Colour background; Colour background;
DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) 0);
DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) nullptr);
if (dw != nullptr) if (dw != nullptr)
background = dw->getBackgroundColour(); background = dw->getBackgroundColour();


+ 4
- 4
src/gui/components/controls/juce_Toolbar.h View File

@@ -279,13 +279,13 @@ public:
/** @internal */ /** @internal */
void mouseDown (const MouseEvent&); void mouseDown (const MouseEvent&);
/** @internal */ /** @internal */
bool isInterestedInDragSource (const String&, Component*);
bool isInterestedInDragSource (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragMove (const String&, Component*, int, int);
void itemDragMove (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragExit (const String&, Component*);
void itemDragExit (const SourceDetails&);
/** @internal */ /** @internal */
void itemDropped (const String&, Component*, int, int);
void itemDropped (const SourceDetails&);
/** @internal */ /** @internal */
void updateAllItemPositions (bool animate); void updateAllItemPositions (bool animate);
/** @internal */ /** @internal */


+ 27
- 25
src/gui/components/controls/juce_TreeView.cpp View File

@@ -943,9 +943,10 @@ void TreeView::hideDragHighlight() noexcept
} }
TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
const StringArray& files, const String& sourceDescription,
Component* sourceComponent) const noexcept
const StringArray& files, const SourceDetails& dragSourceDetails) const noexcept
{ {
x = dragSourceDetails.localPosition.getX();
y = dragSourceDetails.localPosition.getY();
insertIndex = 0; insertIndex = 0;
TreeViewItem* item = getItemAt (y); TreeViewItem* item = getItemAt (y);
@@ -960,7 +961,7 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
if (item->getNumSubItems() == 0 || ! item->isOpen()) if (item->getNumSubItems() == 0 || ! item->isOpen())
{ {
if (files.size() > 0 ? item->isInterestedInFileDrag (files) if (files.size() > 0 ? item->isInterestedInFileDrag (files)
: item->isInterestedInDragSource (sourceDescription, sourceComponent))
: item->isInterestedInDragSource (dragSourceDetails))
{ {
// Check if we're trying to drag into an empty group item.. // Check if we're trying to drag into an empty group item..
if (oldY > itemPos.getY() + itemPos.getHeight() / 4 if (oldY > itemPos.getY() + itemPos.getHeight() / 4
@@ -996,12 +997,13 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
return item->parentItem; return item->parentItem;
} }
void TreeView::handleDrag (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::handleDrag (const StringArray& files, const SourceDetails& dragSourceDetails)
{ {
const bool scrolled = viewport->autoScroll (x, y, 20, 10);
const bool scrolled = viewport->autoScroll (dragSourceDetails.localPosition.getX(),
dragSourceDetails.localPosition.getY(), 20, 10);
int insertIndex;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, sourceDescription, sourceComponent);
int insertIndex, x, y;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, dragSourceDetails);
if (item != nullptr) if (item != nullptr)
{ {
@@ -1010,7 +1012,7 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip
|| dragInsertPointHighlight->lastIndex != insertIndex) || dragInsertPointHighlight->lastIndex != insertIndex)
{ {
if (files.size() > 0 ? item->isInterestedInFileDrag (files) if (files.size() > 0 ? item->isInterestedInFileDrag (files)
: item->isInterestedInDragSource (sourceDescription, sourceComponent))
: item->isInterestedInDragSource (dragSourceDetails))
showDragHighlight (item, insertIndex, x, y); showDragHighlight (item, insertIndex, x, y);
else else
hideDragHighlight(); hideDragHighlight();
@@ -1022,12 +1024,12 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip
} }
} }
void TreeView::handleDrop (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::handleDrop (const StringArray& files, const SourceDetails& dragSourceDetails)
{ {
hideDragHighlight(); hideDragHighlight();
int insertIndex;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, sourceDescription, sourceComponent);
int insertIndex, x, y;
TreeViewItem* const item = getInsertPosition (x, y, insertIndex, files, dragSourceDetails);
if (item != nullptr) if (item != nullptr)
{ {
@@ -1038,8 +1040,8 @@ void TreeView::handleDrop (const StringArray& files, const String& sourceDescrip
} }
else else
{ {
if (item->isInterestedInDragSource (sourceDescription, sourceComponent))
item->itemDropped (sourceDescription, sourceComponent, insertIndex);
if (item->isInterestedInDragSource (dragSourceDetails))
item->itemDropped (dragSourceDetails, insertIndex);
} }
} }
} }
@@ -1057,7 +1059,7 @@ void TreeView::fileDragEnter (const StringArray& files, int x, int y)
void TreeView::fileDragMove (const StringArray& files, int x, int y) void TreeView::fileDragMove (const StringArray& files, int x, int y)
{ {
handleDrag (files, String::empty, 0, x, y);
handleDrag (files, SourceDetails (String::empty, 0, Point<int> (x, y)));
} }
void TreeView::fileDragExit (const StringArray&) void TreeView::fileDragExit (const StringArray&)
@@ -1067,32 +1069,32 @@ void TreeView::fileDragExit (const StringArray&)
void TreeView::filesDropped (const StringArray& files, int x, int y) void TreeView::filesDropped (const StringArray& files, int x, int y)
{ {
handleDrop (files, String::empty, 0, x, y);
handleDrop (files, SourceDetails (String::empty, 0, Point<int> (x, y)));
} }
bool TreeView::isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
bool TreeView::isInterestedInDragSource (const SourceDetails& /*dragSourceDetails*/)
{ {
return true; return true;
} }
void TreeView::itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDragEnter (const SourceDetails& dragSourceDetails)
{ {
itemDragMove (sourceDescription, sourceComponent, x, y);
itemDragMove (dragSourceDetails);
} }
void TreeView::itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDragMove (const SourceDetails& dragSourceDetails)
{ {
handleDrag (StringArray(), sourceDescription, sourceComponent, x, y);
handleDrag (StringArray(), dragSourceDetails);
} }
void TreeView::itemDragExit (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
void TreeView::itemDragExit (const SourceDetails& /*dragSourceDetails*/)
{ {
hideDragHighlight(); hideDragHighlight();
} }
void TreeView::itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y)
void TreeView::itemDropped (const SourceDetails& dragSourceDetails)
{ {
handleDrop (StringArray(), sourceDescription, sourceComponent, x, y);
handleDrop (StringArray(), dragSourceDetails);
} }
//============================================================================== //==============================================================================
@@ -1303,12 +1305,12 @@ void TreeViewItem::filesDropped (const StringArray& /*files*/, int /*insertIndex
{ {
} }
bool TreeViewItem::isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
bool TreeViewItem::isInterestedInDragSource (const DragAndDropTarget::SourceDetails& /*dragSourceDetails*/)
{ {
return false; return false;
} }
void TreeViewItem::itemDropped (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*insertIndex*/)
void TreeViewItem::itemDropped (const DragAndDropTarget::SourceDetails& /*dragSourceDetails*/, int /*insertIndex*/)
{ {
} }


+ 16
- 11
src/gui/components/controls/juce_TreeView.h View File

@@ -384,7 +384,7 @@ public:
To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag(). To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag().
@see DragAndDropTarget::isInterestedInDragSource, itemDropped @see DragAndDropTarget::isInterestedInDragSource, itemDropped
*/ */
virtual bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent);
virtual bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);
/** When a things are dropped into this item, this callback is invoked. /** When a things are dropped into this item, this callback is invoked.
@@ -392,7 +392,7 @@ public:
The insertIndex value indicates where in the list of sub-items the new items should be placed. The insertIndex value indicates where in the list of sub-items the new items should be placed.
@see isInterestedInDragSource, DragAndDropTarget::itemDropped @see isInterestedInDragSource, DragAndDropTarget::itemDropped
*/ */
virtual void itemDropped (const String& sourceDescription, Component* sourceComponent, int insertIndex);
virtual void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);
//============================================================================== //==============================================================================
/** Sets a flag to indicate that the item wants to be allowed /** Sets a flag to indicate that the item wants to be allowed
@@ -523,6 +523,12 @@ private:
TreeViewItem* getNextVisibleItem (bool recurse) const noexcept; TreeViewItem* getNextVisibleItem (bool recurse) const noexcept;
TreeViewItem* findItemFromIdentifierString (const String& identifierString); TreeViewItem* findItemFromIdentifierString (const String& identifierString);
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code!
virtual void isInterestedInDragSource (const String&, Component*) {}
virtual int itemDropped (const String&, Component*, int) { return 0; }
#endif
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeViewItem); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeViewItem);
}; };
@@ -769,15 +775,15 @@ public:
/** @internal */ /** @internal */
void filesDropped (const StringArray& files, int x, int y); void filesDropped (const StringArray& files, int x, int y);
/** @internal */ /** @internal */
bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent);
bool isInterestedInDragSource (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDragEnter (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDragMove (const SourceDetails&);
/** @internal */ /** @internal */
void itemDragExit (const String& sourceDescription, Component* sourceComponent);
void itemDragExit (const SourceDetails&);
/** @internal */ /** @internal */
void itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y);
void itemDropped (const SourceDetails&);
private: private:
friend class TreeViewItem; friend class TreeViewItem;
@@ -806,11 +812,10 @@ private:
void updateButtonUnderMouse (const MouseEvent& e); void updateButtonUnderMouse (const MouseEvent& e);
void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) noexcept; void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) noexcept;
void hideDragHighlight() noexcept; void hideDragHighlight() noexcept;
void handleDrag (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y);
void handleDrop (const StringArray& files, const String& sourceDescription, Component* sourceComponent, int x, int y);
void handleDrag (const StringArray& files, const SourceDetails&);
void handleDrop (const StringArray& files, const SourceDetails&);
TreeViewItem* getInsertPosition (int& x, int& y, int& insertIndex, TreeViewItem* getInsertPosition (int& x, int& y, int& insertIndex,
const StringArray& files, const String& sourceDescription,
Component* sourceComponent) const noexcept;
const StringArray& files, const SourceDetails&) const noexcept;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView);
}; };


+ 2
- 2
src/gui/components/layout/juce_MultiDocumentPanel.cpp View File

@@ -84,7 +84,7 @@ void MultiDocumentPanelWindow::updateOrder()
MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept
{ {
// (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug)
return findParentComponentOfClass ((MultiDocumentPanel*) 0);
return findParentComponentOfClass ((MultiDocumentPanel*) nullptr);
} }
@@ -104,7 +104,7 @@ public:
void currentTabChanged (int, const String&) void currentTabChanged (int, const String&)
{ {
// (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <MultiDocumentPanel> () because of a VC6 compiler bug)
MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) 0);
MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) nullptr);
if (owner != nullptr) if (owner != nullptr)
owner->updateOrder(); owner->updateOrder();


+ 1
- 1
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -1104,7 +1104,7 @@ private:
PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c); PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c);
if (mic == nullptr && c != nullptr) if (mic == nullptr && c != nullptr)
mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) 0);
mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) nullptr);
if (mic != currentChild if (mic != currentChild
&& (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible())) && (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible()))


+ 69
- 66
src/gui/components/mouse/juce_DragAndDropContainer.cpp View File

@@ -51,12 +51,12 @@ public:
Component* const sourceComponent, Component* const sourceComponent,
Component* const mouseDragSource_, Component* const mouseDragSource_,
DragAndDropContainer* const o, DragAndDropContainer* const o,
const Point<int>& imageOffset_)
: image (im),
source (sourceComponent),
const Point<int>& imageOffset_,
ReferenceCountedObject* const customDataObject)
: sourceDetails (desc, sourceComponent, Point<int>(), customDataObject),
image (im),
mouseDragSource (mouseDragSource_), mouseDragSource (mouseDragSource_),
owner (o), owner (o),
dragDesc (desc),
imageOffset (imageOffset_), imageOffset (imageOffset_),
hasCheckedForExternalDrag (false), hasCheckedForExternalDrag (false),
drawImage (true) drawImage (true)
@@ -64,7 +64,7 @@ public:
setSize (im.getWidth(), im.getHeight()); setSize (im.getWidth(), im.getHeight());
if (mouseDragSource == nullptr) if (mouseDragSource == nullptr)
mouseDragSource = source;
mouseDragSource = sourceComponent;
mouseDragSource->addMouseListener (this, false); mouseDragSource->addMouseListener (this, false);
@@ -83,8 +83,10 @@ public:
{ {
mouseDragSource->removeMouseListener (this); mouseDragSource->removeMouseListener (this);
if (getCurrentlyOver() != nullptr && getCurrentlyOver()->isInterestedInDragSource (dragDesc, source))
getCurrentlyOver()->itemDragExit (dragDesc, source);
DragAndDropTarget* const current = getCurrentlyOver();
if (current != nullptr && current->isInterestedInDragSource (sourceDetails))
current->itemDragExit (sourceDetails);
} }
} }
@@ -114,15 +116,15 @@ public:
hit = hit->getComponentAt (relPos.getX(), relPos.getY()); hit = hit->getComponentAt (relPos.getX(), relPos.getY());
} }
// (note: use a local copy of the dragDesc member in case the callback runs
// (note: use a local copy of this in case the callback runs
// a modal loop and deletes this object before the method completes) // a modal loop and deletes this object before the method completes)
const String dragDescLocal (dragDesc);
const DragAndDropTarget::SourceDetails details (sourceDetails);
while (hit != nullptr) while (hit != nullptr)
{ {
DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit); DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit);
if (ddt != nullptr && ddt->isInterestedInDragSource (dragDescLocal, source))
if (ddt != nullptr && ddt->isInterestedInDragSource (details))
{ {
relativePos = hit->getLocalPoint (nullptr, screenPos); relativePos = hit->getLocalPoint (nullptr, screenPos);
return ddt; return ddt;
@@ -156,13 +158,13 @@ public:
setVisible (true); setVisible (true);
if (dropAccepted || source == nullptr)
if (dropAccepted || sourceDetails.sourceComponent == nullptr)
{ {
Desktop::getInstance().getAnimator().fadeOut (this, 120); Desktop::getInstance().getAnimator().fadeOut (this, 120);
} }
else else
{ {
const Point<int> target (source->localPointToGlobal (source->getLocalBounds().getCentre()));
const Point<int> target (sourceDetails.sourceComponent->localPointToGlobal (sourceDetails.sourceComponent->getLocalBounds().getCentre()));
const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre())); const Point<int> ourCentre (localPointToGlobal (getLocalBounds().getCentre()));
Desktop::getInstance().getAnimator().animateComponent (this, Desktop::getInstance().getAnimator().animateComponent (this,
@@ -177,13 +179,14 @@ public:
if (dropAccepted && ddt != nullptr) if (dropAccepted && ddt != nullptr)
{ {
// (note: use a local copy of the dragDesc member in case the callback runs
// (note: use a local copy of this in case the callback runs
// a modal loop and deletes this object before the method completes) // a modal loop and deletes this object before the method completes)
const String dragDescLocal (dragDesc);
DragAndDropTarget::SourceDetails details (sourceDetails);
details.localPosition = relPos;
currentlyOverComp = nullptr; currentlyOverComp = nullptr;
ddt->itemDropped (dragDescLocal, source, relPos.getX(), relPos.getY());
ddt->itemDropped (details);
} }
// careful - this object could now be deleted.. // careful - this object could now be deleted..
@@ -192,9 +195,9 @@ public:
void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos) void updateLocation (const bool canDoExternalDrag, const Point<int>& screenPos)
{ {
// (note: use a local copy of the dragDesc member in case the callback runs
// a modal loop and deletes this object before it returns)
const String dragDescLocal (dragDesc);
// (note: use a local copy of this in case a callback runs a modal loop and deletes
// this object before it returns)
DragAndDropTarget::SourceDetails details (sourceDetails);
Point<int> newPos (screenPos + imageOffset); Point<int> newPos (screenPos + imageOffset);
@@ -206,29 +209,41 @@ public:
setTopLeftPosition (newPos.getX(), newPos.getY()); setTopLeftPosition (newPos.getX(), newPos.getY());
Point<int> relPos; Point<int> relPos;
DragAndDropTarget* const ddt = findTarget (screenPos, relPos);
Component* ddtComp = dynamic_cast <Component*> (ddt);
DragAndDropTarget* const newTarget = findTarget (screenPos, relPos);
Component* newTargetComp = dynamic_cast <Component*> (newTarget);
drawImage = (ddt == nullptr) || ddt->shouldDrawDragImageWhenOver();
drawImage = (newTarget == nullptr) || newTarget->shouldDrawDragImageWhenOver();
if (ddtComp != currentlyOverComp)
if (newTargetComp != currentlyOverComp)
{ {
if (currentlyOverComp != nullptr && source != nullptr
&& getCurrentlyOver()->isInterestedInDragSource (dragDescLocal, source))
DragAndDropTarget* const lastTarget = getCurrentlyOver();
if (lastTarget != nullptr && details.sourceComponent != nullptr
&& lastTarget->isInterestedInDragSource (details))
lastTarget->itemDragExit (details);
currentlyOverComp = newTargetComp;
if (newTarget != nullptr)
{ {
getCurrentlyOver()->itemDragExit (dragDescLocal, source);
details.localPosition = relPos;
if (newTarget->isInterestedInDragSource (details))
newTarget->itemDragEnter (details);
} }
}
currentlyOverComp = ddtComp;
{
DragAndDropTarget* const target = getCurrentlyOver();
if (target != nullptr)
{
details.localPosition = relPos;
if (ddt != nullptr && ddt->isInterestedInDragSource (dragDescLocal, source))
ddt->itemDragEnter (dragDescLocal, source, relPos.getX(), relPos.getY());
if (target->isInterestedInDragSource (details))
target->itemDragMove (details);
}
} }
DragAndDropTarget* target = getCurrentlyOver();
if (target != nullptr && target->isInterestedInDragSource (dragDescLocal, source))
target->itemDragMove (dragDescLocal, source, relPos.getX(), relPos.getY());
if (getCurrentlyOver() == nullptr && canDoExternalDrag && ! hasCheckedForExternalDrag) if (getCurrentlyOver() == nullptr && canDoExternalDrag && ! hasCheckedForExternalDrag)
{ {
if (Desktop::getInstance().findComponentAt (screenPos) == nullptr) if (Desktop::getInstance().findComponentAt (screenPos) == nullptr)
@@ -237,7 +252,7 @@ public:
StringArray files; StringArray files;
bool canMoveFiles = false; bool canMoveFiles = false;
if (owner->shouldDropFilesWhenDraggedExternally (dragDescLocal, source, files, canMoveFiles)
if (owner->shouldDropFilesWhenDraggedExternally (details, files, canMoveFiles)
&& files.size() > 0) && files.size() > 0)
{ {
WeakReference<Component> thisWeakRef (this); WeakReference<Component> thisWeakRef (this);
@@ -262,7 +277,7 @@ public:
void timerCallback() void timerCallback()
{ {
if (source == nullptr)
if (sourceDetails.sourceComponent == nullptr)
{ {
delete this; delete this;
} }
@@ -276,8 +291,8 @@ public:
} }
private: private:
DragAndDropTarget::SourceDetails sourceDetails;
Image image; Image image;
WeakReference<Component> source;
WeakReference<Component> mouseDragSource; WeakReference<Component> mouseDragSource;
DragAndDropContainer* const owner; DragAndDropContainer* const owner;
@@ -287,7 +302,6 @@ private:
return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get());
} }
String dragDesc;
const Point<int> imageOffset; const Point<int> imageOffset;
bool hasCheckedForExternalDrag, drawImage; bool hasCheckedForExternalDrag, drawImage;
@@ -309,7 +323,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
Component* sourceComponent, Component* sourceComponent,
const Image& dragImage_, const Image& dragImage_,
const bool allowDraggingToExternalWindows, const bool allowDraggingToExternalWindows,
const Point<int>* imageOffsetFromMouse)
const Point<int>* imageOffsetFromMouse,
ReferenceCountedObject* customDataObject)
{ {
Image dragImage (dragImage_); Image dragImage (dragImage_);
@@ -378,7 +393,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
} }
dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent, dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent,
draggingSource->getComponentUnderMouse(), this, imageOffset);
draggingSource->getComponentUnderMouse(), this,
imageOffset, customDataObject);
currentDragDesc = sourceDescription; currentDragDesc = sourceDescription;
@@ -420,46 +436,33 @@ const String DragAndDropContainer::getCurrentDragDescription() const
DragAndDropContainer* DragAndDropContainer::findParentDragContainerFor (Component* c) DragAndDropContainer* DragAndDropContainer::findParentDragContainerFor (Component* c)
{ {
return c == nullptr ? nullptr : c->findParentComponentOfClass ((DragAndDropContainer*) 0);
return c == nullptr ? nullptr : c->findParentComponentOfClass ((DragAndDropContainer*) nullptr);
} }
bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)
bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails&, StringArray&, bool&)
{ {
return false; return false;
} }
//============================================================================== //==============================================================================
void DragAndDropTarget::itemDragEnter (const String&, Component*, int, int)
{
}
void DragAndDropTarget::itemDragMove (const String&, Component*, int, int)
DragAndDropTarget::SourceDetails::SourceDetails (const String& description_, Component* sourceComponent_,
const Point<int>& localPosition_, ReferenceCountedObject* const customDataObject_) noexcept
: description (description_),
sourceComponent (sourceComponent_),
localPosition (localPosition_),
customDataObject (customDataObject_)
{ {
} }
void DragAndDropTarget::itemDragExit (const String&, Component*)
{
}
bool DragAndDropTarget::shouldDrawDragImageWhenOver()
{
return true;
}
void DragAndDropTarget::itemDragEnter (const SourceDetails&) {}
void DragAndDropTarget::itemDragMove (const SourceDetails&) {}
void DragAndDropTarget::itemDragExit (const SourceDetails&) {}
bool DragAndDropTarget::shouldDrawDragImageWhenOver() { return true; }
//============================================================================== //==============================================================================
void FileDragAndDropTarget::fileDragEnter (const StringArray&, int, int)
{
}
void FileDragAndDropTarget::fileDragMove (const StringArray&, int, int)
{
}
void FileDragAndDropTarget::fileDragExit (const StringArray&)
{
}
void FileDragAndDropTarget::fileDragEnter (const StringArray&, int, int) {}
void FileDragAndDropTarget::fileDragMove (const StringArray&, int, int) {}
void FileDragAndDropTarget::fileDragExit (const StringArray&) {}
END_JUCE_NAMESPACE END_JUCE_NAMESPACE

+ 11
- 7
src/gui/components/mouse/juce_DragAndDropContainer.h View File

@@ -73,10 +73,9 @@ public:
findParentDragContainerFor() is a handy method to call to find the findParentDragContainerFor() is a handy method to call to find the
drag container to use for a component. drag container to use for a component.
@param sourceDescription a string to use as the description of the thing being
dragged - this will be passed to the objects that might be
dropped-onto so they can decide if they want to handle it or
not
@param sourceDescription a string to use as the description of the thing being dragged - this
will be passed to the objects that might be dropped-onto so they can
decide whether they want to handle it
@param sourceComponent the component that is being dragged @param sourceComponent the component that is being dragged
@param dragImage the image to drag around underneath the mouse. If this is a null image, @param dragImage the image to drag around underneath the mouse. If this is a null image,
a snapshot of the sourceComponent will be used instead. a snapshot of the sourceComponent will be used instead.
@@ -87,12 +86,16 @@ public:
at which the image should be drawn from the mouse. If it isn't at which the image should be drawn from the mouse. If it isn't
specified, then the image will be centred around the mouse. If specified, then the image will be centred around the mouse. If
an image hasn't been passed-in, this will be ignored. an image hasn't been passed-in, this will be ignored.
@param customDataObject Any kind of reference-counted object which you want to have passed to
the target component. A pointer to this object will be made available
to the targets in the DragAndDropTarget::SourceDetails class.
*/ */
void startDragging (const String& sourceDescription, void startDragging (const String& sourceDescription,
Component* sourceComponent, Component* sourceComponent,
const Image& dragImage = Image::null, const Image& dragImage = Image::null,
bool allowDraggingToOtherJuceWindows = false, bool allowDraggingToOtherJuceWindows = false,
const Point<int>* imageOffsetFromMouse = nullptr);
const Point<int>* imageOffsetFromMouse = nullptr,
ReferenceCountedObject* customDataObject = nullptr);
/** Returns true if something is currently being dragged. */ /** Returns true if something is currently being dragged. */
bool isDragAndDropActive() const; bool isDragAndDropActive() const;
@@ -168,8 +171,7 @@ protected:
method) method)
@see performExternalDragDropOfFiles @see performExternalDragDropOfFiles
*/ */
virtual bool shouldDropFilesWhenDraggedExternally (const String& dragSourceDescription,
Component* dragSourceComponent,
virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
StringArray& files, StringArray& files,
bool& canMoveFiles); bool& canMoveFiles);
@@ -179,6 +181,8 @@ private:
ScopedPointer <Component> dragImageComponent; ScopedPointer <Component> dragImageComponent;
String currentDragDesc; String currentDragDesc;
JUCE_DEPRECATED (virtual bool shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)) { return false; }
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer);
}; };


+ 52
- 30
src/gui/components/mouse/juce_DragAndDropTarget.h View File

@@ -49,16 +49,44 @@ public:
/** Destructor. */ /** Destructor. */
virtual ~DragAndDropTarget() {} virtual ~DragAndDropTarget() {}
//==============================================================================
/** Contains details about the source of a drag-and-drop operation.
The contents of this
*/
class JUCE_API SourceDetails
{
public:
/** Creates a SourceDetails object from its various settings. */
SourceDetails (const String& description, Component* sourceComponent,
const Point<int>& localPosition, ReferenceCountedObject* customDataObject = nullptr) noexcept;
/** A descriptor string - this is set DragAndDropContainer::startDragging(). */
String description;
/** The component from the drag operation was started. */
WeakReference<Component> sourceComponent;
/** The local position of the mouse, relative to the target component.
Note that for calls such as isInterestedInDragSource(), this may be a null position.
*/
Point<int> localPosition;
/** A pointer to a user-supplied object which contains some kind of data which is relevant to
the specific classes which are being used. Make sure that you check the type of this object,
and safely dynamic_cast it to your required type.
*/
ReferenceCountedObjectPtr<ReferenceCountedObject> customDataObject;
};
//==============================================================================
/** Callback to check whether this target is interested in the type of object being /** Callback to check whether this target is interested in the type of object being
dragged. dragged.
@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param dragSourceDetails contains information about the source of the drag operation.
@returns true if this component wants to receive the other callbacks regarging this @returns true if this component wants to receive the other callbacks regarging this
type of object; if it returns false, no other callbacks will be made. type of object; if it returns false, no other callbacks will be made.
*/ */
virtual bool isInterestedInDragSource (const String& sourceDescription,
Component* sourceComponent) = 0;
virtual bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) = 0;
/** Callback to indicate that something is being dragged over this component. /** Callback to indicate that something is being dragged over this component.
@@ -68,15 +96,10 @@ public:
Use this callback as a trigger to make your component repaint itself to give the Use this callback as a trigger to make your component repaint itself to give the
user feedback about whether the item can be dropped here or not. user feedback about whether the item can be dropped here or not.
@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
@see itemDragExit @see itemDragExit
*/ */
virtual void itemDragEnter (const String& sourceDescription,
Component* sourceComponent,
int x, int y);
virtual void itemDragEnter (const SourceDetails& dragSourceDetails);
/** Callback to indicate that the user is dragging something over this component. /** Callback to indicate that the user is dragging something over this component.
@@ -84,14 +107,9 @@ public:
something. Normally overriding itemDragEnter() and itemDragExit() are enough, but something. Normally overriding itemDragEnter() and itemDragExit() are enough, but
this lets you know what happens in-between. this lets you know what happens in-between.
@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
*/ */
virtual void itemDragMove (const String& sourceDescription,
Component* sourceComponent,
int x, int y);
virtual void itemDragMove (const SourceDetails& dragSourceDetails);
/** Callback to indicate that something has been dragged off the edge of this component. /** Callback to indicate that something has been dragged off the edge of this component.
@@ -101,12 +119,10 @@ public:
If you've used itemDragEnter() to repaint your component and give feedback, use this If you've used itemDragEnter() to repaint your component and give feedback, use this
as a signal to repaint it in its normal state. as a signal to repaint it in its normal state.
@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param dragSourceDetails contains information about the source of the drag operation.
@see itemDragEnter @see itemDragEnter
*/ */
virtual void itemDragExit (const String& sourceDescription,
Component* sourceComponent);
virtual void itemDragExit (const SourceDetails& dragSourceDetails);
/** Callback to indicate that the user has dropped something onto this component. /** Callback to indicate that the user has dropped something onto this component.
@@ -116,14 +132,9 @@ public:
Note that after this is called, the itemDragExit method may not be called, so you should Note that after this is called, the itemDragExit method may not be called, so you should
clean up in here if there's anything you need to do when the drag finishes. clean up in here if there's anything you need to do when the drag finishes.
@param sourceDescription the description string passed into DragAndDropContainer::startDragging()
@param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
@param x the mouse x position, relative to this component
@param y the mouse y position, relative to this component
@param dragSourceDetails contains information about the source of the drag operation.
*/ */
virtual void itemDropped (const String& sourceDescription,
Component* sourceComponent,
int x, int y) = 0;
virtual void itemDropped (const SourceDetails& dragSourceDetails) = 0;
/** Overriding this allows the target to tell the drag container whether to /** Overriding this allows the target to tell the drag container whether to
draw the drag image while the cursor is over it. draw the drag image while the cursor is over it.
@@ -132,7 +143,18 @@ public:
image will not be shown when the cursor is over this target. image will not be shown when the cursor is over this target.
*/ */
virtual bool shouldDrawDragImageWhenOver(); virtual bool shouldDrawDragImageWhenOver();
};
//==============================================================================
private:
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// The parameters for these methods have changed - please update your code!
virtual void isInterestedInDragSource (const String&, Component*) {}
virtual int itemDragEnter (const String&, Component*, int, int) { return 0; }
virtual int itemDragMove (const String&, Component*, int, int) { return 0; }
virtual int itemDragExit (const String&, Component*) { return 0; }
virtual int itemDropped (const String&, Component*, int, int) { return 0; }
#endif
};
#endif // __JUCE_DRAGANDDROPTARGET_JUCEHEADER__ #endif // __JUCE_DRAGANDDROPTARGET_JUCEHEADER__

+ 1
- 1
src/gui/components/properties/juce_PropertyPanel.cpp View File

@@ -97,7 +97,7 @@ public:
for (int i = propertyComps.size(); --i >= 0;) for (int i = propertyComps.size(); --i >= 0;)
propertyComps.getUnchecked(i)->setVisible (open); propertyComps.getUnchecked(i)->setVisible (open);
PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) 0);
PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) nullptr);
if (pp != nullptr) if (pp != nullptr)
pp->resized(); pp->resized();


+ 2
- 2
src/gui/components/windows/juce_DialogWindow.h View File

@@ -87,7 +87,7 @@ public:
the DialogWindow that is created. To find a pointer to this window from your the DialogWindow that is created. To find a pointer to this window from your
contentComponent, you can do something like this: contentComponent, you can do something like this:
@code @code
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0);
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr);
if (dw != nullptr) if (dw != nullptr)
dw->exitModalState (1234); dw->exitModalState (1234);
@@ -130,7 +130,7 @@ public:
the DialogWindow that is created. To find a pointer to this window from your the DialogWindow that is created. To find a pointer to this window from your
contentComponent, you can do something like this: contentComponent, you can do something like this:
@code @code
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0);
Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr);
if (dw != nullptr) if (dw != nullptr)
dw->exitModalState (1234); dw->exitModalState (1234);


+ 20
- 7
src/gui/components/windows/juce_TooltipWindow.cpp View File

@@ -85,22 +85,35 @@ void TooltipWindow::showFor (const String& tip)
tipShowing = tip; tipShowing = tip;
Point<int> mousePos (Desktop::getMousePosition()); Point<int> mousePos (Desktop::getMousePosition());
Rectangle<int> parentArea;
if (getParentComponent() != nullptr) if (getParentComponent() != nullptr)
{
mousePos = getParentComponent()->getLocalPoint (nullptr, mousePos); mousePos = getParentComponent()->getLocalPoint (nullptr, mousePos);
parentArea = getParentComponent()->getLocalBounds();
}
else
{
parentArea = Desktop::getInstance().getMonitorAreaContaining (mousePos);
}
int x, y, w, h;
int w, h;
getLookAndFeel().getTooltipSize (tip, w, h); getLookAndFeel().getTooltipSize (tip, w, h);
if (mousePos.getX() > getParentWidth() / 2)
x = mousePos.getX() - (w + 12);
int x = mousePos.getX();
if (x > parentArea.getCentreX())
x -= (w + 12);
else else
x = mousePos.getX() + 24;
x += 24;
if (mousePos.getY() > getParentHeight() / 2)
y = mousePos.getY() - (h + 6);
int y = mousePos.getY();
if (y > parentArea.getCentreY())
y -= (h + 6);
else else
y = mousePos.getY() + 6;
y += 6;
x = jlimit (parentArea.getX(), parentArea.getRight() - w, x);
y = jlimit (parentArea.getY(), parentArea.getBottom() - h, y);
setBounds (x, y, w, h); setBounds (x, y, w, h);
setVisible (true); setVisible (true);


+ 1
- 1
src/gui/components/windows/juce_TopLevelWindow.cpp View File

@@ -71,7 +71,7 @@ public:
if (tlw == nullptr && c != nullptr) if (tlw == nullptr && c != nullptr)
// (unable to use the syntax findParentComponentOfClass <TopLevelWindow> () because of a VC6 compiler bug) // (unable to use the syntax findParentComponentOfClass <TopLevelWindow> () because of a VC6 compiler bug)
tlw = c->findParentComponentOfClass ((TopLevelWindow*) 0);
tlw = c->findParentComponentOfClass ((TopLevelWindow*) nullptr);
if (tlw != nullptr) if (tlw != nullptr)
active = tlw; active = tlw;


Loading…
Cancel
Save