1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-05 03:50:07 +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:
Julian Storer 2010-02-25 22:33:44 +00:00
parent bc5a7a6b7e
commit 5fecb8a353
49 changed files with 1251 additions and 1152 deletions

View file

@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_Label.h"
#include "../lookandfeel/juce_LookAndFeel.h"
#include "../windows/juce_ComponentPeer.h"
//==============================================================================
@ -58,7 +59,7 @@ Label::~Label()
{
textValue.removeListener (this);
if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted())
if (ownerComponent != 0)
ownerComponent->removeComponentListener (this);
editor = 0;
@ -78,7 +79,7 @@ void Label::setText (const String& newText,
textWasChanged();
if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted())
if (ownerComponent != 0)
componentMovedOrResized (*ownerComponent, true, true);
if (broadcastChangeMessage)
@ -137,21 +138,23 @@ void Label::setBorderSize (int h, int v)
}
//==============================================================================
Component* Label::getAttachedComponent() const
{
return const_cast <Component*> (static_cast <const Component*> (ownerComponent));
}
void Label::attachToComponent (Component* owner,
const bool onLeft)
{
if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted())
if (ownerComponent != 0)
ownerComponent->removeComponentListener (this);
deletionWatcher = 0;
ownerComponent = owner;
leftOfOwnerComp = onLeft;
if (ownerComponent != 0)
{
deletionWatcher = new ComponentDeletionWatcher (owner);
setVisible (owner->isVisible());
ownerComponent->addComponentListener (this);
componentParentHierarchyChanged (*ownerComponent);
@ -241,7 +244,7 @@ bool Label::updateFromTextEditorContents()
textWasChanged();
if (ownerComponent != 0 && ! deletionWatcher->hasBeenDeleted())
if (ownerComponent != 0)
componentMovedOrResized (*ownerComponent, true, true);
return true;