mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Created a new class Component::SafePointer that keeps a pointer to a component and automatically nulls it if the component is deleted - this makes it a much more elegant replacement for the old ComponentDeletionWatcher class. Removed Component::getComponentUnderMouse(), which doesn't fit with multi-touch interfaces - for similar functionality, use the Desktop::getMouseInputSource() methods to find out what MouseInputSources are available, and ask them about the component they are over or dragging.
This commit is contained in:
parent
bc5a7a6b7e
commit
5fecb8a353
49 changed files with 1251 additions and 1152 deletions
|
|
@ -29,7 +29,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
|
||||
#include "juce_Desktop.h"
|
||||
#include "juce_ComponentDeletionWatcher.h"
|
||||
#include "windows/juce_ComponentPeer.h"
|
||||
#include "mouse/juce_MouseInputSource.h"
|
||||
#include "mouse/juce_MouseListener.h"
|
||||
#include "mouse/juce_MouseEvent.h"
|
||||
|
|
@ -222,6 +222,35 @@ void Desktop::incrementMouseClickCounter() throw()
|
|||
++mouseClickCounter;
|
||||
}
|
||||
|
||||
int Desktop::getNumDraggingMouseSources() const throw()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = mouseSources.size(); --i >= 0;)
|
||||
if (mouseSources.getUnchecked(i)->isDragging())
|
||||
++num;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
MouseInputSource* Desktop::getDraggingMouseSource (int index) const throw()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = mouseSources.size(); --i >= 0;)
|
||||
{
|
||||
MouseInputSource* const mi = mouseSources.getUnchecked(i);
|
||||
|
||||
if (mi->isDragging())
|
||||
{
|
||||
if (index == num)
|
||||
return mi;
|
||||
|
||||
++num;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void Desktop::addGlobalMouseListener (MouseListener* const listener) throw()
|
||||
{
|
||||
|
|
@ -287,7 +316,7 @@ void Desktop::sendMouseMove()
|
|||
|
||||
if (target != 0)
|
||||
{
|
||||
ComponentDeletionWatcher deletionChecker (target);
|
||||
Component::SafePointer<Component> deletionChecker (target);
|
||||
const Point<int> pos (target->globalPositionToRelative (lastFakeMouseMove));
|
||||
const Time now (Time::getCurrentTime());
|
||||
|
||||
|
|
@ -301,7 +330,7 @@ void Desktop::sendMouseMove()
|
|||
else
|
||||
((MouseListener*) mouseListeners[i])->mouseMove (me);
|
||||
|
||||
if (deletionChecker.hasBeenDeleted())
|
||||
if (deletionChecker == 0)
|
||||
return;
|
||||
|
||||
i = jmin (i, mouseListeners.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue