From 65608654c749d970e838cb8704a208b2a2d00228 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 23 Aug 2014 21:59:37 +0100 Subject: [PATCH] Update juce --- .../native/juce_android_OpenSL.cpp | 8 +- .../native/juce_ios_Audio.cpp | 6 +- .../native/juce_win32_WASAPI.cpp | 4 +- .../codecs/juce_AiffAudioFormat.cpp | 2 +- .../codecs/juce_LAMEEncoderAudioFormat.cpp | 4 +- .../juce_AudioUnitPluginFormat.mm | 11 +- .../format_types/juce_VST3PluginFormat.cpp | 15 +- .../format_types/juce_VSTPluginFormat.cpp | 356 +++++++++--------- .../juce_audio_processors.cpp | 5 +- .../processors/juce_AudioProcessor.cpp | 6 +- .../processors/juce_AudioProcessor.h | 2 +- .../processors/juce_AudioProcessorEditor.cpp | 14 +- .../processors/juce_AudioProcessorEditor.h | 42 ++- .../processors/juce_PluginDescription.cpp | 18 +- .../processors/juce_PluginDescription.h | 10 +- .../scanning/juce_KnownPluginList.cpp | 2 +- .../modules/juce_core/containers/juce_Array.h | 3 +- .../containers/juce_NamedValueSet.cpp | 7 +- .../juce_core/containers/juce_NamedValueSet.h | 6 +- source/modules/juce_core/files/juce_File.cpp | 2 +- .../juce_core/javascript/juce_Javascript.cpp | 13 +- source/modules/juce_core/juce_core.cpp | 3 +- .../juce_core/maths/juce_BigInteger.cpp | 4 +- source/modules/juce_core/maths/juce_Range.h | 7 + source/modules/juce_core/memory/juce_Atomic.h | 2 +- .../modules/juce_core/memory/juce_ByteOrder.h | 8 +- .../juce_core/memory/juce_WeakReference.h | 4 +- .../juce_core/native/juce_android_Network.cpp | 2 +- .../native/juce_win32_SystemStats.cpp | 4 +- .../juce_core/native/juce_win32_Threads.cpp | 2 +- .../juce_core/streams/juce_InputStream.cpp | 4 +- .../juce_core/streams/juce_InputStream.h | 6 +- .../streams/juce_MemoryOutputStream.cpp | 2 +- .../streams/juce_MemoryOutputStream.h | 2 +- .../juce_core/streams/juce_OutputStream.cpp | 4 +- .../juce_core/streams/juce_OutputStream.h | 2 +- .../juce_core/system/juce_PlatformDefs.h | 2 +- .../juce_core/system/juce_StandardHeader.h | 4 +- .../juce_core/system/juce_TargetPlatform.h | 2 +- .../modules/juce_core/xml/juce_XmlElement.cpp | 2 +- .../modules/juce_core/xml/juce_XmlElement.h | 13 +- source/modules/juce_core/zip/juce_ZipFile.cpp | 2 +- .../broadcasters/juce_ActionBroadcaster.cpp | 9 +- .../juce_InterprocessConnection.cpp | 2 +- .../messages/juce_ApplicationBase.cpp | 2 +- .../messages/juce_ApplicationBase.h | 8 +- .../messages/juce_MessageManager.cpp | 3 + .../geometry/juce_AffineTransform.h | 27 +- .../juce_graphics/native/juce_win32_Fonts.cpp | 4 +- .../application/juce_Application.h | 8 +- .../components/juce_Component.cpp | 89 +---- .../components/juce_Component.h | 54 ++- .../juce_gui_basics/juce_gui_basics.cpp | 2 +- .../layout/juce_ComponentAnimator.cpp | 11 +- .../layout/juce_ComponentAnimator.h | 4 +- .../layout/juce_ComponentBuilder.cpp | 2 +- .../layout/juce_ComponentBuilder.h | 2 +- .../mouse/juce_MouseCursor.cpp | 2 +- .../juce_gui_basics/mouse/juce_MouseCursor.h | 4 +- .../native/juce_android_Windowing.cpp | 2 +- .../native/juce_linux_Windowing.cpp | 8 +- .../native/juce_mac_NSViewComponentPeer.mm | 7 +- .../native/juce_win32_Windowing.cpp | 23 +- .../juce_gui_basics/widgets/juce_ComboBox.h | 2 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 19 +- .../juce_gui_basics/widgets/juce_ListBox.h | 2 + .../juce_gui_basics/widgets/juce_Slider.cpp | 9 +- .../windows/juce_AlertWindow.cpp | 17 +- .../code_editor/juce_CodeEditorComponent.cpp | 12 +- .../modules/juce_gui_extra/juce_gui_extra.cpp | 5 - .../juce_gui_extra/misc/juce_ColourSelector.h | 2 +- .../native/juce_mac_WebBrowserComponent.mm | 5 + 72 files changed, 476 insertions(+), 487 deletions(-) diff --git a/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index e02951d3f..53dc5df6b 100644 --- a/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -341,8 +341,8 @@ private: SLDataFormat_PCM pcmFormat = { SL_DATAFORMAT_PCM, - numChannels, - sampleRate * 1000, // (sample rate units are millihertz) + (SLuint32) numChannels, + (SLuint32) (sampleRate * 1000), // (sample rate units are millihertz) SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16, SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT, @@ -450,8 +450,8 @@ private: SLDataFormat_PCM pcmFormat = { SL_DATAFORMAT_PCM, - numChannels, - sampleRate * 1000, // (sample rate units are millihertz) + (SLuint32) numChannels, + (SLuint32) (sampleRate * 1000), // (sample rate units are millihertz) SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16, (numChannels == 1) ? SL_SPEAKER_FRONT_CENTER : (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT), diff --git a/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp index b7d16110c..70490aa54 100644 --- a/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -536,9 +536,9 @@ private: return AudioSessionGetProperty (propID, &valueSize, &result); } - static bool setSessionUInt32Property (AudioSessionPropertyID propID, UInt32 v) noexcept { AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } - static bool setSessionFloat32Property (AudioSessionPropertyID propID, Float32 v) noexcept { AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } - static bool setSessionFloat64Property (AudioSessionPropertyID propID, Float64 v) noexcept { AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } + static bool setSessionUInt32Property (AudioSessionPropertyID propID, UInt32 v) noexcept { return AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } + static bool setSessionFloat32Property (AudioSessionPropertyID propID, Float32 v) noexcept { return AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } + static bool setSessionFloat64Property (AudioSessionPropertyID propID, Float64 v) noexcept { return AudioSessionSetProperty (propID, sizeof (v), &v) == kAudioSessionNoError; } JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice) }; diff --git a/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 98e276cf8..320eca1a5 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -33,8 +33,8 @@ namespace WasapiClasses void logFailure (HRESULT hr) { (void) hr; - jassert (hr != 0x800401f0); // If you hit this, it means you're trying to call from - // a thread which hasn't been initialised with CoInitialize(). + jassert (hr != (HRESULT) 0x800401f0); // If you hit this, it means you're trying to call from + // a thread which hasn't been initialised with CoInitialize(). #if JUCE_WASAPI_LOGGING if (FAILED (hr)) diff --git a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index f5b0b9a60..2029bc827 100644 --- a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -37,7 +37,7 @@ const char* const AiffAudioFormat::appleKey = "apple key"; //============================================================================== namespace AiffFileHelpers { - inline int chunkName (const char* const name) { return (int) ByteOrder::littleEndianInt (name); } + inline int chunkName (const char* name) noexcept { return (int) ByteOrder::littleEndianInt (name); } #if JUCE_MSVC #pragma pack (push, 1) diff --git a/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 5d30d443c..8a5263cb1 100644 --- a/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp @@ -165,13 +165,13 @@ bool LAMEEncoderAudioFormat::canHandleFile (const File&) Array LAMEEncoderAudioFormat::getPossibleSampleRates() { const int rates[] = { 32000, 44100, 48000, 0 }; - return Array (rates); + return Array (rates); } Array LAMEEncoderAudioFormat::getPossibleBitDepths() { const int depths[] = { 16, 0 }; - return Array (depths); + return Array (depths); } bool LAMEEncoderAudioFormat::canDoStereo() { return true; } diff --git a/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index fb19e8b6e..798a66234 100644 --- a/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -62,7 +62,7 @@ namespace AudioUnitFormatHelpers static ThreadLocalValue insideCallback; #endif - String osTypeToString (OSType type) + String osTypeToString (OSType type) noexcept { const juce_wchar s[4] = { (juce_wchar) ((type >> 24) & 0xff), (juce_wchar) ((type >> 16) & 0xff), @@ -88,9 +88,6 @@ namespace AudioUnitFormatHelpers String createPluginIdentifier (const AudioComponentDescription& desc) { - jassert (osTypeToString ('abcd') == "abcd"); // agh, must have got the endianness wrong.. - jassert (stringToOSType ("abcd") == (OSType) 'abcd'); // ditto - String s (auIdentifierPrefix); if (desc.componentType == kAudioUnitType_MusicDevice) @@ -215,9 +212,11 @@ namespace AudioUnitFormatHelpers const short resFileId = CFBundleOpenBundleResourceMap (bundleRef); UseResFile (resFileId); - for (ResourceIndex i = 1; i <= Count1Resources ('thng'); ++i) + const OSType thngType = stringToOSType ("thng"); + + for (ResourceIndex i = 1; i <= Count1Resources (thngType); ++i) { - if (Handle h = Get1IndResource ('thng', i)) + if (Handle h = Get1IndResource (thngType, i)) { HLock (h); const uint32* const types = (const uint32*) *h; diff --git a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 29c28e03a..e640ca714 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -428,16 +428,11 @@ public: if (hasFlag (flags, Vst::kIoChanged)) { - double sampleRate = owner->getSampleRate(); - int numSamples = owner->getBlockSize(); + const double sampleRate = owner->getSampleRate(); + const int blockSize = owner->getBlockSize(); - if (sampleRate <= 8000.0) - sampleRate = 44100.0; - - if (numSamples <= 0) - numSamples = 1024; - - owner->prepareToPlay (owner->getSampleRate(), owner->getBlockSize()); + owner->prepareToPlay (sampleRate >= 8000 ? sampleRate : 44100.0, + blockSize > 0 ? blockSize : 1024); } if (hasFlag (flags, Vst::kLatencyChanged)) @@ -1451,7 +1446,7 @@ public: warnOnFailure (view->removed()); warnOnFailure (view->setFrame (nullptr)); - getAudioProcessor()->editorBeingDeleted (this); + processor.editorBeingDeleted (this); #if JUCE_MAC dummyComponent.setView (nullptr); diff --git a/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 787a32a11..5509e2c38 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -29,13 +29,6 @@ #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif -#if JUCE_MAC - static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) - { - return FSPathMakeRef (reinterpret_cast (path.toRawUTF8()), destFSRef, 0) == noErr; - } -#endif - //============================================================================== #undef PRAGMA_ALIGN_SUPPORTED #define VST_FORCE_DEPRECATED 0 @@ -84,74 +77,68 @@ #endif //============================================================================== -const int fxbVersionNum = 1; - -struct fxProgram +namespace { - VstInt32 chunkMagic; // 'CcnK' - VstInt32 byteSize; // of this chunk, excl. magic + byteSize - VstInt32 fxMagic; // 'FxCk' - VstInt32 version; - VstInt32 fxID; // fx unique id - VstInt32 fxVersion; - VstInt32 numParams; - char prgName[28]; - float params[1]; // variable no. of parameters -}; + const int fxbVersionNum = 1; + + struct fxProgram + { + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCk' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numParams; + char prgName[28]; + float params[1]; // variable no. of parameters + }; -struct fxSet -{ - VstInt32 chunkMagic; // 'CcnK' - VstInt32 byteSize; // of this chunk, excl. magic + byteSize - VstInt32 fxMagic; // 'FxBk' - VstInt32 version; - VstInt32 fxID; // fx unique id - VstInt32 fxVersion; - VstInt32 numPrograms; - char future[128]; - fxProgram programs[1]; // variable no. of programs -}; + struct fxSet + { + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxBk' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; + char future[128]; + fxProgram programs[1]; // variable no. of programs + }; -struct fxChunkSet -{ - VstInt32 chunkMagic; // 'CcnK' - VstInt32 byteSize; // of this chunk, excl. magic + byteSize - VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' - VstInt32 version; - VstInt32 fxID; // fx unique id - VstInt32 fxVersion; - VstInt32 numPrograms; - char future[128]; - VstInt32 chunkSize; - char chunk[8]; // variable -}; + struct fxChunkSet + { + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; + char future[128]; + VstInt32 chunkSize; + char chunk[8]; // variable + }; -struct fxProgramSet -{ - VstInt32 chunkMagic; // 'CcnK' - VstInt32 byteSize; // of this chunk, excl. magic + byteSize - VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' - VstInt32 version; - VstInt32 fxID; // fx unique id - VstInt32 fxVersion; - VstInt32 numPrograms; - char name[28]; - VstInt32 chunkSize; - char chunk[8]; // variable -}; + struct fxProgramSet + { + VstInt32 chunkMagic; // 'CcnK' + VstInt32 byteSize; // of this chunk, excl. magic + byteSize + VstInt32 fxMagic; // 'FxCh', 'FPCh', or 'FBCh' + VstInt32 version; + VstInt32 fxID; // fx unique id + VstInt32 fxVersion; + VstInt32 numPrograms; + char name[28]; + VstInt32 chunkSize; + char chunk[8]; // variable + }; -namespace -{ - VstInt32 vst_swap (const VstInt32 x) noexcept - { - #ifdef JUCE_LITTLE_ENDIAN - return (VstInt32) ByteOrder::swap ((uint32) x); - #else - return x; - #endif - } + static VstInt32 fxbName (const char* name) noexcept { return (VstInt32) ByteOrder::bigEndianInt (name); } + static VstInt32 fxbSwap (const VstInt32 x) noexcept { return (VstInt32) ByteOrder::swapIfLittleEndian ((uint32) x); } - float vst_swapFloat (const float x) noexcept + static float fxbSwapFloat (const float x) noexcept { #ifdef JUCE_LITTLE_ENDIAN union { uint32 asInt; float asFloat; } n; @@ -162,8 +149,12 @@ namespace return x; #endif } +} - double getVSTHostTimeNanoseconds() +//============================================================================== +namespace +{ + static double getVSTHostTimeNanoseconds() noexcept { #if JUCE_WINDOWS return timeGetTime() * 1000000.0; @@ -177,39 +168,51 @@ namespace return micro.lo * 1000.0; #endif } -} -//============================================================================== -typedef AEffect* (VSTCALLBACK *MainCall) (audioMasterCallback); + static int shellUIDToCreate = 0; + static int insideVSTCallback = 0; -static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt); + struct IdleCallRecursionPreventer + { + IdleCallRecursionPreventer() : isMessageThread (MessageManager::getInstance()->isThisTheMessageThread()) + { + if (isMessageThread) + ++insideVSTCallback; + } -static int shellUIDToCreate = 0; -static int insideVSTCallback = 0; + ~IdleCallRecursionPreventer() + { + if (isMessageThread) + --insideVSTCallback; + } -class IdleCallRecursionPreventer -{ -public: - IdleCallRecursionPreventer() - : isMessageThread (MessageManager::getInstance()->isThisTheMessageThread()) + const bool isMessageThread; + JUCE_DECLARE_NON_COPYABLE (IdleCallRecursionPreventer) + }; + + #if JUCE_MAC + static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) { - if (isMessageThread) - ++insideVSTCallback; + return FSPathMakeRef (reinterpret_cast (path.toRawUTF8()), destFSRef, 0) == noErr; } + #endif - ~IdleCallRecursionPreventer() + #if JUCE_MAC && JUCE_PPC + static void* newCFMFromMachO (void* const machofp) noexcept { - if (isMessageThread) - --insideVSTCallback; - } + void* result = (void*) new char[8]; -private: - const bool isMessageThread; + ((void**) result)[0] = machofp; + ((void**) result)[1] = result; - JUCE_DECLARE_NON_COPYABLE (IdleCallRecursionPreventer) -}; + return result; + } + #endif +} -class VSTPluginWindow; +//============================================================================== +typedef AEffect* (VSTCALLBACK *MainCall) (audioMasterCallback); +static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt); //============================================================================== // Change this to disable logging of various VST activities @@ -223,27 +226,12 @@ class VSTPluginWindow; #define JUCE_VST_LOG(a) #endif -//============================================================================== -#if JUCE_MAC && JUCE_PPC -static void* NewCFMFromMachO (void* const machofp) noexcept -{ - void* result = (void*) new char[8]; - - ((void**) result)[0] = machofp; - ((void**) result)[1] = result; - - return result; -} -#endif - //============================================================================== #if JUCE_LINUX extern Display* display; extern XContext windowHandleXContext; -typedef void (*EventProcPtr) (XEvent* ev); - namespace { static bool xErrorTriggered = false; @@ -254,6 +242,8 @@ namespace return 0; } + typedef void (*EventProcPtr) (XEvent* ev); + static EventProcPtr getPropertyFromXWindow (Window handle, Atom atom) { XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); @@ -269,8 +259,7 @@ namespace XSetErrorHandler (oldErrorHandler); - return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) - : 0; + return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) : nullptr; } Window getChildWindow (Window windowToCheck) @@ -279,12 +268,7 @@ namespace Window* childWindows; unsigned int numChildren = 0; - XQueryTree (display, - windowToCheck, - &rootWindow, - &parentWindow, - &childWindows, - &numChildren); + XQueryTree (display, windowToCheck, &rootWindow, &parentWindow, &childWindows, &numChildren); if (numChildren > 0) return childWindows [0]; @@ -354,9 +338,9 @@ public: typedef ReferenceCountedObjectPtr Ptr; - static Array & getActiveModules() + static Array& getActiveModules() { - static Array activeModules; + static Array activeModules; return activeModules; } @@ -470,7 +454,7 @@ public: { if (HGLOBAL hGlob = LoadResource (dllModule, res)) { - const char* data = static_cast (LockResource (hGlob)); + const char* data = static_cast (LockResource (hGlob)); return String::fromUTF8 (data, SizeofResource (dllModule, res)); } } @@ -552,7 +536,7 @@ public: } } } -#if JUCE_PPC + #if JUCE_PPC else { FSRef fn; @@ -605,7 +589,7 @@ public: } } } -#endif + #endif return ok; } @@ -683,7 +667,7 @@ public: static void disposeMachOFromCFM (void* ptr) { - delete[] static_cast (ptr); + delete[] static_cast (ptr); } void coerceAEffectFunctionCalls (AEffect* eff) @@ -715,11 +699,11 @@ class VSTPluginInstance : public AudioPluginInstance, private AsyncUpdater { public: - VSTPluginInstance (const ModuleHandle::Ptr& module_) + VSTPluginInstance (const ModuleHandle::Ptr& mh) : effect (nullptr), - module (module_), + module (mh), usesCocoaNSView (false), - name (module_->pluginName), + name (mh->pluginName), wantsMidiMessages (false), initialised (false), isPowerOn (false), @@ -741,7 +725,7 @@ public: { static void* audioMasterCoerced = nullptr; if (audioMasterCoerced == nullptr) - audioMasterCoerced = NewCFMFromMachO ((void*) &audioMaster); + audioMasterCoerced = newCFMFromMachO ((void*) &audioMaster); effect = module->moduleMain ((audioMasterCallback) audioMasterCoerced); } @@ -803,7 +787,7 @@ public: char buffer [512] = { 0 }; dispatch (effGetEffectName, 0, 0, buffer, 0); - desc.descriptiveName = String (buffer).trim(); + desc.descriptiveName = String::fromUTF8 (buffer).trim(); if (desc.descriptiveName.isEmpty()) desc.descriptiveName = name; @@ -818,7 +802,7 @@ public: { char buffer [kVstMaxVendorStrLen + 8] = { 0 }; dispatch (effGetVendorString, 0, 0, buffer, 0); - desc.manufacturerName = buffer; + desc.manufacturerName = String::fromUTF8 (buffer); } desc.version = getVersion(); @@ -1146,8 +1130,7 @@ public: bool isValidChannel (int index, bool isInput) const { - return isInput ? (index < getNumInputChannels()) - : (index < getNumOutputChannels()); + return isPositiveAndBelow (index, isInput ? getNumInputChannels() : getNumOutputChannels()); } //============================================================================== @@ -1214,7 +1197,7 @@ public: char nm[264] = { 0 }; if (dispatch (effGetProgramNameIndexed, jlimit (0, getNumPrograms(), index), -1, nm, 0) != 0) - return String (CharPointer_UTF8 (nm)).trim(); + return String::fromUTF8 (nm).trim(); } } @@ -1449,20 +1432,20 @@ public: const fxSet* const set = (const fxSet*) data; - if ((vst_swap (set->chunkMagic) != 'CcnK' && vst_swap (set->chunkMagic) != 'KncC') - || vst_swap (set->version) > fxbVersionNum) + if ((set->chunkMagic != fxbName ("CcnK") && set->chunkMagic != fxbName ("KncC")) + || fxbSwap (set->version) > fxbVersionNum) return false; - if (vst_swap (set->fxMagic) == 'FxBk') + if (set->fxMagic == fxbName ("FxBk")) { // bank of programs - if (vst_swap (set->numPrograms) >= 0) + if (fxbSwap (set->numPrograms) >= 0) { const int oldProg = getCurrentProgram(); - const int numParams = vst_swap (((const fxProgram*) (set->programs))->numParams); + const int numParams = fxbSwap (((const fxProgram*) (set->programs))->numParams); const int progLen = sizeof (fxProgram) + (numParams - 1) * sizeof (float); - for (int i = 0; i < vst_swap (set->numPrograms); ++i) + for (int i = 0; i < fxbSwap (set->numPrograms); ++i) { if (i != oldProg) { @@ -1470,7 +1453,7 @@ public: if (((const char*) prog) - ((const char*) set) >= (ssize_t) dataSize) return false; - if (vst_swap (set->numPrograms) > 0) + if (fxbSwap (set->numPrograms) > 0) setCurrentProgram (i); if (! restoreProgramSettings (prog)) @@ -1478,7 +1461,7 @@ public: } } - if (vst_swap (set->numPrograms) > 0) + if (fxbSwap (set->numPrograms) > 0) setCurrentProgram (oldProg); const fxProgram* const prog = (const fxProgram*) (((const char*) (set->programs)) + oldProg * progLen); @@ -1489,38 +1472,38 @@ public: return false; } } - else if (vst_swap (set->fxMagic) == 'FxCk') + else if (set->fxMagic == fxbName ("FxCk")) { // single program const fxProgram* const prog = (const fxProgram*) data; - if (vst_swap (prog->chunkMagic) != 'CcnK') + if (prog->chunkMagic != fxbName ("CcnK")) return false; changeProgramName (getCurrentProgram(), prog->prgName); - for (int i = 0; i < vst_swap (prog->numParams); ++i) - setParameter (i, vst_swapFloat (prog->params[i])); + for (int i = 0; i < fxbSwap (prog->numParams); ++i) + setParameter (i, fxbSwapFloat (prog->params[i])); } - else if (vst_swap (set->fxMagic) == 'FBCh' || vst_swap (set->fxMagic) == 'hCBF') + else if (set->fxMagic == fxbName ("FBCh") || set->fxMagic == fxbName ("hCBF")) { // non-preset chunk const fxChunkSet* const cset = (const fxChunkSet*) data; - if (vst_swap (cset->chunkSize) + sizeof (fxChunkSet) - 8 > (unsigned int) dataSize) + if (fxbSwap (cset->chunkSize) + sizeof (fxChunkSet) - 8 > (unsigned int) dataSize) return false; - setChunkData (cset->chunk, vst_swap (cset->chunkSize), false); + setChunkData (cset->chunk, fxbSwap (cset->chunkSize), false); } - else if (vst_swap (set->fxMagic) == 'FPCh' || vst_swap (set->fxMagic) == 'hCPF') + else if (set->fxMagic == fxbName ("FPCh") || set->fxMagic == fxbName ("hCPF")) { // preset chunk const fxProgramSet* const cset = (const fxProgramSet*) data; - if (vst_swap (cset->chunkSize) + sizeof (fxProgramSet) - 8 > (unsigned int) dataSize) + if (fxbSwap (cset->chunkSize) + sizeof (fxProgramSet) - 8 > (unsigned int) dataSize) return false; - setChunkData (cset->chunk, vst_swap (cset->chunkSize), true); + setChunkData (cset->chunk, fxbSwap (cset->chunkSize), true); changeProgramName (getCurrentProgram(), cset->name); } @@ -1548,14 +1531,14 @@ public: dest.setSize (totalLen, true); fxChunkSet* const set = (fxChunkSet*) dest.getData(); - set->chunkMagic = vst_swap ('CcnK'); + set->chunkMagic = fxbName ("CcnK"); set->byteSize = 0; - set->fxMagic = vst_swap ('FBCh'); - set->version = vst_swap (fxbVersionNum); - set->fxID = vst_swap (getUID()); - set->fxVersion = vst_swap (getVersionNumber()); - set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap ((VstInt32) chunk.getSize()); + set->fxMagic = fxbName ("FBCh"); + set->version = fxbSwap (fxbVersionNum); + set->fxID = fxbSwap (getUID()); + set->fxVersion = fxbSwap (getVersionNumber()); + set->numPrograms = fxbSwap (numPrograms); + set->chunkSize = fxbSwap ((VstInt32) chunk.getSize()); chunk.copyTo (set->chunk, 0, chunk.getSize()); } @@ -1565,14 +1548,14 @@ public: dest.setSize (totalLen, true); fxProgramSet* const set = (fxProgramSet*) dest.getData(); - set->chunkMagic = vst_swap ('CcnK'); + set->chunkMagic = fxbName ("CcnK"); set->byteSize = 0; - set->fxMagic = vst_swap ('FPCh'); - set->version = vst_swap (fxbVersionNum); - set->fxID = vst_swap (getUID()); - set->fxVersion = vst_swap (getVersionNumber()); - set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap ((VstInt32) chunk.getSize()); + set->fxMagic = fxbName ("FPCh"); + set->version = fxbSwap (fxbVersionNum); + set->fxID = fxbSwap (getUID()); + set->fxVersion = fxbSwap (getVersionNumber()); + set->numPrograms = fxbSwap (numPrograms); + set->chunkSize = fxbSwap ((VstInt32) chunk.getSize()); getCurrentProgramName().copyToUTF8 (set->name, sizeof (set->name) - 1); chunk.copyTo (set->chunk, 0, chunk.getSize()); @@ -1587,13 +1570,13 @@ public: dest.setSize (len, true); fxSet* const set = (fxSet*) dest.getData(); - set->chunkMagic = vst_swap ('CcnK'); + set->chunkMagic = fxbName ("CcnK"); set->byteSize = 0; - set->fxMagic = vst_swap ('FxBk'); - set->version = vst_swap (fxbVersionNum); - set->fxID = vst_swap (getUID()); - set->fxVersion = vst_swap (getVersionNumber()); - set->numPrograms = vst_swap (numPrograms); + set->fxMagic = fxbName ("FxBk"); + set->version = fxbSwap (fxbVersionNum); + set->fxID = fxbSwap (getUID()); + set->fxVersion = fxbSwap (getVersionNumber()); + set->numPrograms = fxbSwap (numPrograms); const int oldProgram = getCurrentProgram(); MemoryBlock oldSettings; @@ -1688,12 +1671,12 @@ private: bool restoreProgramSettings (const fxProgram* const prog) { - if (vst_swap (prog->chunkMagic) == 'CcnK' && vst_swap (prog->fxMagic) == 'FxCk') + if (prog->chunkMagic == fxbName ("CcnK") && prog->fxMagic == fxbName ("FxCk")) { changeProgramName (getCurrentProgram(), prog->prgName); - for (int i = 0; i < vst_swap (prog->numParams); ++i) - setParameter (i, vst_swapFloat (prog->params[i])); + for (int i = 0; i < fxbSwap (prog->numParams); ++i) + setParameter (i, fxbSwapFloat (prog->params[i])); return true; } @@ -1742,18 +1725,18 @@ private: { const int numParams = getNumParameters(); - prog->chunkMagic = vst_swap ('CcnK'); + prog->chunkMagic = fxbName ("CcnK"); prog->byteSize = 0; - prog->fxMagic = vst_swap ('FxCk'); - prog->version = vst_swap (fxbVersionNum); - prog->fxID = vst_swap (getUID()); - prog->fxVersion = vst_swap (getVersionNumber()); - prog->numParams = vst_swap (numParams); + prog->fxMagic = fxbName ("FxCk"); + prog->version = fxbSwap (fxbVersionNum); + prog->fxID = fxbSwap (getUID()); + prog->fxVersion = fxbSwap (getVersionNumber()); + prog->numParams = fxbSwap (numParams); getCurrentProgramName().copyToUTF8 (prog->prgName, sizeof (prog->prgName) - 1); for (int i = 0; i < numParams; ++i) - prog->params[i] = vst_swapFloat (getParameter (i)); + prog->params[i] = fxbSwapFloat (getParameter (i)); } void updateStoredProgramNames() @@ -1895,7 +1878,8 @@ private: }; //============================================================================== -static Array activeVSTWindows; +class VSTPluginWindow; +static Array activeVSTWindows; //============================================================================== class VSTPluginWindow : public AudioProcessorEditor, @@ -2845,7 +2829,7 @@ FileSearchPath VSTPluginFormat::getDefaultLocationsToSearch() const XmlElement* VSTPluginFormat::getVSTXML (AudioPluginInstance* plugin) { - if (VSTPluginInstance* const vst = dynamic_cast (plugin)) + if (VSTPluginInstance* const vst = dynamic_cast (plugin)) if (vst->module != nullptr) return vst->module->vstXml.get(); @@ -2854,7 +2838,7 @@ const XmlElement* VSTPluginFormat::getVSTXML (AudioPluginInstance* plugin) bool VSTPluginFormat::loadFromFXBFile (AudioPluginInstance* plugin, const void* data, size_t dataSize) { - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) return vst->loadFromFXBFile (data, dataSize); return false; @@ -2862,7 +2846,7 @@ bool VSTPluginFormat::loadFromFXBFile (AudioPluginInstance* plugin, const void* bool VSTPluginFormat::saveToFXBFile (AudioPluginInstance* plugin, MemoryBlock& dest, bool asFXB) { - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) return vst->saveToFXBFile (dest, asFXB); return false; @@ -2870,7 +2854,7 @@ bool VSTPluginFormat::saveToFXBFile (AudioPluginInstance* plugin, MemoryBlock& d bool VSTPluginFormat::getChunkData (AudioPluginInstance* plugin, MemoryBlock& result, bool isPreset) { - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) return vst->getChunkData (result, isPreset, 128); return false; @@ -2878,7 +2862,7 @@ bool VSTPluginFormat::getChunkData (AudioPluginInstance* plugin, MemoryBlock& re bool VSTPluginFormat::setChunkData (AudioPluginInstance* plugin, const void* data, int size, bool isPreset) { - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) return vst->setChunkData (data, size, isPreset); return false; @@ -2888,13 +2872,13 @@ void VSTPluginFormat::setExtraFunctions (AudioPluginInstance* plugin, ExtraFunct { ScopedPointer f (functions); - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) vst->extraFunctions = f; } VSTPluginFormat::VstIntPtr JUCE_CALLTYPE VSTPluginFormat::dispatcher (AudioPluginInstance* plugin, int32 opcode, int32 index, VstIntPtr value, void* ptr, float opt) { - if (VSTPluginInstance* vst = dynamic_cast (plugin)) + if (VSTPluginInstance* vst = dynamic_cast (plugin)) return vst->dispatch (opcode, index, value, ptr, opt); return 0; diff --git a/source/modules/juce_audio_processors/juce_audio_processors.cpp b/source/modules/juce_audio_processors/juce_audio_processors.cpp index 43934d6ca..d1f1679fb 100644 --- a/source/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/source/modules/juce_audio_processors/juce_audio_processors.cpp @@ -41,8 +41,9 @@ //============================================================================== #if JUCE_MAC - #if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU) \ - || ! (defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) + #if JUCE_SUPPORT_CARBON \ + && ((JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU) \ + || ! (defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)) #define Point CarbonDummyPointName // (workaround to avoid definition of "Point" by old Carbon headers) #define Component CarbonDummyCompName #include diff --git a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 86f2e8199..45e174237 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -231,9 +231,6 @@ AudioProcessorEditor* AudioProcessor::createEditorIfNeeded() AudioProcessorEditor* const ed = createEditor(); - // You must make your hasEditor() method return a consistent result! - jassert (hasEditor() == (ed != nullptr)); - if (ed != nullptr) { // you must give your editor comp a size before returning it.. @@ -243,6 +240,9 @@ AudioProcessorEditor* AudioProcessor::createEditorIfNeeded() activeEditor = ed; } + // You must make your hasEditor() method return a consistent result! + jassert (hasEditor() == (ed != nullptr)); + return ed; } diff --git a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 6d663fd28..3e24da192 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -325,7 +325,7 @@ public: /** Called by the host to tell this processor whether it's being used in a non-realtime capacity for offline rendering or bouncing. */ - void setNonRealtime (bool isNonRealtime) noexcept; + virtual void setNonRealtime (bool isNonRealtime) noexcept; //============================================================================== /** Creates the filter's UI. diff --git a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index a4c9d296b..a62541111 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -22,16 +22,22 @@ ============================================================================== */ -AudioProcessorEditor::AudioProcessorEditor (AudioProcessor* const p) - : owner (p) +AudioProcessorEditor::AudioProcessorEditor (AudioProcessor& p) noexcept : processor (p) +{ +} + +AudioProcessorEditor::AudioProcessorEditor (AudioProcessor* p) noexcept : processor (*p) { // the filter must be valid.. - jassert (owner != nullptr); + jassert (p != nullptr); } AudioProcessorEditor::~AudioProcessorEditor() { // if this fails, then the wrapper hasn't called editorBeingDeleted() on the // filter for some reason.. - jassert (owner->getActiveEditor() != this); + jassert (processor.getActiveEditor() != this); } + +void AudioProcessorEditor::setControlHighlight (ParameterControlHighlightInfo) {} +int AudioProcessorEditor::getControlParameterIndex (Component&) { return -1; } diff --git a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index 3c811a254..1755497c3 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -39,9 +39,11 @@ class JUCE_API AudioProcessorEditor : public Component { protected: //============================================================================== - /** Creates an editor for the specified processor. - */ - AudioProcessorEditor (AudioProcessor* owner); + /** Creates an editor for the specified processor. */ + AudioProcessorEditor (AudioProcessor&) noexcept; + + /** Creates an editor for the specified processor. */ + AudioProcessorEditor (AudioProcessor*) noexcept; public: /** Destructor. */ @@ -49,14 +51,40 @@ public: //============================================================================== - /** Returns a pointer to the processor that this editor represents. */ - AudioProcessor* getAudioProcessor() const noexcept { return owner; } + /** The AudioProcessor that this editor represents. */ + AudioProcessor& processor; + /** Returns a pointer to the processor that this editor represents. + This method is here to support legacy code, but it's easier to just use the + AudioProcessorEditor::processor member variable directly to get this object. + */ + AudioProcessor* getAudioProcessor() const noexcept { return &processor; } -private: //============================================================================== - AudioProcessor* const owner; + /** Used by the setParameterHighlighting() method. */ + struct ParameterControlHighlightInfo + { + int parameterIndex; + bool isHighlighted; + Colour suggestedColour; + }; + + /** Some types of plugin can call this to suggest that the control for a particular + parameter should be highlighted. + Currently only AAX plugins will call this, and implementing it is optional. + */ + virtual void setControlHighlight (ParameterControlHighlightInfo); + /** Called by certain plug-in wrappers to find out whether a component is used + to control a parameter. + + If the given component represents a particular plugin parameter, then this + method should return the index of that parameter. If not, it should return -1. + Currently only AAX plugins will call this, and implementing it is optional. + */ + virtual int getControlParameterIndex (Component&); + +private: JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditor) }; diff --git a/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp b/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp index 8e1010fac..5eafc07ce 100644 --- a/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp +++ b/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp @@ -71,18 +71,26 @@ PluginDescription& PluginDescription::operator= (const PluginDescription& other) return *this; } -bool PluginDescription::isDuplicateOf (const PluginDescription& other) const +bool PluginDescription::isDuplicateOf (const PluginDescription& other) const noexcept { return fileOrIdentifier == other.fileOrIdentifier && uid == other.uid; } +static String getPluginDescSuffix (const PluginDescription& d) +{ + return "-" + String::toHexString (d.fileOrIdentifier.hashCode()) + + "-" + String::toHexString (d.uid); +} + +bool PluginDescription::matchesIdentifierString (const String& identifierString) const +{ + return identifierString.endsWithIgnoreCase (getPluginDescSuffix (*this)); +} + String PluginDescription::createIdentifierString() const { - return pluginFormatName - + "-" + name - + "-" + String::toHexString (fileOrIdentifier.hashCode()) - + "-" + String::toHexString (uid); + return pluginFormatName + "-" + name + getPluginDescSuffix (*this); } XmlElement* PluginDescription::createXml() const diff --git a/source/modules/juce_audio_processors/processors/juce_PluginDescription.h b/source/modules/juce_audio_processors/processors/juce_PluginDescription.h index 6361775d4..24b17e5bf 100644 --- a/source/modules/juce_audio_processors/processors/juce_PluginDescription.h +++ b/source/modules/juce_audio_processors/processors/juce_PluginDescription.h @@ -107,7 +107,15 @@ public: This isn't quite as simple as them just having the same file (because of shell plug-ins). */ - bool isDuplicateOf (const PluginDescription& other) const; + bool isDuplicateOf (const PluginDescription& other) const noexcept; + + /** Return true if this description is equivalent to another one which created the + given identifier string. + + Note that this isn't quite as simple as them just calling createIdentifierString() + and comparing the strings, because the identifers can differ (thanks to shell plug-ins). + */ + bool matchesIdentifierString (const String& identifierString) const; //============================================================================== /** Returns a string that can be saved and used to uniquely identify the diff --git a/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index fc3679c24..081ba11a8 100644 --- a/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -46,7 +46,7 @@ PluginDescription* KnownPluginList::getTypeForFile (const String& fileOrIdentifi PluginDescription* KnownPluginList::getTypeForIdentifierString (const String& identifierString) const { for (int i = 0; i < types.size(); ++i) - if (types.getUnchecked(i)->createIdentifierString() == identifierString) + if (types.getUnchecked(i)->matchesIdentifierString (identifierString)) return types.getUnchecked(i); return nullptr; diff --git a/source/modules/juce_core/containers/juce_Array.h b/source/modules/juce_core/containers/juce_Array.h index 375576adc..8e9cf3f9b 100644 --- a/source/modules/juce_core/containers/juce_Array.h +++ b/source/modules/juce_core/containers/juce_Array.h @@ -65,8 +65,7 @@ private: public: //============================================================================== /** Creates an empty array. */ - Array() noexcept - : numUsed (0) + Array() noexcept : numUsed (0) { } diff --git a/source/modules/juce_core/containers/juce_NamedValueSet.cpp b/source/modules/juce_core/containers/juce_NamedValueSet.cpp index c4e198d0f..504ab784f 100644 --- a/source/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/source/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -88,9 +88,8 @@ NamedValueSet& NamedValueSet::operator= (NamedValueSet&& other) noexcept } #endif -NamedValueSet::~NamedValueSet() +NamedValueSet::~NamedValueSet() noexcept { - clear(); } void NamedValueSet::clear() @@ -113,7 +112,7 @@ int NamedValueSet::size() const noexcept return values.size(); } -const var& NamedValueSet::operator[] (const Identifier& name) const +const var& NamedValueSet::operator[] (const Identifier& name) const noexcept { if (const var* v = getVarPointer (name)) return *v; @@ -170,7 +169,7 @@ bool NamedValueSet::set (Identifier name, const var& newValue) return true; } -bool NamedValueSet::contains (const Identifier& name) const +bool NamedValueSet::contains (const Identifier& name) const noexcept { return getVarPointer (name) != nullptr; } diff --git a/source/modules/juce_core/containers/juce_NamedValueSet.h b/source/modules/juce_core/containers/juce_NamedValueSet.h index 021632630..e4a98edc6 100644 --- a/source/modules/juce_core/containers/juce_NamedValueSet.h +++ b/source/modules/juce_core/containers/juce_NamedValueSet.h @@ -54,7 +54,7 @@ public: #endif /** Destructor. */ - ~NamedValueSet(); + ~NamedValueSet() noexcept; bool operator== (const NamedValueSet&) const; bool operator!= (const NamedValueSet&) const; @@ -67,7 +67,7 @@ public: If the name isn't found, this will return a void variant. @see getProperty */ - const var& operator[] (const Identifier& name) const; + const var& operator[] (const Identifier& name) const noexcept; /** Tries to return the named value, but if no such value is found, this will instead return the supplied default value. @@ -89,7 +89,7 @@ public: #endif /** Returns true if the set contains an item with the specified name. */ - bool contains (const Identifier& name) const; + bool contains (const Identifier& name) const noexcept; /** Removes a value from the set. @returns true if a value was removed; false if there was no value diff --git a/source/modules/juce_core/files/juce_File.cpp b/source/modules/juce_core/files/juce_File.cpp index 695d48e68..d5c520a09 100644 --- a/source/modules/juce_core/files/juce_File.cpp +++ b/source/modules/juce_core/files/juce_File.cpp @@ -476,7 +476,7 @@ bool File::loadFileAsData (MemoryBlock& destBlock) const return false; FileInputStream in (*this); - return in.openedOk() && getSize() == in.readIntoMemoryBlock (destBlock); + return in.openedOk() && getSize() == (int64) in.readIntoMemoryBlock (destBlock); } String File::loadFileAsString() const diff --git a/source/modules/juce_core/javascript/juce_Javascript.cpp b/source/modules/juce_core/javascript/juce_Javascript.cpp index af99a84eb..bbcedb7ba 100644 --- a/source/modules/juce_core/javascript/juce_Javascript.cpp +++ b/source/modules/juce_core/javascript/juce_Javascript.cpp @@ -1145,8 +1145,14 @@ struct JavascriptEngine::RootObject : public DynamicObject match (TokenTypes::semicolon); } - s->iterator = parseExpression(); - match (TokenTypes::closeParen); + if (matchIf (TokenTypes::closeParen)) + s->iterator = new Statement (location); + else + { + s->iterator = parseExpression(); + match (TokenTypes::closeParen); + } + s->body = parseStatement(); return s.release(); } @@ -1555,6 +1561,7 @@ struct JavascriptEngine::RootObject : public DynamicObject setMethod ("log", Math_log); setMethod ("log10", Math_log10); setMethod ("exp", Math_exp); setMethod ("pow", Math_pow); setMethod ("sqr", Math_sqr); setMethod ("sqrt", Math_sqrt); + setMethod ("ceil", Math_ceil); setMethod ("floor", Math_floor); } static var Math_pi (Args) { return double_Pi; } @@ -1587,6 +1594,8 @@ struct JavascriptEngine::RootObject : public DynamicObject static var Math_pow (Args a) { return pow (getDouble (a, 0), getDouble (a, 1)); } static var Math_sqr (Args a) { double x = getDouble (a, 0); return x * x; } static var Math_sqrt (Args a) { return std::sqrt (getDouble (a, 0)); } + static var Math_ceil (Args a) { return std::ceil (getDouble (a, 0)); } + static var Math_floor (Args a) { return std::floor (getDouble (a, 0)); } static Identifier getClassName() { static const Identifier i ("Math"); return i; } template static Type sign (Type n) noexcept { return n > 0 ? (Type) 1 : (n < 0 ? (Type) -1 : 0); } diff --git a/source/modules/juce_core/juce_core.cpp b/source/modules/juce_core/juce_core.cpp index 002950e4b..edec1ccc9 100644 --- a/source/modules/juce_core/juce_core.cpp +++ b/source/modules/juce_core/juce_core.cpp @@ -53,6 +53,8 @@ #if JUCE_WINDOWS #include + + #define _WINSOCK_DEPRECATED_NO_WARNINGS 1 #include #include @@ -95,7 +97,6 @@ #endif #if JUCE_MAC || JUCE_IOS - #include #include #include #endif diff --git a/source/modules/juce_core/maths/juce_BigInteger.cpp b/source/modules/juce_core/maths/juce_BigInteger.cpp index b1c42b6f8..dd0961635 100644 --- a/source/modules/juce_core/maths/juce_BigInteger.cpp +++ b/source/modules/juce_core/maths/juce_BigInteger.cpp @@ -307,7 +307,7 @@ void BigInteger::negate() noexcept negative = (! negative) && ! isZero(); } -#if JUCE_USE_INTRINSICS && ! defined (__INTEL_COMPILER) +#if JUCE_USE_MSVC_INTRINSICS && ! defined (__INTEL_COMPILER) #pragma intrinsic (_BitScanReverse) #endif @@ -317,7 +317,7 @@ inline static int highestBitInInt (uint32 n) noexcept #if JUCE_GCC return 31 - __builtin_clz (n); - #elif JUCE_USE_INTRINSICS + #elif JUCE_USE_MSVC_INTRINSICS unsigned long highest; _BitScanReverse (&highest, n); return (int) highest; diff --git a/source/modules/juce_core/maths/juce_Range.h b/source/modules/juce_core/maths/juce_Range.h index 0aa9be46e..6add15234 100644 --- a/source/modules/juce_core/maths/juce_Range.h +++ b/source/modules/juce_core/maths/juce_Range.h @@ -77,6 +77,13 @@ public: : Range (position2, position1); } + /** Returns a range with a given start and length. */ + static Range withStartAndLength (const ValueType startValue, const ValueType length) noexcept + { + jassert (length >= ValueType()); + return Range (startValue, startValue + length); + } + /** Returns a range with the specified start position and a length of zero. */ static Range emptyRange (const ValueType start) noexcept { diff --git a/source/modules/juce_core/memory/juce_Atomic.h b/source/modules/juce_core/memory/juce_Atomic.h index d0dd6be5b..5e9d30c13 100644 --- a/source/modules/juce_core/memory/juce_Atomic.h +++ b/source/modules/juce_core/memory/juce_Atomic.h @@ -218,7 +218,7 @@ private: #else #define JUCE_ATOMICS_WINDOWS 1 // Windows with intrinsics - #if JUCE_USE_INTRINSICS + #if JUCE_USE_MSVC_INTRINSICS #ifndef __INTEL_COMPILER #pragma intrinsic (_InterlockedExchange, _InterlockedIncrement, _InterlockedDecrement, _InterlockedCompareExchange, \ _InterlockedCompareExchange64, _InterlockedExchangeAdd, _ReadWriteBarrier) diff --git a/source/modules/juce_core/memory/juce_ByteOrder.h b/source/modules/juce_core/memory/juce_ByteOrder.h index 0ecf2e480..fcd56bce2 100644 --- a/source/modules/juce_core/memory/juce_ByteOrder.h +++ b/source/modules/juce_core/memory/juce_ByteOrder.h @@ -110,13 +110,13 @@ private: //============================================================================== -#if JUCE_USE_INTRINSICS && ! defined (__INTEL_COMPILER) +#if JUCE_USE_MSVC_INTRINSICS && ! defined (__INTEL_COMPILER) #pragma intrinsic (_byteswap_ulong) #endif inline uint16 ByteOrder::swap (uint16 n) noexcept { - #if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic! + #if JUCE_USE_MSVC_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic! return static_cast (_byteswap_ushort (n)); #else return static_cast ((n << 8) | (n >> 8)); @@ -130,7 +130,7 @@ inline uint32 ByteOrder::swap (uint32 n) noexcept #elif JUCE_GCC && JUCE_INTEL && ! JUCE_NO_INLINE_ASM asm("bswap %%eax" : "=a"(n) : "a"(n)); return n; - #elif JUCE_USE_INTRINSICS + #elif JUCE_USE_MSVC_INTRINSICS return _byteswap_ulong (n); #elif JUCE_MSVC && ! JUCE_NO_INLINE_ASM __asm { @@ -150,7 +150,7 @@ inline uint64 ByteOrder::swap (uint64 value) noexcept { #if JUCE_MAC || JUCE_IOS return OSSwapInt64 (value); - #elif JUCE_USE_INTRINSICS + #elif JUCE_USE_MSVC_INTRINSICS return _byteswap_uint64 (value); #else return (((int64) swap ((uint32) value)) << 32) | swap ((uint32) (value >> 32)); diff --git a/source/modules/juce_core/memory/juce_WeakReference.h b/source/modules/juce_core/memory/juce_WeakReference.h index b56808ad6..c11b19f85 100644 --- a/source/modules/juce_core/memory/juce_WeakReference.h +++ b/source/modules/juce_core/memory/juce_WeakReference.h @@ -158,7 +158,7 @@ public: public: Master() noexcept {} - ~Master() + ~Master() noexcept { // You must remember to call clear() in your source object's destructor! See the notes // for the WeakReference class for an example of how to do this. @@ -187,7 +187,7 @@ public: to zero all the references to this object that may be out there. See the WeakReference class notes for an example of how to do this. */ - void clear() + void clear() noexcept { if (sharedPointer != nullptr) sharedPointer->clearPointer(); diff --git a/source/modules/juce_core/native/juce_android_Network.cpp b/source/modules/juce_core/native/juce_android_Network.cpp index 1b86deeee..29a8cb591 100644 --- a/source/modules/juce_core/native/juce_android_Network.cpp +++ b/source/modules/juce_core/native/juce_android_Network.cpp @@ -166,7 +166,7 @@ public: int numBytes = stream.callIntMethod (HTTPStream.read, javaArray, (jint) bytesToRead); if (numBytes > 0) - env->GetByteArrayRegion (javaArray, 0, numBytes, static_cast (buffer)); + env->GetByteArrayRegion (javaArray, 0, numBytes, static_cast (buffer)); env->DeleteLocalRef (javaArray); return numBytes; diff --git a/source/modules/juce_core/native/juce_win32_SystemStats.cpp b/source/modules/juce_core/native/juce_win32_SystemStats.cpp index 901bc761f..d98e3237b 100644 --- a/source/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/source/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -38,7 +38,7 @@ void Logger::outputDebugString (const String& text) #endif //============================================================================== -#if JUCE_USE_INTRINSICS +#if JUCE_USE_MSVC_INTRINSICS // CPU info functions using intrinsics... @@ -313,7 +313,7 @@ double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHa //============================================================================== static int64 juce_getClockCycleCounter() noexcept { - #if JUCE_USE_INTRINSICS + #if JUCE_USE_MSVC_INTRINSICS // MS intrinsics version... return (int64) __rdtsc(); diff --git a/source/modules/juce_core/native/juce_win32_Threads.cpp b/source/modules/juce_core/native/juce_win32_Threads.cpp index 4eb24e2c0..1421c109f 100644 --- a/source/modules/juce_core/native/juce_win32_Threads.cpp +++ b/source/modules/juce_core/native/juce_win32_Threads.cpp @@ -36,7 +36,7 @@ void* getUser32Function (const char* functionName) } //============================================================================== -#if ! JUCE_USE_INTRINSICS +#if ! JUCE_USE_MSVC_INTRINSICS // In newer compilers, the inline versions of these are used (in juce_Atomic.h), but in // older ones we have to actually call the ops as win32 functions.. long juce_InterlockedExchange (volatile long* a, long b) noexcept { return InterlockedExchange (a, b); } diff --git a/source/modules/juce_core/streams/juce_InputStream.cpp b/source/modules/juce_core/streams/juce_InputStream.cpp index 08ff61ccd..07b9976da 100644 --- a/source/modules/juce_core/streams/juce_InputStream.cpp +++ b/source/modules/juce_core/streams/juce_InputStream.cpp @@ -209,10 +209,10 @@ String InputStream::readNextLine() return String::fromUTF8 (data, (int) i); } -int InputStream::readIntoMemoryBlock (MemoryBlock& block, ssize_t numBytes) +size_t InputStream::readIntoMemoryBlock (MemoryBlock& block, ssize_t numBytes) { MemoryOutputStream mo (block, true); - return mo.writeFromInputStream (*this, numBytes); + return (size_t) mo.writeFromInputStream (*this, numBytes); } String InputStream::readEntireStreamAsString() diff --git a/source/modules/juce_core/streams/juce_InputStream.h b/source/modules/juce_core/streams/juce_InputStream.h index 0c7e2dc50..ebdc795fa 100644 --- a/source/modules/juce_core/streams/juce_InputStream.h +++ b/source/modules/juce_core/streams/juce_InputStream.h @@ -211,7 +211,7 @@ public: /** Tries to read the whole stream and turn it into a string. This will read from the stream's current position until the end-of-stream. - It can read from either UTF-16 or UTF-8 formats. + It can read from UTF-8 data, or UTF-16 if it detects suitable header-bytes. */ virtual String readEntireStreamAsString(); @@ -223,8 +223,8 @@ public: will be read until the stream is exhausted. @returns the number of bytes that were added to the memory block */ - virtual int readIntoMemoryBlock (MemoryBlock& destBlock, - ssize_t maxNumBytesToRead = -1); + virtual size_t readIntoMemoryBlock (MemoryBlock& destBlock, + ssize_t maxNumBytesToRead = -1); //============================================================================== /** Returns the offset of the next byte that will be read from the stream. diff --git a/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 7d07ce627..835b2bd79 100644 --- a/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -175,7 +175,7 @@ bool MemoryOutputStream::setPosition (int64 newPosition) return false; } -int MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite) +int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite) { // before writing from an input, see if we can preallocate to make it more efficient.. int64 availableData = source.getTotalLength() - source.getPosition(); diff --git a/source/modules/juce_core/streams/juce_MemoryOutputStream.h b/source/modules/juce_core/streams/juce_MemoryOutputStream.h index 61cc85c34..2e764effe 100644 --- a/source/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/source/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -116,7 +116,7 @@ public: bool write (const void*, size_t) override; int64 getPosition() override { return (int64) position; } bool setPosition (int64) override; - int writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override; + int64 writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override; bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override; private: diff --git a/source/modules/juce_core/streams/juce_OutputStream.cpp b/source/modules/juce_core/streams/juce_OutputStream.cpp index 7c6d0bd32..c67e3fb8c 100644 --- a/source/modules/juce_core/streams/juce_OutputStream.cpp +++ b/source/modules/juce_core/streams/juce_OutputStream.cpp @@ -252,12 +252,12 @@ bool OutputStream::writeText (const String& text, const bool asUTF16, return true; } -int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite) +int64 OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite) { if (numBytesToWrite < 0) numBytesToWrite = std::numeric_limits::max(); - int numWritten = 0; + int64 numWritten = 0; while (numBytesToWrite > 0) { diff --git a/source/modules/juce_core/streams/juce_OutputStream.h b/source/modules/juce_core/streams/juce_OutputStream.h index de40888fd..102ab5a01 100644 --- a/source/modules/juce_core/streams/juce_OutputStream.h +++ b/source/modules/juce_core/streams/juce_OutputStream.h @@ -221,7 +221,7 @@ public: is exhausted) @returns the number of bytes written */ - virtual int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite); + virtual int64 writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite); //============================================================================== /** Sets the string that will be written to the stream when the writeNewLine() diff --git a/source/modules/juce_core/system/juce_PlatformDefs.h b/source/modules/juce_core/system/juce_PlatformDefs.h index 6f599796d..d28452d56 100644 --- a/source/modules/juce_core/system/juce_PlatformDefs.h +++ b/source/modules/juce_core/system/juce_PlatformDefs.h @@ -68,7 +68,7 @@ @see jassert() */ #define juce_breakDebugger { ::kill (0, SIGTRAP); } -#elif JUCE_USE_INTRINSICS +#elif JUCE_USE_MSVC_INTRINSICS #ifndef __INTEL_COMPILER #pragma intrinsic (__debugbreak) #endif diff --git a/source/modules/juce_core/system/juce_StandardHeader.h b/source/modules/juce_core/system/juce_StandardHeader.h index f9627cad6..e87e565df 100644 --- a/source/modules/juce_core/system/juce_StandardHeader.h +++ b/source/modules/juce_core/system/juce_StandardHeader.h @@ -36,7 +36,7 @@ */ #define JUCE_MAJOR_VERSION 3 #define JUCE_MINOR_VERSION 0 -#define JUCE_BUILDNUMBER 7 +#define JUCE_BUILDNUMBER 8 /** Current Juce version number. @@ -73,7 +73,7 @@ #include #include -#if JUCE_USE_INTRINSICS +#if JUCE_USE_MSVC_INTRINSICS #include #endif diff --git a/source/modules/juce_core/system/juce_TargetPlatform.h b/source/modules/juce_core/system/juce_TargetPlatform.h index 0d12d7d05..00c49bb89 100644 --- a/source/modules/juce_core/system/juce_TargetPlatform.h +++ b/source/modules/juce_core/system/juce_TargetPlatform.h @@ -194,7 +194,7 @@ #endif #if JUCE_64BIT || ! JUCE_VC7_OR_EARLIER - #define JUCE_USE_INTRINSICS 1 + #define JUCE_USE_MSVC_INTRINSICS 1 #endif #else #error unknown compiler diff --git a/source/modules/juce_core/xml/juce_XmlElement.cpp b/source/modules/juce_core/xml/juce_XmlElement.cpp index 000df15d5..0a9f0543a 100644 --- a/source/modules/juce_core/xml/juce_XmlElement.cpp +++ b/source/modules/juce_core/xml/juce_XmlElement.cpp @@ -714,7 +714,7 @@ bool XmlElement::isEquivalentTo (const XmlElement* const other, { if (thisAtt == nullptr || otherAtt == nullptr) { - if (thisAtt == otherAtt) // both 0, so it's a match + if (thisAtt == otherAtt) // both nullptr, so it's a match break; return false; diff --git a/source/modules/juce_core/xml/juce_XmlElement.h b/source/modules/juce_core/xml/juce_XmlElement.h index 4ab4d0886..2f03e93aa 100644 --- a/source/modules/juce_core/xml/juce_XmlElement.h +++ b/source/modules/juce_core/xml/juce_XmlElement.h @@ -599,10 +599,17 @@ public: /** Returns true if the given element is a child of this one. */ bool containsChildElement (const XmlElement* possibleChild) const noexcept; - /** Recursively searches all sub-elements to find one that contains the specified - child element. + /** Recursively searches all sub-elements of this one, looking for an element + which is the direct parent of the specified element. + + Because elements don't store a pointer to their parent, if you have one + and need to find its parent, the only way to do so is to exhaustively + search the whole tree for it. + + If the given child is found somewhere in this element's hierarchy, then + this method will return its parent. If not, it will return nullptr. */ - XmlElement* findParentElementOf (const XmlElement* elementToLookFor) noexcept; + XmlElement* findParentElementOf (const XmlElement* childToSearchFor) noexcept; //============================================================================== /** Sorts the child elements using a comparator. diff --git a/source/modules/juce_core/zip/juce_ZipFile.cpp b/source/modules/juce_core/zip/juce_ZipFile.cpp index 9a3faf9bc..a76d8b890 100644 --- a/source/modules/juce_core/zip/juce_ZipFile.cpp +++ b/source/modules/juce_core/zip/juce_ZipFile.cpp @@ -347,7 +347,7 @@ void ZipFile::init() in->setPosition (pos); MemoryBlock headerData; - if (in->readIntoMemoryBlock (headerData, size) == size) + if (in->readIntoMemoryBlock (headerData, size) == (size_t) size) { pos = 0; diff --git a/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index a7d56a6d3..33f232d5b 100644 --- a/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -25,12 +25,11 @@ class ActionBroadcaster::ActionMessage : public MessageManager::MessageBase { public: - ActionMessage (const ActionBroadcaster* const broadcaster_, - const String& messageText, - ActionListener* const listener_) noexcept - : broadcaster (const_cast (broadcaster_)), + ActionMessage (const ActionBroadcaster* ab, + const String& messageText, ActionListener* l) noexcept + : broadcaster (const_cast (ab)), message (messageText), - listener (listener_) + listener (l) {} void messageCallback() override diff --git a/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 74f797d81..f008cd133 100644 --- a/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -31,7 +31,7 @@ struct InterprocessConnection::ConnectionThread : public Thread private: InterprocessConnection& owner; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConnectionThread); + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConnectionThread) }; //============================================================================== diff --git a/source/modules/juce_events/messages/juce_ApplicationBase.cpp b/source/modules/juce_events/messages/juce_ApplicationBase.cpp index 7a87fdbc6..dafc27e66 100644 --- a/source/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/source/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -232,7 +232,7 @@ int JUCEApplicationBase::main() jassert (app != nullptr); if (! app->initialiseApp()) - return 0; + return app->getApplicationReturnValue(); JUCE_TRY { diff --git a/source/modules/juce_events/messages/juce_ApplicationBase.h b/source/modules/juce_events/messages/juce_ApplicationBase.h index 51f098c9b..073e5d6c7 100644 --- a/source/modules/juce_events/messages/juce_ApplicationBase.h +++ b/source/modules/juce_events/messages/juce_ApplicationBase.h @@ -50,24 +50,24 @@ MyJUCEApp() {} ~MyJUCEApp() {} - void initialise (const String& commandLine) + void initialise (const String& commandLine) override { myMainWindow = new MyApplicationWindow(); myMainWindow->setBounds (100, 100, 400, 500); myMainWindow->setVisible (true); } - void shutdown() + void shutdown() override { myMainWindow = nullptr; } - const String getApplicationName() + const String getApplicationName() override { return "Super JUCE-o-matic"; } - const String getApplicationVersion() + const String getApplicationVersion() override { return "1.0"; } diff --git a/source/modules/juce_events/messages/juce_MessageManager.cpp b/source/modules/juce_events/messages/juce_MessageManager.cpp index 31e2710fc..1383f90f9 100644 --- a/source/modules/juce_events/messages/juce_MessageManager.cpp +++ b/source/modules/juce_events/messages/juce_MessageManager.cpp @@ -288,7 +288,10 @@ bool MessageManagerLock::attemptLock (Thread* const threadToCheck, ThreadPoolJob blockingMessage = new BlockingMessage(); if (! blockingMessage->post()) + { + blockingMessage = nullptr; return false; + } while (! blockingMessage->lockedEvent.wait (20)) { diff --git a/source/modules/juce_graphics/geometry/juce_AffineTransform.h b/source/modules/juce_graphics/geometry/juce_AffineTransform.h index dfc3a29c1..f30fdb81f 100644 --- a/source/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/source/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -83,8 +83,8 @@ public: void transformPoint (ValueType& x, ValueType& y) const noexcept { const ValueType oldX = x; - x = static_cast (mat00 * oldX + mat01 * y + mat02); - y = static_cast (mat10 * oldX + mat11 * y + mat12); + x = static_cast (mat00 * oldX + mat01 * y + mat02); + y = static_cast (mat10 * oldX + mat11 * y + mat12); } /** Transforms two 2D coordinates using this matrix. @@ -97,10 +97,10 @@ public: ValueType& x2, ValueType& y2) const noexcept { const ValueType oldX1 = x1, oldX2 = x2; - x1 = static_cast (mat00 * oldX1 + mat01 * y1 + mat02); - y1 = static_cast (mat10 * oldX1 + mat11 * y1 + mat12); - x2 = static_cast (mat00 * oldX2 + mat01 * y2 + mat02); - y2 = static_cast (mat10 * oldX2 + mat11 * y2 + mat12); + x1 = static_cast (mat00 * oldX1 + mat01 * y1 + mat02); + y1 = static_cast (mat10 * oldX1 + mat11 * y1 + mat12); + x2 = static_cast (mat00 * oldX2 + mat01 * y2 + mat02); + y2 = static_cast (mat10 * oldX2 + mat11 * y2 + mat12); } /** Transforms three 2D coordinates using this matrix. @@ -114,12 +114,12 @@ public: ValueType& x3, ValueType& y3) const noexcept { const ValueType oldX1 = x1, oldX2 = x2, oldX3 = x3; - x1 = static_cast (mat00 * oldX1 + mat01 * y1 + mat02); - y1 = static_cast (mat10 * oldX1 + mat11 * y1 + mat12); - x2 = static_cast (mat00 * oldX2 + mat01 * y2 + mat02); - y2 = static_cast (mat10 * oldX2 + mat11 * y2 + mat12); - x3 = static_cast (mat00 * oldX3 + mat01 * y3 + mat02); - y3 = static_cast (mat10 * oldX3 + mat11 * y3 + mat12); + x1 = static_cast (mat00 * oldX1 + mat01 * y1 + mat02); + y1 = static_cast (mat10 * oldX1 + mat11 * y1 + mat12); + x2 = static_cast (mat00 * oldX2 + mat01 * y2 + mat02); + y2 = static_cast (mat10 * oldX2 + mat11 * y2 + mat12); + x3 = static_cast (mat00 * oldX3 + mat01 * y3 + mat02); + y3 = static_cast (mat10 * oldX3 + mat11 * y3 + mat12); } //============================================================================== @@ -231,8 +231,7 @@ public: float x10, float y10, float x01, float y01) noexcept; - /** Returns the transform that will map three specified points onto three target points. - */ + /** Returns the transform that will map three specified points onto three target points. */ static AffineTransform fromTargetPoints (float sourceX1, float sourceY1, float targetX1, float targetY1, float sourceX2, float sourceY2, float targetX2, float targetY2, float sourceX3, float sourceY3, float targetX3, float targetY3) noexcept; diff --git a/source/modules/juce_graphics/native/juce_win32_Fonts.cpp b/source/modules/juce_graphics/native/juce_win32_Fonts.cpp index ab5dbe8a2..bc5bb3520 100644 --- a/source/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/source/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -506,8 +506,8 @@ private: lf.lfOutPrecision = OUT_OUTLINE_PRECIS; lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; lf.lfQuality = PROOF_QUALITY; - lf.lfItalic = (BYTE) (style == "Italic" ? TRUE : FALSE); - lf.lfWeight = style == "Bold" ? FW_BOLD : FW_NORMAL; + lf.lfItalic = (BYTE) (style.contains ("Italic") ? TRUE : FALSE); + lf.lfWeight = style.contains ("Bold") ? FW_BOLD : FW_NORMAL; lf.lfHeight = -256; name.copyToUTF16 (lf.lfFaceName, sizeof (lf.lfFaceName)); diff --git a/source/modules/juce_gui_basics/application/juce_Application.h b/source/modules/juce_gui_basics/application/juce_Application.h index 1ffb27e67..140cf9df2 100644 --- a/source/modules/juce_gui_basics/application/juce_Application.h +++ b/source/modules/juce_gui_basics/application/juce_Application.h @@ -53,24 +53,24 @@ MyJUCEApp() {} ~MyJUCEApp() {} - void initialise (const String& commandLine) + void initialise (const String& commandLine) override { myMainWindow = new MyApplicationWindow(); myMainWindow->setBounds (100, 100, 400, 500); myMainWindow->setVisible (true); } - void shutdown() + void shutdown() override { myMainWindow = nullptr; } - const String getApplicationName() + const String getApplicationName() override { return "Super JUCE-o-matic"; } - const String getApplicationVersion() + const String getApplicationVersion() override { return "1.0"; } diff --git a/source/modules/juce_gui_basics/components/juce_Component.cpp b/source/modules/juce_gui_basics/components/juce_Component.cpp index 303194bb4..7cbe59fb9 100644 --- a/source/modules/juce_gui_basics/components/juce_Component.cpp +++ b/source/modules/juce_gui_basics/components/juce_Component.cpp @@ -141,7 +141,7 @@ public: } private: - Array listeners; + Array listeners; int numDeepMouseListeners; class BailOutChecker2 @@ -256,7 +256,7 @@ struct Component::ComponentHelpers #if JUCE_MODAL_LOOPS_PERMITTED static void* runModalLoopCallback (void* userData) { - return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); + return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); } #endif @@ -399,16 +399,6 @@ struct Component::ComponentHelpers return convertFromDistantParentSpace (topLevelComp, *target, p); } - static Rectangle getUnclippedArea (const Component& comp) - { - Rectangle r (comp.getLocalBounds()); - - if (Component* const p = comp.getParentComponent()) - r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); - - return r; - } - static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle& clipRect, Point delta) { bool nothingChanged = true; @@ -441,35 +431,6 @@ struct Component::ComponentHelpers return nothingChanged; } - static void subtractObscuredRegions (const Component& comp, RectangleList& result, - Point delta, const Rectangle& clipRect, - const Component* const compToAvoid) - { - for (int i = comp.childComponentList.size(); --i >= 0;) - { - const Component* const c = comp.childComponentList.getUnchecked(i); - - if (c != compToAvoid && c->isVisible()) - { - if (c->isOpaque() && c->componentTransparency == 0) - { - Rectangle childBounds (c->bounds.getIntersection (clipRect)); - childBounds.translate (delta.x, delta.y); - - result.subtract (childBounds); - } - else - { - Rectangle newClip (clipRect.getIntersection (c->bounds)); - newClip.translate (-c->getX(), -c->getY()); - - subtractObscuredRegions (*c, result, c->getPosition() + delta, - newClip, compToAvoid); - } - } - } - } - static Rectangle getParentOrMainMonitorBounds (const Component& comp) { if (Component* p = comp.getParentComponent()) @@ -480,7 +441,7 @@ struct Component::ComponentHelpers }; //============================================================================== -Component::Component() +Component::Component() noexcept : parentComponent (nullptr), lookAndFeel (nullptr), effect (nullptr), @@ -489,7 +450,7 @@ Component::Component() { } -Component::Component (const String& name) +Component::Component (const String& name) noexcept : componentName (name), parentComponent (nullptr), lookAndFeel (nullptr), @@ -620,7 +581,6 @@ bool Component::isShowing() const return false; } - //============================================================================== void* Component::getWindowHandle() const { @@ -880,7 +840,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered) // so by calling setBufferedToImage, you'll be deleting the custom one - this is almost certainly // not what you wanted to happen... If you really do know what you're doing here, and want to // avoid this assertion, just call setCachedComponentImage (nullptr) before setBufferedToImage(). - jassert (cachedImage == nullptr || dynamic_cast (cachedImage.get()) != nullptr); + jassert (cachedImage == nullptr || dynamic_cast (cachedImage.get()) != nullptr); if (shouldBeBuffered) { @@ -1643,7 +1603,7 @@ Component* Component::getChildComponent (const int index) const noexcept int Component::getIndexOfChildComponent (const Component* const child) const noexcept { - return childComponentList.indexOf (const_cast (child)); + return childComponentList.indexOf (const_cast (child)); } Component* Component::findChildWithID (StringRef targetID) const noexcept @@ -1665,7 +1625,7 @@ Component* Component::getTopLevelComponent() const noexcept while (comp->parentComponent != nullptr) comp = comp->parentComponent; - return const_cast (comp); + return const_cast (comp); } bool Component::isParentOf (const Component* possibleChild) const noexcept @@ -2064,7 +2024,10 @@ void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel) // If sizing a top-level-window and the OS paint message is delivered synchronously // before resized() is called, then we'll invoke the callback here, to make sure // the components inside have had a chance to sort their sizes out.. - sendMovedResizedMessagesIfPending(); + #if JUCE_DEBUG + if (! flags.isInsidePaintCall) // (avoids an assertion in plugins hosted in WaveLab) + #endif + sendMovedResizedMessagesIfPending(); #if JUCE_DEBUG flags.isInsidePaintCall = true; @@ -2202,7 +2165,7 @@ void Component::sendLookAndFeelChange() Colour Component::findColour (const int colourId, const bool inheritFromParent) const { if (const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId))) - return Colour ((uint32) static_cast (*v)); + return Colour ((uint32) static_cast (*v)); if (inheritFromParent && parentComponent != nullptr && (lookAndFeel == nullptr || ! lookAndFeel->isColourSpecified (colourId))) @@ -2281,28 +2244,6 @@ Rectangle Component::getBoundsInParent() const noexcept : bounds.transformedBy (*affineTransform); } -void Component::getVisibleArea (RectangleList& result, const bool includeSiblings) const -{ - result.clear(); - const Rectangle unclipped (ComponentHelpers::getUnclippedArea (*this)); - - if (! unclipped.isEmpty()) - { - result.add (unclipped); - - if (includeSiblings) - { - const Component* const c = getTopLevelComponent(); - - ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point()), - c->getLocalBounds(), this); - } - - ComponentHelpers::subtractObscuredRegions (*this, result, Point(), unclipped, nullptr); - result.consolidate(); - } -} - //============================================================================== void Component::mouseEnter (const MouseEvent&) {} void Component::mouseExit (const MouseEvent&) {} @@ -2853,7 +2794,7 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr else { // find the default child component.. - ScopedPointer traverser (createFocusTraverser()); + ScopedPointer traverser (createFocusTraverser()); if (traverser != nullptr) { @@ -2895,7 +2836,7 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext) if (parentComponent != nullptr) { - ScopedPointer traverser (createFocusTraverser()); + ScopedPointer traverser (createFocusTraverser()); if (traverser != nullptr) { @@ -3049,7 +2990,7 @@ Point Component::getMouseXYRelative() const void Component::addKeyListener (KeyListener* const newListener) { if (keyListeners == nullptr) - keyListeners = new Array (); + keyListeners = new Array(); keyListeners->addIfNotAlreadyThere (newListener); } diff --git a/source/modules/juce_gui_basics/components/juce_Component.h b/source/modules/juce_gui_basics/components/juce_Component.h index 85a9d0392..629eac749 100644 --- a/source/modules/juce_gui_basics/components/juce_Component.h +++ b/source/modules/juce_gui_basics/components/juce_Component.h @@ -46,7 +46,7 @@ public: subclass of Component or use one of the other types of component from the library. */ - Component(); + Component() noexcept; /** Destructor. @@ -66,7 +66,7 @@ public: /** Creates a component, setting its name at the same time. @see getName, setName */ - explicit Component (const String& componentName); + explicit Component (const String& componentName) noexcept; /** Returns the name of this component. @see setName @@ -315,16 +315,6 @@ public: */ Rectangle getBoundsInParent() const noexcept; - /** Returns the region of this component that's not obscured by other, opaque components. - - The RectangleList that is returned represents the area of this component - which isn't covered by opaque child components. - - If includeSiblings is true, it will also take into account any siblings - that may be overlapping the component. - */ - void getVisibleArea (RectangleList& result, bool includeSiblings) const; - //============================================================================== /** Returns this component's x coordinate relative the screen's top-left origin. @see getX, localPointToGlobal @@ -807,7 +797,7 @@ public: TargetClass* findParentComponentOfClass() const { for (Component* p = parentComponent; p != nullptr; p = p->parentComponent) - if (TargetClass* const target = dynamic_cast (p)) + if (TargetClass* const target = dynamic_cast (p)) return target; return nullptr; @@ -1166,7 +1156,7 @@ public: By default, components are considered transparent, unless this is used to make it otherwise. - @see isOpaque, getVisibleArea + @see isOpaque */ void setOpaque (bool shouldBeOpaque); @@ -2136,31 +2126,31 @@ public: SafePointer() noexcept {} /** Creates a SafePointer that points at the given component. */ - SafePointer (ComponentType* const component) : weakRef (component) {} + SafePointer (ComponentType* component) : weakRef (component) {} /** Creates a copy of another SafePointer. */ - SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {} + SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {} /** Copies another pointer to this one. */ - SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; } + SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; } /** Copies another pointer to this one. */ - SafePointer& operator= (ComponentType* const newComponent) { weakRef = newComponent; return *this; } + SafePointer& operator= (ComponentType* newComponent) { weakRef = newComponent; return *this; } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ - ComponentType* getComponent() const noexcept { return dynamic_cast (weakRef.get()); } + ComponentType* getComponent() const noexcept { return dynamic_cast (weakRef.get()); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ - operator ComponentType*() const noexcept { return getComponent(); } + operator ComponentType*() const noexcept { return getComponent(); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ - ComponentType* operator->() noexcept { return getComponent(); } + ComponentType* operator->() noexcept { return getComponent(); } /** Returns the component that this pointer refers to, or null if the component no longer exists. */ - const ComponentType* operator->() const noexcept { return getComponent(); } + const ComponentType* operator->() const noexcept { return getComponent(); } /** If the component is valid, this deletes it and sets this pointer to null. */ - void deleteAndZero() { delete getComponent(); } + void deleteAndZero() { delete getComponent(); } bool operator== (ComponentType* component) const noexcept { return weakRef == component; } bool operator!= (ComponentType* component) const noexcept { return weakRef != component; } @@ -2268,20 +2258,20 @@ private: String componentName, componentID; Component* parentComponent; Rectangle bounds; - ScopedPointer positioner; - ScopedPointer affineTransform; - Array childComponentList; + ScopedPointer positioner; + ScopedPointer affineTransform; + Array childComponentList; LookAndFeel* lookAndFeel; MouseCursor cursor; ImageEffectFilter* effect; - ScopedPointer cachedImage; + ScopedPointer cachedImage; class MouseListenerList; friend class MouseListenerList; friend struct ContainerDeletePolicy; - ScopedPointer mouseListeners; - ScopedPointer > keyListeners; - ListenerList componentListeners; + ScopedPointer mouseListeners; + ScopedPointer > keyListeners; + ListenerList componentListeners; NamedValueSet properties; friend class WeakReference; @@ -2308,9 +2298,9 @@ private: bool mouseDownWasBlocked : 1; bool isMoveCallbackPending : 1; bool isResizeCallbackPending : 1; - #if JUCE_DEBUG + #if JUCE_DEBUG bool isInsidePaintCall : 1; - #endif + #endif }; union diff --git a/source/modules/juce_gui_basics/juce_gui_basics.cpp b/source/modules/juce_gui_basics/juce_gui_basics.cpp index 4451e10d1..d7f6feda3 100644 --- a/source/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/source/modules/juce_gui_basics/juce_gui_basics.cpp @@ -49,7 +49,7 @@ #import #import - #if JUCE_SUPPORT_CARBON + #if JUCE_SUPPORT_CARBON && ! (defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) #define Point CarbonDummyPointName #define Component CarbonDummyCompName #import // still needed for SetSystemUIMode() diff --git a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index b7d052c91..a22414bd2 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -25,8 +25,7 @@ class ComponentAnimator::AnimationTask { public: - AnimationTask (Component* const comp) - : component (comp) + AnimationTask (Component* const comp) noexcept : component (comp) { } @@ -34,7 +33,7 @@ public: float finalAlpha, int millisecondsToSpendMoving, bool useProxyComponent, - double startSpeed_, double endSpeed_) + double startSpd, double endSpd) { msElapsed = 0; msTotal = jmax (1, millisecondsToSpendMoving); @@ -51,10 +50,10 @@ public: bottom = component->getBottom(); alpha = component->getAlpha(); - const double invTotalDistance = 4.0 / (startSpeed_ + endSpeed_ + 2.0); - startSpeed = jmax (0.0, startSpeed_ * invTotalDistance); + const double invTotalDistance = 4.0 / (startSpd + endSpd + 2.0); + startSpeed = jmax (0.0, startSpd * invTotalDistance); midSpeed = invTotalDistance; - endSpeed = jmax (0.0, endSpeed_ * invTotalDistance); + endSpeed = jmax (0.0, endSpd * invTotalDistance); if (useProxyComponent) proxy = new ProxyComponent (*component); diff --git a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index f8ef6c685..66c960b62 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h @@ -148,10 +148,10 @@ public: private: //============================================================================== class AnimationTask; - OwnedArray tasks; + OwnedArray tasks; uint32 lastTime; - AnimationTask* findTaskFor (Component* component) const noexcept; + AnimationTask* findTaskFor (Component*) const noexcept; void timerCallback(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentAnimator) diff --git a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index 82519ea5f..433ddf8d6 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -238,7 +238,7 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree const int numExistingChildComps = parent.getNumChildComponents(); - Array componentsInOrder; + Array componentsInOrder; componentsInOrder.ensureStorageAllocated (numExistingChildComps); { diff --git a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index 9a4e0cbf5..c524111f4 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h @@ -226,7 +226,7 @@ public: private: //============================================================================= - OwnedArray types; + OwnedArray types; ScopedPointer component; ImageProvider* imageProvider; #if JUCE_DEBUG diff --git a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 7aef739f3..3f2c84f20 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -128,7 +128,7 @@ private: SpinLock MouseCursor::SharedCursorHandle::lock; //============================================================================== -MouseCursor::MouseCursor() +MouseCursor::MouseCursor() noexcept : cursorHandle (nullptr) { } diff --git a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 45bf3a66d..df540f01a 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h @@ -72,10 +72,10 @@ public: //============================================================================== /** Creates the standard arrow cursor. */ - MouseCursor(); + MouseCursor() noexcept; /** Creates one of the standard mouse cursor */ - MouseCursor (StandardCursorType type); + MouseCursor (StandardCursorType); /** Creates a custom cursor from an image. diff --git a/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp index b2d1ee777..200615f23 100644 --- a/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -43,7 +43,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* en JUCEApplicationBase* app = JUCEApplicationBase::createInstance(); if (! app->initialiseApp()) - exit (0); + exit (app->getApplicationReturnValue()); jassert (MessageManager::getInstance()->isThisTheMessageThread()); } diff --git a/source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index e1ee828a2..b9bd76bbd 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/source/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -1045,7 +1045,7 @@ public: r = Desktop::getInstance().getDisplays().getMainDisplay().userArea; if (! r.isEmpty()) - setBounds (r, shouldBeFullScreen); + setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); component.repaint(); } @@ -1115,9 +1115,9 @@ public: if (c == &component) break; - // TODO: needs scaling correctly - if (c->contains (localPos + bounds.getPosition() - c->getScreenPosition())) - return false; + if (ComponentPeer* peer = c->getPeer()) + if (peer->contains (localPos + bounds.getPosition() - peer->getBounds().getPosition(), true)) + return false; } if (trueIfInAChildWindow) diff --git a/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 7ade4d6bb..45569b83b 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -369,7 +369,7 @@ public: // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (r != component.getBounds() && ! r.isEmpty()) - setBounds (r, shouldBeFullScreen); + setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen); } } } @@ -411,8 +411,9 @@ public: if (NSWindow* const viewWindow = [view window]) { const NSRect windowFrame = [viewWindow frame]; - const NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + localPos.getX(), - windowFrame.origin.y + windowFrame.size.height - localPos.getY()); + const NSPoint windowPoint = [view convertPoint: NSMakePoint (localPos.x, localPos.y) toView: nil]; + const NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + windowPoint.x, + windowFrame.origin.y + windowFrame.size.height - windowPoint.y); if (! isWindowAtPoint (viewWindow, screenPoint)) return false; diff --git a/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 63b5d4dcd..47e838e08 100644 --- a/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -763,7 +763,7 @@ public: ShowWindow (hwnd, SW_SHOWNORMAL); if (! boundsCopy.isEmpty()) - setBounds (boundsCopy, false); + setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, boundsCopy), false); } else { @@ -1528,10 +1528,14 @@ private: // if something in a paint handler calls, e.g. a message box, this can become reentrant and // corrupt the image it's using to paint into, so do a check here. static bool reentrant = false; - if (! (reentrant || dontRepaint)) + if (! reentrant) { const ScopedValueSetter setter (reentrant, true, false); - performPaint (dc, rgn, regionType, paintStruct); + + if (dontRepaint) + component.handleCommandMessage (0); // (this triggers a repaint in the openGL context) + else + performPaint (dc, rgn, regionType, paintStruct); } DeleteObject (rgn); @@ -2896,18 +2900,15 @@ private: ModifierKeys HWNDComponentPeer::currentModifiers; ModifierKeys HWNDComponentPeer::modifiersAtLastCallback; -ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) +ComponentPeer* Component::createNewPeer (int styleFlags, void* parentHWND) { - return new HWNDComponentPeer (*this, styleFlags, - (HWND) nativeWindowToAttachTo, false); + return new HWNDComponentPeer (*this, styleFlags, (HWND) parentHWND, false); } -ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component* component, void* parent) +ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& component, void* parentHWND) { - jassert (component != nullptr); - - return new HWNDComponentPeer (*component, ComponentPeer::windowIgnoresMouseClicks, - (HWND) parent, true); + return new HWNDComponentPeer (component, ComponentPeer::windowIgnoresMouseClicks, + (HWND) parentHWND, true); } diff --git a/source/modules/juce_gui_basics/widgets/juce_ComboBox.h b/source/modules/juce_gui_basics/widgets/juce_ComboBox.h index 30cef785a..11515ba42 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/source/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -418,7 +418,7 @@ private: bool isEnabled : 1, isHeading : 1; }; - OwnedArray items; + OwnedArray items; Value currentId; int lastCurrentId; bool isButtonDown, separatorPending, menuActive, scrollWheelEnabled; diff --git a/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 9034f4490..ed12f980a 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -457,7 +457,7 @@ void ListBox::updateContent() if (selected.size() > 0 && selected [selected.size() - 1] >= totalItems) { - selected.removeRange (Range (totalItems, std::numeric_limits::max())); + selected.removeRange (Range (totalItems, std::numeric_limits::max())); lastRowSelected = getSelectedRow (0); selectionChanged = true; } @@ -516,7 +516,7 @@ void ListBox::deselectRow (const int row) { if (selected.contains (row)) { - selected.removeRange (Range (row, row + 1)); + selected.removeRange (Range (row, row + 1)); if (row == lastRowSelected) lastRowSelected = getSelectedRow (0); @@ -530,7 +530,7 @@ void ListBox::setSelectedRows (const SparseSet& setOfRowsToBeSelected, const NotificationType sendNotificationEventToModel) { selected = setOfRowsToBeSelected; - selected.removeRange (Range (totalItems, std::numeric_limits::max())); + selected.removeRange (Range (totalItems, std::numeric_limits::max())); if (! isRowSelected (lastRowSelected)) lastRowSelected = getSelectedRow (0); @@ -554,10 +554,10 @@ void ListBox::selectRangeOfRows (int firstRow, int lastRow) firstRow = jlimit (0, jmax (0, numRows), firstRow); lastRow = jlimit (0, jmax (0, numRows), lastRow); - selected.addRange (Range (jmin (firstRow, lastRow), - jmax (firstRow, lastRow) + 1)); + selected.addRange (Range (jmin (firstRow, lastRow), + jmax (firstRow, lastRow) + 1)); - selected.removeRange (Range (lastRow, lastRow + 1)); + selected.removeRange (Range (lastRow, lastRow + 1)); } selectRowInternal (lastRow, false, false, true); @@ -652,7 +652,7 @@ int ListBox::getInsertionIndexForPosition (const int x, const int y) const noexc Component* ListBox::getComponentForRowNumber (const int row) const noexcept { if (RowComponent* const listRowComp = viewport->getComponentForRowIfOnscreen (row)) - return static_cast (listRowComp->customComponent); + return static_cast (listRowComp->customComponent); return nullptr; } @@ -853,6 +853,11 @@ void ListBox::colourChanged() repaint(); } +void ListBox::parentHierarchyChanged() +{ + colourChanged(); +} + void ListBox::setOutlineThickness (const int newThickness) { outlineThickness = newThickness; diff --git a/source/modules/juce_gui_basics/widgets/juce_ListBox.h b/source/modules/juce_gui_basics/widgets/juce_ListBox.h index b575d1520..b9fb24629 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/source/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -540,6 +540,8 @@ public: /** @internal */ void colourChanged() override; /** @internal */ + void parentHierarchyChanged() override; + /** @internal */ void startDragAndDrop (const MouseEvent&, const var& dragDescription, bool allowDraggingToOtherWindows); private: diff --git a/source/modules/juce_gui_basics/widgets/juce_Slider.cpp b/source/modules/juce_gui_basics/widgets/juce_Slider.cpp index d72509f1d..db981e329 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/source/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -320,12 +320,12 @@ public: { if (notification != dontSendNotification) { + owner.valueChanged(); + if (notification == sendNotificationSync) handleAsyncUpdate(); else triggerAsyncUpdate(); - - owner.valueChanged(); } } @@ -566,6 +566,7 @@ public: valueBox->setWantsKeyboardFocus (false); valueBox->setText (previousTextBoxContent, dontSendNotification); + valueBox->setTooltip (owner.getTooltip()); if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) valueBox->setEditable (editableText && owner.isEnabled()); @@ -577,10 +578,6 @@ public: valueBox->addMouseListener (&owner, false); valueBox->setMouseCursor (MouseCursor::ParentCursor); } - else - { - valueBox->setTooltip (owner.getTooltip()); - } } else { diff --git a/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index d9741fb94..1ce0ae648 100644 --- a/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -404,7 +404,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (int i = textBlocks.size(); --i >= 0;) { - const AlertTextComp* const ac = static_cast (textBlocks.getUnchecked(i)); + const AlertTextComp* const ac = static_cast (textBlocks.getUnchecked(i)); w = jmax (w, ac->getPreferredWidth()); } @@ -412,7 +412,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (int i = textBlocks.size(); --i >= 0;) { - AlertTextComp* const ac = static_cast (textBlocks.getUnchecked(i)); + AlertTextComp* const ac = static_cast (textBlocks.getUnchecked(i)); ac->updateLayout ((int) (w * 0.8f)); h += ac->getHeight() + 10; } @@ -470,11 +470,11 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) Component* const c = allComps.getUnchecked(i); h = 22; - const int comboIndex = comboBoxes.indexOf (dynamic_cast (c)); + const int comboIndex = comboBoxes.indexOf (dynamic_cast (c)); if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty()) y += labelHeight; - const int tbIndex = textBoxes.indexOf (dynamic_cast (c)); + const int tbIndex = textBoxes.indexOf (dynamic_cast (c)); if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty()) y += labelHeight; @@ -536,7 +536,8 @@ bool AlertWindow::keyPressed (const KeyPress& key) exitModalState (0); return true; } - else if (key.isKeyCode (KeyPress::returnKey) && buttons.size() == 1) + + if (key.isKeyCode (KeyPress::returnKey) && buttons.size() == 1) { buttons.getUnchecked(0)->triggerClick(); return true; @@ -592,8 +593,8 @@ private: LookAndFeel& lf = associatedComponent != nullptr ? associatedComponent->getLookAndFeel() : LookAndFeel::getDefaultLookAndFeel(); - ScopedPointer alertBox (lf.createAlertWindow (title, message, button1, button2, button3, - iconType, numButtons, associatedComponent)); + ScopedPointer alertBox (lf.createAlertWindow (title, message, button1, button2, button3, + iconType, numButtons, associatedComponent)); jassert (alertBox != nullptr); // you have to return one of these! @@ -614,7 +615,7 @@ private: static void* showCallback (void* userData) { - static_cast (userData)->show(); + static_cast (userData)->show(); return nullptr; } }; diff --git a/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index b62245231..00aa69cb7 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -35,7 +35,7 @@ public: const CodeDocument::Position& selStart, const CodeDocument::Position& selEnd) { - Array newTokens; + Array newTokens; newTokens.ensureStorageAllocated (8); if (tokeniser == nullptr) @@ -129,13 +129,13 @@ private: int tokenType; }; - Array tokens; + Array tokens; int highlightColumnStart, highlightColumnEnd; static void createTokens (int startPosition, const String& lineText, CodeDocument::Iterator& source, CodeTokeniser& tokeniser, - Array & newTokens) + Array& newTokens) { CodeDocument::Iterator lastIterator (source); const int lineLength = lineText.length(); @@ -168,7 +168,7 @@ private: source = lastIterator; } - static void replaceTabsWithSpaces (Array & tokens, const int spacesPerTab) + static void replaceTabsWithSpaces (Array& tokens, const int spacesPerTab) { int x = 0; for (int i = 0; i < tokens.size(); ++i) @@ -412,7 +412,7 @@ bool CodeEditorComponent::isTextInputActive() const return true; } -void CodeEditorComponent::setTemporaryUnderlining (const Array >&) +void CodeEditorComponent::setTemporaryUnderlining (const Array >&) { jassertfalse; // TODO Windows IME not yet supported for this comp.. } @@ -1235,7 +1235,7 @@ ApplicationCommandTarget* CodeEditorComponent::getNextCommandTarget() return findFirstTargetParentComponent(); } -void CodeEditorComponent::getAllCommands (Array & commands) +void CodeEditorComponent::getAllCommands (Array& commands) { const CommandID ids[] = { StandardApplicationCommandIDs::cut, StandardApplicationCommandIDs::copy, diff --git a/source/modules/juce_gui_extra/juce_gui_extra.cpp b/source/modules/juce_gui_extra/juce_gui_extra.cpp index a9fab236f..4b80cc21d 100644 --- a/source/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/source/modules/juce_gui_extra/juce_gui_extra.cpp @@ -40,17 +40,12 @@ //============================================================================== #if JUCE_MAC - #define Point CarbonDummyPointName - #define Component CarbonDummyCompName #import #import #import #import #import #import - #import // still needed for SetSystemUIMode() - #undef Point - #undef Component #elif JUCE_IOS diff --git a/source/modules/juce_gui_extra/misc/juce_ColourSelector.h b/source/modules/juce_gui_extra/misc/juce_ColourSelector.h index 2e256bd8d..d16700cbf 100644 --- a/source/modules/juce_gui_extra/misc/juce_ColourSelector.h +++ b/source/modules/juce_gui_extra/misc/juce_ColourSelector.h @@ -145,7 +145,7 @@ private: ScopedPointer sliders[4]; ScopedPointer colourSpace; ScopedPointer hueSelector; - OwnedArray swatchComponents; + OwnedArray swatchComponents; const int flags; int edgeGap; Rectangle previewArea; diff --git a/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 6b863280f..a522809e5 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm @@ -70,6 +70,7 @@ private: static void runOpenPanel (id, SEL, WebView*, id resultListener, BOOL allowMultipleFiles) { + #if JUCE_MODAL_LOOPS_PERMITTED FileChooser chooser (TRANS("Select the file you want to upload..."), File::getSpecialLocation (File::userHomeDirectory), "*"); @@ -81,6 +82,10 @@ private: for (int i = 0; i < files.size(); ++i) [resultListener chooseFilename: juceStringToNS (files.getReference(i).getFullPathName())]; } + #else + (void) resultListener; (void) allowMultipleFiles; + jassertfalse; // Can't use this without modal loops being enabled! + #endif } };