diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a4557bcdc3..7746797262 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -41477,7 +41477,7 @@ public: && comp.hitTest (localPoint.getX(), localPoint.getY()); } - static const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) + static Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) { if (comp.affineTransform == nullptr) return pointInParentSpace - comp.getPosition(); @@ -41485,7 +41485,7 @@ public: return pointInParentSpace.toFloat().transformedBy (comp.affineTransform->inverted()).toInt() - comp.getPosition(); } - static const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) + static Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) { if (comp.affineTransform == nullptr) return areaInParentSpace - comp.getPosition(); @@ -41493,7 +41493,7 @@ public: return areaInParentSpace.toFloat().transformed (comp.affineTransform->inverted()).getSmallestIntegerContainer() - comp.getPosition(); } - static const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) + static Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) { if (comp.affineTransform == nullptr) return pointInLocalSpace + comp.getPosition(); @@ -41501,7 +41501,7 @@ public: return (pointInLocalSpace + comp.getPosition()).toFloat().transformedBy (*comp.affineTransform).toInt(); } - static const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) + static Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) { if (comp.affineTransform == nullptr) return areaInLocalSpace + comp.getPosition(); @@ -41510,7 +41510,7 @@ public: } template - static const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) + static Type convertFromDistantParentSpace (const Component* parent, const Component& target, const Type& coordInParent) { const Component* const directParent = target.getParentComponent(); jassert (directParent != nullptr); @@ -41522,7 +41522,7 @@ public: } template - static const Type convertCoordinate (const Component* target, const Component* source, Type p) + static Type convertCoordinate (const Component* target, const Component* source, Type p) { while (source != nullptr) { @@ -43528,66 +43528,41 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point& return; } - if (! flags.mouseInsideFlag) - { - flags.mouseInsideFlag = true; - flags.mouseOverFlag = true; - flags.mouseDownFlag = false; - - BailOutChecker checker (this); + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.repaintOnMouseActivityFlag) - repaint(); + BailOutChecker checker (this); - const MouseEvent me (source, relativePos, source.getCurrentModifiers(), - this, this, time, relativePos, time, 0, false); - mouseEnter (me); + const MouseEvent me (source, relativePos, source.getCurrentModifiers(), + this, this, time, relativePos, time, 0, false); + mouseEnter (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseEnter, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); } void Component::internalMouseExit (MouseInputSource& source, const Point& relativePos, const Time& time) { - BailOutChecker checker (this); - - if (flags.mouseDownFlag) - { - internalMouseUp (source, relativePos, time, source.getCurrentModifiers().getRawFlags()); - - if (checker.shouldBailOut()) - return; - } + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.mouseInsideFlag || flags.mouseOverFlag) - { - flags.mouseInsideFlag = false; - flags.mouseOverFlag = false; - flags.mouseDownFlag = false; + BailOutChecker checker (this); - if (flags.repaintOnMouseActivityFlag) - repaint(); + const MouseEvent me (source, relativePos, source.getCurrentModifiers(), + this, this, time, relativePos, time, 0, false); - const MouseEvent me (source, relativePos, source.getCurrentModifiers(), - this, this, time, relativePos, time, 0, false); - mouseExit (me); + mouseExit (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseExit, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); } void Component::internalMouseDown (MouseInputSource& source, const Point& relativePos, const Time& time) @@ -43612,8 +43587,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r this, this, time, relativePos, time, source.getNumberOfMultipleClicks(), false); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); return; } } @@ -43643,9 +43617,6 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r return; } - flags.mouseDownFlag = true; - flags.mouseOverFlag = true; - if (flags.repaintOnMouseActivityFlag) repaint(); @@ -43657,84 +43628,70 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r if (checker.shouldBailOut()) return; - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); } void Component::internalMouseUp (MouseInputSource& source, const Point& relativePos, const Time& time, const ModifierKeys& oldModifiers) { - if (flags.mouseDownFlag) - { - flags.mouseDownFlag = false; + BailOutChecker checker (this); - BailOutChecker checker (this); + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.repaintOnMouseActivityFlag) - repaint(); + const MouseEvent me (source, relativePos, + oldModifiers, this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); - const MouseEvent me (source, relativePos, - oldModifiers, this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); + mouseUp (me); + + if (checker.shouldBailOut()) + return; - mouseUp (me); + Desktop& desktop = Desktop::getInstance(); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseUp, me); - if (checker.shouldBailOut()) - return; + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); + if (checker.shouldBailOut()) + return; - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); + // check for double-click + if (me.getNumberOfClicks() >= 2) + { + mouseDoubleClick (me); if (checker.shouldBailOut()) return; - // check for double-click - if (me.getNumberOfClicks() >= 2) - { - mouseDoubleClick (me); - - if (checker.shouldBailOut()) - return; - - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); - } + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); } } void Component::internalMouseDrag (MouseInputSource& source, const Point& relativePos, const Time& time) { - if (flags.mouseDownFlag) - { - flags.mouseOverFlag = reallyContains (relativePos, false); - - BailOutChecker checker (this); + BailOutChecker checker (this); - const MouseEvent me (source, relativePos, - source.getCurrentModifiers(), this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); + const MouseEvent me (source, relativePos, + source.getCurrentModifiers(), this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); - mouseDrag (me); + mouseDrag (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseDrag, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); } void Component::internalMouseMove (MouseInputSource& source, const Point& relativePos, const Time& time) @@ -43752,15 +43709,12 @@ void Component::internalMouseMove (MouseInputSource& source, const Point& r } else { - flags.mouseOverFlag = true; - mouseMove (me); if (checker.shouldBailOut()) return; - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseMove, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseMove, me); } @@ -44138,27 +44092,47 @@ void Component::giveAwayFocus (const bool sendFocusLossEvent) bool Component::isMouseOver (const bool includeChildren) const { - if (flags.mouseOverFlag) - return true; + const Desktop& desktop = Desktop::getInstance(); - if (includeChildren) + for (int i = desktop.getNumMouseSources(); --i >= 0;) { - Desktop& desktop = Desktop::getInstance(); + const MouseInputSource* const mi = desktop.getMouseSource(i); - for (int i = desktop.getNumMouseSources(); --i >= 0;) - { - Component* const c = desktop.getMouseSource(i)->getComponentUnderMouse(); + Component* const c = mi->getComponentUnderMouse(); - if (isParentOf (c) && c->flags.mouseOverFlag) // (mouseOverFlag checked in case it's being dragged outside the comp) - return true; - } + if ((c == this || (includeChildren && isParentOf (c))) + && c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()), false)) + return true; + } + + return false; +} + +bool Component::isMouseButtonDown() const +{ + const Desktop& desktop = Desktop::getInstance(); + + for (int i = desktop.getNumMouseSources(); --i >= 0;) + { + const MouseInputSource* const mi = desktop.getMouseSource(i); + + if (mi->isDragging() && mi->getComponentUnderMouse() == this) + return true; } return false; } -bool Component::isMouseButtonDown() const noexcept { return flags.mouseDownFlag; } -bool Component::isMouseOverOrDragging() const noexcept { return flags.mouseOverFlag || flags.mouseDownFlag; } +bool Component::isMouseOverOrDragging() const +{ + const Desktop& desktop = Desktop::getInstance(); + + for (int i = desktop.getNumMouseSources(); --i >= 0;) + if (desktop.getMouseSource(i)->getComponentUnderMouse() == this) + return true; + + return false; +} bool JUCE_CALLTYPE Component::isMouseButtonDownAnywhere() noexcept { @@ -44566,6 +44540,22 @@ void Desktop::handleAsyncUpdate() focusListeners.call (&FocusChangeListener::globalFocusChanged, currentFocus); } +void Desktop::resetTimer() +{ + if (mouseListeners.size() == 0) + stopTimer(); + else + startTimer (100); + + lastFakeMouseMove = getMousePosition(); +} + +ListenerList & Desktop::getMouseListeners() +{ + resetTimer(); + return mouseListeners; +} + void Desktop::addGlobalMouseListener (MouseListener* const listener) { mouseListeners.add (listener); @@ -44611,16 +44601,6 @@ void Desktop::sendMouseMove() } } -void Desktop::resetTimer() -{ - if (mouseListeners.size() == 0) - stopTimer(); - else - startTimer (100); - - lastFakeMouseMove = getMousePosition(); -} - void Desktop::setKioskModeComponent (Component* componentToUse, const bool allowMenusAndBars) { if (kioskModeComponent != componentToUse) @@ -63082,7 +63062,7 @@ ModifierKeys& ModifierKeys::operator= (const ModifierKeys& other) noexcept ModifierKeys ModifierKeys::currentModifiers; -const ModifierKeys ModifierKeys::getCurrentModifiers() noexcept +ModifierKeys ModifierKeys::getCurrentModifiers() noexcept { return currentModifiers; } @@ -73580,7 +73560,7 @@ public: return static_cast (componentUnderMouse); } - const ModifierKeys getCurrentModifiers() const + ModifierKeys getCurrentModifiers() const { return ModifierKeys::getCurrentModifiers().withoutMouseButtons().withFlags (buttonState.getRawFlags()); } @@ -73610,7 +73590,7 @@ public: return nullptr; } - const Point getScreenPosition() const + Point getScreenPosition() const { // This needs to return the live position if possible, but it mustn't update the lastScreenPos // value, because that can cause continuity problems. @@ -73716,8 +73696,12 @@ public: if (current != nullptr) { + WeakReference safeOldComp (current); setButtons (screenPos, time, ModifierKeys()); - sendMouseExit (current, screenPos, time); + + if (safeOldComp != nullptr) + sendMouseExit (current, screenPos, time); + buttonState = originalButtonState; } @@ -74019,8 +74003,8 @@ bool MouseInputSource::canHover() const { return isMouse(); } bool MouseInputSource::hasMouseWheel() const { return isMouse(); } int MouseInputSource::getIndex() const { return pimpl->index; } bool MouseInputSource::isDragging() const { return pimpl->isDragging(); } -const Point MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } -const ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } +Point MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } +ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); } void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); } int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); } @@ -93447,7 +93431,7 @@ void GlyphArrangement::stretchRangeOfGlyphs (int startIndex, int num, } } -const Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const +Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const { jassert (startIndex >= 0); @@ -108537,6 +108521,21 @@ public: bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) { + jassert (destSamples != nullptr); + const int64 samplesAvailable = lengthInSamples - startSampleInFile; + + if (samplesAvailable < numSamples) + { + for (int i = numDestChannels; --i >= 0;) + if (destSamples[i] != nullptr) + zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * numSamples); + + numSamples = (int) samplesAvailable; + } + + if (numSamples <= 0) + return true; + OSStatus status = ExtAudioFileSeek (audioFileRef, startSampleInFile); if (status != noErr) return false; @@ -251296,7 +251295,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = Win32ComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { Win32ComponentPeer::updateKeyModifiers(); @@ -251499,7 +251498,7 @@ void Desktop::createMouseInputSources() mouseSources.add (new MouseInputSource (0, true)); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { POINT mousePos; GetCursorPos (&mousePos); @@ -268009,7 +268008,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = LinuxComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { Window root, child; int x, y, winx, winy; @@ -268184,7 +268183,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept && (matchedDepth == desiredDepth); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { Window root, child; int x, y, winx, winy; @@ -271048,6 +271047,16 @@ namespace { return [NSString stringWithUTF8String: s.toUTF8()]; } + + NSString* nsStringLiteral (const char* const s) noexcept + { + return [NSString stringWithUTF8String: s]; + } + + NSString* nsEmptyString() noexcept + { + return [NSString string]; + } } #endif // __JUCE_OSX_OBJCHELPERS_JUCEHEADER__ @@ -271795,7 +271804,7 @@ private: if (req == nil) return nil; - [req setHTTPMethod: isPost ? @"POST" : @"GET"]; + [req setHTTPMethod: nsStringLiteral (isPost ? "POST" : "GET")]; //[req setCachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData]; StringArray headerLines; @@ -273219,7 +273228,7 @@ String File::getVersion() const if (info != nil) { - NSString* name = [info valueForKey: @"CFBundleShortVersionString"]; + NSString* name = [info valueForKey: nsStringLiteral ("CFBundleShortVersionString")]; if (name != nil) result = nsStringToJuce (name); @@ -273260,7 +273269,7 @@ bool File::moveToTrash() const return [[NSWorkspace sharedWorkspace] performFileOperation: NSWorkspaceRecycleOperation source: [p stringByDeletingLastPathComponent] - destination: @"" + destination: nsEmptyString() files: [NSArray arrayWithObject: [p lastPathComponent]] tag: nil ]; #endif @@ -273383,7 +273392,7 @@ void File::revealToUser() const { #if ! JUCE_IOS if (exists()) - [[NSWorkspace sharedWorkspace] selectFile: juceStringToNS (getFullPathName()) inFileViewerRootedAtPath: @""]; + [[NSWorkspace sharedWorkspace] selectFile: juceStringToNS (getFullPathName()) inFileViewerRootedAtPath: nsEmptyString()]; else if (getParentDirectory().exists()) getParentDirectory().revealToUser(); #endif @@ -274467,13 +274476,13 @@ void Font::getPlatformDefaultFontNames (String& defaultSans, String& defaultSeri namespace { template - const Rectangle convertToRectInt (const RectType& r) + Rectangle convertToRectInt (const RectType& r) { return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); } template - const Rectangle convertToRectFloat (const RectType& r) + Rectangle convertToRectFloat (const RectType& r) { return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); } @@ -275618,7 +275627,7 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) ModifierKeys UIViewComponentPeer::currentModifiers; -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return UIViewComponentPeer::currentModifiers; } @@ -276558,7 +276567,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept return true; } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { return juce_lastMousePos; } @@ -277422,7 +277431,7 @@ END_JUCE_NAMESPACE (void) request; (void) frame; - NSURL* url = [actionInformation valueForKey: @"WebActionOriginalURLKey"]; + NSURL* url = [actionInformation valueForKey: nsStringLiteral ("WebActionOriginalURLKey")]; if (ownerComponent->pageAboutToLoad (nsStringToJuce ([url absoluteString]))) [listener use]; @@ -277440,8 +277449,8 @@ public: WebBrowserComponentInternal (WebBrowserComponent* owner) { webView = [[WebView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) - frameName: @"" - groupName: @""]; + frameName: nsEmptyString() + groupName: nsEmptyString()]; setView (webView); clickListener = [[DownloadClickDetector alloc] initWithWebBrowserOwner: owner]; @@ -277466,7 +277475,7 @@ public: if (postData != nullptr && postData->getSize() > 0) { - [r setHTTPMethod: @"POST"]; + [r setHTTPMethod: nsStringLiteral ("POST")]; [r setHTTPBody: [NSData dataWithBytes: postData->getData() length: postData->getSize()]]; } @@ -279051,7 +279060,7 @@ using namespace JUCE_NAMESPACE; - (void) broadcastMessageCallback: (NSNotification*) n { NSDictionary* dict = (NSDictionary*) [n userInfo]; - const String messageString (nsStringToJuce ((NSString*) [dict valueForKey: @"message"])); + const String messageString (nsStringToJuce ((NSString*) [dict valueForKey: nsStringLiteral ("message")])); MessageManager::getInstance()->deliverBroadcastMessage (messageString); } @@ -279170,7 +279179,7 @@ bool MessageManager::postMessageToSystemQueue (Message* message) void MessageManager::broadcastMessage (const String& message) { NSDictionary* info = [NSDictionary dictionaryWithObject: juceStringToNS (message) - forKey: @"message"]; + forKey: nsStringLiteral ("message")]; [[NSDistributedNotificationCenter defaultCenter] postNotificationName: AppDelegateRedirector::getBroacastEventName() object: nil @@ -279973,13 +279982,13 @@ void Font::getPlatformDefaultFontNames (String& defaultSans, String& defaultSeri namespace { template - const Rectangle convertToRectInt (const RectType& r) + Rectangle convertToRectInt (const RectType& r) { return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); } template - const Rectangle convertToRectFloat (const RectType& r) + Rectangle convertToRectFloat (const RectType& r) { return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); } @@ -281736,7 +281745,7 @@ void NSViewComponentPeer::updateKeysDown (NSEvent* ev, bool isKeyDown) } } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return NSViewComponentPeer::currentModifiers; } @@ -282369,7 +282378,7 @@ BOOL NSViewComponentPeer::sendDragCallback (const int type, id NSPasteboard* pasteBoard = [sender draggingPasteboard]; StringArray files; - NSString* iTunesPasteboardType = @"CorePasteboardFlavorType 0x6974756E"; // 'itun' + NSString* iTunesPasteboardType = nsStringLiteral ("CorePasteboardFlavorType 0x6974756E"); // 'itun' if (bestType == NSFilesPromisePboardType && [[pasteBoard types] containsObject: iTunesPasteboardType]) @@ -282379,13 +282388,13 @@ BOOL NSViewComponentPeer::sendDragCallback (const int type, id if ([list isKindOfClass: [NSDictionary class]]) { NSDictionary* iTunesDictionary = (NSDictionary*) list; - NSArray* tracks = [iTunesDictionary valueForKey: @"Tracks"]; + NSArray* tracks = [iTunesDictionary valueForKey: nsStringLiteral ("Tracks")]; NSEnumerator* enumerator = [tracks objectEnumerator]; NSDictionary* track; while ((track = [enumerator nextObject]) != nil) { - NSURL* url = [NSURL URLWithString: [track valueForKey: @"Location"]]; + NSURL* url = [NSURL URLWithString: [track valueForKey: nsStringLiteral ("Location")]]; if ([url isFileURL]) files.add (nsStringToJuce ([url path])); @@ -282769,7 +282778,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType const String& title, const String& message, Component* associatedComponent) { - OSXMessageBox box (iconType, title, message, @"OK", nil, nil, 0, false); + OSXMessageBox box (iconType, title, message, nsStringLiteral ("OK"), nil, nil, 0, false); (void) box.getResult(); } @@ -282777,7 +282786,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIcon const String& title, const String& message, Component* associatedComponent) { - new OSXMessageBox (iconType, title, message, @"OK", nil, nil, 0, true); + new OSXMessageBox (iconType, title, message, nsStringLiteral ("OK"), nil, nil, 0, true); } bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType iconType, @@ -282786,7 +282795,9 @@ bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType ModalComponentManager::Callback* callback) { ScopedPointer mb (new OSXMessageBox (iconType, title, message, - @"OK", @"Cancel", nil, callback, callback != nullptr)); + nsStringLiteral ("OK"), + nsStringLiteral ("Cancel"), + nil, callback, callback != nullptr)); if (callback == nullptr) return mb->getResult() == 1; @@ -282800,7 +282811,10 @@ int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (AlertWindow::AlertIconTy ModalComponentManager::Callback* callback) { ScopedPointer mb (new OSXMessageBox (iconType, title, message, - @"Yes", @"Cancel", @"No", callback, callback != nullptr)); + nsStringLiteral ("Yes"), + nsStringLiteral ("Cancel"), + nsStringLiteral ("No"), + callback, callback != nullptr)); if (callback == nullptr) return mb->getResult(); @@ -282874,7 +282888,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept return true; } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { JUCE_AUTORELEASEPOOL const NSPoint p ([NSEvent mouseLocation]); @@ -283226,7 +283240,7 @@ public: componentPeerChanged(); } - const Rectangle getViewBounds() const + Rectangle getViewBounds() const { NSRect r = [view frame]; return Rectangle (0, 0, (int) r.size.width, (int) r.size.height); @@ -284122,7 +284136,7 @@ public: { NSMenuItem* item = [parent addItemWithTitle: juceStringToNS (name) action: nil - keyEquivalent: @""]; + keyEquivalent: nsEmptyString()]; [item setTag: tag]; NSMenu* sub = createMenu (child, name, menuId, tag); @@ -284226,7 +284240,7 @@ public: NSString* text = juceStringToNS (iter.itemName.upToFirstOccurrenceOf ("", false, true)); if (text == nil) - text = @""; + text = nsEmptyString(); if (iter.isSeparator) { @@ -284236,7 +284250,7 @@ public: { NSMenuItem* item = [menuToAddTo addItemWithTitle: text action: nil - keyEquivalent: @""]; + keyEquivalent: nsEmptyString()]; [item setEnabled: false]; } @@ -284244,7 +284258,7 @@ public: { NSMenuItem* item = [menuToAddTo addItemWithTitle: text action: nil - keyEquivalent: @""]; + keyEquivalent: nsEmptyString()]; [item setTag: iter.itemId]; [item setEnabled: iter.isEnabled]; @@ -284258,7 +284272,7 @@ public: { NSMenuItem* item = [menuToAddTo addItemWithTitle: text action: @selector (menuItemInvoked:) - keyEquivalent: @""]; + keyEquivalent: nsEmptyString()]; [item setTag: iter.itemId]; [item setEnabled: iter.isEnabled]; @@ -284341,7 +284355,7 @@ private: static void flashMenuBar (NSMenu* menu) { - if ([[menu title] isEqualToString: @"Apple"]) + if ([[menu title] isEqualToString: nsStringLiteral ("Apple")]) return; [menu retain]; @@ -284349,7 +284363,7 @@ private: const unichar f35Key = NSF35FunctionKey; NSString* f35String = [NSString stringWithCharacters: &f35Key length: 1]; - NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"x" + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: nsStringLiteral ("x") action: nil keyEquivalent: f35String]; [item setTarget: nil]; @@ -284504,11 +284518,11 @@ namespace MainMenuHelpers NSMenuItem* item; // Services... - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Services", nil) - action: nil keyEquivalent: @""]; + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Services"), nil) + action: nil keyEquivalent: nsEmptyString()]; [menu addItem: item]; [item release]; - NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: @"Services"]; + NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Services")]; [menu setSubmenu: servicesMenu forItem: item]; [NSApp setServicesMenu: servicesMenu]; [servicesMenu release]; @@ -284516,20 +284530,20 @@ namespace MainMenuHelpers // Hide + Show stuff... item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Hide " + appName) - action: @selector (hide:) keyEquivalent: @"h"]; + action: @selector (hide:) keyEquivalent: nsStringLiteral ("h")]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) - action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Hide Others"), nil) + action: @selector (hideOtherApplications:) keyEquivalent: nsStringLiteral ("h")]; [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) - action: @selector (unhideAllApplications:) keyEquivalent: @""]; + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (nsStringLiteral ("Show All"), nil) + action: @selector (unhideAllApplications:) keyEquivalent: nsEmptyString()]; [item setTarget: NSApp]; [menu addItem: item]; [item release]; @@ -284538,7 +284552,7 @@ namespace MainMenuHelpers // Quit item.... item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Quit " + appName) - action: @selector (terminate:) keyEquivalent: @"q"]; + action: @selector (terminate:) keyEquivalent: nsStringLiteral ("q")]; [item setTarget: NSApp]; [menu addItem: item]; @@ -284557,10 +284571,10 @@ namespace MainMenuHelpers { JUCE_AUTORELEASEPOOL - NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: @"MainMenu"]; - NSMenuItem* item = [mainMenu addItemWithTitle: @"Apple" action: nil keyEquivalent: @""]; + NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("MainMenu")]; + NSMenuItem* item = [mainMenu addItemWithTitle: nsStringLiteral ("Apple") action: nil keyEquivalent: nsEmptyString()]; - NSMenu* appMenu = [[NSMenu alloc] initWithTitle: @"Apple"]; + NSMenu* appMenu = [[NSMenu alloc] initWithTitle: nsStringLiteral ("Apple")]; [NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu]; [mainMenu setSubmenu: appMenu forItem: item]; @@ -284874,7 +284888,7 @@ static QTMovie* openMovieFromStream (InputStream* movieStream, File& movieFile) movie = [QTMovie movieWithDataReference: [QTDataReference dataReferenceWithReferenceToData: [NSData dataWithBytes: temp.getData() length: temp.getSize()] name: [NSString stringWithUTF8String: suffixesToTry[i]] - MIMEType: @""] + MIMEType: nsEmptyString()] error: nil]; if (movie != 0) @@ -285937,7 +285951,7 @@ END_JUCE_NAMESPACE (void) request; (void) frame; - NSURL* url = [actionInformation valueForKey: @"WebActionOriginalURLKey"]; + NSURL* url = [actionInformation valueForKey: nsStringLiteral ("WebActionOriginalURLKey")]; if (ownerComponent->pageAboutToLoad (nsStringToJuce ([url absoluteString]))) [listener use]; @@ -285955,8 +285969,8 @@ public: WebBrowserComponentInternal (WebBrowserComponent* owner) { webView = [[WebView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) - frameName: @"" - groupName: @""]; + frameName: nsEmptyString() + groupName: nsEmptyString()]; setView (webView); clickListener = [[DownloadClickDetector alloc] initWithWebBrowserOwner: owner]; @@ -285981,7 +285995,7 @@ public: if (postData != nullptr && postData->getSize() > 0) { - [r setHTTPMethod: @"POST"]; + [r setHTTPMethod: nsStringLiteral ("POST")]; [r setHTTPBody: [NSData dataWithBytes: postData->getData() length: postData->getSize()]]; } @@ -288217,7 +288231,7 @@ END_JUCE_NAMESPACE #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: QTSampleBufferHostTimeAttribute]; #else - NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: @"hostTime"]; + NSNumber* hosttime = (NSNumber*) [sampleBuffer attributeForKey: nsStringLiteral ("hostTime")]; #endif int64 presentationTime = (hosttime != nil) @@ -288314,10 +288328,10 @@ void CameraDevice::startRecordingToFile (const File& file, int quality) if ([mediaType isEqualToString: QTMediaTypeVideo]) options = [QTCompressionOptions compressionOptionsWithIdentifier: - quality >= 1 ? @"QTCompressionOptionsSD480SizeH264Video" - : @"QTCompressionOptions240SizeH264Video"]; + quality >= 1 ? nsStringLiteral ("QTCompressionOptionsSD480SizeH264Video")_ + nsStringLiteral ("QTCompressionOptions240SizeH264Video")]; else if ([mediaType isEqualToString: QTMediaTypeSound]) - options = [QTCompressionOptions compressionOptionsWithIdentifier: @"QTCompressionOptionsHighQualityAACAudio"]; + options = [QTCompressionOptions compressionOptionsWithIdentifier: nsStringLiteral ("QTCompressionOptionsHighQualityAACAudio")]; [d->fileOutput setCompressionOptions: options forConnection: connection]; } @@ -292296,7 +292310,7 @@ void Desktop::createMouseInputSources() mouseSources.add (new MouseInputSource (i, false)); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { return AndroidComponentPeer::lastMousePos; } @@ -292317,7 +292331,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = AndroidComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return AndroidComponentPeer::currentModifiers; } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 09f681f635..3ca662c1a5 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 18 +#define JUCE_BUILDNUMBER 19 /** Current Juce version number. @@ -23937,21 +23937,21 @@ public: /** Middle mouse button flag. */ middleButtonModifier = 64, -#if JUCE_MAC + #if JUCE_MAC /** Command key flag - on windows this is the same as the CTRL key flag. */ commandModifier = 8, /** Popup menu flag - on windows this is the same as rightButtonModifier, on the Mac it's the same as (rightButtonModifier | ctrlModifier). */ popupMenuClickModifier = rightButtonModifier | ctrlModifier, -#else + #else /** Command key flag - on windows this is the same as the CTRL key flag. */ commandModifier = ctrlModifier, /** Popup menu flag - on windows this is the same as rightButtonModifier, on the Mac it's the same as (rightButtonModifier | ctrlModifier). */ popupMenuClickModifier = rightButtonModifier, -#endif + #endif /** Represents a combination of all the shift, alt, ctrl and command key modifiers. */ allKeyboardModifiers = shiftModifier | ctrlModifier | altModifier | commandModifier, @@ -23961,10 +23961,10 @@ public: }; /** Returns a copy of only the mouse-button flags */ - const ModifierKeys withOnlyMouseButtons() const noexcept { return ModifierKeys (flags & allMouseButtonModifiers); } + ModifierKeys withOnlyMouseButtons() const noexcept { return ModifierKeys (flags & allMouseButtonModifiers); } /** Returns a copy of only the non-mouse flags */ - const ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); } + ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); } bool operator== (const ModifierKeys& other) const noexcept { return flags == other.flags; } bool operator!= (const ModifierKeys& other) const noexcept { return flags != other.flags; } @@ -23986,7 +23986,7 @@ public: @see getCurrentModifiersRealtime */ - static const ModifierKeys getCurrentModifiers() noexcept; + static ModifierKeys getCurrentModifiers() noexcept; /** Creates a ModifierKeys object to represent the current state of the keyboard and mouse buttons. @@ -24002,7 +24002,7 @@ public: update the value returned by getCurrentModifiers(), which could cause subtle changes in the behaviour of some components. */ - static const ModifierKeys getCurrentModifiersRealtime() noexcept; + static ModifierKeys getCurrentModifiersRealtime() noexcept; private: @@ -26185,12 +26185,12 @@ public: This is only relevent for floating-point rectangles, of course. @see toFloat() */ - const Rectangle getSmallestIntegerContainer() const noexcept + Rectangle getSmallestIntegerContainer() const noexcept { const int x1 = (int) std::floor (static_cast (x)); const int y1 = (int) std::floor (static_cast (y)); - const int x2 = (int) std::ceil (static_cast (x + w)); - const int y2 = (int) std::ceil (static_cast (y + h)); + const int x2 = (int) std::ceil (static_cast (x + w)); + const int y2 = (int) std::ceil (static_cast (y + h)); return Rectangle (x1, y1, x2 - x1, y2 - y1); } @@ -26221,7 +26221,7 @@ public: Obviously this is mainly useful for rectangles that use integer types. @see getSmallestIntegerContainer */ - const Rectangle toFloat() const noexcept + Rectangle toFloat() const noexcept { return Rectangle (static_cast (x), static_cast (y), static_cast (w), static_cast (h)); @@ -32500,7 +32500,7 @@ public: @see isMouseButtonDownAnywhere, isMouseOver, isMouseOverOrDragging */ - bool isMouseButtonDown() const noexcept; + bool isMouseButtonDown() const; /** True if the mouse is over this component, or if it's being dragged in this component. @@ -32508,7 +32508,7 @@ public: @see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere */ - bool isMouseOverOrDragging() const noexcept; + bool isMouseOverOrDragging() const; /** Returns true if a mouse button is currently down. @@ -32989,9 +32989,6 @@ private: bool bufferToImageFlag : 1; bool bringToFrontOnClickFlag : 1; bool repaintOnMouseActivityFlag : 1; - bool mouseDownFlag : 1; - bool mouseOverFlag : 1; - bool mouseInsideFlag : 1; bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; @@ -34462,6 +34459,7 @@ private: void timerCallback(); void resetTimer(); + ListenerList & getMouseListeners(); int getNumDisplayMonitors() const noexcept; const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; @@ -57762,7 +57760,7 @@ public: /** Returns the y position of the bottom of the glyph. */ float getBottom() const { return y + font.getDescent(); } /** Returns the bounds of the glyph. */ - const Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } + Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } /** Shifts the glyph's position by a relative amount. */ void moveBy (float deltaX, float deltaY); @@ -57941,7 +57939,7 @@ public: @param includeWhitespace if true, the extent of any whitespace characters will also be taken into account */ - const Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; + Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; /** Shifts a set of glyphs by a given amount. @@ -62943,12 +62941,12 @@ public: bool isDragging() const; /** Returns the last-known screen position of this source. */ - const Point getScreenPosition() const; + Point getScreenPosition() const; /** Returns a set of modifiers that indicate which buttons are currently held down on this device. */ - const ModifierKeys getCurrentModifiers() const; + ModifierKeys getCurrentModifiers() const; /** Returns the component that was last known to be under this pointer. */ Component* getComponentUnderMouse() const; @@ -63025,7 +63023,7 @@ private: friend class MouseInputSourceInternal; ScopedPointer pimpl; - static const Point getCurrentMousePosition(); + static Point getCurrentMousePosition(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInputSource); }; diff --git a/src/audio/audio_file_formats/juce_CoreAudioFormat.cpp b/src/audio/audio_file_formats/juce_CoreAudioFormat.cpp index 3f869c3b06..af5070ce4e 100644 --- a/src/audio/audio_file_formats/juce_CoreAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_CoreAudioFormat.cpp @@ -135,6 +135,21 @@ public: bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) { + jassert (destSamples != nullptr); + const int64 samplesAvailable = lengthInSamples - startSampleInFile; + + if (samplesAvailable < numSamples) + { + for (int i = numDestChannels; --i >= 0;) + if (destSamples[i] != nullptr) + zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * numSamples); + + numSamples = (int) samplesAvailable; + } + + if (numSamples <= 0) + return true; + OSStatus status = ExtAudioFileSeek (audioFileRef, startSampleInFile); if (status != noErr) return false; diff --git a/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp b/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp index 0c0c76bfac..ba27dc65f1 100644 --- a/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp +++ b/src/audio/plugin_client/VST/juce_VST_Wrapper.cpp @@ -155,7 +155,7 @@ BEGIN_JUCE_NAMESPACE extern void detachComponentFromWindowRef (Component* component, void* nsWindow); extern void setNativeHostWindowSize (void* nsWindow, Component* editorComp, int newWidth, int newHeight, const PluginHostType& host); extern void checkWindowVisibility (void* nsWindow, Component* component); - extern void forwardCurrentKeyEventToHost (Component* component); + extern bool forwardCurrentKeyEventToHost (Component* component); #endif #if JUCE_LINUX @@ -1275,12 +1275,11 @@ public: } #if JUCE_MAC - bool keyPressed (const KeyPress& kp) + bool keyPressed (const KeyPress&) { // If we have an unused keypress, move the key-focus to a host window // and re-inject the event.. - forwardCurrentKeyEventToHost (this); - return true; + return forwardCurrentKeyEventToHost (this); } #endif diff --git a/src/audio/plugin_client/VST/juce_VST_Wrapper.mm b/src/audio/plugin_client/VST/juce_VST_Wrapper.mm index 839895ed9f..8520948d9b 100644 --- a/src/audio/plugin_client/VST/juce_VST_Wrapper.mm +++ b/src/audio/plugin_client/VST/juce_VST_Wrapper.mm @@ -229,12 +229,15 @@ void checkWindowVisibility (void* nsWindow, Component* comp) #endif } -void forwardCurrentKeyEventToHost (Component* comp) +bool forwardCurrentKeyEventToHost (Component* comp) { - #if ! JUCE_64BIT + #if JUCE_64BIT + return false; + #else NSWindow* win = [(NSView*) comp->getWindowHandle() window]; [[win parentWindow] makeKeyWindow]; [NSApp postEvent: [NSApp currentEvent] atStart: YES]; + return true; #endif } diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index c26adad169..f99f236ed2 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 18 +#define JUCE_BUILDNUMBER 19 /** Current Juce version number. diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index e0f5a37f26..2c2ae82926 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -236,7 +236,7 @@ public: && comp.hitTest (localPoint.getX(), localPoint.getY()); } - static const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) + static Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) { if (comp.affineTransform == nullptr) return pointInParentSpace - comp.getPosition(); @@ -244,7 +244,7 @@ public: return pointInParentSpace.toFloat().transformedBy (comp.affineTransform->inverted()).toInt() - comp.getPosition(); } - static const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) + static Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) { if (comp.affineTransform == nullptr) return areaInParentSpace - comp.getPosition(); @@ -252,7 +252,7 @@ public: return areaInParentSpace.toFloat().transformed (comp.affineTransform->inverted()).getSmallestIntegerContainer() - comp.getPosition(); } - static const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) + static Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) { if (comp.affineTransform == nullptr) return pointInLocalSpace + comp.getPosition(); @@ -260,7 +260,7 @@ public: return (pointInLocalSpace + comp.getPosition()).toFloat().transformedBy (*comp.affineTransform).toInt(); } - static const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) + static Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) { if (comp.affineTransform == nullptr) return areaInLocalSpace + comp.getPosition(); @@ -269,7 +269,7 @@ public: } template - static const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) + static Type convertFromDistantParentSpace (const Component* parent, const Component& target, const Type& coordInParent) { const Component* const directParent = target.getParentComponent(); jassert (directParent != nullptr); @@ -281,7 +281,7 @@ public: } template - static const Type convertCoordinate (const Component* target, const Component* source, Type p) + static Type convertCoordinate (const Component* target, const Component* source, Type p) { while (source != nullptr) { @@ -2326,66 +2326,41 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point& return; } - if (! flags.mouseInsideFlag) - { - flags.mouseInsideFlag = true; - flags.mouseOverFlag = true; - flags.mouseDownFlag = false; - - BailOutChecker checker (this); + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.repaintOnMouseActivityFlag) - repaint(); + BailOutChecker checker (this); - const MouseEvent me (source, relativePos, source.getCurrentModifiers(), - this, this, time, relativePos, time, 0, false); - mouseEnter (me); + const MouseEvent me (source, relativePos, source.getCurrentModifiers(), + this, this, time, relativePos, time, 0, false); + mouseEnter (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseEnter, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); } void Component::internalMouseExit (MouseInputSource& source, const Point& relativePos, const Time& time) { - BailOutChecker checker (this); - - if (flags.mouseDownFlag) - { - internalMouseUp (source, relativePos, time, source.getCurrentModifiers().getRawFlags()); - - if (checker.shouldBailOut()) - return; - } + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.mouseInsideFlag || flags.mouseOverFlag) - { - flags.mouseInsideFlag = false; - flags.mouseOverFlag = false; - flags.mouseDownFlag = false; + BailOutChecker checker (this); - if (flags.repaintOnMouseActivityFlag) - repaint(); + const MouseEvent me (source, relativePos, source.getCurrentModifiers(), + this, this, time, relativePos, time, 0, false); - const MouseEvent me (source, relativePos, source.getCurrentModifiers(), - this, this, time, relativePos, time, 0, false); - mouseExit (me); + mouseExit (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseExit, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); } //============================================================================== @@ -2411,8 +2386,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r this, this, time, relativePos, time, source.getNumberOfMultipleClicks(), false); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); return; } } @@ -2442,9 +2416,6 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r return; } - flags.mouseDownFlag = true; - flags.mouseOverFlag = true; - if (flags.repaintOnMouseActivityFlag) repaint(); @@ -2456,8 +2427,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r if (checker.shouldBailOut()) return; - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseDown, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); } @@ -2465,76 +2435,63 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r //============================================================================== void Component::internalMouseUp (MouseInputSource& source, const Point& relativePos, const Time& time, const ModifierKeys& oldModifiers) { - if (flags.mouseDownFlag) - { - flags.mouseDownFlag = false; + BailOutChecker checker (this); - BailOutChecker checker (this); + if (flags.repaintOnMouseActivityFlag) + repaint(); - if (flags.repaintOnMouseActivityFlag) - repaint(); + const MouseEvent me (source, relativePos, + oldModifiers, this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); - const MouseEvent me (source, relativePos, - oldModifiers, this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); + mouseUp (me); - mouseUp (me); + if (checker.shouldBailOut()) + return; - if (checker.shouldBailOut()) - return; + Desktop& desktop = Desktop::getInstance(); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseUp, me); + + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); + if (checker.shouldBailOut()) + return; - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseUp, me); + // check for double-click + if (me.getNumberOfClicks() >= 2) + { + mouseDoubleClick (me); if (checker.shouldBailOut()) return; - // check for double-click - if (me.getNumberOfClicks() >= 2) - { - mouseDoubleClick (me); - - if (checker.shouldBailOut()) - return; - - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); - } + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDoubleClick, me); } } void Component::internalMouseDrag (MouseInputSource& source, const Point& relativePos, const Time& time) { - if (flags.mouseDownFlag) - { - flags.mouseOverFlag = reallyContains (relativePos, false); - - BailOutChecker checker (this); + BailOutChecker checker (this); - const MouseEvent me (source, relativePos, - source.getCurrentModifiers(), this, this, time, - getLocalPoint (nullptr, source.getLastMouseDownPosition()), - source.getLastMouseDownTime(), - source.getNumberOfMultipleClicks(), - source.hasMouseMovedSignificantlySincePressed()); + const MouseEvent me (source, relativePos, + source.getCurrentModifiers(), this, this, time, + getLocalPoint (nullptr, source.getLastMouseDownPosition()), + source.getLastMouseDownTime(), + source.getNumberOfMultipleClicks(), + source.hasMouseMovedSignificantlySincePressed()); - mouseDrag (me); + mouseDrag (me); - if (checker.shouldBailOut()) - return; + if (checker.shouldBailOut()) + return; - Desktop& desktop = Desktop::getInstance(); - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); + Desktop::getInstance().getMouseListeners().callChecked (checker, &MouseListener::mouseDrag, me); - MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); - } + MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDrag, me); } void Component::internalMouseMove (MouseInputSource& source, const Point& relativePos, const Time& time) @@ -2552,15 +2509,12 @@ void Component::internalMouseMove (MouseInputSource& source, const Point& r } else { - flags.mouseOverFlag = true; - mouseMove (me); if (checker.shouldBailOut()) return; - desktop.resetTimer(); - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); + desktop.getMouseListeners().callChecked (checker, &MouseListener::mouseMove, me); MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseMove, me); } @@ -2941,27 +2895,47 @@ void Component::giveAwayFocus (const bool sendFocusLossEvent) //============================================================================== bool Component::isMouseOver (const bool includeChildren) const { - if (flags.mouseOverFlag) - return true; + const Desktop& desktop = Desktop::getInstance(); - if (includeChildren) + for (int i = desktop.getNumMouseSources(); --i >= 0;) { - Desktop& desktop = Desktop::getInstance(); + const MouseInputSource* const mi = desktop.getMouseSource(i); - for (int i = desktop.getNumMouseSources(); --i >= 0;) - { - Component* const c = desktop.getMouseSource(i)->getComponentUnderMouse(); + Component* const c = mi->getComponentUnderMouse(); - if (isParentOf (c) && c->flags.mouseOverFlag) // (mouseOverFlag checked in case it's being dragged outside the comp) - return true; - } + if ((c == this || (includeChildren && isParentOf (c))) + && c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()), false)) + return true; } return false; } -bool Component::isMouseButtonDown() const noexcept { return flags.mouseDownFlag; } -bool Component::isMouseOverOrDragging() const noexcept { return flags.mouseOverFlag || flags.mouseDownFlag; } +bool Component::isMouseButtonDown() const +{ + const Desktop& desktop = Desktop::getInstance(); + + for (int i = desktop.getNumMouseSources(); --i >= 0;) + { + const MouseInputSource* const mi = desktop.getMouseSource(i); + + if (mi->isDragging() && mi->getComponentUnderMouse() == this) + return true; + } + + return false; +} + +bool Component::isMouseOverOrDragging() const +{ + const Desktop& desktop = Desktop::getInstance(); + + for (int i = desktop.getNumMouseSources(); --i >= 0;) + if (desktop.getMouseSource(i)->getComponentUnderMouse() == this) + return true; + + return false; +} bool JUCE_CALLTYPE Component::isMouseButtonDownAnywhere() noexcept { diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 3df438078c..e77fce4206 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -1769,7 +1769,7 @@ public: @see isMouseButtonDownAnywhere, isMouseOver, isMouseOverOrDragging */ - bool isMouseButtonDown() const noexcept; + bool isMouseButtonDown() const; /** True if the mouse is over this component, or if it's being dragged in this component. @@ -1777,7 +1777,7 @@ public: @see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere */ - bool isMouseOverOrDragging() const noexcept; + bool isMouseOverOrDragging() const; /** Returns true if a mouse button is currently down. @@ -2271,9 +2271,6 @@ private: bool bufferToImageFlag : 1; bool bringToFrontOnClickFlag : 1; bool repaintOnMouseActivityFlag : 1; - bool mouseDownFlag : 1; - bool mouseOverFlag : 1; - bool mouseInsideFlag : 1; bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; diff --git a/src/gui/components/juce_Desktop.cpp b/src/gui/components/juce_Desktop.cpp index 6e2e0de600..494cdfa6cf 100644 --- a/src/gui/components/juce_Desktop.cpp +++ b/src/gui/components/juce_Desktop.cpp @@ -352,6 +352,22 @@ void Desktop::handleAsyncUpdate() } //============================================================================== +void Desktop::resetTimer() +{ + if (mouseListeners.size() == 0) + stopTimer(); + else + startTimer (100); + + lastFakeMouseMove = getMousePosition(); +} + +ListenerList & Desktop::getMouseListeners() +{ + resetTimer(); + return mouseListeners; +} + void Desktop::addGlobalMouseListener (MouseListener* const listener) { mouseListeners.add (listener); @@ -397,16 +413,6 @@ void Desktop::sendMouseMove() } } -void Desktop::resetTimer() -{ - if (mouseListeners.size() == 0) - stopTimer(); - else - startTimer (100); - - lastFakeMouseMove = getMousePosition(); -} - //============================================================================== void Desktop::setKioskModeComponent (Component* componentToUse, const bool allowMenusAndBars) { diff --git a/src/gui/components/juce_Desktop.h b/src/gui/components/juce_Desktop.h index 7ac29d35b5..6c71e48c35 100644 --- a/src/gui/components/juce_Desktop.h +++ b/src/gui/components/juce_Desktop.h @@ -392,6 +392,7 @@ private: void timerCallback(); void resetTimer(); + ListenerList & getMouseListeners(); int getNumDisplayMonitors() const noexcept; const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; diff --git a/src/gui/components/keyboard/juce_ModifierKeys.cpp b/src/gui/components/keyboard/juce_ModifierKeys.cpp index 764c3b0ed8..d5b4715772 100644 --- a/src/gui/components/keyboard/juce_ModifierKeys.cpp +++ b/src/gui/components/keyboard/juce_ModifierKeys.cpp @@ -49,7 +49,7 @@ ModifierKeys& ModifierKeys::operator= (const ModifierKeys& other) noexcept ModifierKeys ModifierKeys::currentModifiers; -const ModifierKeys ModifierKeys::getCurrentModifiers() noexcept +ModifierKeys ModifierKeys::getCurrentModifiers() noexcept { return currentModifiers; } diff --git a/src/gui/components/keyboard/juce_ModifierKeys.h b/src/gui/components/keyboard/juce_ModifierKeys.h index 313ec29fd5..9893b7dc91 100644 --- a/src/gui/components/keyboard/juce_ModifierKeys.h +++ b/src/gui/components/keyboard/juce_ModifierKeys.h @@ -128,21 +128,21 @@ public: /** Middle mouse button flag. */ middleButtonModifier = 64, -#if JUCE_MAC + #if JUCE_MAC /** Command key flag - on windows this is the same as the CTRL key flag. */ commandModifier = 8, /** Popup menu flag - on windows this is the same as rightButtonModifier, on the Mac it's the same as (rightButtonModifier | ctrlModifier). */ popupMenuClickModifier = rightButtonModifier | ctrlModifier, -#else + #else /** Command key flag - on windows this is the same as the CTRL key flag. */ commandModifier = ctrlModifier, /** Popup menu flag - on windows this is the same as rightButtonModifier, on the Mac it's the same as (rightButtonModifier | ctrlModifier). */ popupMenuClickModifier = rightButtonModifier, -#endif + #endif /** Represents a combination of all the shift, alt, ctrl and command key modifiers. */ allKeyboardModifiers = shiftModifier | ctrlModifier | altModifier | commandModifier, @@ -153,10 +153,10 @@ public: //============================================================================== /** Returns a copy of only the mouse-button flags */ - const ModifierKeys withOnlyMouseButtons() const noexcept { return ModifierKeys (flags & allMouseButtonModifiers); } + ModifierKeys withOnlyMouseButtons() const noexcept { return ModifierKeys (flags & allMouseButtonModifiers); } /** Returns a copy of only the non-mouse flags */ - const ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); } + ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); } bool operator== (const ModifierKeys& other) const noexcept { return flags == other.flags; } bool operator!= (const ModifierKeys& other) const noexcept { return flags != other.flags; } @@ -180,7 +180,7 @@ public: @see getCurrentModifiersRealtime */ - static const ModifierKeys getCurrentModifiers() noexcept; + static ModifierKeys getCurrentModifiers() noexcept; /** Creates a ModifierKeys object to represent the current state of the keyboard and mouse buttons. @@ -196,7 +196,7 @@ public: update the value returned by getCurrentModifiers(), which could cause subtle changes in the behaviour of some components. */ - static const ModifierKeys getCurrentModifiersRealtime() noexcept; + static ModifierKeys getCurrentModifiersRealtime() noexcept; private: diff --git a/src/gui/components/mouse/juce_MouseInputSource.cpp b/src/gui/components/mouse/juce_MouseInputSource.cpp index 976c63725a..f9b22ff19a 100644 --- a/src/gui/components/mouse/juce_MouseInputSource.cpp +++ b/src/gui/components/mouse/juce_MouseInputSource.cpp @@ -59,7 +59,7 @@ public: return static_cast (componentUnderMouse); } - const ModifierKeys getCurrentModifiers() const + ModifierKeys getCurrentModifiers() const { return ModifierKeys::getCurrentModifiers().withoutMouseButtons().withFlags (buttonState.getRawFlags()); } @@ -89,7 +89,7 @@ public: return nullptr; } - const Point getScreenPosition() const + Point getScreenPosition() const { // This needs to return the live position if possible, but it mustn't update the lastScreenPos // value, because that can cause continuity problems. @@ -197,8 +197,12 @@ public: if (current != nullptr) { + WeakReference safeOldComp (current); setButtons (screenPos, time, ModifierKeys()); - sendMouseExit (current, screenPos, time); + + if (safeOldComp != nullptr) + sendMouseExit (current, screenPos, time); + buttonState = originalButtonState; } @@ -507,8 +511,8 @@ bool MouseInputSource::canHover() const { return bool MouseInputSource::hasMouseWheel() const { return isMouse(); } int MouseInputSource::getIndex() const { return pimpl->index; } bool MouseInputSource::isDragging() const { return pimpl->isDragging(); } -const Point MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } -const ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } +Point MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } +ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); } void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); } int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); } diff --git a/src/gui/components/mouse/juce_MouseInputSource.h b/src/gui/components/mouse/juce_MouseInputSource.h index 4e5408273a..6d649093f0 100644 --- a/src/gui/components/mouse/juce_MouseInputSource.h +++ b/src/gui/components/mouse/juce_MouseInputSource.h @@ -97,12 +97,12 @@ public: bool isDragging() const; /** Returns the last-known screen position of this source. */ - const Point getScreenPosition() const; + Point getScreenPosition() const; /** Returns a set of modifiers that indicate which buttons are currently held down on this device. */ - const ModifierKeys getCurrentModifiers() const; + ModifierKeys getCurrentModifiers() const; /** Returns the component that was last known to be under this pointer. */ Component* getComponentUnderMouse() const; @@ -180,7 +180,7 @@ private: friend class MouseInputSourceInternal; ScopedPointer pimpl; - static const Point getCurrentMousePosition(); + static Point getCurrentMousePosition(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInputSource); }; diff --git a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp index 077c8882d1..65c481403d 100644 --- a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp +++ b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp @@ -623,7 +623,7 @@ void GlyphArrangement::stretchRangeOfGlyphs (int startIndex, int num, } } -const Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const +Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const { jassert (startIndex >= 0); diff --git a/src/gui/graphics/fonts/juce_GlyphArrangement.h b/src/gui/graphics/fonts/juce_GlyphArrangement.h index 231fb855b5..23c90d064e 100644 --- a/src/gui/graphics/fonts/juce_GlyphArrangement.h +++ b/src/gui/graphics/fonts/juce_GlyphArrangement.h @@ -67,7 +67,7 @@ public: /** Returns the y position of the bottom of the glyph. */ float getBottom() const { return y + font.getDescent(); } /** Returns the bounds of the glyph. */ - const Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } + Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } //============================================================================== /** Shifts the glyph's position by a relative amount. */ @@ -255,7 +255,7 @@ public: @param includeWhitespace if true, the extent of any whitespace characters will also be taken into account */ - const Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; + Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; /** Shifts a set of glyphs by a given amount. diff --git a/src/gui/graphics/geometry/juce_Rectangle.h b/src/gui/graphics/geometry/juce_Rectangle.h index 369d57455b..cab1ced63e 100644 --- a/src/gui/graphics/geometry/juce_Rectangle.h +++ b/src/gui/graphics/geometry/juce_Rectangle.h @@ -620,12 +620,12 @@ public: This is only relevent for floating-point rectangles, of course. @see toFloat() */ - const Rectangle getSmallestIntegerContainer() const noexcept + Rectangle getSmallestIntegerContainer() const noexcept { const int x1 = (int) std::floor (static_cast (x)); const int y1 = (int) std::floor (static_cast (y)); - const int x2 = (int) std::ceil (static_cast (x + w)); - const int y2 = (int) std::ceil (static_cast (y + h)); + const int x2 = (int) std::ceil (static_cast (x + w)); + const int y2 = (int) std::ceil (static_cast (y + h)); return Rectangle (x1, y1, x2 - x1, y2 - y1); } @@ -656,7 +656,7 @@ public: Obviously this is mainly useful for rectangles that use integer types. @see getSmallestIntegerContainer */ - const Rectangle toFloat() const noexcept + Rectangle toFloat() const noexcept { return Rectangle (static_cast (x), static_cast (y), static_cast (w), static_cast (h)); diff --git a/src/native/android/juce_android_Windowing.cpp b/src/native/android/juce_android_Windowing.cpp index e2f95f702f..a98e36ea36 100644 --- a/src/native/android/juce_android_Windowing.cpp +++ b/src/native/android/juce_android_Windowing.cpp @@ -578,7 +578,7 @@ void Desktop::createMouseInputSources() mouseSources.add (new MouseInputSource (i, false)); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { return AndroidComponentPeer::lastMousePos; } @@ -600,7 +600,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = AndroidComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return AndroidComponentPeer::currentModifiers; } diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index a567a3f506..fa3437c27c 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -2616,7 +2616,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = LinuxComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { Window root, child; int x, y, winx, winy; @@ -2798,7 +2798,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept && (matchedDepth == desiredDepth); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { Window root, child; int x, y, winx, winy; diff --git a/src/native/mac/juce_ios_UIViewComponentPeer.mm b/src/native/mac/juce_ios_UIViewComponentPeer.mm index 357af16b77..4f058c7815 100644 --- a/src/native/mac/juce_ios_UIViewComponentPeer.mm +++ b/src/native/mac/juce_ios_UIViewComponentPeer.mm @@ -286,7 +286,7 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) ModifierKeys UIViewComponentPeer::currentModifiers; -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return UIViewComponentPeer::currentModifiers; } diff --git a/src/native/mac/juce_ios_Windowing.mm b/src/native/mac/juce_ios_Windowing.mm index 6d472332fb..419941e1e5 100644 --- a/src/native/mac/juce_ios_Windowing.mm +++ b/src/native/mac/juce_ios_Windowing.mm @@ -228,7 +228,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept return true; } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { return juce_lastMousePos; } diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index 203e00bc9c..7dcab41e45 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -32,13 +32,13 @@ namespace { template - const Rectangle convertToRectInt (const RectType& r) + Rectangle convertToRectInt (const RectType& r) { return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); } template - const Rectangle convertToRectFloat (const RectType& r) + Rectangle convertToRectFloat (const RectType& r) { return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); } diff --git a/src/native/mac/juce_mac_NSViewComponent.mm b/src/native/mac/juce_mac_NSViewComponent.mm index 2981a9d046..26f7192a37 100644 --- a/src/native/mac/juce_mac_NSViewComponent.mm +++ b/src/native/mac/juce_mac_NSViewComponent.mm @@ -105,7 +105,7 @@ public: componentPeerChanged(); } - const Rectangle getViewBounds() const + Rectangle getViewBounds() const { NSRect r = [view frame]; return Rectangle (0, 0, (int) r.size.width, (int) r.size.height); diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 5b6aacbdcf..a14dc709f5 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -905,7 +905,7 @@ void NSViewComponentPeer::updateKeysDown (NSEvent* ev, bool isKeyDown) } } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { return NSViewComponentPeer::currentModifiers; } diff --git a/src/native/mac/juce_mac_Windowing.mm b/src/native/mac/juce_mac_Windowing.mm index 89bc7502e1..e9f170d89e 100644 --- a/src/native/mac/juce_mac_Windowing.mm +++ b/src/native/mac/juce_mac_Windowing.mm @@ -217,7 +217,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept return true; } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { JUCE_AUTORELEASEPOOL const NSPoint p ([NSEvent mouseLocation]); diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 099b312437..f3946e5230 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -2575,7 +2575,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept currentModifiers = Win32ComponentPeer::currentModifiers; } -const ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept +ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept { Win32ComponentPeer::updateKeyModifiers(); @@ -2785,7 +2785,7 @@ void Desktop::createMouseInputSources() mouseSources.add (new MouseInputSource (0, true)); } -const Point MouseInputSource::getCurrentMousePosition() +Point MouseInputSource::getCurrentMousePosition() { POINT mousePos; GetCursorPos (&mousePos);