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
|
|
@ -31,6 +31,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
#include "../../../containers/juce_BitArray.h"
|
||||
#include "../mouse/juce_DragAndDropContainer.h"
|
||||
#include "../mouse/juce_MouseInputSource.h"
|
||||
#include "../../graphics/imaging/juce_Image.h"
|
||||
|
||||
|
||||
|
|
@ -168,6 +169,24 @@ public:
|
|||
void paint (Graphics& g);
|
||||
TreeViewItem* findItemAt (int y, Rectangle<int>& itemPosition) const;
|
||||
|
||||
static bool isMouseDraggingInChildCompOf (Component* const comp)
|
||||
{
|
||||
for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;)
|
||||
{
|
||||
MouseInputSource* source = Desktop::getInstance().getMouseSource(i);
|
||||
|
||||
if (source->isDragging())
|
||||
{
|
||||
Component* const underMouse = source->getComponentUnderMouse();
|
||||
|
||||
if (underMouse != 0 && (comp == underMouse || comp->isParentOf (underMouse)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void updateComponents()
|
||||
{
|
||||
const int visibleTop = -getY();
|
||||
|
|
@ -229,10 +248,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if ((! keep)
|
||||
&& Component::isMouseButtonDownAnywhere()
|
||||
&& (comp == Component::getComponentUnderMouse()
|
||||
|| comp->isParentOf (Component::getComponentUnderMouse())))
|
||||
if ((! keep) && isMouseDraggingInChildCompOf (comp))
|
||||
{
|
||||
keep = true;
|
||||
comp->setSize (0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue