| @@ -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; | |||
| OwnedArray <Project::Item> selectedNodes; | |||
| getAllSelectedNodesInTree (sourceComponent, selectedNodes); | |||
| getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, 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; | |||
| getAllSelectedNodesInTree (sourceComponent, selectedNodes); | |||
| getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes); | |||
| if (selectedNodes.size() > 0) | |||
| { | |||
| @@ -92,8 +92,8 @@ public: | |||
| // Drag-and-drop stuff.. | |||
| bool isInterestedInFileDrag (const StringArray& files); | |||
| 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); | |||
| @@ -133,7 +133,7 @@ public: | |||
| // These methods implement the DragAndDropTarget interface, and allow our component | |||
| // 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 | |||
| // sort of object that you're interested in before returning true, but for | |||
| @@ -141,25 +141,25 @@ public: | |||
| return true; | |||
| } | |||
| void itemDragEnter (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*x*/, int /*y*/) | |||
| void itemDragEnter (const SourceDetails& /*dragSourceDetails*/) | |||
| { | |||
| somethingIsBeingDraggedOver = true; | |||
| 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; | |||
| 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; | |||
| repaint(); | |||
| @@ -4576,7 +4576,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg | |||
| 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 | |||
| @@ -18682,7 +18682,7 @@ ApplicationCommandTarget* ApplicationCommandManager::findTargetForComponent (Com | |||
| if (target == nullptr && c != nullptr) | |||
| // (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; | |||
| } | |||
| @@ -18811,7 +18811,7 @@ ApplicationCommandTarget* ApplicationCommandTarget::findFirstTargetParentCompone | |||
| if (c != nullptr) | |||
| // (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; | |||
| } | |||
| @@ -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) | |||
| { | |||
| @@ -55852,7 +55851,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in | |||
| { | |||
| if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette) | |||
| { | |||
| ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) 0); | |||
| ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) nullptr); | |||
| if (palette != nullptr) | |||
| palette->replaceComponent (tc); | |||
| @@ -55872,7 +55871,8 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in | |||
| const int currentIndex = items.indexOf (tc); | |||
| 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 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)) | |||
| { | |||
| @@ -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) | |||
| tc->setState (Button::buttonNormal); | |||
| @@ -56076,7 +56076,7 @@ private: | |||
| { | |||
| Colour background; | |||
| DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) 0); | |||
| DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| background = dw->getBackgroundColour(); | |||
| @@ -57333,9 +57333,10 @@ void TreeView::hideDragHighlight() noexcept | |||
| } | |||
| 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; | |||
| TreeViewItem* item = getItemAt (y); | |||
| @@ -57350,7 +57351,7 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, | |||
| if (item->getNumSubItems() == 0 || ! item->isOpen()) | |||
| { | |||
| 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.. | |||
| if (oldY > itemPos.getY() + itemPos.getHeight() / 4 | |||
| @@ -57386,12 +57387,13 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, | |||
| 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) | |||
| { | |||
| @@ -57400,7 +57402,7 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip | |||
| || dragInsertPointHighlight->lastIndex != insertIndex) | |||
| { | |||
| if (files.size() > 0 ? item->isInterestedInFileDrag (files) | |||
| : item->isInterestedInDragSource (sourceDescription, sourceComponent)) | |||
| : item->isInterestedInDragSource (dragSourceDetails)) | |||
| showDragHighlight (item, insertIndex, x, y); | |||
| else | |||
| 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(); | |||
| 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) | |||
| { | |||
| @@ -57428,8 +57430,8 @@ void TreeView::handleDrop (const StringArray& files, const String& sourceDescrip | |||
| } | |||
| 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) | |||
| { | |||
| handleDrag (files, String::empty, 0, x, y); | |||
| handleDrag (files, SourceDetails (String::empty, 0, Point<int> (x, y))); | |||
| } | |||
| void TreeView::fileDragExit (const StringArray&) | |||
| @@ -57456,32 +57458,32 @@ void TreeView::fileDragExit (const StringArray&) | |||
| 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; | |||
| } | |||
| 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(); | |||
| } | |||
| 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 | |||
| @@ -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; | |||
| } | |||
| 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 | |||
| { | |||
| // (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 | |||
| @@ -62974,7 +62976,7 @@ public: | |||
| void currentTabChanged (int, const String&) | |||
| { | |||
| // (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) | |||
| owner->updateOrder(); | |||
| @@ -70854,7 +70856,7 @@ private: | |||
| PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c); | |||
| if (mic == nullptr && c != nullptr) | |||
| mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) 0); | |||
| mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) nullptr); | |||
| if (mic != currentChild | |||
| && (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible())) | |||
| @@ -71541,12 +71543,12 @@ public: | |||
| Component* const sourceComponent, | |||
| Component* const mouseDragSource_, | |||
| 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_), | |||
| owner (o), | |||
| dragDesc (desc), | |||
| imageOffset (imageOffset_), | |||
| hasCheckedForExternalDrag (false), | |||
| drawImage (true) | |||
| @@ -71554,7 +71556,7 @@ public: | |||
| setSize (im.getWidth(), im.getHeight()); | |||
| if (mouseDragSource == nullptr) | |||
| mouseDragSource = source; | |||
| mouseDragSource = sourceComponent; | |||
| mouseDragSource->addMouseListener (this, false); | |||
| @@ -71573,8 +71575,10 @@ public: | |||
| { | |||
| 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()); | |||
| } | |||
| // (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) | |||
| const String dragDescLocal (dragDesc); | |||
| const DragAndDropTarget::SourceDetails details (sourceDetails); | |||
| while (hit != nullptr) | |||
| { | |||
| 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); | |||
| return ddt; | |||
| @@ -71646,13 +71650,13 @@ public: | |||
| setVisible (true); | |||
| if (dropAccepted || source == nullptr) | |||
| if (dropAccepted || sourceDetails.sourceComponent == nullptr) | |||
| { | |||
| Desktop::getInstance().getAnimator().fadeOut (this, 120); | |||
| } | |||
| 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())); | |||
| Desktop::getInstance().getAnimator().animateComponent (this, | |||
| @@ -71667,13 +71671,14 @@ public: | |||
| 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) | |||
| const String dragDescLocal (dragDesc); | |||
| DragAndDropTarget::SourceDetails details (sourceDetails); | |||
| details.localPosition = relPos; | |||
| currentlyOverComp = nullptr; | |||
| ddt->itemDropped (dragDescLocal, source, relPos.getX(), relPos.getY()); | |||
| ddt->itemDropped (details); | |||
| } | |||
| // careful - this object could now be deleted.. | |||
| @@ -71682,9 +71687,9 @@ public: | |||
| 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); | |||
| @@ -71696,29 +71701,41 @@ public: | |||
| setTopLeftPosition (newPos.getX(), newPos.getY()); | |||
| 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 (Desktop::getInstance().findComponentAt (screenPos) == nullptr) | |||
| @@ -71727,7 +71744,7 @@ public: | |||
| StringArray files; | |||
| bool canMoveFiles = false; | |||
| if (owner->shouldDropFilesWhenDraggedExternally (dragDescLocal, source, files, canMoveFiles) | |||
| if (owner->shouldDropFilesWhenDraggedExternally (details, files, canMoveFiles) | |||
| && files.size() > 0) | |||
| { | |||
| WeakReference<Component> thisWeakRef (this); | |||
| @@ -71752,7 +71769,7 @@ public: | |||
| void timerCallback() | |||
| { | |||
| if (source == nullptr) | |||
| if (sourceDetails.sourceComponent == nullptr) | |||
| { | |||
| delete this; | |||
| } | |||
| @@ -71766,8 +71783,8 @@ public: | |||
| } | |||
| private: | |||
| DragAndDropTarget::SourceDetails sourceDetails; | |||
| Image image; | |||
| WeakReference<Component> source; | |||
| WeakReference<Component> mouseDragSource; | |||
| DragAndDropContainer* const owner; | |||
| @@ -71777,7 +71794,6 @@ private: | |||
| return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); | |||
| } | |||
| String dragDesc; | |||
| const Point<int> imageOffset; | |||
| bool hasCheckedForExternalDrag, drawImage; | |||
| @@ -71797,7 +71813,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| Component* sourceComponent, | |||
| const Image& dragImage_, | |||
| const bool allowDraggingToExternalWindows, | |||
| const Point<int>* imageOffsetFromMouse) | |||
| const Point<int>* imageOffsetFromMouse, | |||
| ReferenceCountedObject* customDataObject) | |||
| { | |||
| Image dragImage (dragImage_); | |||
| @@ -71866,7 +71883,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| } | |||
| dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent, | |||
| draggingSource->getComponentUnderMouse(), this, imageOffset); | |||
| draggingSource->getComponentUnderMouse(), this, | |||
| imageOffset, customDataObject); | |||
| currentDragDesc = sourceDescription; | |||
| @@ -71908,42 +71926,31 @@ const String DragAndDropContainer::getCurrentDragDescription() const | |||
| 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; | |||
| } | |||
| 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 of inlined file: juce_DragAndDropContainer.cpp ***/ | |||
| @@ -73115,7 +73122,7 @@ public: | |||
| for (int i = propertyComps.size(); --i >= 0;) | |||
| propertyComps.getUnchecked(i)->setVisible (open); | |||
| PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) 0); | |||
| PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) nullptr); | |||
| if (pp != nullptr) | |||
| pp->resized(); | |||
| @@ -79771,22 +79778,35 @@ void TooltipWindow::showFor (const String& tip) | |||
| tipShowing = tip; | |||
| Point<int> mousePos (Desktop::getMousePosition()); | |||
| Rectangle<int> parentArea; | |||
| if (getParentComponent() != nullptr) | |||
| { | |||
| 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); | |||
| if (mousePos.getX() > getParentWidth() / 2) | |||
| x = mousePos.getX() - (w + 12); | |||
| int x = mousePos.getX(); | |||
| if (x > parentArea.getCentreX()) | |||
| x -= (w + 12); | |||
| 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 | |||
| 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); | |||
| setVisible (true); | |||
| @@ -79915,7 +79935,7 @@ public: | |||
| if (tlw == nullptr && c != nullptr) | |||
| // (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) | |||
| active = tlw; | |||
| @@ -50619,16 +50619,42 @@ public: | |||
| /** Destructor. */ | |||
| 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 | |||
| 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 | |||
| 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. | |||
| @@ -50638,15 +50664,10 @@ public: | |||
| 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. | |||
| @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 | |||
| */ | |||
| 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. | |||
| @@ -50654,14 +50675,9 @@ public: | |||
| something. Normally overriding itemDragEnter() and itemDragExit() are enough, but | |||
| 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. | |||
| @@ -50671,12 +50687,10 @@ public: | |||
| If you've used itemDragEnter() to repaint your component and give feedback, use this | |||
| 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 | |||
| */ | |||
| 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. | |||
| @@ -50686,14 +50700,9 @@ public: | |||
| 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. | |||
| @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 | |||
| 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. | |||
| */ | |||
| 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__ | |||
| @@ -50749,10 +50768,9 @@ public: | |||
| findParentDragContainerFor() is a handy method to call to find the | |||
| 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 dragImage the image to drag around underneath the mouse. If this is a null image, | |||
| 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 | |||
| specified, then the image will be centred around the mouse. If | |||
| 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, | |||
| Component* sourceComponent, | |||
| const Image& dragImage = Image::null, | |||
| bool allowDraggingToOtherJuceWindows = false, | |||
| const Point<int>* imageOffsetFromMouse = nullptr); | |||
| const Point<int>* imageOffsetFromMouse = nullptr, | |||
| ReferenceCountedObject* customDataObject = nullptr); | |||
| /** Returns true if something is currently being dragged. */ | |||
| bool isDragAndDropActive() const; | |||
| @@ -50842,8 +50864,7 @@ protected: | |||
| method) | |||
| @see performExternalDragDropOfFiles | |||
| */ | |||
| virtual bool shouldDropFilesWhenDraggedExternally (const String& dragSourceDescription, | |||
| Component* dragSourceComponent, | |||
| virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails, | |||
| StringArray& files, | |||
| bool& canMoveFiles); | |||
| @@ -50853,6 +50874,8 @@ private: | |||
| ScopedPointer <Component> dragImageComponent; | |||
| String currentDragDesc; | |||
| JUCE_DEPRECATED (virtual bool shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)) { return false; } | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer); | |||
| }; | |||
| @@ -51100,13 +51123,13 @@ public: | |||
| /** @internal */ | |||
| void mouseDown (const MouseEvent&); | |||
| /** @internal */ | |||
| bool isInterestedInDragSource (const String&, Component*); | |||
| bool isInterestedInDragSource (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragMove (const String&, Component*, int, int); | |||
| void itemDragMove (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragExit (const String&, Component*); | |||
| void itemDragExit (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDropped (const String&, Component*, int, int); | |||
| void itemDropped (const SourceDetails&); | |||
| /** @internal */ | |||
| void updateAllItemPositions (bool animate); | |||
| /** @internal */ | |||
| @@ -54388,7 +54411,7 @@ public: | |||
| To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag(). | |||
| @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. | |||
| @@ -54396,7 +54419,7 @@ public: | |||
| The insertIndex value indicates where in the list of sub-items the new items should be placed. | |||
| @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 | |||
| 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* 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); | |||
| }; | |||
| @@ -54761,15 +54790,15 @@ public: | |||
| /** @internal */ | |||
| void filesDropped (const StringArray& files, int x, int y); | |||
| /** @internal */ | |||
| bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent); | |||
| bool isInterestedInDragSource (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDragEnter (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDragMove (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragExit (const String& sourceDescription, Component* sourceComponent); | |||
| void itemDragExit (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDropped (const SourceDetails&); | |||
| private: | |||
| friend class TreeViewItem; | |||
| @@ -54798,11 +54827,10 @@ private: | |||
| void updateButtonUnderMouse (const MouseEvent& e); | |||
| void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) 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, | |||
| 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); | |||
| }; | |||
| @@ -64832,7 +64860,7 @@ public: | |||
| the DialogWindow that is created. To find a pointer to this window from your | |||
| contentComponent, you can do something like this: | |||
| @code | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| dw->exitModalState (1234); | |||
| @@ -64875,7 +64903,7 @@ public: | |||
| the DialogWindow that is created. To find a pointer to this window from your | |||
| contentComponent, you can do something like this: | |||
| @code | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| dw->exitModalState (1234); | |||
| @@ -244,7 +244,7 @@ ApplicationCommandTarget* ApplicationCommandManager::findTargetForComponent (Com | |||
| if (target == nullptr && c != nullptr) | |||
| // (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; | |||
| } | |||
| @@ -74,7 +74,7 @@ ApplicationCommandTarget* ApplicationCommandTarget::findFirstTargetParentCompone | |||
| if (c != nullptr) | |||
| // (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; | |||
| } | |||
| @@ -464,7 +464,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg | |||
| 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 | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 53 | |||
| #define JUCE_BUILDNUMBER 73 | |||
| #define JUCE_BUILDNUMBER 74 | |||
| /** Current Juce version number. | |||
| @@ -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) | |||
| { | |||
| @@ -579,7 +578,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in | |||
| { | |||
| if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette) | |||
| { | |||
| ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) 0); | |||
| ToolbarItemPalette* const palette = tc->findParentComponentOfClass ((ToolbarItemPalette*) nullptr); | |||
| if (palette != nullptr) | |||
| palette->replaceComponent (tc); | |||
| @@ -599,7 +598,8 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in | |||
| const int currentIndex = items.indexOf (tc); | |||
| 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 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)) | |||
| { | |||
| @@ -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) | |||
| tc->setState (Button::buttonNormal); | |||
| @@ -806,7 +806,7 @@ private: | |||
| { | |||
| Colour background; | |||
| DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) 0); | |||
| DialogWindow* const dw = findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| background = dw->getBackgroundColour(); | |||
| @@ -279,13 +279,13 @@ public: | |||
| /** @internal */ | |||
| void mouseDown (const MouseEvent&); | |||
| /** @internal */ | |||
| bool isInterestedInDragSource (const String&, Component*); | |||
| bool isInterestedInDragSource (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragMove (const String&, Component*, int, int); | |||
| void itemDragMove (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragExit (const String&, Component*); | |||
| void itemDragExit (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDropped (const String&, Component*, int, int); | |||
| void itemDropped (const SourceDetails&); | |||
| /** @internal */ | |||
| void updateAllItemPositions (bool animate); | |||
| /** @internal */ | |||
| @@ -943,9 +943,10 @@ void TreeView::hideDragHighlight() noexcept | |||
| } | |||
| 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; | |||
| TreeViewItem* item = getItemAt (y); | |||
| @@ -960,7 +961,7 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, | |||
| if (item->getNumSubItems() == 0 || ! item->isOpen()) | |||
| { | |||
| 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.. | |||
| if (oldY > itemPos.getY() + itemPos.getHeight() / 4 | |||
| @@ -996,12 +997,13 @@ TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex, | |||
| 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) | |||
| { | |||
| @@ -1010,7 +1012,7 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip | |||
| || dragInsertPointHighlight->lastIndex != insertIndex) | |||
| { | |||
| if (files.size() > 0 ? item->isInterestedInFileDrag (files) | |||
| : item->isInterestedInDragSource (sourceDescription, sourceComponent)) | |||
| : item->isInterestedInDragSource (dragSourceDetails)) | |||
| showDragHighlight (item, insertIndex, x, y); | |||
| else | |||
| 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(); | |||
| 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) | |||
| { | |||
| @@ -1038,8 +1040,8 @@ void TreeView::handleDrop (const StringArray& files, const String& sourceDescrip | |||
| } | |||
| 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) | |||
| { | |||
| handleDrag (files, String::empty, 0, x, y); | |||
| handleDrag (files, SourceDetails (String::empty, 0, Point<int> (x, y))); | |||
| } | |||
| void TreeView::fileDragExit (const StringArray&) | |||
| @@ -1067,32 +1069,32 @@ void TreeView::fileDragExit (const StringArray&) | |||
| 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; | |||
| } | |||
| 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(); | |||
| } | |||
| 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; | |||
| } | |||
| void TreeViewItem::itemDropped (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*insertIndex*/) | |||
| void TreeViewItem::itemDropped (const DragAndDropTarget::SourceDetails& /*dragSourceDetails*/, int /*insertIndex*/) | |||
| { | |||
| } | |||
| @@ -384,7 +384,7 @@ public: | |||
| To respond to drag-and-drop of files from external applications, see isInterestedInFileDrag(). | |||
| @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. | |||
| @@ -392,7 +392,7 @@ public: | |||
| The insertIndex value indicates where in the list of sub-items the new items should be placed. | |||
| @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 | |||
| @@ -523,6 +523,12 @@ private: | |||
| TreeViewItem* getNextVisibleItem (bool recurse) const noexcept; | |||
| 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); | |||
| }; | |||
| @@ -769,15 +775,15 @@ public: | |||
| /** @internal */ | |||
| void filesDropped (const StringArray& files, int x, int y); | |||
| /** @internal */ | |||
| bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent); | |||
| bool isInterestedInDragSource (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragEnter (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDragEnter (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragMove (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDragMove (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDragExit (const String& sourceDescription, Component* sourceComponent); | |||
| void itemDragExit (const SourceDetails&); | |||
| /** @internal */ | |||
| void itemDropped (const String& sourceDescription, Component* sourceComponent, int x, int y); | |||
| void itemDropped (const SourceDetails&); | |||
| private: | |||
| friend class TreeViewItem; | |||
| @@ -806,11 +812,10 @@ private: | |||
| void updateButtonUnderMouse (const MouseEvent& e); | |||
| void showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) 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, | |||
| 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); | |||
| }; | |||
| @@ -84,7 +84,7 @@ void MultiDocumentPanelWindow::updateOrder() | |||
| MultiDocumentPanel* MultiDocumentPanelWindow::getOwner() const noexcept | |||
| { | |||
| // (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&) | |||
| { | |||
| // (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) | |||
| owner->updateOrder(); | |||
| @@ -1104,7 +1104,7 @@ private: | |||
| PopupMenu::ItemComponent* mic = dynamic_cast <PopupMenu::ItemComponent*> (c); | |||
| if (mic == nullptr && c != nullptr) | |||
| mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) 0); | |||
| mic = c->findParentComponentOfClass ((PopupMenu::ItemComponent*) nullptr); | |||
| if (mic != currentChild | |||
| && (isOver || (activeSubMenu == nullptr) || ! activeSubMenu->isVisible())) | |||
| @@ -51,12 +51,12 @@ public: | |||
| Component* const sourceComponent, | |||
| Component* const mouseDragSource_, | |||
| 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_), | |||
| owner (o), | |||
| dragDesc (desc), | |||
| imageOffset (imageOffset_), | |||
| hasCheckedForExternalDrag (false), | |||
| drawImage (true) | |||
| @@ -64,7 +64,7 @@ public: | |||
| setSize (im.getWidth(), im.getHeight()); | |||
| if (mouseDragSource == nullptr) | |||
| mouseDragSource = source; | |||
| mouseDragSource = sourceComponent; | |||
| mouseDragSource->addMouseListener (this, false); | |||
| @@ -83,8 +83,10 @@ public: | |||
| { | |||
| 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()); | |||
| } | |||
| // (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) | |||
| const String dragDescLocal (dragDesc); | |||
| const DragAndDropTarget::SourceDetails details (sourceDetails); | |||
| while (hit != nullptr) | |||
| { | |||
| 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); | |||
| return ddt; | |||
| @@ -156,13 +158,13 @@ public: | |||
| setVisible (true); | |||
| if (dropAccepted || source == nullptr) | |||
| if (dropAccepted || sourceDetails.sourceComponent == nullptr) | |||
| { | |||
| Desktop::getInstance().getAnimator().fadeOut (this, 120); | |||
| } | |||
| 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())); | |||
| Desktop::getInstance().getAnimator().animateComponent (this, | |||
| @@ -177,13 +179,14 @@ public: | |||
| 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) | |||
| const String dragDescLocal (dragDesc); | |||
| DragAndDropTarget::SourceDetails details (sourceDetails); | |||
| details.localPosition = relPos; | |||
| currentlyOverComp = nullptr; | |||
| ddt->itemDropped (dragDescLocal, source, relPos.getX(), relPos.getY()); | |||
| ddt->itemDropped (details); | |||
| } | |||
| // careful - this object could now be deleted.. | |||
| @@ -192,9 +195,9 @@ public: | |||
| 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); | |||
| @@ -206,29 +209,41 @@ public: | |||
| setTopLeftPosition (newPos.getX(), newPos.getY()); | |||
| 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 (Desktop::getInstance().findComponentAt (screenPos) == nullptr) | |||
| @@ -237,7 +252,7 @@ public: | |||
| StringArray files; | |||
| bool canMoveFiles = false; | |||
| if (owner->shouldDropFilesWhenDraggedExternally (dragDescLocal, source, files, canMoveFiles) | |||
| if (owner->shouldDropFilesWhenDraggedExternally (details, files, canMoveFiles) | |||
| && files.size() > 0) | |||
| { | |||
| WeakReference<Component> thisWeakRef (this); | |||
| @@ -262,7 +277,7 @@ public: | |||
| void timerCallback() | |||
| { | |||
| if (source == nullptr) | |||
| if (sourceDetails.sourceComponent == nullptr) | |||
| { | |||
| delete this; | |||
| } | |||
| @@ -276,8 +291,8 @@ public: | |||
| } | |||
| private: | |||
| DragAndDropTarget::SourceDetails sourceDetails; | |||
| Image image; | |||
| WeakReference<Component> source; | |||
| WeakReference<Component> mouseDragSource; | |||
| DragAndDropContainer* const owner; | |||
| @@ -287,7 +302,6 @@ private: | |||
| return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); | |||
| } | |||
| String dragDesc; | |||
| const Point<int> imageOffset; | |||
| bool hasCheckedForExternalDrag, drawImage; | |||
| @@ -309,7 +323,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| Component* sourceComponent, | |||
| const Image& dragImage_, | |||
| const bool allowDraggingToExternalWindows, | |||
| const Point<int>* imageOffsetFromMouse) | |||
| const Point<int>* imageOffsetFromMouse, | |||
| ReferenceCountedObject* customDataObject) | |||
| { | |||
| Image dragImage (dragImage_); | |||
| @@ -378,7 +393,8 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| } | |||
| dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent, | |||
| draggingSource->getComponentUnderMouse(), this, imageOffset); | |||
| draggingSource->getComponentUnderMouse(), this, | |||
| imageOffset, customDataObject); | |||
| currentDragDesc = sourceDescription; | |||
| @@ -420,46 +436,33 @@ const String DragAndDropContainer::getCurrentDragDescription() const | |||
| 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; | |||
| } | |||
| //============================================================================== | |||
| 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 | |||
| @@ -73,10 +73,9 @@ public: | |||
| findParentDragContainerFor() is a handy method to call to find the | |||
| 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 dragImage the image to drag around underneath the mouse. If this is a null image, | |||
| 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 | |||
| specified, then the image will be centred around the mouse. If | |||
| 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, | |||
| Component* sourceComponent, | |||
| const Image& dragImage = Image::null, | |||
| bool allowDraggingToOtherJuceWindows = false, | |||
| const Point<int>* imageOffsetFromMouse = nullptr); | |||
| const Point<int>* imageOffsetFromMouse = nullptr, | |||
| ReferenceCountedObject* customDataObject = nullptr); | |||
| /** Returns true if something is currently being dragged. */ | |||
| bool isDragAndDropActive() const; | |||
| @@ -168,8 +171,7 @@ protected: | |||
| method) | |||
| @see performExternalDragDropOfFiles | |||
| */ | |||
| virtual bool shouldDropFilesWhenDraggedExternally (const String& dragSourceDescription, | |||
| Component* dragSourceComponent, | |||
| virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails, | |||
| StringArray& files, | |||
| bool& canMoveFiles); | |||
| @@ -179,6 +181,8 @@ private: | |||
| ScopedPointer <Component> dragImageComponent; | |||
| String currentDragDesc; | |||
| JUCE_DEPRECATED (virtual bool shouldDropFilesWhenDraggedExternally (const String&, Component*, StringArray&, bool&)) { return false; } | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer); | |||
| }; | |||
| @@ -49,16 +49,44 @@ public: | |||
| /** Destructor. */ | |||
| 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 | |||
| 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 | |||
| 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. | |||
| @@ -68,15 +96,10 @@ public: | |||
| 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. | |||
| @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 | |||
| */ | |||
| 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. | |||
| @@ -84,14 +107,9 @@ public: | |||
| something. Normally overriding itemDragEnter() and itemDragExit() are enough, but | |||
| 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. | |||
| @@ -101,12 +119,10 @@ public: | |||
| If you've used itemDragEnter() to repaint your component and give feedback, use this | |||
| 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 | |||
| */ | |||
| 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. | |||
| @@ -116,14 +132,9 @@ public: | |||
| 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. | |||
| @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 | |||
| 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. | |||
| */ | |||
| 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__ | |||
| @@ -97,7 +97,7 @@ public: | |||
| for (int i = propertyComps.size(); --i >= 0;) | |||
| propertyComps.getUnchecked(i)->setVisible (open); | |||
| PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) 0); | |||
| PropertyPanel* const pp = findParentComponentOfClass ((PropertyPanel*) nullptr); | |||
| if (pp != nullptr) | |||
| pp->resized(); | |||
| @@ -87,7 +87,7 @@ public: | |||
| the DialogWindow that is created. To find a pointer to this window from your | |||
| contentComponent, you can do something like this: | |||
| @code | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| dw->exitModalState (1234); | |||
| @@ -130,7 +130,7 @@ public: | |||
| the DialogWindow that is created. To find a pointer to this window from your | |||
| contentComponent, you can do something like this: | |||
| @code | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); | |||
| Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) nullptr); | |||
| if (dw != nullptr) | |||
| dw->exitModalState (1234); | |||
| @@ -85,22 +85,35 @@ void TooltipWindow::showFor (const String& tip) | |||
| tipShowing = tip; | |||
| Point<int> mousePos (Desktop::getMousePosition()); | |||
| Rectangle<int> parentArea; | |||
| if (getParentComponent() != nullptr) | |||
| { | |||
| 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); | |||
| if (mousePos.getX() > getParentWidth() / 2) | |||
| x = mousePos.getX() - (w + 12); | |||
| int x = mousePos.getX(); | |||
| if (x > parentArea.getCentreX()) | |||
| x -= (w + 12); | |||
| 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 | |||
| 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); | |||
| setVisible (true); | |||
| @@ -71,7 +71,7 @@ public: | |||
| if (tlw == nullptr && c != nullptr) | |||
| // (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) | |||
| active = tlw; | |||