diff --git a/extras/audio plugins/wrapper/juce_PluginHeaders.h b/extras/audio plugins/wrapper/juce_PluginHeaders.h index e8633a452e..d45b9c1c62 100644 --- a/extras/audio plugins/wrapper/juce_PluginHeaders.h +++ b/extras/audio plugins/wrapper/juce_PluginHeaders.h @@ -26,6 +26,8 @@ #include "juce_IncludeCharacteristics.h" #include "../../../juce_amalgamated.h" +#ifndef __JUCE_PLUGINHEADERS_JUCEHEADER__ +#define __JUCE_PLUGINHEADERS_JUCEHEADER__ #if JUCE_MAC && JUCE_SUPPORT_CARBON @@ -70,3 +72,5 @@ private: #else struct FakeMouseMoveGenerator {}; #endif + +#endif diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index 24d1752472..40e1e7e252 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -163,7 +163,7 @@ private: }; //============================================================================== -class CustomMenuComponent : public PopupMenuCustomComponent, +class CustomMenuComponent : public PopupMenu::CustomComponent, public Timer { public: diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 39a55ae2c8..0f34c6119c 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -48483,10 +48483,6 @@ public: content->setWantsKeyboardFocus (false); } - ~ListViewport() - { - } - ListBoxRowComponent* getComponentForRow (const int row) const throw() { return rows [row % jmax (1, rows.size())]; @@ -48510,7 +48506,7 @@ public: return -1; } - void visibleAreaChanged (int, int, int, int) + void visibleAreaChanged (const Rectangle&) { updateVisibleArea (true); @@ -52428,10 +52424,6 @@ public: { } - ~Iterator() - { - } - bool next() { if (atom == &tempAtom) @@ -52948,35 +52940,31 @@ private: class TextEditorViewport : public Viewport { public: - TextEditorViewport (TextEditor* const owner_) + TextEditorViewport (TextEditor& owner_) : owner (owner_), lastWordWrapWidth (0), rentrant (false) { } - ~TextEditorViewport() - { - } - - void visibleAreaChanged (int, int, int, int) + void visibleAreaChanged (const Rectangle&) { if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars // appear and disappear, causing the wrap width to change. { - const float wordWrapWidth = owner->getWordWrapWidth(); + const float wordWrapWidth = owner.getWordWrapWidth(); if (wordWrapWidth != lastWordWrapWidth) { lastWordWrapWidth = wordWrapWidth; rentrant = true; - owner->updateTextHolderSize(); + owner.updateTextHolderSize(); rentrant = false; } } } private: - TextEditor* const owner; + TextEditor& owner; float lastWordWrapWidth; bool rentrant; @@ -53034,7 +53022,7 @@ TextEditor::TextEditor (const String& name, { setOpaque (true); - addAndMakeVisible (viewport = new TextEditorViewport (this)); + addAndMakeVisible (viewport = new TextEditorViewport (*this)); viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); viewport->setWantsKeyboardFocus (false); viewport->setScrollBarsShown (false, false); @@ -55784,10 +55772,6 @@ public: { } - ~TreeViewContentComponent() - { - } - void mouseDown (const MouseEvent& e) { updateButtonUnderMouse (e); @@ -56168,7 +56152,6 @@ class TreeView::TreeViewport : public Viewport { public: TreeViewport() throw() : lastX (-1) {} - ~TreeViewport() throw() {} void updateComponents (const bool triggerResize = false) { @@ -56184,10 +56167,10 @@ public: repaint(); } - void visibleAreaChanged (int x, int, int, int) + void visibleAreaChanged (const Rectangle& newVisibleArea) { - const bool hasScrolledSideways = (x != lastX); - lastX = x; + const bool hasScrolledSideways = (newVisibleArea.getX() != lastX); + lastX = newVisibleArea.getX(); updateComponents (hasScrolledSideways); } @@ -64508,7 +64491,7 @@ Viewport::~Viewport() deleteContentComp(); } -void Viewport::visibleAreaChanged (int, int, int, int) +void Viewport::visibleAreaChanged (const Rectangle&) { } @@ -64529,8 +64512,8 @@ void Viewport::setViewedComponent (Component* const newViewedComponent) if (contentComp != 0) { - contentComp->setTopLeftPosition (0, 0); contentHolder.addAndMakeVisible (contentComp); + setViewPosition (0, 0); contentComp->addComponentListener (this); } @@ -64654,9 +64637,9 @@ void Viewport::updateVisibleArea() Rectangle contentBounds; if (contentComp != 0) - contentBounds = contentComp->getBounds(); + contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds()); - const Point visibleOrigin (-contentBounds.getPosition()); + Point visibleOrigin (-contentBounds.getPosition()); if (hBarVisible) { @@ -64666,6 +64649,10 @@ void Viewport::updateVisibleArea() horizontalScrollBar.setSingleStepSize (singleStepX); horizontalScrollBar.cancelPendingUpdate(); } + else + { + visibleOrigin.setX (0); + } if (vBarVisible) { @@ -64675,11 +64662,17 @@ void Viewport::updateVisibleArea() verticalScrollBar.setSingleStepSize (singleStepY); verticalScrollBar.cancelPendingUpdate(); } + else + { + visibleOrigin.setY (0); + } // Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers. horizontalScrollBar.setVisible (hBarVisible); verticalScrollBar.setVisible (vBarVisible); + setViewPosition (visibleOrigin); + const Rectangle visibleArea (visibleOrigin.getX(), visibleOrigin.getY(), jmin (contentBounds.getWidth() - visibleOrigin.getX(), contentArea.getWidth()), jmin (contentBounds.getHeight() - visibleOrigin.getY(), contentArea.getHeight())); @@ -64687,7 +64680,7 @@ void Viewport::updateVisibleArea() if (lastVisibleArea != visibleArea) { lastVisibleArea = visibleArea; - visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight()); + visibleAreaChanged (visibleArea); } horizontalScrollBar.handleUpdateNowIfNeeded(); @@ -77287,6 +77280,32 @@ void ComponentPeer::handleFileDragExit (const StringArray& files) lastDragAndDropCompUnderMouse = 0; } +// We'll use an async message to deliver the drop, because if the target decides +// to run a modal loop, it can gum-up the operating system.. +class AsyncFileDropMessage : public CallbackMessage +{ +public: + AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_, + const Point& position_, const StringArray& files_) + : target (target_), dropTarget (dropTarget_), position (position_), files (files_) + { + } + + void messageCallback() + { + if (target != 0) + dropTarget->filesDropped (files, position.getX(), position.getY()); + } + +private: + WeakReference target; + FileDragAndDropTarget* const dropTarget; + const Point position; + const StringArray files; + + JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage); +}; + void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position) { handleFileDragMove (files, position); @@ -77311,32 +77330,6 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position_, const StringArray& files_) - : target (target_), dropTarget (dropTarget_), position (position_), files (files_) - { - } - - void messageCallback() - { - if (target != 0) - dropTarget->filesDropped (files, position.getX(), position.getY()); - } - - private: - WeakReference target; - FileDragAndDropTarget* dropTarget; - Point position; - StringArray files; - - // (NB: don't make this non-copyable, which messes up in VC) - }; - (new AsyncFileDropMessage (targetComp, target, targetComp->getLocalPoint (component, position), files))->post(); } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index c9932de171..adcbe8aea3 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -37855,8 +37855,7 @@ public: This will be called when the visible area is moved either be scrolling or by calls to setViewPosition(), etc. */ - virtual void visibleAreaChanged (int visibleX, int visibleY, - int visibleW, int visibleH); + virtual void visibleAreaChanged (const Rectangle& newVisibleArea); /** Turns scrollbars on or off. @@ -37938,6 +37937,11 @@ private: void updateVisibleArea(); void deleteContentComp(); + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // If you get an error here, it's because this method's parameters have changed! See the new definition above.. + virtual int visibleAreaChanged (int, int, int, int) { return 0; } + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Viewport); }; diff --git a/src/gui/components/controls/juce_ListBox.cpp b/src/gui/components/controls/juce_ListBox.cpp index 547d1aa283..4614a287d4 100644 --- a/src/gui/components/controls/juce_ListBox.cpp +++ b/src/gui/components/controls/juce_ListBox.cpp @@ -169,10 +169,6 @@ public: content->setWantsKeyboardFocus (false); } - ~ListViewport() - { - } - ListBoxRowComponent* getComponentForRow (const int row) const throw() { return rows [row % jmax (1, rows.size())]; @@ -196,7 +192,7 @@ public: return -1; } - void visibleAreaChanged (int, int, int, int) + void visibleAreaChanged (const Rectangle&) { updateVisibleArea (true); diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 88da68300a..b57ef0fe34 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -382,10 +382,6 @@ public: { } - ~Iterator() - { - } - //============================================================================== bool next() { @@ -912,35 +908,31 @@ private: class TextEditorViewport : public Viewport { public: - TextEditorViewport (TextEditor* const owner_) + TextEditorViewport (TextEditor& owner_) : owner (owner_), lastWordWrapWidth (0), rentrant (false) { } - ~TextEditorViewport() - { - } - - void visibleAreaChanged (int, int, int, int) + void visibleAreaChanged (const Rectangle&) { if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars // appear and disappear, causing the wrap width to change. { - const float wordWrapWidth = owner->getWordWrapWidth(); + const float wordWrapWidth = owner.getWordWrapWidth(); if (wordWrapWidth != lastWordWrapWidth) { lastWordWrapWidth = wordWrapWidth; rentrant = true; - owner->updateTextHolderSize(); + owner.updateTextHolderSize(); rentrant = false; } } } private: - TextEditor* const owner; + TextEditor& owner; float lastWordWrapWidth; bool rentrant; @@ -1000,7 +992,7 @@ TextEditor::TextEditor (const String& name, { setOpaque (true); - addAndMakeVisible (viewport = new TextEditorViewport (this)); + addAndMakeVisible (viewport = new TextEditorViewport (*this)); viewport->setViewedComponent (textHolder = new TextHolderComponent (*this)); viewport->setWantsKeyboardFocus (false); viewport->setScrollBarsShown (false, false); diff --git a/src/gui/components/controls/juce_TreeView.cpp b/src/gui/components/controls/juce_TreeView.cpp index 0fe56a752e..203d23735c 100644 --- a/src/gui/components/controls/juce_TreeView.cpp +++ b/src/gui/components/controls/juce_TreeView.cpp @@ -47,10 +47,6 @@ public: { } - ~TreeViewContentComponent() - { - } - void mouseDown (const MouseEvent& e) { updateButtonUnderMouse (e); @@ -432,7 +428,6 @@ class TreeView::TreeViewport : public Viewport { public: TreeViewport() throw() : lastX (-1) {} - ~TreeViewport() throw() {} void updateComponents (const bool triggerResize = false) { @@ -448,10 +443,10 @@ public: repaint(); } - void visibleAreaChanged (int x, int, int, int) + void visibleAreaChanged (const Rectangle& newVisibleArea) { - const bool hasScrolledSideways = (x != lastX); - lastX = x; + const bool hasScrolledSideways = (newVisibleArea.getX() != lastX); + lastX = newVisibleArea.getX(); updateComponents (hasScrolledSideways); } diff --git a/src/gui/components/layout/juce_Viewport.cpp b/src/gui/components/layout/juce_Viewport.cpp index dc599e42af..630abd6037 100644 --- a/src/gui/components/layout/juce_Viewport.cpp +++ b/src/gui/components/layout/juce_Viewport.cpp @@ -62,7 +62,7 @@ Viewport::~Viewport() } //============================================================================== -void Viewport::visibleAreaChanged (int, int, int, int) +void Viewport::visibleAreaChanged (const Rectangle&) { } @@ -84,8 +84,8 @@ void Viewport::setViewedComponent (Component* const newViewedComponent) if (contentComp != 0) { - contentComp->setTopLeftPosition (0, 0); contentHolder.addAndMakeVisible (contentComp); + setViewPosition (0, 0); contentComp->addComponentListener (this); } @@ -210,9 +210,9 @@ void Viewport::updateVisibleArea() Rectangle contentBounds; if (contentComp != 0) - contentBounds = contentComp->getBounds(); + contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds()); - const Point visibleOrigin (-contentBounds.getPosition()); + Point visibleOrigin (-contentBounds.getPosition()); if (hBarVisible) { @@ -222,6 +222,10 @@ void Viewport::updateVisibleArea() horizontalScrollBar.setSingleStepSize (singleStepX); horizontalScrollBar.cancelPendingUpdate(); } + else + { + visibleOrigin.setX (0); + } if (vBarVisible) { @@ -231,11 +235,17 @@ void Viewport::updateVisibleArea() verticalScrollBar.setSingleStepSize (singleStepY); verticalScrollBar.cancelPendingUpdate(); } + else + { + visibleOrigin.setY (0); + } // Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers. horizontalScrollBar.setVisible (hBarVisible); verticalScrollBar.setVisible (vBarVisible); + setViewPosition (visibleOrigin); + const Rectangle visibleArea (visibleOrigin.getX(), visibleOrigin.getY(), jmin (contentBounds.getWidth() - visibleOrigin.getX(), contentArea.getWidth()), jmin (contentBounds.getHeight() - visibleOrigin.getY(), contentArea.getHeight())); @@ -243,7 +253,7 @@ void Viewport::updateVisibleArea() if (lastVisibleArea != visibleArea) { lastVisibleArea = visibleArea; - visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight()); + visibleAreaChanged (visibleArea); } horizontalScrollBar.handleUpdateNowIfNeeded(); diff --git a/src/gui/components/layout/juce_Viewport.h b/src/gui/components/layout/juce_Viewport.h index 242f8c8bae..c8d41cf9b8 100644 --- a/src/gui/components/layout/juce_Viewport.h +++ b/src/gui/components/layout/juce_Viewport.h @@ -179,8 +179,7 @@ public: This will be called when the visible area is moved either be scrolling or by calls to setViewPosition(), etc. */ - virtual void visibleAreaChanged (int visibleX, int visibleY, - int visibleW, int visibleH); + virtual void visibleAreaChanged (const Rectangle& newVisibleArea); //============================================================================== /** Turns scrollbars on or off. @@ -265,6 +264,11 @@ private: void updateVisibleArea(); void deleteContentComp(); + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // If you get an error here, it's because this method's parameters have changed! See the new definition above.. + virtual int visibleAreaChanged (int, int, int, int) { return 0; } + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Viewport); }; diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index cf680f36f7..ea866ea233 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -484,6 +484,32 @@ void ComponentPeer::handleFileDragExit (const StringArray& files) lastDragAndDropCompUnderMouse = 0; } +// We'll use an async message to deliver the drop, because if the target decides +// to run a modal loop, it can gum-up the operating system.. +class AsyncFileDropMessage : public CallbackMessage +{ +public: + AsyncFileDropMessage (Component* target_, FileDragAndDropTarget* dropTarget_, + const Point& position_, const StringArray& files_) + : target (target_), dropTarget (dropTarget_), position (position_), files (files_) + { + } + + void messageCallback() + { + if (target != 0) + dropTarget->filesDropped (files, position.getX(), position.getY()); + } + +private: + WeakReference target; + FileDragAndDropTarget* const dropTarget; + const Point position; + const StringArray files; + + JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage); +}; + void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position) { handleFileDragMove (files, position); @@ -508,32 +534,6 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point& position_, const StringArray& files_) - : target (target_), dropTarget (dropTarget_), position (position_), files (files_) - { - } - - void messageCallback() - { - if (target != 0) - dropTarget->filesDropped (files, position.getX(), position.getY()); - } - - private: - WeakReference target; - FileDragAndDropTarget* dropTarget; - Point position; - StringArray files; - - // (NB: don't make this non-copyable, which messes up in VC) - }; - (new AsyncFileDropMessage (targetComp, target, targetComp->getLocalPoint (component, position), files))->post(); } }