mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-16 00:34:19 +00:00
Fixed the position of the drag image when dragging listboxes. Minor fix for mac graphics contexts, and win32 webcam latency adjustment.
This commit is contained in:
parent
9000fc6604
commit
df5f73910b
7 changed files with 149 additions and 92 deletions
|
|
@ -47841,23 +47841,7 @@ public:
|
|||
if (dragDescription.isNotEmpty())
|
||||
{
|
||||
isDragging = true;
|
||||
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
Image* dragImage = owner.createSnapshotOfSelectedRows();
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
dragContainer->startDragging (dragDescription, &owner, dragImage, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
owner.startDragAndDrop (e, dragDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48596,36 +48580,77 @@ void ListBox::repaintRow (const int rowNumber) throw()
|
|||
repaint (r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
Image* ListBox::createSnapshotOfSelectedRows()
|
||||
Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
||||
{
|
||||
Image* snapshot = Image::createNativeImage (Image::ARGB, getWidth(), getHeight(), true);
|
||||
Graphics g (*snapshot);
|
||||
|
||||
Rectangle imageArea;
|
||||
const int firstRow = getRowContainingPosition (0, 0);
|
||||
|
||||
for (int i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
int i;
|
||||
for (i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
{
|
||||
Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);
|
||||
|
||||
if (rowComp != 0 && isRowSelected (firstRow + i))
|
||||
{
|
||||
g.saveState();
|
||||
|
||||
int x = 0, y = 0;
|
||||
rowComp->relativePositionToOtherComponent (this, x, y);
|
||||
|
||||
g.setOrigin (x, y);
|
||||
g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight());
|
||||
const Rectangle rowRect (x, y, rowComp->getWidth(), rowComp->getHeight());
|
||||
|
||||
rowComp->paintEntireComponent (g);
|
||||
if (imageArea.isEmpty())
|
||||
imageArea = rowRect;
|
||||
else
|
||||
imageArea = imageArea.getUnion (rowRect);
|
||||
}
|
||||
}
|
||||
|
||||
g.restoreState();
|
||||
imageArea = imageArea.getIntersection (Rectangle (0, 0, getWidth(), getHeight()));
|
||||
imageX = imageArea.getX();
|
||||
imageY = imageArea.getY();
|
||||
Image* snapshot = Image::createNativeImage (Image::ARGB, imageArea.getWidth(), imageArea.getHeight(), true);
|
||||
|
||||
for (i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
{
|
||||
Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);
|
||||
|
||||
if (rowComp != 0 && isRowSelected (firstRow + i))
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
rowComp->relativePositionToOtherComponent (this, x, y);
|
||||
|
||||
Graphics g (*snapshot);
|
||||
g.setOrigin (x - imageX, y - imageY);
|
||||
if (g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight()))
|
||||
rowComp->paintEntireComponent (g);
|
||||
}
|
||||
}
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescription)
|
||||
{
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
int x, y;
|
||||
Image* dragImage = createSnapshotOfSelectedRows (x, y);
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
MouseEvent e2 (e.getEventRelativeTo (this));
|
||||
const Point p ((float) (x - e2.x), (float) (y - e2.y));
|
||||
dragContainer->startDragging (dragDescription, this, dragImage, true, &p);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
}
|
||||
|
||||
Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingComponentToUpdate)
|
||||
{
|
||||
(void) existingComponentToUpdate;
|
||||
|
|
@ -51215,23 +51240,7 @@ public:
|
|||
if (dragDescription.isNotEmpty())
|
||||
{
|
||||
isDragging = true;
|
||||
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
Image* dragImage = owner.createSnapshotOfSelectedRows();
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
dragContainer->startDragging (dragDescription, &owner, dragImage, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
owner.startDragAndDrop (e, dragDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -250242,6 +250251,21 @@ public:
|
|||
{
|
||||
firstRecordedTime = Time::getCurrentTime();
|
||||
recordNextFrameTime = false;
|
||||
|
||||
ComSmartPtr <IPin> pin;
|
||||
if (getPin (filter, PINDIR_OUTPUT, &pin))
|
||||
{
|
||||
ComSmartPtr <IAMPushSource> pushSource;
|
||||
hr = pin->QueryInterface (IID_IAMPushSource, (void**) &pushSource);
|
||||
|
||||
if (pushSource != 0)
|
||||
{
|
||||
REFERENCE_TIME latency = 0;
|
||||
hr = ps->GetLatency (&latency);
|
||||
|
||||
firstRecordedTime -= RelativeTime ((double) latency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageSwapLock.enter();
|
||||
|
|
@ -262505,6 +262529,7 @@ public:
|
|||
numGradientLookupEntries (0)
|
||||
{
|
||||
CGContextRetain (context);
|
||||
CGContextSaveGState(context);
|
||||
CGContextSetShouldSmoothFonts (context, true);
|
||||
CGContextSetShouldAntialias (context, true);
|
||||
CGContextSetBlendMode (context, kCGBlendModeNormal);
|
||||
|
|
@ -262518,6 +262543,7 @@ public:
|
|||
|
||||
~CoreGraphicsContext()
|
||||
{
|
||||
CGContextRestoreGState (context);
|
||||
CGContextRelease (context);
|
||||
CGColorSpaceRelease (rgbColourSpace);
|
||||
CGColorSpaceRelease (greyColourSpace);
|
||||
|
|
@ -266973,6 +266999,7 @@ public:
|
|||
numGradientLookupEntries (0)
|
||||
{
|
||||
CGContextRetain (context);
|
||||
CGContextSaveGState(context);
|
||||
CGContextSetShouldSmoothFonts (context, true);
|
||||
CGContextSetShouldAntialias (context, true);
|
||||
CGContextSetBlendMode (context, kCGBlendModeNormal);
|
||||
|
|
@ -266986,6 +267013,7 @@ public:
|
|||
|
||||
~CoreGraphicsContext()
|
||||
{
|
||||
CGContextRestoreGState (context);
|
||||
CGContextRelease (context);
|
||||
CGColorSpaceRelease (rgbColourSpace);
|
||||
CGColorSpaceRelease (greyColourSpace);
|
||||
|
|
|
|||
|
|
@ -37244,7 +37244,7 @@ public:
|
|||
|
||||
@see Component::createComponentSnapshot
|
||||
*/
|
||||
Image* createSnapshotOfSelectedRows();
|
||||
Image* createSnapshotOfSelectedRows (int& x, int& y);
|
||||
|
||||
/** Returns the viewport that this ListBox uses.
|
||||
|
||||
|
|
@ -37275,6 +37275,8 @@ public:
|
|||
void mouseUp (const MouseEvent&);
|
||||
/** @internal */
|
||||
void colourChanged();
|
||||
/** @internal */
|
||||
void startDragAndDrop (const MouseEvent& e, const String& dragDescription);
|
||||
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
|
|
|
|||
|
|
@ -137,23 +137,7 @@ public:
|
|||
if (dragDescription.isNotEmpty())
|
||||
{
|
||||
isDragging = true;
|
||||
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
Image* dragImage = owner.createSnapshotOfSelectedRows();
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
dragContainer->startDragging (dragDescription, &owner, dragImage, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
owner.startDragAndDrop (e, dragDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -904,36 +888,76 @@ void ListBox::repaintRow (const int rowNumber) throw()
|
|||
repaint (r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
Image* ListBox::createSnapshotOfSelectedRows()
|
||||
Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
||||
{
|
||||
Image* snapshot = Image::createNativeImage (Image::ARGB, getWidth(), getHeight(), true);
|
||||
Graphics g (*snapshot);
|
||||
|
||||
Rectangle imageArea;
|
||||
const int firstRow = getRowContainingPosition (0, 0);
|
||||
|
||||
for (int i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
int i;
|
||||
for (i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
{
|
||||
Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);
|
||||
|
||||
if (rowComp != 0 && isRowSelected (firstRow + i))
|
||||
{
|
||||
g.saveState();
|
||||
|
||||
int x = 0, y = 0;
|
||||
rowComp->relativePositionToOtherComponent (this, x, y);
|
||||
|
||||
g.setOrigin (x, y);
|
||||
g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight());
|
||||
const Rectangle rowRect (x, y, rowComp->getWidth(), rowComp->getHeight());
|
||||
|
||||
rowComp->paintEntireComponent (g);
|
||||
if (imageArea.isEmpty())
|
||||
imageArea = rowRect;
|
||||
else
|
||||
imageArea = imageArea.getUnion (rowRect);
|
||||
}
|
||||
}
|
||||
|
||||
g.restoreState();
|
||||
imageArea = imageArea.getIntersection (Rectangle (0, 0, getWidth(), getHeight()));
|
||||
imageX = imageArea.getX();
|
||||
imageY = imageArea.getY();
|
||||
Image* snapshot = Image::createNativeImage (Image::ARGB, imageArea.getWidth(), imageArea.getHeight(), true);
|
||||
|
||||
for (i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
{
|
||||
Component* rowComp = viewport->getComponentForRowIfOnscreen (firstRow + i);
|
||||
|
||||
if (rowComp != 0 && isRowSelected (firstRow + i))
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
rowComp->relativePositionToOtherComponent (this, x, y);
|
||||
|
||||
Graphics g (*snapshot);
|
||||
g.setOrigin (x - imageX, y - imageY);
|
||||
if (g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight()))
|
||||
rowComp->paintEntireComponent (g);
|
||||
}
|
||||
}
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescription)
|
||||
{
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
int x, y;
|
||||
Image* dragImage = createSnapshotOfSelectedRows (x, y);
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
MouseEvent e2 (e.getEventRelativeTo (this));
|
||||
const Point p ((float) (x - e2.x), (float) (y - e2.y));
|
||||
dragContainer->startDragging (dragDescription, this, dragImage, true, &p);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingComponentToUpdate)
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ public:
|
|||
|
||||
@see Component::createComponentSnapshot
|
||||
*/
|
||||
Image* createSnapshotOfSelectedRows();
|
||||
Image* createSnapshotOfSelectedRows (int& x, int& y);
|
||||
|
||||
/** Returns the viewport that this ListBox uses.
|
||||
|
||||
|
|
@ -558,6 +558,8 @@ public:
|
|||
void mouseUp (const MouseEvent&);
|
||||
/** @internal */
|
||||
void colourChanged();
|
||||
/** @internal */
|
||||
void startDragAndDrop (const MouseEvent& e, const String& dragDescription);
|
||||
|
||||
juce_UseDebuggingNewOperator
|
||||
|
||||
|
|
|
|||
|
|
@ -200,23 +200,7 @@ public:
|
|||
if (dragDescription.isNotEmpty())
|
||||
{
|
||||
isDragging = true;
|
||||
|
||||
DragAndDropContainer* const dragContainer
|
||||
= DragAndDropContainer::findParentDragContainerFor (this);
|
||||
|
||||
if (dragContainer != 0)
|
||||
{
|
||||
Image* dragImage = owner.createSnapshotOfSelectedRows();
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
|
||||
dragContainer->startDragging (dragDescription, &owner, dragImage, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to be able to do a drag-and-drop operation, the listbox needs to
|
||||
// be inside a component which is also a DragAndDropContainer.
|
||||
jassertfalse
|
||||
}
|
||||
owner.startDragAndDrop (e, dragDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ public:
|
|||
numGradientLookupEntries (0)
|
||||
{
|
||||
CGContextRetain (context);
|
||||
CGContextSaveGState(context);
|
||||
CGContextSetShouldSmoothFonts (context, true);
|
||||
CGContextSetShouldAntialias (context, true);
|
||||
CGContextSetBlendMode (context, kCGBlendModeNormal);
|
||||
|
|
@ -149,6 +150,7 @@ public:
|
|||
|
||||
~CoreGraphicsContext()
|
||||
{
|
||||
CGContextRestoreGState (context);
|
||||
CGContextRelease (context);
|
||||
CGColorSpaceRelease (rgbColourSpace);
|
||||
CGColorSpaceRelease (greyColourSpace);
|
||||
|
|
|
|||
|
|
@ -191,6 +191,21 @@ public:
|
|||
{
|
||||
firstRecordedTime = Time::getCurrentTime();
|
||||
recordNextFrameTime = false;
|
||||
|
||||
ComSmartPtr <IPin> pin;
|
||||
if (getPin (filter, PINDIR_OUTPUT, &pin))
|
||||
{
|
||||
ComSmartPtr <IAMPushSource> pushSource;
|
||||
hr = pin->QueryInterface (IID_IAMPushSource, (void**) &pushSource);
|
||||
|
||||
if (pushSource != 0)
|
||||
{
|
||||
REFERENCE_TIME latency = 0;
|
||||
hr = ps->GetLatency (&latency);
|
||||
|
||||
firstRecordedTime -= RelativeTime ((double) latency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageSwapLock.enter();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue