From 58169580010033b3307cfee0685d34c8d659873b Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 4 May 2020 09:59:23 +0100 Subject: [PATCH] Squashed some deprecation warnings on the latest iOS and macOS versions --- .../juce_audio_devices/native/juce_ios_Audio.cpp | 2 ++ .../native/juce_ios_UIViewComponentPeer.mm | 15 +++++++++++++-- .../juce_gui_basics/native/juce_ios_Windowing.mm | 2 +- modules/juce_video/native/juce_ios_CameraDevice.h | 9 +++++++++ modules/juce_video/native/juce_mac_CameraDevice.h | 9 +++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index d17528e405..05399ada3a 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -671,6 +671,7 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, //============================================================================== #if JUCE_MODULE_AVAILABLE_juce_graphics + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") Image getIcon (int size) { if (interAppAudioConnected) @@ -681,6 +682,7 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, } return Image(); } + JUCE_END_IGNORE_WARNINGS_GCC_LIKE #endif void switchApplication() diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 73bb66917a..e23aad7822 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -29,6 +29,17 @@ static bool isUsingOldRotationMethod() noexcept return isPreV8; } +static UIInterfaceOrientation getWindowOrientation() +{ + UIApplication* sharedApplication = [UIApplication sharedApplication]; + + #if (defined (__IPHONE_13_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_13_0) + return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation]; + #else + return [sharedApplication statusBarOrientation]; + #endif +} + namespace Orientations { static Desktop::DisplayOrientation convertToJuce (UIInterfaceOrientation orientation) @@ -267,7 +278,7 @@ public: { const Rectangle screen (convertToRectInt ([UIScreen mainScreen].bounds)); - switch ([[UIApplication sharedApplication] statusBarOrientation]) + switch (getWindowOrientation()) { case UIInterfaceOrientationPortrait: return r; @@ -298,7 +309,7 @@ public: { const Rectangle screen (convertToRectInt ([UIScreen mainScreen].bounds)); - switch ([[UIApplication sharedApplication] statusBarOrientation]) + switch (getWindowOrientation()) { case UIInterfaceOrientationPortrait: return r; diff --git a/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/modules/juce_gui_basics/native/juce_ios_Windowing.mm index 6c26618e5f..f45bd4e9be 100644 --- a/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -723,7 +723,7 @@ double Desktop::getDefaultMasterScale() Desktop::DisplayOrientation Desktop::getCurrentOrientation() const { UIInterfaceOrientation orientation = SystemStats::isRunningInAppExtensionSandbox() ? UIInterfaceOrientationPortrait - : [[UIApplication sharedApplication] statusBarOrientation]; + : getWindowOrientation(); return Orientations::convertToJuce (orientation); } diff --git a/modules/juce_video/native/juce_ios_CameraDevice.h b/modules/juce_video/native/juce_ios_CameraDevice.h index 609098021c..a195235f7a 100644 --- a/modules/juce_video/native/juce_ios_CameraDevice.h +++ b/modules/juce_video/native/juce_ios_CameraDevice.h @@ -16,6 +16,11 @@ ============================================================================== */ +#if (defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") + #define JUCE_DEPRECATION_IGNORED 1 +#endif + struct CameraDevice::Pimpl { using InternalOpenCameraResultCallback = std::function; @@ -1324,3 +1329,7 @@ String CameraDevice::getFileExtension() { return ".mov"; } + +#if JUCE_DEPRECATION_IGNORED + JUCE_END_IGNORE_WARNINGS_GCC_LIKE +#endif diff --git a/modules/juce_video/native/juce_mac_CameraDevice.h b/modules/juce_video/native/juce_mac_CameraDevice.h index b2e82e88ae..7e964455c8 100644 --- a/modules/juce_video/native/juce_mac_CameraDevice.h +++ b/modules/juce_video/native/juce_mac_CameraDevice.h @@ -16,6 +16,11 @@ ============================================================================== */ +#if ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") + #define JUCE_DEPRECATION_IGNORED 1 +#endif + struct CameraDevice::Pimpl { Pimpl (CameraDevice& ownerToUse, const String& deviceNameToUse, int /*index*/, @@ -403,3 +408,7 @@ String CameraDevice::getFileExtension() { return ".mov"; } + +#if JUCE_DEPRECATION_IGNORED + JUCE_END_IGNORE_WARNINGS_GCC_LIKE +#endif