1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-07 04:10:08 +00:00

Viewport positioning fix. Changed parameters of Viewport::visibleAreaChanged(). Small plugin header fix.

This commit is contained in:
Julian Storer 2011-01-10 12:33:38 +00:00
parent 5d30aecaf2
commit efd1e4c88a
10 changed files with 119 additions and 121 deletions

View file

@ -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();
}
}