mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-18 00:54:19 +00:00
Added ListenerList class and changed some components to use it for their listener dispatching. Sorted out bug in popup menus and win32 mouse wheel.
This commit is contained in:
parent
b974203d0f
commit
2676bb02f2
42 changed files with 1815 additions and 1867 deletions
|
|
@ -50,9 +50,11 @@ Component* Component::currentlyFocusedComponent = 0;
|
|||
static Array <Component*> modalComponentStack, modalComponentReturnValueKeys;
|
||||
static Array <int> modalReturnValues;
|
||||
|
||||
static const int customCommandMessage = 0x7fff0001;
|
||||
static const int exitModalStateMessage = 0x7fff0002;
|
||||
|
||||
enum ComponentMessageNumbers
|
||||
{
|
||||
customCommandMessage = 0x7fff0001,
|
||||
exitModalStateMessage = 0x7fff0002
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
#define checkMessageManagerIsLocked jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());
|
||||
|
|
@ -70,7 +72,6 @@ Component::Component() throw()
|
|||
bufferedImage_ (0),
|
||||
mouseListeners_ (0),
|
||||
keyListeners_ (0),
|
||||
componentListeners_ (0),
|
||||
componentFlags_ (0)
|
||||
{
|
||||
}
|
||||
|
|
@ -85,23 +86,13 @@ Component::Component (const String& name) throw()
|
|||
bufferedImage_ (0),
|
||||
mouseListeners_ (0),
|
||||
keyListeners_ (0),
|
||||
componentListeners_ (0),
|
||||
componentFlags_ (0)
|
||||
{
|
||||
}
|
||||
|
||||
Component::~Component()
|
||||
{
|
||||
if (componentListeners_ != 0)
|
||||
{
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentBeingDeleted (*this);
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
componentListeners.call (&ComponentListener::componentBeingDeleted, *this);
|
||||
|
||||
if (parentComponent_ != 0)
|
||||
{
|
||||
|
|
@ -124,7 +115,6 @@ Component::~Component()
|
|||
delete bufferedImage_;
|
||||
delete mouseListeners_;
|
||||
delete keyListeners_;
|
||||
delete componentListeners_;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -147,22 +137,8 @@ void Component::setName (const String& name)
|
|||
peer->setTitle (name);
|
||||
}
|
||||
|
||||
if (componentListeners_ != 0)
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentNameChanged (*this);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
|
||||
BailOutChecker checker (this);
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentNameChanged, *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,23 +192,12 @@ void Component::visibilityChanged()
|
|||
|
||||
void Component::sendVisibilityChangeMessage()
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
visibilityChanged();
|
||||
|
||||
if (safePointer != 0 && componentListeners_ != 0)
|
||||
{
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentVisibilityChanged (*this);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
if (! checker.shouldBailOut())
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentVisibilityChanged, *this);
|
||||
}
|
||||
|
||||
bool Component::isShowing() const throw()
|
||||
|
|
@ -903,24 +868,14 @@ void Component::sendMovedResizedMessages (const bool wasMoved, const bool wasRes
|
|||
}
|
||||
}
|
||||
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (parentComponent_ != 0)
|
||||
parentComponent_->childBoundsChanged (this);
|
||||
|
||||
if (componentListeners_ != 0)
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentMovedOrResized (*this, wasMoved, wasResized);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
if (! checker.shouldBailOut())
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentMovedOrResized,
|
||||
*this, wasMoved, wasResized);
|
||||
}
|
||||
JUCE_CATCH_EXCEPTION
|
||||
}
|
||||
|
|
@ -1288,7 +1243,13 @@ Component* Component::getTopLevelComponent() const throw()
|
|||
|
||||
bool Component::isParentOf (const Component* possibleChild) const throw()
|
||||
{
|
||||
while (possibleChild->isValidComponent())
|
||||
if (! possibleChild->isValidComponent())
|
||||
{
|
||||
jassert (possibleChild == 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (possibleChild != 0)
|
||||
{
|
||||
possibleChild = possibleChild->parentComponent_;
|
||||
|
||||
|
|
@ -1310,58 +1271,46 @@ void Component::childrenChanged()
|
|||
|
||||
void Component::internalChildrenChanged()
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
const bool hasListeners = componentListeners_ != 0;
|
||||
|
||||
childrenChanged();
|
||||
|
||||
if (hasListeners)
|
||||
if (componentListeners.isEmpty())
|
||||
{
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
childrenChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
BailOutChecker checker (this);
|
||||
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentChildrenChanged (*this);
|
||||
childrenChanged();
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
if (! checker.shouldBailOut())
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentChildrenChanged, *this);
|
||||
}
|
||||
}
|
||||
|
||||
void Component::internalHierarchyChanged()
|
||||
{
|
||||
BailOutChecker checker (this);
|
||||
|
||||
parentHierarchyChanged();
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (componentListeners_ != 0)
|
||||
{
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentParentHierarchyChanged (*this);
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentParentHierarchyChanged, *this);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
for (int i = childComponentList_.size(); --i >= 0;)
|
||||
{
|
||||
childComponentList_.getUnchecked (i)->internalHierarchyChanged();
|
||||
|
||||
// you really shouldn't delete the parent component during a callback telling you
|
||||
// that it's changed..
|
||||
jassert (safePointer != 0);
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
{
|
||||
// you really shouldn't delete the parent component during a callback telling you
|
||||
// that it's changed..
|
||||
jassertfalse;
|
||||
return;
|
||||
}
|
||||
|
||||
i = jmin (i, childComponentList_.size());
|
||||
}
|
||||
|
|
@ -2077,18 +2026,14 @@ void Component::parentSizeChanged()
|
|||
|
||||
void Component::addComponentListener (ComponentListener* const newListener) throw()
|
||||
{
|
||||
if (componentListeners_ == 0)
|
||||
componentListeners_ = new VoidArray();
|
||||
|
||||
componentListeners_->addIfNotAlreadyThere (newListener);
|
||||
componentListeners.add (newListener);
|
||||
}
|
||||
|
||||
void Component::removeComponentListener (ComponentListener* const listenerToRemove) throw()
|
||||
{
|
||||
jassert (isValidComponent());
|
||||
|
||||
if (componentListeners_ != 0)
|
||||
componentListeners_->removeValue (listenerToRemove);
|
||||
componentListeners.remove (listenerToRemove);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -2204,13 +2149,13 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>&
|
|||
return;
|
||||
}
|
||||
|
||||
if (isValidComponent() && ! flags.mouseInsideFlag)
|
||||
if (! flags.mouseInsideFlag)
|
||||
{
|
||||
flags.mouseInsideFlag = true;
|
||||
flags.mouseOverFlag = true;
|
||||
flags.draggingFlag = false;
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (flags.repaintOnMouseActivityFlag)
|
||||
repaint();
|
||||
|
|
@ -2221,20 +2166,14 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>&
|
|||
|
||||
mouseEnter (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
Desktop::getInstance().resetTimer();
|
||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me);
|
||||
|
||||
for (int i = Desktop::getInstance().mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) Desktop::getInstance().mouseListeners[i])->mouseEnter (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, Desktop::getInstance().mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2242,7 +2181,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>&
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked(i))->mouseEnter (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2253,16 +2192,19 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>&
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked(i)))->mouseEnter (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked(i)))->mouseEnter (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2272,13 +2214,13 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>&
|
|||
|
||||
void Component::internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time)
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (flags.draggingFlag)
|
||||
{
|
||||
internalMouseUp (source, relativePos, time, source.getCurrentModifiers().getRawFlags());
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2296,20 +2238,14 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r
|
|||
time, 0, false);
|
||||
mouseExit (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
Desktop::getInstance().resetTimer();
|
||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseExit, me);
|
||||
|
||||
for (int i = Desktop::getInstance().mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) Desktop::getInstance().mouseListeners[i])->mouseExit (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, Desktop::getInstance().mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2317,7 +2253,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseExit (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2328,16 +2264,19 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseExit (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseExit (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2406,13 +2345,13 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (isCurrentlyBlockedByAnotherModalComponent())
|
||||
{
|
||||
internalModalInputAttempt();
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
// If processing the input attempt has exited the modal loop, we'll allow the event
|
||||
|
|
@ -2425,17 +2364,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
source.getNumberOfMultipleClicks(), false);
|
||||
|
||||
desktop.resetTimer();
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseDown (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2449,7 +2378,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
c->toFront (true);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2461,7 +2390,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
grabFocusInternal (focusChangedByMouseClick);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2476,20 +2405,14 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
source.getNumberOfMultipleClicks(), false);
|
||||
mouseDown (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
desktop.resetTimer();
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me);
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseDown (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2497,7 +2420,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDown (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2508,16 +2431,19 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDown (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDown (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2527,13 +2453,13 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r
|
|||
//==============================================================================
|
||||
void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers)
|
||||
{
|
||||
if (isValidComponent() && flags.draggingFlag)
|
||||
if (flags.draggingFlag)
|
||||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
|
||||
flags.draggingFlag = false;
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (flags.repaintOnMouseActivityFlag)
|
||||
repaint();
|
||||
|
|
@ -2547,20 +2473,14 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
|
||||
mouseUp (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
desktop.resetTimer();
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me);
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseUp (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2568,7 +2488,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseUp (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2580,16 +2500,19 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseUp (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseUp (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2603,20 +2526,17 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
|
||||
mouseDoubleClick (me);
|
||||
|
||||
int i;
|
||||
for (i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseDoubleClick (me);
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
for (int i = numListeners; --i >= 0;)
|
||||
{
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
|
||||
for (i = numListeners; --i >= 0;)
|
||||
{
|
||||
if (safePointer == 0 || mouseListeners_ == 0)
|
||||
if (mouseListeners_ == 0)
|
||||
return;
|
||||
|
||||
MouseListener* const ml = (MouseListener*)((*mouseListeners_)[i]);
|
||||
|
|
@ -2624,23 +2544,26 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
ml->mouseDoubleClick (me);
|
||||
}
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
Component* p = parentComponent_;
|
||||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDoubleClick (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDoubleClick (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2651,13 +2574,13 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel
|
|||
|
||||
void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& relativePos, const Time& time)
|
||||
{
|
||||
if (isValidComponent() && flags.draggingFlag)
|
||||
if (flags.draggingFlag)
|
||||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
|
||||
flags.mouseOverFlag = reallyContains (relativePos.getX(), relativePos.getY(), false);
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
const MouseEvent me (source, relativePos,
|
||||
source.getCurrentModifiers(), this, time,
|
||||
|
|
@ -2668,20 +2591,14 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r
|
|||
|
||||
mouseDrag (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
desktop.resetTimer();
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me);
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseDrag (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2689,7 +2606,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDrag (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2700,16 +2617,19 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDrag (me);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDrag (me);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2719,73 +2639,66 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r
|
|||
|
||||
void Component::internalMouseMove (MouseInputSource& source, const Point<int>& relativePos, const Time& time)
|
||||
{
|
||||
SafePointer<Component> safePointer (this);
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
BailOutChecker checker (this);
|
||||
|
||||
if (isValidComponent())
|
||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(),
|
||||
this, time, relativePos,
|
||||
time, 0, false);
|
||||
|
||||
if (isCurrentlyBlockedByAnotherModalComponent())
|
||||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
// allow blocked mouse-events to go to global listeners..
|
||||
desktop.sendMouseMove();
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.mouseOverFlag = true;
|
||||
|
||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(),
|
||||
this, time, relativePos,
|
||||
time, 0, false);
|
||||
mouseMove (me);
|
||||
|
||||
if (isCurrentlyBlockedByAnotherModalComponent())
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
desktop.resetTimer();
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me);
|
||||
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
// allow blocked mouse-events to go to global listeners..
|
||||
desktop.sendMouseMove();
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.mouseOverFlag = true;
|
||||
|
||||
mouseMove (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
desktop.resetTimer();
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
for (int i = mouseListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseMove (me);
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseMove (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
Component* p = parentComponent_;
|
||||
|
||||
while (p != 0)
|
||||
{
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
for (int i = mouseListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseMove (me);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
}
|
||||
}
|
||||
|
||||
Component* p = parentComponent_;
|
||||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseMove (me);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2794,7 +2707,7 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>&
|
|||
const Time& time, const float amountX, const float amountY)
|
||||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
SafePointer<Component> safePointer (this);
|
||||
BailOutChecker checker (this);
|
||||
|
||||
const float wheelIncrementX = amountX * (1.0f / 256.0f);
|
||||
const float wheelIncrementY = amountY * (1.0f / 256.0f);
|
||||
|
|
@ -2805,32 +2718,19 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>&
|
|||
if (isCurrentlyBlockedByAnotherModalComponent())
|
||||
{
|
||||
// allow blocked mouse-events to go to global listeners..
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY);
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
for (int i = desktop.mouseListeners.size(); --i >= 0;)
|
||||
{
|
||||
((MouseListener*) desktop.mouseListeners[i])->mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, desktop.mouseListeners.size());
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (mouseListeners_ != 0)
|
||||
{
|
||||
|
|
@ -2838,7 +2738,7 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>&
|
|||
{
|
||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
|
||||
if (safePointer == 0)
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners_->size());
|
||||
|
|
@ -2849,16 +2749,19 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>&
|
|||
|
||||
while (p != 0)
|
||||
{
|
||||
SafePointer<Component> parentPointer (p);
|
||||
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
if (p->numDeepMouseListeners > 0)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
BailOutChecker checker (this, p);
|
||||
|
||||
if (safePointer == 0 || parentPointer == 0)
|
||||
return;
|
||||
for (int i = p->numDeepMouseListeners; --i >= 0;)
|
||||
{
|
||||
((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY);
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
i = jmin (i, p->numDeepMouseListeners);
|
||||
}
|
||||
}
|
||||
|
||||
p = p->parentComponent_;
|
||||
|
|
@ -2877,39 +2780,29 @@ void Component::broughtToFront()
|
|||
|
||||
void Component::internalBroughtToFront()
|
||||
{
|
||||
if (isValidComponent())
|
||||
{
|
||||
if (flags.hasHeavyweightPeerFlag)
|
||||
Desktop::getInstance().componentBroughtToFront (this);
|
||||
if (! isValidComponent())
|
||||
return;
|
||||
|
||||
SafePointer<Component> safePointer (this);
|
||||
broughtToFront();
|
||||
if (flags.hasHeavyweightPeerFlag)
|
||||
Desktop::getInstance().componentBroughtToFront (this);
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
BailOutChecker checker (this);
|
||||
broughtToFront();
|
||||
|
||||
if (componentListeners_ != 0)
|
||||
{
|
||||
for (int i = componentListeners_->size(); --i >= 0;)
|
||||
{
|
||||
((ComponentListener*) componentListeners_->getUnchecked (i))
|
||||
->componentBroughtToFront (*this);
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
if (safePointer == 0)
|
||||
return;
|
||||
componentListeners.callChecked (checker, &ComponentListener::componentBroughtToFront, *this);
|
||||
|
||||
i = jmin (i, componentListeners_->size());
|
||||
}
|
||||
}
|
||||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
// when brought to the front and there's a modal component blocking this one,
|
||||
// we need to bring the modal one to the front instead..
|
||||
// When brought to the front and there's a modal component blocking this one,
|
||||
// we need to bring the modal one to the front instead..
|
||||
Component* const cm = getCurrentlyModalComponent();
|
||||
|
||||
Component* const cm = getCurrentlyModalComponent();
|
||||
|
||||
if (cm != 0 && cm->getTopLevelComponent() != getTopLevelComponent())
|
||||
bringModalComponentToFront();
|
||||
}
|
||||
if (cm != 0 && cm->getTopLevelComponent() != getTopLevelComponent())
|
||||
bringModalComponentToFront();
|
||||
}
|
||||
|
||||
void Component::focusGained (FocusChangeType)
|
||||
|
|
@ -3311,6 +3204,18 @@ ComponentPeer* Component::getPeer() const throw()
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Component::BailOutChecker::BailOutChecker (Component* const component1, Component* const component2_)
|
||||
: safePointer1 (component1), safePointer2 (component2_), component2 (component2_)
|
||||
{
|
||||
jassert (component1 != 0);
|
||||
}
|
||||
|
||||
bool Component::BailOutChecker::shouldBailOut() const throw()
|
||||
{
|
||||
return safePointer1 == 0 || safePointer2 != component2;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
ComponentDeletionWatcher::ComponentDeletionWatcher (const Component* const componentToWatch_) throw()
|
||||
: componentToWatch (componentToWatch_),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue