Browse Source

More mouse input refactoring.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
c9c8824294
24 changed files with 516 additions and 302 deletions
  1. +219
    -119
      juce_amalgamated.cpp
  2. +36
    -32
      juce_amalgamated.h
  3. +6
    -6
      src/containers/juce_Array.h
  4. +7
    -7
      src/containers/juce_HeapBlock.h
  5. +7
    -7
      src/containers/juce_OwnedArray.h
  6. +9
    -9
      src/containers/juce_ReferenceCountedArray.h
  7. +4
    -4
      src/containers/juce_Variant.cpp
  8. +1
    -1
      src/core/juce_StandardHeader.h
  9. +3
    -1
      src/gui/components/controls/juce_Slider.cpp
  10. +1
    -4
      src/gui/components/juce_Desktop.cpp
  11. +2
    -0
      src/gui/components/juce_Desktop.h
  12. +51
    -12
      src/gui/components/mouse/juce_MouseInputSource.cpp
  13. +2
    -1
      src/gui/components/special/juce_MagnifierComponent.cpp
  14. +10
    -4
      src/gui/components/windows/juce_ComponentPeer.cpp
  15. +2
    -2
      src/gui/components/windows/juce_ComponentPeer.h
  16. +3
    -0
      src/gui/graphics/geometry/juce_Point.h
  17. +11
    -6
      src/native/linux/juce_linux_Windowing.cpp
  18. +69
    -75
      src/native/mac/juce_iphone_UIViewComponentPeer.mm
  19. +1
    -1
      src/native/mac/juce_mac_MessageManager.mm
  20. +9
    -4
      src/native/mac/juce_mac_MiscUtilities.mm
  21. +8
    -2
      src/native/mac/juce_mac_NSViewComponentPeer.mm
  22. +46
    -1
      src/native/mac/juce_mac_QuickTimeMovieComponent.mm
  23. +1
    -1
      src/native/windows/juce_win32_ActiveXComponent.cpp
  24. +8
    -3
      src/native/windows/juce_win32_Windowing.cpp

+ 219
- 119
juce_amalgamated.cpp View File

@@ -3603,7 +3603,7 @@ var::operator int() const
case voidType: break; case voidType: break;
case intType: return value.intValue; case intType: return value.intValue;
case boolType: return value.boolValue ? 1 : 0; case boolType: return value.boolValue ? 1 : 0;
case doubleType: return (int) value.doubleValue;
case doubleType: return static_cast <int> (value.doubleValue);
case stringType: return value.stringValue->getIntValue(); case stringType: return value.stringValue->getIntValue();
case objectType: break; case objectType: break;
default: jassertfalse; break; default: jassertfalse; break;
@@ -3683,9 +3683,9 @@ bool var::equals (const var& other) const throw()
switch (type) switch (type)
{ {
case voidType: return other.isVoid(); case voidType: return other.isVoid();
case intType: return value.intValue == (int) other;
case boolType: return value.boolValue == (bool) other;
case doubleType: return value.doubleValue == (double) other;
case intType: return value.intValue == static_cast <int> (other);
case boolType: return value.boolValue == static_cast <bool> (other);
case doubleType: return value.doubleValue == static_cast <double> (other);
case stringType: return (*(value.stringValue)) == other.toString(); case stringType: return (*(value.stringValue)) == other.toString();
case objectType: return value.objectValue == other.getObject(); case objectType: return value.objectValue == other.getObject();
case methodType: return value.methodValue == other.value.methodValue && other.isMethod(); case methodType: return value.methodValue == other.value.methodValue && other.isMethod();
@@ -41758,10 +41758,7 @@ Desktop::Desktop() throw()
: mouseClickCounter (0), : mouseClickCounter (0),
kioskModeComponent (0) kioskModeComponent (0)
{ {
const int maxNumMice = 1;
for (int i = maxNumMice; --i >= 0;)
mouseSources.add (new MouseInputSource (i, true));

createMouseInputSources();
refreshMonitorSizes(); refreshMonitorSizes();
} }


@@ -49443,7 +49440,9 @@ void Slider::restoreMouseIfHidden()
if (mouseWasHidden) if (mouseWasHidden)
{ {
mouseWasHidden = false; mouseWasHidden = false;
Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement (false);

for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;)
Desktop::getInstance().getMouseSource(i)->enableUnboundedMouseMovement (false);


const double pos = (sliderBeingDragged == 2) ? getMaxValue() const double pos = (sliderBeingDragged == 2) ? getMaxValue()
: ((sliderBeingDragged == 1) ? getMinValue() : ((sliderBeingDragged == 1) ? getMinValue()
@@ -70382,11 +70381,53 @@ public:
return 0; return 0;
} }


const Point<int> getScreenPosition() const
const Point<int> getScreenPosition() const throw()
{ {
return lastScreenPos + unboundedMouseOffset; return lastScreenPos + unboundedMouseOffset;
} }


void sendMouseEnter (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " enter: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseEnter (source, comp->globalPositionToRelative (screenPos), time);
}

void sendMouseExit (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " exit: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseExit (source, comp->globalPositionToRelative (screenPos), time);
}

void sendMouseMove (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " move: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseMove (source, comp->globalPositionToRelative (screenPos), time);
}

void sendMouseDown (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " down: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseDown (source, comp->globalPositionToRelative (screenPos), time);
}

void sendMouseDrag (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " drag: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseDrag (source, comp->globalPositionToRelative (screenPos), time);
}

void sendMouseUp (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " up: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseUp (source, comp->globalPositionToRelative (screenPos), time, getCurrentModifiers());
}

void sendMouseWheel (Component* const comp, const Point<int>& screenPos, const int64 time, float x, float y)
{
//DBG ("Mouse " + String (source.getIndex()) + " wheel: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseWheel (source, comp->globalPositionToRelative (screenPos), time, x, y);
}

void setButtons (const Point<int>& screenPos, const int64 time, const ModifierKeys& newButtonState) void setButtons (const Point<int>& screenPos, const int64 time, const ModifierKeys& newButtonState)
{ {
if (buttonState != newButtonState) if (buttonState != newButtonState)
@@ -70403,8 +70444,7 @@ public:
Component* const current = getComponentUnderMouse(); Component* const current = getComponentUnderMouse();


if (current != 0) if (current != 0)
current->internalMouseUp (source, current->globalPositionToRelative (screenPos + unboundedMouseOffset),
time, getCurrentModifiers());
sendMouseUp (current, screenPos + unboundedMouseOffset, time);


enableUnboundedMouseMovement (false, false); enableUnboundedMouseMovement (false, false);
} }
@@ -70420,8 +70460,7 @@ public:
if (current != 0) if (current != 0)
{ {
registerMouseDown (screenPos, time, current); registerMouseDown (screenPos, time, current);

current->internalMouseDown (source, current->globalPositionToRelative (screenPos), time);
sendMouseDown (current, screenPos, time);
} }
} }
} }
@@ -70439,7 +70478,7 @@ public:
if (current != 0) if (current != 0)
{ {
setButtons (screenPos, time, ModifierKeys()); setButtons (screenPos, time, ModifierKeys());
current->internalMouseExit (source, current->globalPositionToRelative (screenPos), time);
sendMouseExit (current, screenPos, time);
buttonState = originalButtonState; buttonState = originalButtonState;
} }


@@ -70447,7 +70486,7 @@ public:
current = getComponentUnderMouse(); current = getComponentUnderMouse();


if (current != 0) if (current != 0)
current->internalMouseEnter (source, current->globalPositionToRelative (screenPos), time);
sendMouseEnter (current, screenPos, time);


revealCursor (false); revealCursor (false);
setButtons (screenPos, time, originalButtonState); setButtons (screenPos, time, originalButtonState);
@@ -70480,19 +70519,17 @@ public:


if (current != 0) if (current != 0)
{ {
const Point<int> pos (current->globalPositionToRelative (lastScreenPos));

if (isDragging()) if (isDragging())
{ {
registerMouseDrag (newScreenPos); registerMouseDrag (newScreenPos);
current->internalMouseDrag (source, pos + unboundedMouseOffset, time);
sendMouseDrag (current, newScreenPos + unboundedMouseOffset, time);


if (isUnboundedMouseModeOn) if (isUnboundedMouseModeOn)
handleUnboundedDrag (current); handleUnboundedDrag (current);
} }
else else
{ {
current->internalMouseMove (source, pos, time);
sendMouseMove (current, newScreenPos, time);
} }
} }


@@ -70540,7 +70577,7 @@ public:
{ {
Component* current = getComponentUnderMouse(); Component* current = getComponentUnderMouse();
if (current != 0) if (current != 0)
current->internalMouseWheel (source, current->globalPositionToRelative (screenPos), time, x, y);
sendMouseWheel (current, screenPos, time, x, y);
} }
} }


@@ -74355,7 +74392,8 @@ void MagnifierComponent::mouseExit (const MouseEvent& e)
void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy) void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy)
{ {
if (peer != 0) if (peer != 0)
peer->handleMouseWheel (Point<int> (scaleInt (e.x), scaleInt (e.y)), e.eventTime.toMilliseconds(),
peer->handleMouseWheel (e.source.getIndex(),
Point<int> (scaleInt (e.x), scaleInt (e.y)), e.eventTime.toMilliseconds(),
ix * 256.0f, iy * 256.0f); ix * 256.0f, iy * 256.0f);
else else
Component::mouseWheelMove (e, ix, iy); Component::mouseWheelMove (e, ix, iy);
@@ -76373,14 +76411,20 @@ void ComponentPeer::updateCurrentModifiers() throw()
ModifierKeys::updateCurrentModifiers(); ModifierKeys::updateCurrentModifiers();
} }


void ComponentPeer::handleMouseEvent (const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time)
void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time)
{ {
Desktop::getInstance().getMainMouseSource().handleEvent (this, positionWithinPeer, time, newMods);
MouseInputSource* const mouse = Desktop::getInstance().getMouseSource (touchIndex);
jassert (mouse != 0); // not enough sources!

mouse->handleEvent (this, positionWithinPeer, time, newMods);
} }


void ComponentPeer::handleMouseWheel (const Point<int>& positionWithinPeer, const int64 time, float x, float y)
void ComponentPeer::handleMouseWheel (const int touchIndex, const Point<int>& positionWithinPeer, const int64 time, const float x, const float y)
{ {
Desktop::getInstance().getMainMouseSource().handleWheel (this, positionWithinPeer, time, x, y);
MouseInputSource* const mouse = Desktop::getInstance().getMouseSource (touchIndex);
jassert (mouse != 0); // not enough sources!

mouse->handleWheel (this, positionWithinPeer, time, x, y);
} }


void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo)
@@ -214806,7 +214850,7 @@ public:
if (fullScreen != shouldBeFullScreen) if (fullScreen != shouldBeFullScreen)
{ {
fullScreen = shouldBeFullScreen; fullScreen = shouldBeFullScreen;
const Component::SafePointer deletionChecker (component);
const Component::SafePointer<Component> deletionChecker (component);


if (! fullScreen) if (! fullScreen)
{ {
@@ -215474,7 +215518,7 @@ private:


void doMouseEvent (const Point<int>& position) void doMouseEvent (const Point<int>& position)
{ {
handleMouseEvent (position, currentModifiers, getMouseEventTime());
handleMouseEvent (0, position, currentModifiers, getMouseEventTime());
} }


void doMouseMove (const Point<int>& position) void doMouseMove (const Point<int>& position)
@@ -215545,7 +215589,7 @@ private:


const float amount = jlimit (-1000.0f, 1000.0f, 0.75f * HIWORD (wParam)); const float amount = jlimit (-1000.0f, 1000.0f, 0.75f * HIWORD (wParam));


handleMouseWheel (position, getMouseEventTime(),
handleMouseWheel (0, position, getMouseEventTime(),
isVertical ? 0.0f : amount, isVertical ? 0.0f : amount,
isVertical ? amount : 0.0f); isVertical ? amount : 0.0f);
} }
@@ -216439,6 +216483,11 @@ bool AlertWindow::showNativeDialogBox (const String& title,
: MB_OK)) == IDOK; : MB_OK)) == IDOK;
} }


void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}

const Point<int> Desktop::getMousePosition() const Point<int> Desktop::getMousePosition()
{ {
POINT mousePos; POINT mousePos;
@@ -218194,7 +218243,7 @@ namespace ActiveXHelpers
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_RBUTTONUP: case WM_RBUTTONUP:
peer->handleMouseEvent (mousePos, Win32ComponentPeer::currentModifiers, mouseEventTime);
peer->handleMouseEvent (0, mousePos, Win32ComponentPeer::currentModifiers, mouseEventTime);
break; break;


default: default:
@@ -232601,7 +232650,7 @@ public:


if (map == WheelUp || map == WheelDown) if (map == WheelUp || map == WheelDown)
{ {
handleMouseWheel (Point<int> (buttonPressEvent->x, buttonPressEvent->y),
handleMouseWheel (0, Point<int> (buttonPressEvent->x, buttonPressEvent->y),
getEventTime (buttonPressEvent->time), 0, map == WheelDown ? -84.0f : 84.0f); getEventTime (buttonPressEvent->time), 0, map == WheelDown ? -84.0f : 84.0f);
} }
if (map == LeftButton) if (map == LeftButton)
@@ -232624,7 +232673,7 @@ public:
{ {
toFront (true); toFront (true);


handleMouseEvent (Point<int> (buttonPressEvent->x, buttonPressEvent->y), currentModifiers,
handleMouseEvent (0, Point<int> (buttonPressEvent->x, buttonPressEvent->y), currentModifiers,
getEventTime (buttonPressEvent->time)); getEventTime (buttonPressEvent->time));
} }


@@ -232646,7 +232695,7 @@ public:
else if (map == MiddleButton) else if (map == MiddleButton)
currentModifiers = currentModifiers.withoutFlags (ModifierKeys::middleButtonModifier); currentModifiers = currentModifiers.withoutFlags (ModifierKeys::middleButtonModifier);


handleMouseEvent (Point<int> (buttonRelEvent->x, buttonRelEvent->y), currentModifiers,
handleMouseEvent (0, Point<int> (buttonRelEvent->x, buttonRelEvent->y), currentModifiers,
getEventTime (buttonRelEvent->time)); getEventTime (buttonRelEvent->time));


clearLastMousePos(); clearLastMousePos();
@@ -232688,7 +232737,7 @@ public:
} }
} }


handleMouseEvent (mousePos - getScreenPosition(), currentModifiers, getEventTime (movedEvent->time));
handleMouseEvent (0, mousePos - getScreenPosition(), currentModifiers, getEventTime (movedEvent->time));
} }


break; break;
@@ -232702,7 +232751,7 @@ public:
if (! currentModifiers.isAnyMouseButtonDown()) if (! currentModifiers.isAnyMouseButtonDown())
{ {
updateKeyModifiers (enterEvent->state); updateKeyModifiers (enterEvent->state);
handleMouseEvent (Point<int> (enterEvent->x, enterEvent->y), currentModifiers, getEventTime (enterEvent->time));
handleMouseEvent (0, Point<int> (enterEvent->x, enterEvent->y), currentModifiers, getEventTime (enterEvent->time));
} }


break; break;
@@ -232719,7 +232768,7 @@ public:
|| leaveEvent->mode == NotifyUngrab) || leaveEvent->mode == NotifyUngrab)
{ {
updateKeyModifiers (leaveEvent->state); updateKeyModifiers (leaveEvent->state);
handleMouseEvent (Point<int> (leaveEvent->x, leaveEvent->y), currentModifiers, getEventTime (leaveEvent->time));
handleMouseEvent (0, Point<int> (leaveEvent->x, leaveEvent->y), currentModifiers, getEventTime (leaveEvent->time));
} }


break; break;
@@ -234106,6 +234155,11 @@ void juce_updateMultiMonitorInfo (Array <Rectangle<int> >& monitorCoords, const
} }
} }


void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}

bool Desktop::canUseSemiTransparentWindows() throw() bool Desktop::canUseSemiTransparentWindows() throw()
{ {
return false; return false;
@@ -239230,14 +239284,19 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi
if (files.size() == 0) if (files.size() == 0)
return false; return false;


// This method must be called in response to a component's mouseDrag event!
jassert (Desktop::getInstance().getMainMouseSource().isDragging());
MouseInputSource* draggingSource = Desktop::getInstance().getDraggingMouseSource(0);

if (draggingSource == 0)
{
jassertfalse // This method must be called in response to a component's mouseDown or mouseDrag event!
return false;
}


Component* sourceComp = Desktop::getInstance().getMainMouseSource().getComponentUnderMouse();
Component* sourceComp = draggingSource->getComponentUnderMouse();


if (sourceComp == 0) if (sourceComp == 0)
{ {
jassertfalse // this method must be called in response to a component's mouseDrag event!
jassertfalse // This method must be called in response to a component's mouseDown or mouseDrag event!
return false; return false;
} }


@@ -240760,6 +240819,8 @@ public:
void grabFocus(); void grabFocus();
void textInputRequired (const Point<int>& position); void textInputRequired (const Point<int>& position);


void handleTouches (UIEvent* e, bool isDown, bool isUp, bool isCancel);

void repaint (int x, int y, int w, int h); void repaint (int x, int y, int w, int h);
void performAnyPendingRepaintsNow(); void performAnyPendingRepaintsNow();


@@ -240769,6 +240830,14 @@ public:
JuceUIView* view; JuceUIView* view;
bool isSharedWindow, fullScreen, insideDrawRect; bool isSharedWindow, fullScreen, insideDrawRect;
static ModifierKeys currentModifiers; static ModifierKeys currentModifiers;

static int64 getMouseTime (UIEvent* e)
{
return (Time::currentTimeMillis() - Time::getMillisecondCounter())
+ (int64) ([e timestamp] * 1000.0);
}

Array <UITouch*> currentTouches;
}; };


END_JUCE_NAMESPACE END_JUCE_NAMESPACE
@@ -240812,97 +240881,31 @@ void ModifierKeys::updateCurrentModifiers() throw()
currentModifiers = UIViewComponentPeer::currentModifiers; currentModifiers = UIViewComponentPeer::currentModifiers;
} }


static int64 getMouseTime (UIEvent* e)
{
return (Time::currentTimeMillis() - Time::getMillisecondCounter())
+ (int64) ([e timestamp] * 1000.0);
}

JUCE_NAMESPACE::Point<int> juce_lastMousePos; JUCE_NAMESPACE::Point<int> juce_lastMousePos;


- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;

NSArray* const t = [[event touchesForView: self] allObjects];

switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();

owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));

JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers
= JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers.withoutMouseButtons()
.withFlags (JUCE_NAMESPACE::ModifierKeys::leftButtonModifier);

owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}

default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, true, false, false);
} }


- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;

NSArray* const t = [[event touchesForView: self] allObjects];

switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();

owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}

default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, false, false, false);
} }


- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;

NSArray* const t = [[event touchesForView: self] allObjects];

switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();

JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers
= JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers.withoutMouseButtons();

owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}

default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, false, true, false);
} }


- (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner != 0)
owner->handleTouches (event, false, true, true);

[self touchesEnded: touches withEvent: event]; [self touchesEnded: touches withEvent: event];
} }


@@ -241004,6 +241007,8 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,


view.hidden = ! component->isVisible(); view.hidden = ! component->isVisible();
window.hidden = ! component->isVisible(); window.hidden = ! component->isVisible();

view.multipleTouchEnabled = YES;
} }


setTitle (component->getName()); setTitle (component->getName());
@@ -241253,6 +241258,47 @@ void UIViewComponentPeer::setIcon (const Image& /*newIcon*/)
// to do.. // to do..
} }


void UIViewComponentPeer::handleTouches (UIEvent* event, const bool isDown, const bool isUp, bool isCancel)
{
NSArray* touches = [[event touchesForView: view] allObjects];

for (unsigned int i = 0; i < [touches count]; ++i)
{
UITouch* touch = [touches objectAtIndex: i];

CGPoint p = [touch locationInView: view];
const Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + getScreenPosition();

const int64 time = getMouseTime (event);

int touchIndex = currentTouches.indexOf (touch);

if (touchIndex < 0)
{
touchIndex = currentTouches.size();
currentTouches.add (touch);
}

if (isDown)
{
currentModifiers = currentModifiers.withoutMouseButtons();
handleMouseEvent (touchIndex, pos, currentModifiers, time);
currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
}
else if (isUp)
{
currentModifiers = currentModifiers.withoutMouseButtons();
currentTouches.remove (touchIndex);
}

if (isCancel)
currentTouches.clear();

handleMouseEvent (touchIndex, pos, currentModifiers, time);
}
}

static UIViewComponentPeer* currentlyFocusedPeer = 0; static UIViewComponentPeer* currentlyFocusedPeer = 0;


void UIViewComponentPeer::viewFocusGain() void UIViewComponentPeer::viewFocusGain()
@@ -241401,6 +241447,12 @@ Image* juce_createIconForFile (const File& file)
return 0; return 0;
} }


void Desktop::createMouseInputSources()
{
for (int i = 0; i < 10; ++i)
mouseSources.add (new MouseInputSource (i, false));
}

bool Desktop::canUseSemiTransparentWindows() throw() bool Desktop::canUseSemiTransparentWindows() throw()
{ {
return true; return true;
@@ -246367,7 +246419,7 @@ bool NSViewComponentPeer::redirectPerformKeyEquivalent (NSEvent* ev)
void NSViewComponentPeer::sendMouseEvent (NSEvent* ev) void NSViewComponentPeer::sendMouseEvent (NSEvent* ev)
{ {
updateModifiers (ev); updateModifiers (ev);
handleMouseEvent (getMousePos (ev, view), currentModifiers, getMouseTime (ev));
handleMouseEvent (0, getMousePos (ev, view), currentModifiers, getMouseTime (ev));
} }


void NSViewComponentPeer::redirectMouseDown (NSEvent* ev) void NSViewComponentPeer::redirectMouseDown (NSEvent* ev)
@@ -246412,7 +246464,7 @@ void NSViewComponentPeer::redirectMouseWheel (NSEvent* ev)
{ {
updateModifiers (ev); updateModifiers (ev);


handleMouseWheel (getMousePos (ev, view), getMouseTime (ev),
handleMouseWheel (0, getMousePos (ev, view), getMouseTime (ev),
[ev deltaX] * 10.0f, [ev deltaY] * 10.0f); [ev deltaX] * 10.0f, [ev deltaY] * 10.0f);
} }


@@ -246585,6 +246637,11 @@ void NSViewComponentPeer::viewMovedToWindow()
window = [view window]; window = [view window];
} }


void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}

void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars) void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
{ {
// Very annoyingly, this function has to use the old SetSystemUIMode function, // Very annoyingly, this function has to use the old SetSystemUIMode function,
@@ -248222,6 +248279,48 @@ void FileChooser::showPlatformDialog (Array<File>& results,
// compiled on its own). // compiled on its own).
#if JUCE_INCLUDED_FILE && JUCE_QUICKTIME #if JUCE_INCLUDED_FILE && JUCE_QUICKTIME


END_JUCE_NAMESPACE

#define NonInterceptingQTMovieView MakeObjCClassName(NonInterceptingQTMovieView)

@interface NonInterceptingQTMovieView : QTMovieView
{
}

- (id) initWithFrame: (NSRect) frame;
- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent;
- (NSView*) hitTest: (NSPoint) p;

@end

@implementation NonInterceptingQTMovieView

- (id) initWithFrame: (NSRect) frame
{
self = [super initWithFrame: frame];
[self setNextResponder: [self superview]];
return self;
}

- (void) dealloc
{
[super dealloc];
}

- (NSView*) hitTest: (NSPoint) point
{
return [self isControllerVisible] ? [super hitTest: point] : nil;
}

- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent
{
return YES;
}

@end

BEGIN_JUCE_NAMESPACE

#define theMovie ((QTMovie*) movie) #define theMovie ((QTMovie*) movie)


QuickTimeMovieComponent::QuickTimeMovieComponent() QuickTimeMovieComponent::QuickTimeMovieComponent()
@@ -248230,8 +248329,9 @@ QuickTimeMovieComponent::QuickTimeMovieComponent()
setOpaque (true); setOpaque (true);
setVisible (true); setVisible (true);


QTMovieView* view = [[QTMovieView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f)];
QTMovieView* view = [[NonInterceptingQTMovieView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f)];
setView (view); setView (view);
[view release];
} }


QuickTimeMovieComponent::~QuickTimeMovieComponent() QuickTimeMovieComponent::~QuickTimeMovieComponent()
@@ -249366,7 +249466,7 @@ static bool isEventBlockedByModalComps (NSEvent* e)
case NSRightMouseUp: case NSRightMouseUp:
case NSOtherMouseUp: case NSOtherMouseUp:
case NSOtherMouseDragged: case NSOtherMouseDragged:
if (Desktop::getInstance().getMainMouseSource().isDragging())
if (Desktop::getInstance().getDraggingMouseSource(0) != 0)
return false; return false;
break; break;




+ 36
- 32
juce_amalgamated.h View File

@@ -43,7 +43,7 @@


#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 51 #define JUCE_MINOR_VERSION 51
#define JUCE_BUILDNUMBER 5
#define JUCE_BUILDNUMBER 6


#define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER) #define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER)


@@ -1508,7 +1508,7 @@ public:
} }


HeapBlock (const size_t numElements) HeapBlock (const size_t numElements)
: data ((ElementType*) ::juce_malloc (numElements * sizeof (ElementType)))
: data (reinterpret_cast <ElementType*> (::juce_malloc (numElements * sizeof (ElementType))))
{ {
} }


@@ -1542,13 +1542,13 @@ public:
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
::juce_free (data); ::juce_free (data);
data = (ElementType*) ::juce_malloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * elementSize));
} }


void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
::juce_free (data); ::juce_free (data);
data = (ElementType*) ::juce_calloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_calloc (newNumElements * elementSize));
} }


void allocate (const size_t newNumElements, const bool initialiseToZero) void allocate (const size_t newNumElements, const bool initialiseToZero)
@@ -1556,17 +1556,17 @@ public:
::juce_free (data); ::juce_free (data);


if (initialiseToZero) if (initialiseToZero)
data = (ElementType*) ::juce_calloc (newNumElements * sizeof (ElementType));
data = reinterpret_cast <ElementType*> (::juce_calloc (newNumElements * sizeof (ElementType)));
else else
data = (ElementType*) ::juce_malloc (newNumElements * sizeof (ElementType));
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * sizeof (ElementType)));
} }


void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
if (data == 0) if (data == 0)
data = (ElementType*) ::juce_malloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * elementSize));
else else
data = (ElementType*) ::juce_realloc (data, newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_realloc (data, newNumElements * elementSize));
} }


void free() void free()
@@ -2058,13 +2058,13 @@ public:
int indexOf (const ElementType& elementToLookFor) const int indexOf (const ElementType& elementToLookFor) const
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const ElementType* e = data.elements;
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed; const ElementType* const end = e + numUsed;


while (e != end) while (e != end)
{ {
if (elementToLookFor == *e) if (elementToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());


++e; ++e;
} }
@@ -2075,7 +2075,7 @@ public:
bool contains (const ElementType& elementToLookFor) const bool contains (const ElementType& elementToLookFor) const
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const ElementType* e = data.elements;
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed; const ElementType* const end = e + numUsed;


while (e != end) while (e != end)
@@ -2251,7 +2251,7 @@ public:
void addSorted (ElementComparator& comparator, const ElementType& newElement) void addSorted (ElementComparator& comparator, const ElementType& newElement)
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ElementType*) data.elements, newElement, 0, numUsed), newElement);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed), newElement);
} }


template <class ElementComparator> template <class ElementComparator>
@@ -2324,7 +2324,7 @@ public:
{ {
if (valueToRemove == *e) if (valueToRemove == *e)
{ {
remove ((int) (e - data.elements));
remove ((int) (e - data.elements.getData()));
break; break;
} }


@@ -2479,7 +2479,7 @@ public:
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
(void) comparator; // if you pass in an object with a static compareElements() method, this (void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
sortArray (comparator, (ElementType*) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }


inline const TypeOfCriticalSectionToUse& getLock() const throw() { return data; } inline const TypeOfCriticalSectionToUse& getLock() const throw() { return data; }
@@ -3478,13 +3478,13 @@ public:
int indexOf (const ObjectClass* const objectToLookFor) const throw() int indexOf (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements;
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed; ObjectClass* const* const end = e + numUsed;


while (e != end) while (e != end)
{ {
if (objectToLookFor == *e) if (objectToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());


++e; ++e;
} }
@@ -3495,7 +3495,7 @@ public:
bool contains (const ObjectClass* const objectToLookFor) const throw() bool contains (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements;
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed; ObjectClass* const* const end = e + numUsed;


while (e != end) while (e != end)
@@ -3587,7 +3587,7 @@ public:
(void) comparator; // if you pass in an object with a static compareElements() method, this (void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed), newObject);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed), newObject);
} }


template <class ElementComparator> template <class ElementComparator>
@@ -3653,13 +3653,13 @@ public:
const bool deleteObject = true) const bool deleteObject = true)
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();


for (int i = numUsed; --i >= 0;) for (int i = numUsed; --i >= 0;)
{ {
if (objectToRemove == *e) if (objectToRemove == *e)
{ {
remove ((int) (e - data.elements), deleteObject);
remove ((int) (e - data.elements.getData()), deleteObject);
break; break;
} }


@@ -3792,7 +3792,7 @@ public:
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused


const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
sortArray (comparator, (ObjectClass**) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }


inline const TypeOfCriticalSectionToUse& getLock() const throw() { return data; } inline const TypeOfCriticalSectionToUse& getLock() const throw() { return data; }
@@ -4905,7 +4905,7 @@ public:
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return (((unsigned int) index) < (unsigned int) numUsed) ? data.elements [index] return (((unsigned int) index) < (unsigned int) numUsed) ? data.elements [index]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }


inline const ReferenceCountedObjectPtr<ObjectClass> getUnchecked (const int index) const throw() inline const ReferenceCountedObjectPtr<ObjectClass> getUnchecked (const int index) const throw()
@@ -4919,26 +4919,26 @@ public:
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [0] return numUsed > 0 ? data.elements [0]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }


inline const ReferenceCountedObjectPtr<ObjectClass> getLast() const throw() inline const ReferenceCountedObjectPtr<ObjectClass> getLast() const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [numUsed - 1] return numUsed > 0 ? data.elements [numUsed - 1]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }


int indexOf (const ObjectClass* const objectToLookFor) const throw() int indexOf (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed; ObjectClass** const end = e + numUsed;


while (e != end) while (e != end)
{ {
if (objectToLookFor == *e) if (objectToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());


++e; ++e;
} }
@@ -4949,7 +4949,7 @@ public:
bool contains (const ObjectClass* const objectToLookFor) const throw() bool contains (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed; ObjectClass** const end = e + numUsed;


while (e != end) while (e != end)
@@ -5068,7 +5068,7 @@ public:
ObjectClass* newObject) throw() ObjectClass* newObject) throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed), newObject);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed), newObject);
} }


template <class ElementComparator> template <class ElementComparator>
@@ -5076,7 +5076,7 @@ public:
ObjectClass* newObject) throw() ObjectClass* newObject) throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const int index = findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed);
const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed);


if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0) if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0)
set (index - 1, newObject); // replace an existing object that matches set (index - 1, newObject); // replace an existing object that matches
@@ -5241,7 +5241,7 @@ public:
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused


const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
sortArray (comparator, (ObjectClass**) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }


void minimiseStorageOverheads() throw() void minimiseStorageOverheads() throw()
@@ -9208,6 +9208,8 @@ public:


void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); }


const String toString() const { return String (x) + ", " + String (y); }

juce_UseDebuggingNewOperator juce_UseDebuggingNewOperator


private: private:
@@ -12957,6 +12959,8 @@ private:
Component* kioskModeComponent; Component* kioskModeComponent;
Rectangle<int> kioskComponentOriginalBounds; Rectangle<int> kioskComponentOriginalBounds;


void createMouseInputSources();

void timerCallback(); void timerCallback();
void sendMouseMove(); void sendMouseMove();
void resetTimer() throw(); void resetTimer() throw();
@@ -26939,8 +26943,8 @@ public:


virtual void performAnyPendingRepaintsNow() = 0; virtual void performAnyPendingRepaintsNow() = 0;


void handleMouseEvent (const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time);
void handleMouseWheel (const Point<int>& positionWithinPeer, const int64 time, float x, float y);
void handleMouseEvent (int touchIndex, const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time);
void handleMouseWheel (int touchIndex, const Point<int>& positionWithinPeer, const int64 time, float x, float y);


void handleUserClosingWindow(); void handleUserClosingWindow();




+ 6
- 6
src/containers/juce_Array.h View File

@@ -282,13 +282,13 @@ public:
int indexOf (const ElementType& elementToLookFor) const int indexOf (const ElementType& elementToLookFor) const
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const ElementType* e = data.elements;
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed; const ElementType* const end = e + numUsed;
while (e != end) while (e != end)
{ {
if (elementToLookFor == *e) if (elementToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());
++e; ++e;
} }
@@ -304,7 +304,7 @@ public:
bool contains (const ElementType& elementToLookFor) const bool contains (const ElementType& elementToLookFor) const
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const ElementType* e = data.elements;
const ElementType* e = data.elements.getData();
const ElementType* const end = e + numUsed; const ElementType* const end = e + numUsed;
while (e != end) while (e != end)
@@ -579,7 +579,7 @@ public:
void addSorted (ElementComparator& comparator, const ElementType& newElement) void addSorted (ElementComparator& comparator, const ElementType& newElement)
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ElementType*) data.elements, newElement, 0, numUsed), newElement);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed), newElement);
} }
/** Finds the index of an element in the array, assuming that the array is sorted. /** Finds the index of an element in the array, assuming that the array is sorted.
@@ -683,7 +683,7 @@ public:
{ {
if (valueToRemove == *e) if (valueToRemove == *e)
{ {
remove ((int) (e - data.elements));
remove ((int) (e - data.elements.getData()));
break; break;
} }
@@ -929,7 +929,7 @@ public:
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
(void) comparator; // if you pass in an object with a static compareElements() method, this (void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
sortArray (comparator, (ElementType*) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }
//============================================================================== //==============================================================================


+ 7
- 7
src/containers/juce_HeapBlock.h View File

@@ -90,7 +90,7 @@ public:
If you want an array of zero values, you can use the calloc() method instead. If you want an array of zero values, you can use the calloc() method instead.
*/ */
HeapBlock (const size_t numElements) HeapBlock (const size_t numElements)
: data ((ElementType*) ::juce_malloc (numElements * sizeof (ElementType)))
: data (reinterpret_cast <ElementType*> (::juce_malloc (numElements * sizeof (ElementType))))
{ {
} }
@@ -180,7 +180,7 @@ public:
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
::juce_free (data); ::juce_free (data);
data = (ElementType*) ::juce_malloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * elementSize));
} }
/** Allocates a specified amount of memory and clears it. /** Allocates a specified amount of memory and clears it.
@@ -189,7 +189,7 @@ public:
void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
::juce_free (data); ::juce_free (data);
data = (ElementType*) ::juce_calloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_calloc (newNumElements * elementSize));
} }
/** Allocates a specified amount of memory and optionally clears it. /** Allocates a specified amount of memory and optionally clears it.
@@ -201,9 +201,9 @@ public:
::juce_free (data); ::juce_free (data);
if (initialiseToZero) if (initialiseToZero)
data = (ElementType*) ::juce_calloc (newNumElements * sizeof (ElementType));
data = reinterpret_cast <ElementType*> (::juce_calloc (newNumElements * sizeof (ElementType)));
else else
data = (ElementType*) ::juce_malloc (newNumElements * sizeof (ElementType));
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * sizeof (ElementType)));
} }
/** Re-allocates a specified amount of memory. /** Re-allocates a specified amount of memory.
@@ -214,9 +214,9 @@ public:
void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
if (data == 0) if (data == 0)
data = (ElementType*) ::juce_malloc (newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_malloc (newNumElements * elementSize));
else else
data = (ElementType*) ::juce_realloc (data, newNumElements * elementSize);
data = reinterpret_cast <ElementType*> (::juce_realloc (data, newNumElements * elementSize));
} }
/** Frees any currently-allocated data. /** Frees any currently-allocated data.


+ 7
- 7
src/containers/juce_OwnedArray.h View File

@@ -159,13 +159,13 @@ public:
int indexOf (const ObjectClass* const objectToLookFor) const throw() int indexOf (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements;
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed; ObjectClass* const* const end = e + numUsed;
while (e != end) while (e != end)
{ {
if (objectToLookFor == *e) if (objectToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());
++e; ++e;
} }
@@ -181,7 +181,7 @@ public:
bool contains (const ObjectClass* const objectToLookFor) const throw() bool contains (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass* const* e = data.elements;
ObjectClass* const* e = data.elements.getData();
ObjectClass* const* const end = e + numUsed; ObjectClass* const* const end = e + numUsed;
while (e != end) while (e != end)
@@ -333,7 +333,7 @@ public:
(void) comparator; // if you pass in an object with a static compareElements() method, this (void) comparator; // if you pass in an object with a static compareElements() method, this
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed), newObject);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed), newObject);
} }
/** Finds the index of an object in the array, assuming that the array is sorted. /** Finds the index of an object in the array, assuming that the array is sorted.
@@ -430,13 +430,13 @@ public:
const bool deleteObject = true) const bool deleteObject = true)
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();
for (int i = numUsed; --i >= 0;) for (int i = numUsed; --i >= 0;)
{ {
if (objectToRemove == *e) if (objectToRemove == *e)
{ {
remove ((int) (e - data.elements), deleteObject);
remove ((int) (e - data.elements.getData()), deleteObject);
break; break;
} }
@@ -650,7 +650,7 @@ public:
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
sortArray (comparator, (ObjectClass**) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }
//============================================================================== //==============================================================================


+ 9
- 9
src/containers/juce_ReferenceCountedArray.h View File

@@ -130,7 +130,7 @@ public:
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return (((unsigned int) index) < (unsigned int) numUsed) ? data.elements [index] return (((unsigned int) index) < (unsigned int) numUsed) ? data.elements [index]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }
/** Returns a pointer to the object at this index in the array, without checking whether the index is in-range. /** Returns a pointer to the object at this index in the array, without checking whether the index is in-range.
@@ -154,7 +154,7 @@ public:
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [0] return numUsed > 0 ? data.elements [0]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }
/** Returns a pointer to the last object in the array. /** Returns a pointer to the last object in the array.
@@ -166,7 +166,7 @@ public:
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [numUsed - 1] return numUsed > 0 ? data.elements [numUsed - 1]
: (ObjectClass*) 0;
: static_cast <ObjectClass*> (0);
} }
//============================================================================== //==============================================================================
@@ -178,13 +178,13 @@ public:
int indexOf (const ObjectClass* const objectToLookFor) const throw() int indexOf (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed; ObjectClass** const end = e + numUsed;
while (e != end) while (e != end)
{ {
if (objectToLookFor == *e) if (objectToLookFor == *e)
return (int) (e - data.elements);
return (int) (e - data.elements.getData());
++e; ++e;
} }
@@ -200,7 +200,7 @@ public:
bool contains (const ObjectClass* const objectToLookFor) const throw() bool contains (const ObjectClass* const objectToLookFor) const throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
ObjectClass** e = data.elements;
ObjectClass** e = data.elements.getData();
ObjectClass** const end = e + numUsed; ObjectClass** const end = e + numUsed;
while (e != end) while (e != end)
@@ -378,7 +378,7 @@ public:
ObjectClass* newObject) throw() ObjectClass* newObject) throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
insert (findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed), newObject);
insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed), newObject);
} }
/** Inserts or replaces an object in the array, assuming it is sorted. /** Inserts or replaces an object in the array, assuming it is sorted.
@@ -391,7 +391,7 @@ public:
ObjectClass* newObject) throw() ObjectClass* newObject) throw()
{ {
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
const int index = findInsertIndexInSortedArray (comparator, (ObjectClass**) data.elements, newObject, 0, numUsed);
const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed);
if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0) if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0)
set (index - 1, newObject); // replace an existing object that matches set (index - 1, newObject); // replace an existing object that matches
@@ -661,7 +661,7 @@ public:
// avoids getting warning messages about the parameter being unused // avoids getting warning messages about the parameter being unused
const ScopedLockType lock (getLock()); const ScopedLockType lock (getLock());
sortArray (comparator, (ObjectClass**) data.elements, 0, size() - 1, retainOrderOfEquivalentItems);
sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems);
} }
//============================================================================== //==============================================================================


+ 4
- 4
src/containers/juce_Variant.cpp View File

@@ -134,7 +134,7 @@ var::operator int() const
case voidType: break; case voidType: break;
case intType: return value.intValue; case intType: return value.intValue;
case boolType: return value.boolValue ? 1 : 0; case boolType: return value.boolValue ? 1 : 0;
case doubleType: return (int) value.doubleValue;
case doubleType: return static_cast <int> (value.doubleValue);
case stringType: return value.stringValue->getIntValue(); case stringType: return value.stringValue->getIntValue();
case objectType: break; case objectType: break;
default: jassertfalse; break; default: jassertfalse; break;
@@ -215,9 +215,9 @@ bool var::equals (const var& other) const throw()
switch (type) switch (type)
{ {
case voidType: return other.isVoid(); case voidType: return other.isVoid();
case intType: return value.intValue == (int) other;
case boolType: return value.boolValue == (bool) other;
case doubleType: return value.doubleValue == (double) other;
case intType: return value.intValue == static_cast <int> (other);
case boolType: return value.boolValue == static_cast <bool> (other);
case doubleType: return value.doubleValue == static_cast <double> (other);
case stringType: return (*(value.stringValue)) == other.toString(); case stringType: return (*(value.stringValue)) == other.toString();
case objectType: return value.objectValue == other.getObject(); case objectType: return value.objectValue == other.getObject();
case methodType: return value.methodValue == other.value.methodValue && other.isMethod(); case methodType: return value.methodValue == other.value.methodValue && other.isMethod();


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 51 #define JUCE_MINOR_VERSION 51
#define JUCE_BUILDNUMBER 5
#define JUCE_BUILDNUMBER 6
/** Current Juce version number. /** Current Juce version number.


+ 3
- 1
src/gui/components/controls/juce_Slider.cpp View File

@@ -1143,7 +1143,9 @@ void Slider::restoreMouseIfHidden()
if (mouseWasHidden) if (mouseWasHidden)
{ {
mouseWasHidden = false; mouseWasHidden = false;
Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement (false);
for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;)
Desktop::getInstance().getMouseSource(i)->enableUnboundedMouseMovement (false);
const double pos = (sliderBeingDragged == 2) ? getMaxValue() const double pos = (sliderBeingDragged == 2) ? getMaxValue()
: ((sliderBeingDragged == 1) ? getMinValue() : ((sliderBeingDragged == 1) ? getMinValue()


+ 1
- 4
src/gui/components/juce_Desktop.cpp View File

@@ -40,10 +40,7 @@ Desktop::Desktop() throw()
: mouseClickCounter (0), : mouseClickCounter (0),
kioskModeComponent (0) kioskModeComponent (0)
{ {
const int maxNumMice = 1;
for (int i = maxNumMice; --i >= 0;)
mouseSources.add (new MouseInputSource (i, true));
createMouseInputSources();
refreshMonitorSizes(); refreshMonitorSizes();
} }


+ 2
- 0
src/gui/components/juce_Desktop.h View File

@@ -302,6 +302,8 @@ private:
Component* kioskModeComponent; Component* kioskModeComponent;
Rectangle<int> kioskComponentOriginalBounds; Rectangle<int> kioskComponentOriginalBounds;
void createMouseInputSources();
void timerCallback(); void timerCallback();
void sendMouseMove(); void sendMouseMove();
void resetTimer() throw(); void resetTimer() throw();


+ 51
- 12
src/gui/components/mouse/juce_MouseInputSource.cpp View File

@@ -92,11 +92,54 @@ public:
return 0; return 0;
} }
const Point<int> getScreenPosition() const
const Point<int> getScreenPosition() const throw()
{ {
return lastScreenPos + unboundedMouseOffset; return lastScreenPos + unboundedMouseOffset;
} }
//==============================================================================
void sendMouseEnter (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " enter: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseEnter (source, comp->globalPositionToRelative (screenPos), time);
}
void sendMouseExit (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " exit: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseExit (source, comp->globalPositionToRelative (screenPos), time);
}
void sendMouseMove (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " move: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseMove (source, comp->globalPositionToRelative (screenPos), time);
}
void sendMouseDown (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " down: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseDown (source, comp->globalPositionToRelative (screenPos), time);
}
void sendMouseDrag (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " drag: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseDrag (source, comp->globalPositionToRelative (screenPos), time);
}
void sendMouseUp (Component* const comp, const Point<int>& screenPos, const int64 time)
{
//DBG ("Mouse " + String (source.getIndex()) + " up: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseUp (source, comp->globalPositionToRelative (screenPos), time, getCurrentModifiers());
}
void sendMouseWheel (Component* const comp, const Point<int>& screenPos, const int64 time, float x, float y)
{
//DBG ("Mouse " + String (source.getIndex()) + " wheel: " + comp->globalPositionToRelative (screenPos).toString() + " - Comp: " + String::toHexString ((int) comp));
comp->internalMouseWheel (source, comp->globalPositionToRelative (screenPos), time, x, y);
}
//============================================================================== //==============================================================================
void setButtons (const Point<int>& screenPos, const int64 time, const ModifierKeys& newButtonState) void setButtons (const Point<int>& screenPos, const int64 time, const ModifierKeys& newButtonState)
{ {
@@ -114,8 +157,7 @@ public:
Component* const current = getComponentUnderMouse(); Component* const current = getComponentUnderMouse();
if (current != 0) if (current != 0)
current->internalMouseUp (source, current->globalPositionToRelative (screenPos + unboundedMouseOffset),
time, getCurrentModifiers());
sendMouseUp (current, screenPos + unboundedMouseOffset, time);
enableUnboundedMouseMovement (false, false); enableUnboundedMouseMovement (false, false);
} }
@@ -131,8 +173,7 @@ public:
if (current != 0) if (current != 0)
{ {
registerMouseDown (screenPos, time, current); registerMouseDown (screenPos, time, current);
current->internalMouseDown (source, current->globalPositionToRelative (screenPos), time);
sendMouseDown (current, screenPos, time);
} }
} }
} }
@@ -150,7 +191,7 @@ public:
if (current != 0) if (current != 0)
{ {
setButtons (screenPos, time, ModifierKeys()); setButtons (screenPos, time, ModifierKeys());
current->internalMouseExit (source, current->globalPositionToRelative (screenPos), time);
sendMouseExit (current, screenPos, time);
buttonState = originalButtonState; buttonState = originalButtonState;
} }
@@ -158,7 +199,7 @@ public:
current = getComponentUnderMouse(); current = getComponentUnderMouse();
if (current != 0) if (current != 0)
current->internalMouseEnter (source, current->globalPositionToRelative (screenPos), time);
sendMouseEnter (current, screenPos, time);
revealCursor (false); revealCursor (false);
setButtons (screenPos, time, originalButtonState); setButtons (screenPos, time, originalButtonState);
@@ -191,19 +232,17 @@ public:
if (current != 0) if (current != 0)
{ {
const Point<int> pos (current->globalPositionToRelative (lastScreenPos));
if (isDragging()) if (isDragging())
{ {
registerMouseDrag (newScreenPos); registerMouseDrag (newScreenPos);
current->internalMouseDrag (source, pos + unboundedMouseOffset, time);
sendMouseDrag (current, newScreenPos + unboundedMouseOffset, time);
if (isUnboundedMouseModeOn) if (isUnboundedMouseModeOn)
handleUnboundedDrag (current); handleUnboundedDrag (current);
} }
else else
{ {
current->internalMouseMove (source, pos, time);
sendMouseMove (current, newScreenPos, time);
} }
} }
@@ -252,7 +291,7 @@ public:
{ {
Component* current = getComponentUnderMouse(); Component* current = getComponentUnderMouse();
if (current != 0) if (current != 0)
current->internalMouseWheel (source, current->globalPositionToRelative (screenPos), time, x, y);
sendMouseWheel (current, screenPos, time, x, y);
} }
} }


+ 2
- 1
src/gui/components/special/juce_MagnifierComponent.cpp View File

@@ -327,7 +327,8 @@ void MagnifierComponent::mouseExit (const MouseEvent& e)
void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy) void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy)
{ {
if (peer != 0) if (peer != 0)
peer->handleMouseWheel (Point<int> (scaleInt (e.x), scaleInt (e.y)), e.eventTime.toMilliseconds(),
peer->handleMouseWheel (e.source.getIndex(),
Point<int> (scaleInt (e.x), scaleInt (e.y)), e.eventTime.toMilliseconds(),
ix * 256.0f, iy * 256.0f); ix * 256.0f, iy * 256.0f);
else else
Component::mouseWheelMove (e, ix, iy); Component::mouseWheelMove (e, ix, iy);


+ 10
- 4
src/gui/components/windows/juce_ComponentPeer.cpp View File

@@ -101,14 +101,20 @@ void ComponentPeer::updateCurrentModifiers() throw()
} }
//============================================================================== //==============================================================================
void ComponentPeer::handleMouseEvent (const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time)
void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time)
{ {
Desktop::getInstance().getMainMouseSource().handleEvent (this, positionWithinPeer, time, newMods);
MouseInputSource* const mouse = Desktop::getInstance().getMouseSource (touchIndex);
jassert (mouse != 0); // not enough sources!
mouse->handleEvent (this, positionWithinPeer, time, newMods);
} }
void ComponentPeer::handleMouseWheel (const Point<int>& positionWithinPeer, const int64 time, float x, float y)
void ComponentPeer::handleMouseWheel (const int touchIndex, const Point<int>& positionWithinPeer, const int64 time, const float x, const float y)
{ {
Desktop::getInstance().getMainMouseSource().handleWheel (this, positionWithinPeer, time, x, y);
MouseInputSource* const mouse = Desktop::getInstance().getMouseSource (touchIndex);
jassert (mouse != 0); // not enough sources!
mouse->handleWheel (this, positionWithinPeer, time, x, y);
} }
//============================================================================== //==============================================================================


+ 2
- 2
src/gui/components/windows/juce_ComponentPeer.h View File

@@ -293,8 +293,8 @@ public:
virtual void performAnyPendingRepaintsNow() = 0; virtual void performAnyPendingRepaintsNow() = 0;
//============================================================================== //==============================================================================
void handleMouseEvent (const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time);
void handleMouseWheel (const Point<int>& positionWithinPeer, const int64 time, float x, float y);
void handleMouseEvent (int touchIndex, const Point<int>& positionWithinPeer, const ModifierKeys& newMods, const int64 time);
void handleMouseWheel (int touchIndex, const Point<int>& positionWithinPeer, const int64 time, float x, float y);
void handleUserClosingWindow(); void handleUserClosingWindow();


+ 3
- 0
src/gui/graphics/geometry/juce_Point.h View File

@@ -101,6 +101,9 @@ public:
*/ */
void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); } void applyTransform (const AffineTransform& transform) throw() { transform.transformPoint (x, y); }
/** Returns the point as a string in the form "x, y". */
const String toString() const { return String (x) + ", " + String (y); }
//============================================================================== //==============================================================================
juce_UseDebuggingNewOperator juce_UseDebuggingNewOperator


+ 11
- 6
src/native/linux/juce_linux_Windowing.cpp View File

@@ -1150,7 +1150,7 @@ public:
if (map == WheelUp || map == WheelDown) if (map == WheelUp || map == WheelDown)
{ {
handleMouseWheel (Point<int> (buttonPressEvent->x, buttonPressEvent->y),
handleMouseWheel (0, Point<int> (buttonPressEvent->x, buttonPressEvent->y),
getEventTime (buttonPressEvent->time), 0, map == WheelDown ? -84.0f : 84.0f); getEventTime (buttonPressEvent->time), 0, map == WheelDown ? -84.0f : 84.0f);
} }
if (map == LeftButton) if (map == LeftButton)
@@ -1173,7 +1173,7 @@ public:
{ {
toFront (true); toFront (true);
handleMouseEvent (Point<int> (buttonPressEvent->x, buttonPressEvent->y), currentModifiers,
handleMouseEvent (0, Point<int> (buttonPressEvent->x, buttonPressEvent->y), currentModifiers,
getEventTime (buttonPressEvent->time)); getEventTime (buttonPressEvent->time));
} }
@@ -1195,7 +1195,7 @@ public:
else if (map == MiddleButton) else if (map == MiddleButton)
currentModifiers = currentModifiers.withoutFlags (ModifierKeys::middleButtonModifier); currentModifiers = currentModifiers.withoutFlags (ModifierKeys::middleButtonModifier);
handleMouseEvent (Point<int> (buttonRelEvent->x, buttonRelEvent->y), currentModifiers,
handleMouseEvent (0, Point<int> (buttonRelEvent->x, buttonRelEvent->y), currentModifiers,
getEventTime (buttonRelEvent->time)); getEventTime (buttonRelEvent->time));
clearLastMousePos(); clearLastMousePos();
@@ -1237,7 +1237,7 @@ public:
} }
} }
handleMouseEvent (mousePos - getScreenPosition(), currentModifiers, getEventTime (movedEvent->time));
handleMouseEvent (0, mousePos - getScreenPosition(), currentModifiers, getEventTime (movedEvent->time));
} }
break; break;
@@ -1251,7 +1251,7 @@ public:
if (! currentModifiers.isAnyMouseButtonDown()) if (! currentModifiers.isAnyMouseButtonDown())
{ {
updateKeyModifiers (enterEvent->state); updateKeyModifiers (enterEvent->state);
handleMouseEvent (Point<int> (enterEvent->x, enterEvent->y), currentModifiers, getEventTime (enterEvent->time));
handleMouseEvent (0, Point<int> (enterEvent->x, enterEvent->y), currentModifiers, getEventTime (enterEvent->time));
} }
break; break;
@@ -1268,7 +1268,7 @@ public:
|| leaveEvent->mode == NotifyUngrab) || leaveEvent->mode == NotifyUngrab)
{ {
updateKeyModifiers (leaveEvent->state); updateKeyModifiers (leaveEvent->state);
handleMouseEvent (Point<int> (leaveEvent->x, leaveEvent->y), currentModifiers, getEventTime (leaveEvent->time));
handleMouseEvent (0, Point<int> (leaveEvent->x, leaveEvent->y), currentModifiers, getEventTime (leaveEvent->time));
} }
break; break;
@@ -2667,6 +2667,11 @@ void juce_updateMultiMonitorInfo (Array <Rectangle<int> >& monitorCoords, const
} }
//============================================================================== //==============================================================================
void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}
bool Desktop::canUseSemiTransparentWindows() throw() bool Desktop::canUseSemiTransparentWindows() throw()
{ {
return false; return false;


+ 69
- 75
src/native/mac/juce_iphone_UIViewComponentPeer.mm View File

@@ -123,6 +123,8 @@ public:
void grabFocus(); void grabFocus();
void textInputRequired (const Point<int>& position); void textInputRequired (const Point<int>& position);
void handleTouches (UIEvent* e, bool isDown, bool isUp, bool isCancel);
//============================================================================== //==============================================================================
void repaint (int x, int y, int w, int h); void repaint (int x, int y, int w, int h);
void performAnyPendingRepaintsNow(); void performAnyPendingRepaintsNow();
@@ -134,6 +136,14 @@ public:
JuceUIView* view; JuceUIView* view;
bool isSharedWindow, fullScreen, insideDrawRect; bool isSharedWindow, fullScreen, insideDrawRect;
static ModifierKeys currentModifiers; static ModifierKeys currentModifiers;
static int64 getMouseTime (UIEvent* e)
{
return (Time::currentTimeMillis() - Time::getMillisecondCounter())
+ (int64) ([e timestamp] * 1000.0);
}
Array <UITouch*> currentTouches;
}; };
//============================================================================== //==============================================================================
@@ -180,98 +190,32 @@ void ModifierKeys::updateCurrentModifiers() throw()
currentModifiers = UIViewComponentPeer::currentModifiers; currentModifiers = UIViewComponentPeer::currentModifiers;
} }
static int64 getMouseTime (UIEvent* e)
{
return (Time::currentTimeMillis() - Time::getMillisecondCounter())
+ (int64) ([e timestamp] * 1000.0);
}
JUCE_NAMESPACE::Point<int> juce_lastMousePos; JUCE_NAMESPACE::Point<int> juce_lastMousePos;
//============================================================================== //==============================================================================
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;
NSArray* const t = [[event touchesForView: self] allObjects];
switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();
owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers
= JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers.withoutMouseButtons()
.withFlags (JUCE_NAMESPACE::ModifierKeys::leftButtonModifier);
owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}
default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, true, false, false);
} }
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;
NSArray* const t = [[event touchesForView: self] allObjects];
switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();
owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}
default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, false, false, false);
} }
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner == 0)
return;
NSArray* const t = [[event touchesForView: self] allObjects];
switch ([t count])
{
case 1: // One finger..
{
CGPoint p = [[t objectAtIndex: 0] locationInView: self];
const JUCE_NAMESPACE::Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + owner->getScreenPosition();
JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers
= JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers.withoutMouseButtons();
owner->handleMouseEvent (pos, JUCE_NAMESPACE::UIViewComponentPeer::currentModifiers, getMouseTime (event));
}
default:
//xxx multi-touch..
break;
}
if (owner != 0)
owner->handleTouches (event, false, true, false);
} }
- (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event - (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event
{ {
if (owner != 0)
owner->handleTouches (event, false, true, true);
[self touchesEnded: touches withEvent: event]; [self touchesEnded: touches withEvent: event];
} }
@@ -378,6 +322,8 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component,
view.hidden = ! component->isVisible(); view.hidden = ! component->isVisible();
window.hidden = ! component->isVisible(); window.hidden = ! component->isVisible();
view.multipleTouchEnabled = YES;
} }
setTitle (component->getName()); setTitle (component->getName());
@@ -628,6 +574,48 @@ void UIViewComponentPeer::setIcon (const Image& /*newIcon*/)
// to do.. // to do..
} }
//==============================================================================
void UIViewComponentPeer::handleTouches (UIEvent* event, const bool isDown, const bool isUp, bool isCancel)
{
NSArray* touches = [[event touchesForView: view] allObjects];
for (unsigned int i = 0; i < [touches count]; ++i)
{
UITouch* touch = [touches objectAtIndex: i];
CGPoint p = [touch locationInView: view];
const Point<int> pos ((int) p.x, (int) p.y);
juce_lastMousePos = pos + getScreenPosition();
const int64 time = getMouseTime (event);
int touchIndex = currentTouches.indexOf (touch);
if (touchIndex < 0)
{
touchIndex = currentTouches.size();
currentTouches.add (touch);
}
if (isDown)
{
currentModifiers = currentModifiers.withoutMouseButtons();
handleMouseEvent (touchIndex, pos, currentModifiers, time);
currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
}
else if (isUp)
{
currentModifiers = currentModifiers.withoutMouseButtons();
currentTouches.remove (touchIndex);
}
if (isCancel)
currentTouches.clear();
handleMouseEvent (touchIndex, pos, currentModifiers, time);
}
}
//============================================================================== //==============================================================================
static UIViewComponentPeer* currentlyFocusedPeer = 0; static UIViewComponentPeer* currentlyFocusedPeer = 0;
@@ -783,6 +771,12 @@ Image* juce_createIconForFile (const File& file)
} }
//============================================================================== //==============================================================================
void Desktop::createMouseInputSources()
{
for (int i = 0; i < 10; ++i)
mouseSources.add (new MouseInputSource (i, false));
}
bool Desktop::canUseSemiTransparentWindows() throw() bool Desktop::canUseSemiTransparentWindows() throw()
{ {
return true; return true;


+ 1
- 1
src/native/mac/juce_mac_MessageManager.mm View File

@@ -354,7 +354,7 @@ static bool isEventBlockedByModalComps (NSEvent* e)
case NSRightMouseUp: case NSRightMouseUp:
case NSOtherMouseUp: case NSOtherMouseUp:
case NSOtherMouseDragged: case NSOtherMouseDragged:
if (Desktop::getInstance().getMainMouseSource().isDragging())
if (Desktop::getInstance().getDraggingMouseSource(0) != 0)
return false; return false;
break; break;


+ 9
- 4
src/native/mac/juce_mac_MiscUtilities.mm View File

@@ -90,14 +90,19 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi
if (files.size() == 0) if (files.size() == 0)
return false; return false;
// This method must be called in response to a component's mouseDrag event!
jassert (Desktop::getInstance().getMainMouseSource().isDragging());
MouseInputSource* draggingSource = Desktop::getInstance().getDraggingMouseSource(0);
Component* sourceComp = Desktop::getInstance().getMainMouseSource().getComponentUnderMouse();
if (draggingSource == 0)
{
jassertfalse // This method must be called in response to a component's mouseDown or mouseDrag event!
return false;
}
Component* sourceComp = draggingSource->getComponentUnderMouse();
if (sourceComp == 0) if (sourceComp == 0)
{ {
jassertfalse // this method must be called in response to a component's mouseDrag event!
jassertfalse // This method must be called in response to a component's mouseDown or mouseDrag event!
return false; return false;
} }


+ 8
- 2
src/native/mac/juce_mac_NSViewComponentPeer.mm View File

@@ -1355,7 +1355,7 @@ bool NSViewComponentPeer::redirectPerformKeyEquivalent (NSEvent* ev)
void NSViewComponentPeer::sendMouseEvent (NSEvent* ev) void NSViewComponentPeer::sendMouseEvent (NSEvent* ev)
{ {
updateModifiers (ev); updateModifiers (ev);
handleMouseEvent (getMousePos (ev, view), currentModifiers, getMouseTime (ev));
handleMouseEvent (0, getMousePos (ev, view), currentModifiers, getMouseTime (ev));
} }
void NSViewComponentPeer::redirectMouseDown (NSEvent* ev) void NSViewComponentPeer::redirectMouseDown (NSEvent* ev)
@@ -1400,7 +1400,7 @@ void NSViewComponentPeer::redirectMouseWheel (NSEvent* ev)
{ {
updateModifiers (ev); updateModifiers (ev);
handleMouseWheel (getMousePos (ev, view), getMouseTime (ev),
handleMouseWheel (0, getMousePos (ev, view), getMouseTime (ev),
[ev deltaX] * 10.0f, [ev deltaY] * 10.0f); [ev deltaX] * 10.0f, [ev deltaY] * 10.0f);
} }
@@ -1574,6 +1574,12 @@ void NSViewComponentPeer::viewMovedToWindow()
window = [view window]; window = [view window];
} }
//==============================================================================
void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}
//============================================================================== //==============================================================================
void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars) void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
{ {


+ 46
- 1
src/native/mac/juce_mac_QuickTimeMovieComponent.mm View File

@@ -27,6 +27,50 @@
// compiled on its own). // compiled on its own).
#if JUCE_INCLUDED_FILE && JUCE_QUICKTIME #if JUCE_INCLUDED_FILE && JUCE_QUICKTIME
END_JUCE_NAMESPACE
//==============================================================================
#define NonInterceptingQTMovieView MakeObjCClassName(NonInterceptingQTMovieView)
@interface NonInterceptingQTMovieView : QTMovieView
{
}
- (id) initWithFrame: (NSRect) frame;
- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent;
- (NSView*) hitTest: (NSPoint) p;
@end
@implementation NonInterceptingQTMovieView
- (id) initWithFrame: (NSRect) frame
{
self = [super initWithFrame: frame];
[self setNextResponder: [self superview]];
return self;
}
- (void) dealloc
{
[super dealloc];
}
- (NSView*) hitTest: (NSPoint) point
{
return [self isControllerVisible] ? [super hitTest: point] : nil;
}
- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent
{
return YES;
}
@end
BEGIN_JUCE_NAMESPACE
//==============================================================================
#define theMovie ((QTMovie*) movie) #define theMovie ((QTMovie*) movie)
//============================================================================== //==============================================================================
@@ -36,8 +80,9 @@ QuickTimeMovieComponent::QuickTimeMovieComponent()
setOpaque (true); setOpaque (true);
setVisible (true); setVisible (true);
QTMovieView* view = [[QTMovieView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f)];
QTMovieView* view = [[NonInterceptingQTMovieView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f)];
setView (view); setView (view);
[view release];
} }
QuickTimeMovieComponent::~QuickTimeMovieComponent() QuickTimeMovieComponent::~QuickTimeMovieComponent()


+ 1
- 1
src/native/windows/juce_win32_ActiveXComponent.cpp View File

@@ -282,7 +282,7 @@ namespace ActiveXHelpers
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_RBUTTONUP: case WM_RBUTTONUP:
peer->handleMouseEvent (mousePos, Win32ComponentPeer::currentModifiers, mouseEventTime);
peer->handleMouseEvent (0, mousePos, Win32ComponentPeer::currentModifiers, mouseEventTime);
break; break;
default: default:


+ 8
- 3
src/native/windows/juce_win32_Windowing.cpp View File

@@ -563,7 +563,7 @@ public:
if (fullScreen != shouldBeFullScreen) if (fullScreen != shouldBeFullScreen)
{ {
fullScreen = shouldBeFullScreen; fullScreen = shouldBeFullScreen;
const Component::SafePointer deletionChecker (component);
const Component::SafePointer<Component> deletionChecker (component);
if (! fullScreen) if (! fullScreen)
{ {
@@ -1243,7 +1243,7 @@ private:
//============================================================================== //==============================================================================
void doMouseEvent (const Point<int>& position) void doMouseEvent (const Point<int>& position)
{ {
handleMouseEvent (position, currentModifiers, getMouseEventTime());
handleMouseEvent (0, position, currentModifiers, getMouseEventTime());
} }
void doMouseMove (const Point<int>& position) void doMouseMove (const Point<int>& position)
@@ -1314,7 +1314,7 @@ private:
const float amount = jlimit (-1000.0f, 1000.0f, 0.75f * HIWORD (wParam)); const float amount = jlimit (-1000.0f, 1000.0f, 0.75f * HIWORD (wParam));
handleMouseWheel (position, getMouseEventTime(),
handleMouseWheel (0, position, getMouseEventTime(),
isVertical ? 0.0f : amount, isVertical ? 0.0f : amount,
isVertical ? amount : 0.0f); isVertical ? amount : 0.0f);
} }
@@ -2227,6 +2227,11 @@ bool AlertWindow::showNativeDialogBox (const String& title,
//============================================================================== //==============================================================================
void Desktop::createMouseInputSources()
{
mouseSources.add (new MouseInputSource (0, true));
}
const Point<int> Desktop::getMousePosition() const Point<int> Desktop::getMousePosition()
{ {
POINT mousePos; POINT mousePos;


Loading…
Cancel
Save