From 2d01e326db361f5c402b58e40f8843ec67952144 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 15 Jan 2025 20:01:43 +0000 Subject: [PATCH] ObjCHelpers: Rename makeCGRect from makeNSRect --- .../juce_audio_plugin_client_AU_1.mm | 4 ++-- .../juce_audio_processors/juce_audio_processors.cpp | 4 ++-- .../juce_BluetoothMidiDevicePairingDialogue_mac.mm | 2 +- modules/juce_core/native/juce_ObjCHelpers_mac.h | 11 +++++++---- .../native/accessibility/juce_Accessibility_mac.mm | 4 ++-- .../juce_gui_basics/native/juce_FileChooser_mac.mm | 2 +- .../native/juce_NSViewComponentPeer_mac.mm | 12 ++++++------ .../native/juce_NSViewComponent_mac.mm | 2 +- modules/juce_opengl/native/juce_OpenGL_mac.h | 2 +- 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm index 09021d7de1..becdbe1f1d 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm @@ -1687,7 +1687,7 @@ public: static NSView* createViewFor (AudioProcessor* filter, JuceAU* au, AudioProcessorEditor* const editor) { auto* editorCompHolder = new EditorCompHolder (editor); - auto r = convertToHostBounds (makeNSRect (editorCompHolder->getSizeToContainChild())); + auto r = convertToHostBounds (makeCGRect (editorCompHolder->getSizeToContainChild())); static JuceUIViewClass cls; auto* view = [[cls.createInstance() initWithFrame: r] autorelease]; @@ -1766,7 +1766,7 @@ public: [CATransaction begin]; [CATransaction setValue: (id) kCFBooleanTrue forKey:kCATransactionDisableActions]; - auto rect = convertToHostBounds (makeNSRect (lastBounds)); + auto rect = convertToHostBounds (makeCGRect (lastBounds)); auto* view = (NSView*) getWindowHandle(); auto superRect = [[view superview] frame]; diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp index a3d5d7ed9e..fc4eab2268 100644 --- a/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/modules/juce_audio_processors/juce_audio_processors.cpp @@ -160,8 +160,8 @@ private: { auto* view = static_cast (getView()); const auto newArea = peer->getAreaCoveredBy (*this); - [view setFrame: makeNSRect (newArea.withHeight (newArea.getHeight() + 1))]; - [view setFrame: makeNSRect (newArea)]; + [view setFrame: makeCGRect (newArea.withHeight (newArea.getHeight() + 1))]; + [view setFrame: makeCGRect (newArea)]; } } diff --git a/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_mac.mm b/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_mac.mm index 7717568bdf..2e023dc6b8 100644 --- a/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_mac.mm +++ b/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_mac.mm @@ -94,7 +94,7 @@ private: { if (bounds != nullptr) { - auto nsBounds = makeNSRect (*bounds); + auto nsBounds = makeCGRect (*bounds); auto mainScreenHeight = [] { diff --git a/modules/juce_core/native/juce_ObjCHelpers_mac.h b/modules/juce_core/native/juce_ObjCHelpers_mac.h index f533412b37..192fe6abe3 100644 --- a/modules/juce_core/native/juce_ObjCHelpers_mac.h +++ b/modules/juce_core/native/juce_ObjCHelpers_mac.h @@ -141,16 +141,19 @@ inline var nsDictionaryToVar (const NSDictionary* dictionary) return jsonDataToVar (jsonObjectToData (dictionary)); } -#if JUCE_MAC +// NSRect is just another name for CGRect, but CGRect is available on iOS *and* macOS. +// Use makeCGRect below. template -NSRect makeNSRect (const RectangleType& r) noexcept +CGRect makeNSRect (const RectangleType& r) noexcept = delete; + +template +CGRect makeCGRect (const RectangleType& r) noexcept { - return NSMakeRect (static_cast (r.getX()), + return CGRectMake (static_cast (r.getX()), static_cast (r.getY()), static_cast (r.getWidth()), static_cast (r.getHeight())); } -#endif #if JUCE_INTEL template diff --git a/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm b/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm index a6001b00e7..9811226260 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm +++ b/modules/juce_gui_basics/native/accessibility/juce_Accessibility_mac.mm @@ -167,7 +167,7 @@ private: addMethod (@selector (accessibilityFrame), [] (id self, SEL) { if (auto* handler = getHandler (self)) - return flippedScreenRect (makeNSRect (handler->getComponent().getScreenBounds())); + return flippedScreenRect (makeCGRect (handler->getComponent().getScreenBounds())); return NSZeroRect; }); @@ -429,7 +429,7 @@ private: addMethod (@selector (accessibilityFrameForRange:), [] (id self, SEL, NSRange range) { if (auto* textInterface = getTextInterface (self)) - return flippedScreenRect (makeNSRect (textInterface->getTextBounds (nsRangeToJuce (range)).getBounds())); + return flippedScreenRect (makeCGRect (textInterface->getTextBounds (nsRangeToJuce (range)).getBounds())); return NSZeroRect; }); diff --git a/modules/juce_gui_basics/native/juce_FileChooser_mac.mm b/modules/juce_gui_basics/native/juce_FileChooser_mac.mm index 24c84c8129..a7e696586d 100644 --- a/modules/juce_gui_basics/native/juce_FileChooser_mac.mm +++ b/modules/juce_gui_basics/native/juce_FileChooser_mac.mm @@ -123,7 +123,7 @@ public: if (preview != nullptr) { - nsViewPreview = [[NSView alloc] initWithFrame: makeNSRect (preview->getLocalBounds())]; + nsViewPreview = [[NSView alloc] initWithFrame: makeCGRect (preview->getLocalBounds())]; [panel setAccessoryView: nsViewPreview]; preview->addToDesktop (0, (void*) nsViewPreview); diff --git a/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm b/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm index 58c33abafa..422d84646d 100644 --- a/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm +++ b/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm @@ -190,7 +190,7 @@ public: appFocusChangeCallback = appFocusChanged; isEventBlockedByModalComps = checkEventBlockedByModalComps; - auto r = makeNSRect (component.getLocalBounds()); + auto r = makeCGRect (component.getLocalBounds()); view = [createViewInstance() initWithFrame: r]; setOwner (view, this); @@ -391,7 +391,7 @@ public: void setBounds (const Rectangle& newBounds, bool) override { - auto r = makeNSRect (newBounds); + auto r = makeCGRect (newBounds); auto oldViewSize = [view frame].size; if (isSharedWindow) @@ -1115,7 +1115,7 @@ public: const Rectangle currentBounds { (float) frameSize.width, (float) frameSize.height }; for (auto& i : deferredRepaints) - [view setNeedsDisplayInRect: makeNSRect (i)]; + [view setNeedsDisplayInRect: makeCGRect (i)]; lastRepaintTime = Time::getMillisecondCounter(); @@ -1312,7 +1312,7 @@ public: constrainer->checkBounds (pos, original, screenBounds, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); - return flippedScreenRect (makeNSRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (scale, pos))); + return flippedScreenRect (makeCGRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (scale, pos))); } static void showArrowCursorIfNeeded() @@ -2574,7 +2574,7 @@ struct JuceNSViewClass final : public NSViewComponentPeerWrappergetTextBounds (codePointRange).getRectangle (0); const auto areaOnDesktop = comp->localAreaToGlobal (rect); - return flippedScreenRect (makeNSRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop))); + return flippedScreenRect (makeCGRect (detail::ScalingHelpers::scaledScreenPosToUnscaled (areaOnDesktop))); } } } @@ -2842,7 +2842,7 @@ struct JuceNSWindowClass final : public NSViewComponentPeerWrappergetMaximumHeight()); const auto constrained = expanded.constrainedWithin (safeScreenBounds); - return flippedScreenRect (makeNSRect ([&] + return flippedScreenRect (makeCGRect ([&] { if (constrained == owner->getBounds().toFloat()) return owner->lastSizeBeforeZoom.toFloat(); diff --git a/modules/juce_gui_extra/native/juce_NSViewComponent_mac.mm b/modules/juce_gui_extra/native/juce_NSViewComponent_mac.mm index d91ef3fb03..f14aaa2b54 100644 --- a/modules/juce_gui_extra/native/juce_NSViewComponent_mac.mm +++ b/modules/juce_gui_extra/native/juce_NSViewComponent_mac.mm @@ -75,7 +75,7 @@ public: const auto newArea = peer->getAreaCoveredBy (owner); if (convertToRectInt ([view frame]) != newArea) - [view setFrame: makeNSRect (newArea)]; + [view setFrame: makeCGRect (newArea)]; } } diff --git a/modules/juce_opengl/native/juce_OpenGL_mac.h b/modules/juce_opengl/native/juce_OpenGL_mac.h index 1a856e7df6..0f2eaeb4a7 100644 --- a/modules/juce_opengl/native/juce_OpenGL_mac.h +++ b/modules/juce_opengl/native/juce_OpenGL_mac.h @@ -220,7 +220,7 @@ public: const auto newArea = peer->getAreaCoveredBy (owner); if (convertToRectInt ([view frame]) != newArea) - [view setFrame: makeNSRect (newArea)]; + [view setFrame: makeCGRect (newArea)]; } }