mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-14 00:14:18 +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
|
|
@ -30,9 +30,9 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_MouseInputSource.h"
|
||||
#include "juce_MouseEvent.h"
|
||||
#include "../juce_Component.h"
|
||||
#include "../juce_ComponentDeletionWatcher.h"
|
||||
#include "../../../events/juce_AsyncUpdater.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
#include "../windows/juce_ComponentPeer.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
Component* getComponentUnderMouse() const
|
||||
{
|
||||
return componentUnderMouse != 0 ? const_cast<Component*> (componentUnderMouse->getComponent()) : 0;
|
||||
return const_cast<Component*> (static_cast <const Component*> (componentUnderMouse));
|
||||
}
|
||||
|
||||
const ModifierKeys getCurrentModifiers() const
|
||||
|
|
@ -144,7 +144,7 @@ public:
|
|||
|
||||
if (newComponent != current)
|
||||
{
|
||||
ScopedPointer<ComponentDeletionWatcher> newCompWatcher (newComponent != 0 ? new ComponentDeletionWatcher (newComponent) : 0);
|
||||
Component::SafePointer<Component> safeNewComp (newComponent);
|
||||
const ModifierKeys originalButtonState (buttonState);
|
||||
|
||||
if (current != 0)
|
||||
|
|
@ -154,9 +154,8 @@ public:
|
|||
buttonState = originalButtonState;
|
||||
}
|
||||
|
||||
componentUnderMouse = newCompWatcher;
|
||||
componentUnderMouse = safeNewComp;
|
||||
current = getComponentUnderMouse();
|
||||
Component::componentUnderMouse = current;
|
||||
|
||||
if (current != 0)
|
||||
current->internalMouseEnter (source, current->globalPositionToRelative (screenPos), time);
|
||||
|
|
@ -406,7 +405,7 @@ public:
|
|||
|
||||
private:
|
||||
MouseInputSource& source;
|
||||
ScopedPointer<ComponentDeletionWatcher> componentUnderMouse;
|
||||
Component::SafePointer<Component> componentUnderMouse;
|
||||
ComponentPeer* lastPeer;
|
||||
|
||||
Point<int> unboundedMouseOffset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue