mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Viewport positioning fix. Changed parameters of Viewport::visibleAreaChanged(). Small plugin header fix.
This commit is contained in:
parent
5d30aecaf2
commit
efd1e4c88a
10 changed files with 119 additions and 121 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class CustomMenuComponent : public PopupMenuCustomComponent,
|
||||
class CustomMenuComponent : public PopupMenu::CustomComponent,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -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<int>&)
|
||||
{
|
||||
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<int>&)
|
||||
{
|
||||
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<int>& 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<int>&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -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<int> contentBounds;
|
||||
if (contentComp != 0)
|
||||
contentBounds = contentComp->getBounds();
|
||||
contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds());
|
||||
|
||||
const Point<int> visibleOrigin (-contentBounds.getPosition());
|
||||
Point<int> 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<int> 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<int>& 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<Component> target;
|
||||
FileDragAndDropTarget* const dropTarget;
|
||||
const Point<int> position;
|
||||
const StringArray files;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage);
|
||||
};
|
||||
|
||||
void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<int>& position)
|
||||
{
|
||||
handleFileDragMove (files, position);
|
||||
|
|
@ -77311,32 +77330,6 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<in
|
|||
return;
|
||||
}
|
||||
|
||||
// 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<int>& 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<Component> target;
|
||||
FileDragAndDropTarget* dropTarget;
|
||||
Point<int> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<int>& 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);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int>&)
|
||||
{
|
||||
updateVisibleArea (true);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int>&)
|
||||
{
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<int>& newVisibleArea)
|
||||
{
|
||||
const bool hasScrolledSideways = (x != lastX);
|
||||
lastX = x;
|
||||
const bool hasScrolledSideways = (newVisibleArea.getX() != lastX);
|
||||
lastX = newVisibleArea.getX();
|
||||
updateComponents (hasScrolledSideways);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ Viewport::~Viewport()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void Viewport::visibleAreaChanged (int, int, int, int)
|
||||
void Viewport::visibleAreaChanged (const Rectangle<int>&)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -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<int> contentBounds;
|
||||
if (contentComp != 0)
|
||||
contentBounds = contentComp->getBounds();
|
||||
contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds());
|
||||
|
||||
const Point<int> visibleOrigin (-contentBounds.getPosition());
|
||||
Point<int> 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<int> 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();
|
||||
|
|
|
|||
|
|
@ -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<int>& 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);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int>& 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<Component> target;
|
||||
FileDragAndDropTarget* const dropTarget;
|
||||
const Point<int> position;
|
||||
const StringArray files;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (AsyncFileDropMessage);
|
||||
};
|
||||
|
||||
void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<int>& position)
|
||||
{
|
||||
handleFileDragMove (files, position);
|
||||
|
|
@ -508,32 +534,6 @@ void ComponentPeer::handleFileDragDrop (const StringArray& files, const Point<in
|
|||
return;
|
||||
}
|
||||
|
||||
// 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<int>& 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<Component> target;
|
||||
FileDragAndDropTarget* dropTarget;
|
||||
Point<int> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue