| @@ -81,7 +81,7 @@ public: | |||||
| appFocusChangeCallback = appFocusChanged; | appFocusChangeCallback = appFocusChanged; | ||||
| isEventBlockedByModalComps = checkEventBlockedByModalComps; | isEventBlockedByModalComps = checkEventBlockedByModalComps; | ||||
| NSRect r = makeNSRect (component.getLocalBounds()); | |||||
| auto r = makeNSRect (component.getLocalBounds()); | |||||
| view = [createViewInstance() initWithFrame: r]; | view = [createViewInstance() initWithFrame: r]; | ||||
| setOwner (view, this); | setOwner (view, this); | ||||
| @@ -164,7 +164,8 @@ public: | |||||
| #endif | #endif | ||||
| } | } | ||||
| const float alpha = component.getAlpha(); | |||||
| auto alpha = component.getAlpha(); | |||||
| if (alpha < 1.0f) | if (alpha < 1.0f) | ||||
| setAlpha (alpha); | setAlpha (alpha); | ||||
| @@ -247,8 +248,8 @@ public: | |||||
| { | { | ||||
| fullScreen = isNowFullScreen; | fullScreen = isNowFullScreen; | ||||
| NSRect r = makeNSRect (newBounds); | |||||
| NSSize oldViewSize = [view frame].size; | |||||
| auto r = makeNSRect (newBounds); | |||||
| auto oldViewSize = [view frame].size; | |||||
| if (isSharedWindow) | if (isSharedWindow) | ||||
| { | { | ||||
| @@ -272,7 +273,7 @@ public: | |||||
| Rectangle<int> getBounds (const bool global) const | Rectangle<int> getBounds (const bool global) const | ||||
| { | { | ||||
| NSRect r = [view frame]; | |||||
| auto r = [view frame]; | |||||
| NSWindow* viewWindow = [view window]; | NSWindow* viewWindow = [view window]; | ||||
| if (global && viewWindow != nil) | if (global && viewWindow != nil) | ||||
| @@ -338,7 +339,7 @@ public: | |||||
| { | { | ||||
| if (! isSharedWindow) | if (! isSharedWindow) | ||||
| { | { | ||||
| Rectangle<int> r (lastNonFullscreenBounds); | |||||
| auto r = lastNonFullscreenBounds; | |||||
| if (isMinimised()) | if (isMinimised()) | ||||
| setMinimised (false); | setMinimised (false); | ||||
| @@ -400,10 +401,10 @@ public: | |||||
| { | { | ||||
| if (NSWindow* const viewWindow = [view window]) | if (NSWindow* const viewWindow = [view window]) | ||||
| { | { | ||||
| const NSRect windowFrame = [viewWindow frame]; | |||||
| const NSPoint windowPoint = [view convertPoint: NSMakePoint (localPos.x, viewFrame.size.height - localPos.y) toView: nil]; | |||||
| const NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + windowPoint.x, | |||||
| windowFrame.origin.y + windowPoint.y); | |||||
| NSRect windowFrame = [viewWindow frame]; | |||||
| NSPoint windowPoint = [view convertPoint: NSMakePoint (localPos.x, viewFrame.size.height - localPos.y) toView: nil]; | |||||
| NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + windowPoint.x, | |||||
| windowFrame.origin.y + windowPoint.y); | |||||
| if (! isWindowAtPoint (viewWindow, screenPoint)) | if (! isWindowAtPoint (viewWindow, screenPoint)) | ||||
| return false; | return false; | ||||
| @@ -440,7 +441,7 @@ public: | |||||
| { | { | ||||
| if (hasNativeTitleBar()) | if (hasNativeTitleBar()) | ||||
| { | { | ||||
| const Rectangle<int> screen (getFrameSize().subtractedFrom (component.getParentMonitorArea())); | |||||
| auto screen = getFrameSize().subtractedFrom (component.getParentMonitorArea()); | |||||
| fullScreen = component.getScreenBounds().expanded (2, 2).contains (screen); | fullScreen = component.getScreenBounds().expanded (2, 2).contains (screen); | ||||
| } | } | ||||
| @@ -691,12 +692,12 @@ public: | |||||
| bool handleKeyEvent (NSEvent* ev, bool isKeyDown) | bool handleKeyEvent (NSEvent* ev, bool isKeyDown) | ||||
| { | { | ||||
| const String unicode (nsStringToJuce ([ev characters])); | |||||
| const int keyCode = getKeyCodeFromEvent (ev); | |||||
| auto unicode = nsStringToJuce ([ev characters]); | |||||
| auto keyCode = getKeyCodeFromEvent (ev); | |||||
| #if JUCE_DEBUG_KEYCODES | #if JUCE_DEBUG_KEYCODES | ||||
| DBG ("unicode: " + unicode + " " + String::toHexString ((int) unicode[0])); | DBG ("unicode: " + unicode + " " + String::toHexString ((int) unicode[0])); | ||||
| String unmodified (nsStringToJuce ([ev charactersIgnoringModifiers])); | |||||
| auto unmodified = nsStringToJuce ([ev charactersIgnoringModifiers]); | |||||
| DBG ("unmodified: " + unmodified + " " + String::toHexString ((int) unmodified[0])); | DBG ("unmodified: " + unmodified + " " + String::toHexString ((int) unmodified[0])); | ||||
| #endif | #endif | ||||
| @@ -706,9 +707,9 @@ public: | |||||
| { | { | ||||
| bool used = false; | bool used = false; | ||||
| for (String::CharPointerType u (unicode.getCharPointer()); ! u.isEmpty();) | |||||
| for (auto u = unicode.getCharPointer(); ! u.isEmpty();) | |||||
| { | { | ||||
| juce_wchar textCharacter = u.getAndAdvance(); | |||||
| auto textCharacter = u.getAndAdvance(); | |||||
| switch (keyCode) | switch (keyCode) | ||||
| { | { | ||||
| @@ -794,7 +795,7 @@ public: | |||||
| if (r.size.width < 1.0f || r.size.height < 1.0f) | if (r.size.width < 1.0f || r.size.height < 1.0f) | ||||
| return; | return; | ||||
| CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; | |||||
| auto cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; | |||||
| if (! component.isOpaque()) | if (! component.isOpaque()) | ||||
| CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | ||||
| @@ -849,8 +850,8 @@ public: | |||||
| { | { | ||||
| const Point<int> offset (-roundToInt (r.origin.x), | const Point<int> offset (-roundToInt (r.origin.x), | ||||
| -roundToInt ([view frame].size.height - (r.origin.y + r.size.height))); | -roundToInt ([view frame].size.height - (r.origin.y + r.size.height))); | ||||
| const int clipW = (int) (r.size.width + 0.5f); | |||||
| const int clipH = (int) (r.size.height + 0.5f); | |||||
| auto clipW = (int) (r.size.width + 0.5f); | |||||
| auto clipH = (int) (r.size.height + 0.5f); | |||||
| RectangleList<int> clip; | RectangleList<int> clip; | ||||
| getClipRects (clip, offset, clipW, clipH); | getClipRects (clip, offset, clipW, clipH); | ||||
| @@ -863,7 +864,8 @@ public: | |||||
| ! component.isOpaque()); | ! component.isOpaque()); | ||||
| { | { | ||||
| const int intScale = roundToInt (displayScale); | |||||
| auto intScale = roundToInt (displayScale); | |||||
| if (intScale != 1) | if (intScale != 1) | ||||
| clip.scaleAll (intScale); | clip.scaleAll (intScale); | ||||
| @@ -898,9 +900,9 @@ public: | |||||
| if (isTimerRunning()) | if (isTimerRunning()) | ||||
| return; | return; | ||||
| const uint32 now = Time::getMillisecondCounter(); | |||||
| uint32 msSinceLastRepaint = (lastRepaintTime >= now) ? now - lastRepaintTime | |||||
| : (std::numeric_limits<uint32>::max() - lastRepaintTime) + now; | |||||
| auto now = Time::getMillisecondCounter(); | |||||
| auto msSinceLastRepaint = (lastRepaintTime >= now) ? now - lastRepaintTime | |||||
| : (std::numeric_limits<uint32>::max() - lastRepaintTime) + now; | |||||
| static uint32 minimumRepaintInterval = 1000 / 30; // 30fps | static uint32 minimumRepaintInterval = 1000 / 30; // 30fps | ||||
| @@ -1036,12 +1038,12 @@ public: | |||||
| { | { | ||||
| if (constrainer != nullptr && ! isKioskMode()) | if (constrainer != nullptr && ! isKioskMode()) | ||||
| { | { | ||||
| const float scale = getComponent().getDesktopScaleFactor(); | |||||
| auto scale = getComponent().getDesktopScaleFactor(); | |||||
| auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r))); | auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r))); | ||||
| auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame]))); | auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame]))); | ||||
| const Rectangle<int> screenBounds (Desktop::getInstance().getDisplays().getTotalBounds (true)); | |||||
| auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true); | |||||
| #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | ||||
| const bool inLiveResize = [window inLiveResize]; | const bool inLiveResize = [window inLiveResize]; | ||||
| @@ -1102,9 +1104,8 @@ public: | |||||
| static void updateKeysDown (NSEvent* ev, bool isKeyDown) | static void updateKeysDown (NSEvent* ev, bool isKeyDown) | ||||
| { | { | ||||
| updateModifiers (ev); | updateModifiers (ev); | ||||
| int keyCode = getKeyCodeFromEvent (ev); | |||||
| if (keyCode != 0) | |||||
| if (auto keyCode = getKeyCodeFromEvent (ev)) | |||||
| { | { | ||||
| if (isKeyDown) | if (isKeyDown) | ||||
| keysCurrentlyDown.addIfNotAlreadyThere (keyCode); | keysCurrentlyDown.addIfNotAlreadyThere (keyCode); | ||||
| @@ -1129,10 +1130,8 @@ public: | |||||
| #if JUCE_SUPPORT_CARBON | #if JUCE_SUPPORT_CARBON | ||||
| if (TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource()) | if (TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource()) | ||||
| { | { | ||||
| CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty (currentKeyboard, | |||||
| kTISPropertyUnicodeKeyLayoutData); | |||||
| if (layoutData != nullptr) | |||||
| if (auto layoutData = (CFDataRef) TISGetInputSourceProperty (currentKeyboard, | |||||
| kTISPropertyUnicodeKeyLayoutData)) | |||||
| { | { | ||||
| if (auto* layoutPtr = (const UCKeyboardLayout*) CFDataGetBytePtr (layoutData)) | if (auto* layoutPtr = (const UCKeyboardLayout*) CFDataGetBytePtr (layoutData)) | ||||
| { | { | ||||
| @@ -1157,7 +1156,7 @@ public: | |||||
| unmodified = nsStringToJuce ([ev charactersIgnoringModifiers]); | unmodified = nsStringToJuce ([ev charactersIgnoringModifiers]); | ||||
| } | } | ||||
| int keyCode = unmodified[0]; | |||||
| auto keyCode = (int) unmodified[0]; | |||||
| if (keyCode == 0x19) // (backwards-tab) | if (keyCode == 0x19) // (backwards-tab) | ||||
| keyCode = '\t'; | keyCode = '\t'; | ||||
| @@ -1381,14 +1380,14 @@ private: | |||||
| object_setInstanceVariable (viewOrWindow, "owner", newOwner); | object_setInstanceVariable (viewOrWindow, "owner", newOwner); | ||||
| } | } | ||||
| void getClipRects (RectangleList<int>& clip, const Point<int> offset, const int clipW, const int clipH) | |||||
| void getClipRects (RectangleList<int>& clip, Point<int> offset, int clipW, int clipH) | |||||
| { | { | ||||
| const NSRect* rects = nullptr; | const NSRect* rects = nullptr; | ||||
| NSInteger numRects = 0; | NSInteger numRects = 0; | ||||
| [view getRectsBeingDrawn: &rects count: &numRects]; | [view getRectsBeingDrawn: &rects count: &numRects]; | ||||
| const Rectangle<int> clipBounds (clipW, clipH); | const Rectangle<int> clipBounds (clipW, clipH); | ||||
| const CGFloat viewH = [view frame].size.height; | |||||
| auto viewH = [view frame].size.height; | |||||
| clip.ensureStorageAllocated ((int) numRects); | clip.ensureStorageAllocated ((int) numRects); | ||||
| @@ -1423,6 +1422,7 @@ private: | |||||
| return false; | return false; | ||||
| NSWindow* const w = [e window]; | NSWindow* const w = [e window]; | ||||
| if (w == nil || [w worksWhenModal]) | if (w == nil || [w worksWhenModal]) | ||||
| return false; | return false; | ||||
| @@ -1491,7 +1491,7 @@ private: | |||||
| if (! [NSApp isActive]) | if (! [NSApp isActive]) | ||||
| [NSApp activateIgnoringOtherApps: YES]; | [NSApp activateIgnoringOtherApps: YES]; | ||||
| if (Component* const modal = Component::getCurrentlyModalComponent()) | |||||
| if (auto* modal = Component::getCurrentlyModalComponent()) | |||||
| modal->inputAttemptWhenModal(); | modal->inputAttemptWhenModal(); | ||||
| } | } | ||||
| @@ -1736,8 +1736,8 @@ private: | |||||
| { | { | ||||
| if (auto* target = owner->findCurrentTextInputTarget()) | if (auto* target = owner->findCurrentTextInputTarget()) | ||||
| { | { | ||||
| const Range<int> r ((int) theRange.location, | |||||
| (int) (theRange.location + theRange.length)); | |||||
| Range<int> r ((int) theRange.location, | |||||
| (int) (theRange.location + theRange.length)); | |||||
| return [[[NSAttributedString alloc] initWithString: juceStringToNS (target->getTextInRange (r))] autorelease]; | return [[[NSAttributedString alloc] initWithString: juceStringToNS (target->getTextInRange (r))] autorelease]; | ||||
| } | } | ||||
| @@ -1823,7 +1823,7 @@ private: | |||||
| { | { | ||||
| if (auto* owner = getOwner (self)) | if (auto* owner = getOwner (self)) | ||||
| if (owner->sendDragCallback (0, sender)) | if (owner->sendDragCallback (0, sender)) | ||||
| return NSDragOperationCopy | NSDragOperationMove | NSDragOperationGeneric; | |||||
| return NSDragOperationGeneric; | |||||
| return NSDragOperationNone; | return NSDragOperationNone; | ||||
| } | } | ||||
| @@ -2004,7 +2004,7 @@ ComponentPeer* NSViewComponentPeer::currentlyFocusedPeer = nullptr; | |||||
| Array<int> NSViewComponentPeer::keysCurrentlyDown; | Array<int> NSViewComponentPeer::keysCurrentlyDown; | ||||
| //============================================================================== | //============================================================================== | ||||
| bool KeyPress::isKeyCurrentlyDown (const int keyCode) | |||||
| bool KeyPress::isKeyCurrentlyDown (int keyCode) | |||||
| { | { | ||||
| if (NSViewComponentPeer::keysCurrentlyDown.contains (keyCode)) | if (NSViewComponentPeer::keysCurrentlyDown.contains (keyCode)) | ||||
| return true; | return true; | ||||
| @@ -2174,7 +2174,6 @@ const int KeyPress::F33Key = NSF33FunctionKey; | |||||
| const int KeyPress::F34Key = NSF34FunctionKey; | const int KeyPress::F34Key = NSF34FunctionKey; | ||||
| const int KeyPress::F35Key = NSF35FunctionKey; | const int KeyPress::F35Key = NSF35FunctionKey; | ||||
| const int KeyPress::numberPad0 = 0x30020; | const int KeyPress::numberPad0 = 0x30020; | ||||
| const int KeyPress::numberPad1 = 0x30021; | const int KeyPress::numberPad1 = 0x30021; | ||||
| const int KeyPress::numberPad2 = 0x30022; | const int KeyPress::numberPad2 = 0x30022; | ||||