diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index 54bfe9846e..3b89431975 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -1,303 +1,358 @@ -JUCE breaking changes -===================== - -Develop Branch -============= - -Change ------- -The String (bool) constructor and operator<< (String&, bool) have been -explicitly deleted. - -Possible Issues ---------------- -Previous code which relied on an implicit bool to int type conversion to -produce a String will not compile. - -Workaround ----------- -Cast your bool to an integer to generate a string representation of it. - -Rationale ---------- -Letting things implicitly convert to bool to produce a String opens the door to -all kinds of nasty type conversion edge cases. Furthermore, before this change, -MacOS would automatically convert bools to ints but this wouldn't occur on -different platform. Now the behaviour is consistent across all operating -systems supported by JUCE. - - -Change ------- -The writeAsJSON virtual method of the DynamicObject class requires an -additional parameter, maximumDecimalPlaces, to specify the maximum precision of -floating point numbers. - -Possible Issues ---------------- -Classes which inherit from DynamicObject and override this method will need to -update their method signature. - -Workaround ----------- -Your custom DynamicObject class can choose to ignore the additional parameter -if you don't wish to support this behaviour. - -Rationale ---------- -When serialising the results of calculations to JSON the rounding of floating -point numbers can result in numbers with 17 significant figures where only a -few are required. This change to DynamicObject is required to support -truncating those numbers. - - - -Version 5.1.0 -============= - -Change ------- -The option to set the C++ language standard is now located in the project -settings instead of the build configuration settings. - -Possible Issues ---------------- -Projects that had a specific verison of the C++ language standard set for -exporter build configurations will instead use the default (C++11) when -re-saving with the new Projucer. - -Workaround ----------- -Change the "C++ Language Standard" setting in the main project settings to the -required version - the Projucer will add this value to the exported project as -a compiler flag when saving exporters. - -Rationale ---------- -Having a different C++ language standard option for each build configuration -was unnecessary and was not fully implemented for all exporters. Changing it to -a per-project settings means that the preference will propagate to all -exporters and only needs to be set in one place. - - -Change ------- -PopupMenus now scale according to the AffineTransform and scaling factor of -their target components. - -Possible Issues ---------------- -Developers who have manually scaled their PopupMenus to fit the scaling factor -of the parent UI will now have the scaling applied two times in a row. - -Workaround ----------- -1. Do not apply your own manual scaling to make your popups match the UI - scaling - -or - -2. Override the Look&Feel method - PopupMenu::LookAndFeelMethods::shouldPopupMenuScaleWithTargetComponent and - return false. See - https://github.com/WeAreROLI/JUCE/blob/c288c94c2914af20f36c03ca9c5401fcb555e4e9/modules/juce_gui_basics/menus/juce_PopupMenu.h#725 - -Rationale ---------- -Previously, PopupMenus would not scale if the GUI of the target component (or -any of it’s parents) were scaled. The only way to scale PopupMenus was via the -global scaling factor. This had several drawbacks as the global scaling factor -would scale everything. This was especially problematic in plug-in editors. - - -Change ------- -Removed the setSecurityFlags() method from the Windows implementation of -WebInputStream as it disabled HTTPS security features. - -Possible Issues ---------------- -Any code previously relying on connections to insecure webpages succeeding will -no longer work. - -Workaround ----------- -Check network connectivity on Windows and re-write any code that relied on -insecure connections. - -Rationale ---------- -The previous behaviour resulted in network connections on Windows having all -the HTTPS security features disabled, exposing users to network attacks. HTTPS -connections on Windows are now secure and will fail when connecting to an -insecure web address. - - -Change ------- -Pointer arithmetic on a pointer will have the same result regardless if it is -wrapped in JUCE's Atomic class or not. - -Possible Issues ---------------- -Any code using pointer arithmetic on Atomic will now have a different -result leading to undefined behaviour or crashes. - -Workaround ----------- -Re-write your code in a way that it does not depend on your pointer being -wrapped in JUCE's Atomic or not. See rationale. - -Rationale ---------- -Before this change, pointer arithmetic with JUCE's Atomic type would yield -confusing results. For example, the following code would assert before this -change: - -int* a; Atomic b; - -jassert (++a == ++b); - -Pointer a in the above code would be advanced by sizeof(int) whereas the JUCE's -Atomic always advances it's underlying pointer by a single byte. The same is -true for operator+=/operator-= and operator--. The difference in behaviour is -confusing and unintuitive. Furthermore, this aligns JUCE's Atomic type with -std::atomic. - - - -Version 4.3.1 -============= - -Change ------- -JUCE has changed the way native VST3/AudioUnit parameter ids are calculated. - -Possible Issues ---------------- -DAW projects with automation data written by an AudioUnit or VST3 plug-in built -with pre JUCE 4.3.1 versions will load incorrectly when opened by an AudioUnit -or VST3 built with JUCE versions 4.3.1 and later. Plug-ins using -JUCE_FORCE_USE_LEGACY_IDS are not affected. - -Workaround ----------- -Disable JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS in the -juce_audio_plugin_client module config page in the Projucer. For new plug-ins, -be sure to use the default value for this property. - -Rationale --------- -JUCE needs to convert between its own JUCE parameter id format (strings) to the -native parameter id formats of the various plug-in backends. For VST3 and -AudioUnits, JUCE uses a hash function to generate a numeric id. However, some -VST3/AudioUnit hosts (specifically Studio One) have a bug that ignore any -parameters that have a negative parameter id. Therefore, the hash function for -VST3/AudioUnits needed to be changed to only return positive-valued hashes. - - - -Version 4.3.0 -============= - -Change ------- -A revised multi-bus API was released which supersedes the previously flawed -multi-bus API - JUCE versions 4.0.0 - 4.2.4 (inclusive). - -Possible Issues ---------------- -If you have developed a plug-in with JUCE versions 4.0.0 - 4.2.4 (inclusive), -then you will need to update your plug-in to the new multi-bus API. Pre JUCE -4.0.0 plug-ins are not affected apart from other breaking changes listed in -this document. - -Woraround ---------- -None. - -Rationale --------- -A flawed multi-bus API was introduced with JUCE versions 4.0.0 up until version -4.2.4 (inclusive) which was not API compatible with pre JUCE 4 plug-ins. JUCE -4.3.0 releases a revised multi-bus API which restores pre JUCE 4 API -compatibility. However, the new multi-bus API is not compatible with the flawed -multi-bus API (JUCE version 4.0.0 - 4.2.4). - - -Change ------- -JUCE now generates the AAX plug-in bus layout configuration id independent from -the position as it appears in the Projucer’s legacy "Channel layout -configuration" field. - -Possible Issues ---------------- -ProTools projects generated with a < 4.3.0 JUCE versions of your plug-in, may -load the incorrect bus configuration when upgrading your plug-in to >= 4.3.0 -versions of JUCE. - -Workaround ----------- -Implement AudioProcessor’s getAAXPluginIDForMainBusConfig callback to manually -override which AAX plug-in id is associated to a specific bus layout of your -plug-in. This workaround is only necessary if you have released your plug-in -built with a version previous to JUCE 4.3.0. - -Rationale --------- -The new multi-bus API offers more features, flexibility and accuracy in -specifying bus layouts which cannot be expressed by the Projucer’s legacy -"Channel layout configuration" field. The native plug-in format backends use -the new multi-bus callback APIs to negotiate channel layouts with the host - -including the AAX plug-in ids assigned to specific bus layouts. With the -callback API, there is no notion of an order in which the channel -configurations appear - as was the case with the legacy "Channel layout -configuration" field - and therefore cannot be used to generate the AAX plug-in -id. To remain backward compatible to pre JUCE 4.0.0 plug-ins, JUCE does -transparently convert the legacy "Channel layout configuration" field to the -new callback based multi-bus API, but this does not take the order into account -in which the channel configurations appear in the legacy "Channel layout -configuration" field. - - - -Version 4.2.1 -============= - -Change ------- -JUCE now uses the paramID property used in AudioProcessorParameterWithID to -uniquely identify parameters to the host. - -Possible Issues ---------------- -DAW projects with automation data written by an audio plug-in built with pre -JUCE 4.2.1 will load incorrectly when opened by an audio plug-in built with -JUCE 4.2.1 and later. - -Workaround ----------- -Enable JUCE_FORCE_USE_LEGACY_IDS in the juce_audio_plugin_client module config -page in the Projucer. For new plug-ins, be sure to disable this property. - -Rationale --------- -Each parameter of the AudioProcessor has an id associated so that the plug-in’s -host can uniquely identify parameters. The id has a different data-type for -different plug-in types (for example VST uses integers, AAX uses string -identifiers). Before 4.2.1, JUCE generated the parameter id by using the index -of the parameter, i.e. the first parameter had id zero, the second parameter -had id one, etc. This caused problems for certain plug-in types where JUCE -needs to add internal parameters to the plug-in (for example VST3 requires the -bypass control to be a parameter - so JUCE automatically creates this parameter -for you in the VST3 backend). This causes subtle problems if a parameter is -added to an update of an already published plug-in. The new parameter’s id -would be identical to the id of the bypass parameter in old versions of your -plug-in, causing seemingly random plug-in bypass behaviour when user’s upgrade -their plug-in. - -Most plug-in backends differentiate between a parameter’s id an index, so this -distinction was adopted starting with JUCE 4.2.1 by deriving the parameter’s -unique id from the paramID property of AudioProcessorParameterWithID class. - +JUCE breaking changes +===================== + +Version 5.1.2 +============= + +Change +------ +The method used to classify AudioUnit, VST3 and AAX plug-in parameters as +either continuous or discrete has changed, and AudioUnit and AudioUnit v3 +parameters are marked as high precision by default. + +Possible Issues +--------------- +Plug-ins: DAW projects with automation data written by an AudioUnit, AudioUnit +v3 VST3 or AAX plug-in built with JUCE version 5.1.1 or earlier may load +incorrectly when opened by an AudioUnit, AudioUnit v3, VST3 or AAX plug-in +built with JUCE version 5.1.2 and later. + +Hosts: The AudioPluginInstance::getParameterNumSteps method now returns correct +values for AU and VST3 plug-ins. + +Workaround +---------- +Plug-ins: Enable JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE in the +juce_audio_plugin_client module config page in the Projucer. + +Hosts: Use AudioPluginInstance::getDefaultNumParameterSteps as the number of +steps for all parameters. + +Rationale +--------- +The old system for presenting plug-in parameters to a host as either continuous +or discrete is inconsistent between plug-in types and lacks sufficient +flexibility. This change harmonises the behaviour and allows individual +parameters to be marked as continuous or discrete. If AudioUnit and AudioUnit +v3 parameters are not marked as high precision then hosts like Logic Pro only +offer a limited number of parameter values, which again produces different +behaviour for different plug-in types. + + +Change +------ +A new FrameRateType fps23976 has been added to AudioPlayHead, + +Possible Issues +--------------- +Previously JUCE would report the FrameRateType fps24 for both 24 and 23.976 +fps. If your code uses switch statements (or similar) to handle all possible +frame rate types, then this change may cause it to fall through. + +Workaround +---------- +Add fps23976 to your switch statement and handle it appropriately. + +Rationale +--------- +JUCE should be able to handle all popular frame rate codes but was missing +support for 23.976. + + +Change +------ +The String (bool) constructor and operator<< (String&, bool) have been +explicitly deleted. + +Possible Issues +--------------- +Previous code which relied on an implicit bool to int type conversion to +produce a String will not compile. + +Workaround +---------- +Cast your bool to an integer to generate a string representation of it. + +Rationale +--------- +Letting things implicitly convert to bool to produce a String opens the door to +all kinds of nasty type conversion edge cases. Furthermore, before this change, +MacOS would automatically convert bools to ints but this wouldn't occur on +different platform. Now the behaviour is consistent across all operating +systems supported by JUCE. + + +Change +------ +The writeAsJSON virtual method of the DynamicObject class requires an +additional parameter, maximumDecimalPlaces, to specify the maximum precision of +floating point numbers. + +Possible Issues +--------------- +Classes which inherit from DynamicObject and override this method will need to +update their method signature. + +Workaround +---------- +Your custom DynamicObject class can choose to ignore the additional parameter +if you don't wish to support this behaviour. + +Rationale +--------- +When serialising the results of calculations to JSON the rounding of floating +point numbers can result in numbers with 17 significant figures where only a +few are required. This change to DynamicObject is required to support +truncating those numbers. + + + +Version 5.1.0 +============= + +Change +------ +The option to set the C++ language standard is now located in the project +settings instead of the build configuration settings. + +Possible Issues +--------------- +Projects that had a specific verison of the C++ language standard set for +exporter build configurations will instead use the default (C++11) when +re-saving with the new Projucer. + +Workaround +---------- +Change the "C++ Language Standard" setting in the main project settings to the +required version - the Projucer will add this value to the exported project as +a compiler flag when saving exporters. + +Rationale +--------- +Having a different C++ language standard option for each build configuration +was unnecessary and was not fully implemented for all exporters. Changing it to +a per-project settings means that the preference will propagate to all +exporters and only needs to be set in one place. + + +Change +------ +PopupMenus now scale according to the AffineTransform and scaling factor of +their target components. + +Possible Issues +--------------- +Developers who have manually scaled their PopupMenus to fit the scaling factor +of the parent UI will now have the scaling applied two times in a row. + +Workaround +---------- +1. Do not apply your own manual scaling to make your popups match the UI + scaling + +or + +2. Override the Look&Feel method + PopupMenu::LookAndFeelMethods::shouldPopupMenuScaleWithTargetComponent and + return false. See + https://github.com/WeAreROLI/JUCE/blob/c288c94c2914af20f36c03ca9c5401fcb555e4e9/modules/juce_gui_basics/menus/juce_PopupMenu.h#725 + +Rationale +--------- +Previously, PopupMenus would not scale if the GUI of the target component (or +any of it’s parents) were scaled. The only way to scale PopupMenus was via the +global scaling factor. This had several drawbacks as the global scaling factor +would scale everything. This was especially problematic in plug-in editors. + + +Change +------ +Removed the setSecurityFlags() method from the Windows implementation of +WebInputStream as it disabled HTTPS security features. + +Possible Issues +--------------- +Any code previously relying on connections to insecure webpages succeeding will +no longer work. + +Workaround +---------- +Check network connectivity on Windows and re-write any code that relied on +insecure connections. + +Rationale +--------- +The previous behaviour resulted in network connections on Windows having all +the HTTPS security features disabled, exposing users to network attacks. HTTPS +connections on Windows are now secure and will fail when connecting to an +insecure web address. + + +Change +------ +Pointer arithmetic on a pointer will have the same result regardless if it is +wrapped in JUCE's Atomic class or not. + +Possible Issues +--------------- +Any code using pointer arithmetic on Atomic will now have a different +result leading to undefined behaviour or crashes. + +Workaround +---------- +Re-write your code in a way that it does not depend on your pointer being +wrapped in JUCE's Atomic or not. See rationale. + +Rationale +--------- +Before this change, pointer arithmetic with JUCE's Atomic type would yield +confusing results. For example, the following code would assert before this +change: + +int* a; Atomic b; + +jassert (++a == ++b); + +Pointer a in the above code would be advanced by sizeof(int) whereas the JUCE's +Atomic always advances it's underlying pointer by a single byte. The same is +true for operator+=/operator-= and operator--. The difference in behaviour is +confusing and unintuitive. Furthermore, this aligns JUCE's Atomic type with +std::atomic. + + + +Version 4.3.1 +============= + +Change +------ +JUCE has changed the way native VST3/AudioUnit parameter ids are calculated. + +Possible Issues +--------------- +DAW projects with automation data written by an AudioUnit or VST3 plug-in built +with pre JUCE 4.3.1 versions will load incorrectly when opened by an AudioUnit +or VST3 built with JUCE versions 4.3.1 and later. Plug-ins using +JUCE_FORCE_USE_LEGACY_PARAM_IDS are not affected. + +Workaround +---------- +Disable JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS in the +juce_audio_plugin_client module config page in the Projucer. For new plug-ins, +be sure to use the default value for this property. + +Rationale +-------- +JUCE needs to convert between its own JUCE parameter id format (strings) to the +native parameter id formats of the various plug-in backends. For VST3 and +AudioUnits, JUCE uses a hash function to generate a numeric id. However, some +VST3/AudioUnit hosts (specifically Studio One) have a bug that ignore any +parameters that have a negative parameter id. Therefore, the hash function for +VST3/AudioUnits needed to be changed to only return positive-valued hashes. + + + +Version 4.3.0 +============= + +Change +------ +A revised multi-bus API was released which supersedes the previously flawed +multi-bus API - JUCE versions 4.0.0 - 4.2.4 (inclusive). + +Possible Issues +--------------- +If you have developed a plug-in with JUCE versions 4.0.0 - 4.2.4 (inclusive), +then you will need to update your plug-in to the new multi-bus API. Pre JUCE +4.0.0 plug-ins are not affected apart from other breaking changes listed in +this document. + +Woraround +--------- +None. + +Rationale +-------- +A flawed multi-bus API was introduced with JUCE versions 4.0.0 up until version +4.2.4 (inclusive) which was not API compatible with pre JUCE 4 plug-ins. JUCE +4.3.0 releases a revised multi-bus API which restores pre JUCE 4 API +compatibility. However, the new multi-bus API is not compatible with the flawed +multi-bus API (JUCE version 4.0.0 - 4.2.4). + + +Change +------ +JUCE now generates the AAX plug-in bus layout configuration id independent from +the position as it appears in the Projucer’s legacy "Channel layout +configuration" field. + +Possible Issues +--------------- +ProTools projects generated with a < 4.3.0 JUCE versions of your plug-in, may +load the incorrect bus configuration when upgrading your plug-in to >= 4.3.0 +versions of JUCE. + +Workaround +---------- +Implement AudioProcessor’s getAAXPluginIDForMainBusConfig callback to manually +override which AAX plug-in id is associated to a specific bus layout of your +plug-in. This workaround is only necessary if you have released your plug-in +built with a version previous to JUCE 4.3.0. + +Rationale +-------- +The new multi-bus API offers more features, flexibility and accuracy in +specifying bus layouts which cannot be expressed by the Projucer’s legacy +"Channel layout configuration" field. The native plug-in format backends use +the new multi-bus callback APIs to negotiate channel layouts with the host - +including the AAX plug-in ids assigned to specific bus layouts. With the +callback API, there is no notion of an order in which the channel +configurations appear - as was the case with the legacy "Channel layout +configuration" field - and therefore cannot be used to generate the AAX plug-in +id. To remain backward compatible to pre JUCE 4.0.0 plug-ins, JUCE does +transparently convert the legacy "Channel layout configuration" field to the +new callback based multi-bus API, but this does not take the order into account +in which the channel configurations appear in the legacy "Channel layout +configuration" field. + + + +Version 4.2.1 +============= + +Change +------ +JUCE now uses the paramID property used in AudioProcessorParameterWithID to +uniquely identify parameters to the host. + +Possible Issues +--------------- +DAW projects with automation data written by an audio plug-in built with pre +JUCE 4.2.1 will load incorrectly when opened by an audio plug-in built with +JUCE 4.2.1 and later. + +Workaround +---------- +Enable JUCE_FORCE_USE_LEGACY_PARAM_IDS in the juce_audio_plugin_client module config +page in the Projucer. For new plug-ins, be sure to disable this property. + +Rationale +-------- +Each parameter of the AudioProcessor has an id associated so that the plug-in’s +host can uniquely identify parameters. The id has a different data-type for +different plug-in types (for example VST uses integers, AAX uses string +identifiers). Before 4.2.1, JUCE generated the parameter id by using the index +of the parameter, i.e. the first parameter had id zero, the second parameter +had id one, etc. This caused problems for certain plug-in types where JUCE +needs to add internal parameters to the plug-in (for example VST3 requires the +bypass control to be a parameter - so JUCE automatically creates this parameter +for you in the VST3 backend). This causes subtle problems if a parameter is +added to an update of an already published plug-in. The new parameter’s id +would be identical to the id of the bypass parameter in old versions of your +plug-in, causing seemingly random plug-in bypass behaviour when user’s upgrade +their plug-in. + +Most plug-in backends differentiate between a parameter’s id an index, so this +distinction was adopted starting with JUCE 4.2.1 by deriving the parameter’s +unique id from the paramID property of AudioProcessorParameterWithID class. + diff --git a/ChangeList.txt b/ChangeList.txt index 6171704bea..6345d60f49 100644 --- a/ChangeList.txt +++ b/ChangeList.txt @@ -1,56 +1,70 @@ -== Major JUCE features and updates == +== Major JUCE features and updates == This file just lists the more notable headline features. For more detailed info -about minor changes and bugfixes, please see the git log! - -Version 5.1.1 - - Fixed Windows live build engine on Visual Studio 2017 - - Fixed a compiler error in juce_MathFunctions.h in Visual Studio 2013 - - Fixed a potential crash when using the ProcessorDuplicator - - Fixed a compiler-error in Filter::IIR - - Fixed an issue where the WavFileFormatWriter could not create files with discrete channels - - Fixed an issue where a window which is beneath a hidden window would not receive any clicks on Linux - - Altered the format of BREAKING-CHANGES.txt to display better on GitHub - - Projucer: Fixed an issue in exporter tilde expansion - - Fixed compiler errors when building the DSP module with a static version of FFTW - - Fixed an audio glitch when bypassing the convolution engine - - Fixed an issue where a JUCE VST2 would not correctly report that it supports resizing of it’s plugin editor - - Various documentation tweaks and fixes - -Version 5.1.0 - - Release of the JUCE DSP module - - Multichannel audio readers and writers - - Plugin editor Hi-DPI scaling support - - Major improvements to Projucer module search paths - - Added Projucer support for iOS app groups - - Added support for AVFoundation and deprecated the use of Quicktime - - Added a new real-time audio thread priority for Android - - Various Projucer UI fixes - - Various documentation fixes - - Various minor improvements and bug fixes - -Version 5.0.2 - - Improved project save speed in the Projucer - - Added option to save individual exporters in the Projucer - - Added the ability to create custom colour schemes for the Projucer’s code editor - - Minor fixes to JUCE’s SVG parser - - Various bug fixes in the way JUCE handles Hi-DPI monitors - - Improved code browsing in Visual Studio Exports - - Improved the handling of audio device buffer size changes on iOS - - Fixed bug in the Win32 FileChooser dialog when selecting a nonexistent root drive - - Fixed a Projucer crash when saving projects with no targets - - Fixed a bug where Projucer generated Makefiles would not trigger a recompilation when header files had changed - - The standalone plugin target is now compatible with effect plug-ins - - Fixed an issue where it was not possible to use the live build engine on plugin projects - - Improved the way the Projucer’s live-build engine searches for platform headers on Windows - - Fixed an issue where the Projucer would complain about not having internet even if the user had a license - - Fixed a use-after-free in the AUv3 wrapper - - Fixed an issue where the channel layout would not be reported correctly in the AUv3 wrapper - - Fixed a potential memory overrun issue when hosting VST2 plugins with more than eight channels - - Fixed a problem with the Mac main menu bar showing menus in the wrong position - - Various Projucer UI fixes - - Various documentation fixes +about minor changes and bugfixes, please see the git log! + +Version 5.1.2 + - Fixed multiple plugin-resizing bugs + - Added support for AUv3 MIDI and screen size negotiation + - Added support for Xcode 9 and iOS 11 + - Added an In-App Purchases module + - Added backwards compatible constexpr support + - Standalone plug-in improvements + - Better .jucer file change monitoring in the Projucer + - Increased the speed of AU parameter lookup + - Improved the Android thread management when dealing with web requests + - Better denormal support + - Plug-in parameters can be explicitly marked as continuous or discrete + - Multiple documentation updates + +Version 5.1.1 + - Fixed Windows live build engine on Visual Studio 2017 + - Fixed a compiler error in juce_MathFunctions.h in Visual Studio 2013 + - Fixed a potential crash when using the ProcessorDuplicator + - Fixed a compiler-error in Filter::IIR + - Fixed an issue where the WavFileFormatWriter could not create files with discrete channels + - Fixed an issue where a window which is beneath a hidden window would not receive any clicks on Linux + - Altered the format of BREAKING-CHANGES.txt to display better on GitHub + - Projucer: Fixed an issue in exporter tilde expansion + - Fixed compiler errors when building the DSP module with a static version of FFTW + - Fixed an audio glitch when bypassing the convolution engine + - Fixed an issue where a JUCE VST2 would not correctly report that it supports resizing of it’s plugin editor + - Various documentation tweaks and fixes + +Version 5.1.0 + - Release of the JUCE DSP module + - Multichannel audio readers and writers + - Plugin editor Hi-DPI scaling support + - Major improvements to Projucer module search paths + - Added Projucer support for iOS app groups + - Added support for AVFoundation and deprecated the use of Quicktime + - Added a new real-time audio thread priority for Android + - Various Projucer UI fixes + - Various documentation fixes + - Various minor improvements and bug fixes + +Version 5.0.2 + - Improved project save speed in the Projucer + - Added option to save individual exporters in the Projucer + - Added the ability to create custom colour schemes for the Projucer’s code editor + - Minor fixes to JUCE’s SVG parser + - Various bug fixes in the way JUCE handles Hi-DPI monitors + - Improved code browsing in Visual Studio Exports + - Improved the handling of audio device buffer size changes on iOS + - Fixed bug in the Win32 FileChooser dialog when selecting a nonexistent root drive + - Fixed a Projucer crash when saving projects with no targets + - Fixed a bug where Projucer generated Makefiles would not trigger a recompilation when header files had changed + - The standalone plugin target is now compatible with effect plug-ins + - Fixed an issue where it was not possible to use the live build engine on plugin projects + - Improved the way the Projucer’s live-build engine searches for platform headers on Windows + - Fixed an issue where the Projucer would complain about not having internet even if the user had a license + - Fixed a use-after-free in the AUv3 wrapper + - Fixed an issue where the channel layout would not be reported correctly in the AUv3 wrapper + - Fixed a potential memory overrun issue when hosting VST2 plugins with more than eight channels + - Fixed a problem with the Mac main menu bar showing menus in the wrong position + - Various Projucer UI fixes + - Various documentation fixes - Various minor improvements and bug fixes Version 5.0.1 diff --git a/examples/AUv3Synth/AUv3Synth.jucer b/examples/AUv3Synth/AUv3Synth.jucer index 0c7c06a559..7b17373909 100644 --- a/examples/AUv3Synth/AUv3Synth.jucer +++ b/examples/AUv3Synth/AUv3Synth.jucer @@ -8,7 +8,7 @@ pluginCode="AUv3" pluginChannelConfigs="" pluginIsSynth="1" pluginWantsMidiIn="1" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="AUv3SynthAU" pluginRTASCategory="" aaxIdentifier="com.roli.development.AUv3Synth" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" buildStandalone="1" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/AUv3Synth/JuceLibraryCode/AppConfig.h b/examples/AUv3Synth/JuceLibraryCode/AppConfig.h index 078bbfa8d1..d0b979b58a 100644 --- a/examples/AUv3Synth/JuceLibraryCode/AppConfig.h +++ b/examples/AUv3Synth/JuceLibraryCode/AppConfig.h @@ -101,6 +101,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp b/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp index 348bf98d8c..72a9ba6ac2 100644 --- a/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp +++ b/examples/AUv3Synth/Source/AUv3SynthProcessor.cpp @@ -96,19 +96,16 @@ public: const String getName() const override { return "AUv3 Synth"; } int getNumPrograms() override { return 4; } int getCurrentProgram() override { return currentProgram; } - void setCurrentProgram (int index) override { currentProgram = index; } + void setCurrentProgram (int index) override { currentProgram = index; } + const String getProgramName (int index) override { switch (index) { - case 0: - return "Piano"; - case 1: - return "Singing"; - case 2: - return "Pinched Balloon"; - case 3: - return "Gazeebo"; + case 0: return "Piano"; + case 1: return "Singing"; + case 2: return "Pinched Balloon"; + case 3: return "Gazeebo"; } return ""; diff --git a/examples/AnimationAppExample/AnimationAppExample.jucer b/examples/AnimationAppExample/AnimationAppExample.jucer index e43013d113..2e7b99820b 100644 --- a/examples/AnimationAppExample/AnimationAppExample.jucer +++ b/examples/AnimationAppExample/AnimationAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/AudioAppExample/AudioAppExample.jucer b/examples/AudioAppExample/AudioAppExample.jucer index b4d3b3527e..2bf41dc1cc 100644 --- a/examples/AudioAppExample/AudioAppExample.jucer +++ b/examples/AudioAppExample/AudioAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer b/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer index e34cd4f0ec..628bc9205b 100644 --- a/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer +++ b/examples/BLOCKS/BlocksDrawing/BlocksDrawing.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer b/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer index f60f16577d..e6dbb8b747 100644 --- a/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer +++ b/examples/BLOCKS/BlocksMonitor/BlocksMonitor.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer b/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer index c6b5c4543a..6bd522aea2 100644 --- a/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer +++ b/examples/BLOCKS/BlocksSynth/BlocksSynth.jucer @@ -2,7 +2,7 @@ diff --git a/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer b/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer index 7242e4f028..3f2ad15dc2 100644 --- a/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer +++ b/examples/BouncingBallWavetableDemo/BouncingBallWavetableDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/ComponentTutorialExample/ComponentTutorialExample.jucer b/examples/ComponentTutorialExample/ComponentTutorialExample.jucer index 206f63e255..fa6139fa01 100644 --- a/examples/ComponentTutorialExample/ComponentTutorialExample.jucer +++ b/examples/ComponentTutorialExample/ComponentTutorialExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/DSP module plugin demo/DSP module plugin demo.jucer b/examples/DSP module plugin demo/DSP module plugin demo.jucer index 67e37a1318..102740cc95 100644 --- a/examples/DSP module plugin demo/DSP module plugin demo.jucer +++ b/examples/DSP module plugin demo/DSP module plugin demo.jucer @@ -11,7 +11,7 @@ pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="DSPmoduleplugindemoAU" pluginRTASCategory="" aaxIdentifier="com.yourcompany.DSPmoduleplugindemo" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.juce.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.juce.com" companyEmail="info@juce.com" cppLanguageStandard="14"> @@ -125,5 +125,5 @@ - + diff --git a/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h b/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h index 8b2406b7fe..968d52ea3c 100644 --- a/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h +++ b/examples/DSP module plugin demo/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif @@ -187,6 +191,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 0 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/DSP module plugin demo/Source/PluginEditor.cpp b/examples/DSP module plugin demo/Source/PluginEditor.cpp index 982fe6cd93..6573a34e12 100644 --- a/examples/DSP module plugin demo/Source/PluginEditor.cpp +++ b/examples/DSP module plugin demo/Source/PluginEditor.cpp @@ -123,6 +123,10 @@ DspModulePluginDemoAudioProcessorEditor::DspModulePluginDemoAudioProcessorEditor cabinetSimButton.addListener (this); cabinetSimButton.setButtonText (processor.cabinetSimParam->name); + addAndMakeVisible (oversamplingButton); + oversamplingButton.addListener (this); + oversamplingButton.setButtonText (processor.oversamplingParam->name); + //============================================================================== setSize (600, 400); } @@ -172,9 +176,13 @@ void DspModulePluginDemoAudioProcessorEditor::resized() //============================================================================== auto buttonSlice = bounds.removeFromTop (30); - cabinetSimButton.setSize (200, bounds.getHeight()); + cabinetSimButton.setSize (200, buttonSlice.getHeight()); cabinetSimButton.setCentrePosition (buttonSlice.getCentre()); - bounds.removeFromTop (15); + bounds.removeFromTop(5); + + buttonSlice = bounds.removeFromTop (30); + oversamplingButton.setSize(200, buttonSlice.getHeight()); + oversamplingButton.setCentrePosition(buttonSlice.getCentre()); } //============================================================================== void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box) @@ -198,3 +206,15 @@ void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box) processor.cabinetTypeParam->operator= (index); } } + +void DspModulePluginDemoAudioProcessorEditor::buttonClicked (Button* button) +{ + if (button == &cabinetSimButton) + { + processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState()); + } + else if (button == &oversamplingButton) + { + processor.oversamplingParam->operator= (oversamplingButton.getToggleState()); + } +} diff --git a/examples/DSP module plugin demo/Source/PluginEditor.h b/examples/DSP module plugin demo/Source/PluginEditor.h index d2a36b8bbd..ab43e1fbe9 100644 --- a/examples/DSP module plugin demo/Source/PluginEditor.h +++ b/examples/DSP module plugin demo/Source/PluginEditor.h @@ -86,7 +86,7 @@ public: private: //============================================================================== void comboBoxChanged (ComboBox*) override; - void buttonClicked (Button*) override { processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState()); } + void buttonClicked (Button*) override; //============================================================================== DspModulePluginDemoAudioProcessor& processor; @@ -94,7 +94,7 @@ private: ScopedPointer inputVolumeSlider, outputVolumeSlider, lowPassFilterFreqSlider, highPassFilterFreqSlider; ComboBox stereoBox, slopeBox, waveshaperBox, cabinetTypeBox; - ToggleButton cabinetSimButton; + ToggleButton cabinetSimButton, oversamplingButton; Label inputVolumeLabel, outputVolumeLabel, lowPassFilterFreqLabel, highPassFilterFreqLabel, stereoLabel, slopeLabel, waveshaperLabel, diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.cpp b/examples/DSP module plugin demo/Source/PluginProcessor.cpp index 17ea3d6788..389776a3c8 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.cpp +++ b/examples/DSP module plugin demo/Source/PluginProcessor.cpp @@ -38,6 +38,9 @@ DspModulePluginDemoAudioProcessor::DspModulePluginDemoAudioProcessor() waveShapers { {std::tanh}, {dsp::FastMathApproximations::tanh} }, clipping { clip } { + // Oversampling 2 times with IIR filtering + oversampling = new dsp::Oversampling (2, 1, dsp::Oversampling::filterHalfBandPolyphaseIIR, false); + addParameter (inputVolumeParam = new AudioParameterFloat ("INPUT", "Input Volume", { 0.f, 60.f, 0.f, 1.0f }, 0.f, "dB")); addParameter (highPassFilterFreqParam = new AudioParameterFloat ("HPFREQ", "Pre Highpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20.f, "Hz")); addParameter (lowPassFilterFreqParam = new AudioParameterFloat ("LPFREQ", "Post Lowpass Freq.", { 20.f, 20000.f, 0.f, 0.5f }, 20000.f, "Hz")); @@ -50,12 +53,11 @@ DspModulePluginDemoAudioProcessor::DspModulePluginDemoAudioProcessor() "Cassette recorder cabinet" }, 0)); addParameter (cabinetSimParam = new AudioParameterBool ("CABSIM", "Cabinet Sim", false)); + addParameter (oversamplingParam = new AudioParameterBool ("OVERS", "Oversampling", false)); addParameter (outputVolumeParam = new AudioParameterFloat ("OUTPUT", "Output Volume", { -40.f, 40.f, 0.f, 1.0f }, 0.f, "dB")); cabinetType.set (0); - - } DspModulePluginDemoAudioProcessor::~DspModulePluginDemoAudioProcessor() @@ -82,8 +84,6 @@ void DspModulePluginDemoAudioProcessor::prepareToPlay (double sampleRate, int sa auto channels = static_cast (jmin (getMainBusNumInputChannels(), getMainBusNumOutputChannels())); dsp::ProcessSpec spec { sampleRate, static_cast (samplesPerBlock), channels }; - updateParameters(); - lowPassFilter.prepare (spec); highPassFilter.prepare (spec); @@ -92,6 +92,11 @@ void DspModulePluginDemoAudioProcessor::prepareToPlay (double sampleRate, int sa convolution.prepare (spec); cabinetType.set (-1); + + oversampling->initProcessing (static_cast (samplesPerBlock)); + + updateParameters(); + reset(); } void DspModulePluginDemoAudioProcessor::reset() @@ -99,6 +104,7 @@ void DspModulePluginDemoAudioProcessor::reset() lowPassFilter.reset(); highPassFilter.reset(); convolution.reset(); + oversampling->reset(); } void DspModulePluginDemoAudioProcessor::releaseResources() @@ -108,6 +114,8 @@ void DspModulePluginDemoAudioProcessor::releaseResources() void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing context) noexcept { + ScopedNoDenormals noDenormals; + // Input volume applied with a LinearSmoothedValue inputVolume.process (context); @@ -115,20 +123,34 @@ void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing oversampledBlock; + + setLatencySamples (audioCurrentlyOversampled ? roundFloatToInt (oversampling->getLatencyInSamples()) : 0); + + if (audioCurrentlyOversampled) + oversampledBlock = oversampling->processSamplesUp (context.getInputBlock()); + + dsp::ProcessContextReplacing waveshaperContext = audioCurrentlyOversampled ? dsp::ProcessContextReplacing (oversampledBlock) : context; + // Waveshaper processing, for distortion generation, thanks to the input gain // The fast tanh can be used instead of std::tanh to reduce the CPU load auto waveshaperIndex = waveshaperParam->getIndex(); if (isPositiveAndBelow (waveshaperIndex, (int) numWaveShapers) ) { - waveShapers[waveshaperIndex].process (context); + waveShapers[waveshaperIndex].process (waveshaperContext); if (waveshaperIndex == 1) - clipping.process(context); + clipping.process (waveshaperContext); - context.getOutputBlock() *= 0.7f; + waveshaperContext.getOutputBlock() *= 0.7f; } + // Downsampling + if (audioCurrentlyOversampled) + oversampling->processSamplesDown (context.getOutputBlock()); + // Post-lowpass filtering lowPassFilter.process (context); @@ -209,13 +231,20 @@ bool DspModulePluginDemoAudioProcessor::producesMidi() const //============================================================================== void DspModulePluginDemoAudioProcessor::updateParameters() { + auto newOversampling = oversamplingParam->get(); + if (newOversampling != audioCurrentlyOversampled) + { + audioCurrentlyOversampled = newOversampling; + oversampling->reset(); + } + + //============================================================================== auto inputdB = Decibels::decibelsToGain (inputVolumeParam->get()); auto outputdB = Decibels::decibelsToGain (outputVolumeParam->get()); if (inputVolume.getGainLinear() != inputdB) inputVolume.setGainLinear (inputdB); if (outputVolume.getGainLinear() != outputdB) outputVolume.setGainLinear (outputdB); - dsp::IIR::Coefficients::Ptr newHighPassCoeffs, newLowPassCoeffs; auto newSlopeType = slopeParam->getIndex(); if (newSlopeType == 0) @@ -240,12 +269,13 @@ void DspModulePluginDemoAudioProcessor::updateParameters() auto maxSize = static_cast (roundDoubleToInt (8192 * getSampleRate() / 44100)); if (type == 0) - convolution.loadImpulseResponse (BinaryData::Impulse1_wav, BinaryData::Impulse1_wavSize, false, maxSize); + convolution.loadImpulseResponse (BinaryData::Impulse1_wav, BinaryData::Impulse1_wavSize, false, true, maxSize); else - convolution.loadImpulseResponse (BinaryData::Impulse2_wav, BinaryData::Impulse2_wavSize, false, maxSize); + convolution.loadImpulseResponse (BinaryData::Impulse2_wav, BinaryData::Impulse2_wavSize, false, true, maxSize); } cabinetIsBypassed = ! cabinetSimParam->get(); + } //============================================================================== diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.h b/examples/DSP module plugin demo/Source/PluginProcessor.h index 2a8fd42ef0..4574cb33a7 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.h +++ b/examples/DSP module plugin demo/Source/PluginProcessor.h @@ -88,6 +88,7 @@ public: AudioParameterChoice* cabinetTypeParam; AudioParameterBool* cabinetSimParam; + AudioParameterBool* oversamplingParam; private: //============================================================================== @@ -103,6 +104,9 @@ private: dsp::Gain inputVolume, outputVolume; + ScopedPointer> oversampling; + bool audioCurrentlyOversampled = false; + Atomic cabinetType; bool cabinetIsBypassed = false; diff --git a/examples/DSPDemo/DSPDemo.jucer b/examples/DSPDemo/DSPDemo.jucer index f7122fb571..2535f5fa48 100644 --- a/examples/DSPDemo/DSPDemo.jucer +++ b/examples/DSPDemo/DSPDemo.jucer @@ -3,7 +3,7 @@ diff --git a/examples/DSPDemo/JuceLibraryCode/AppConfig.h b/examples/DSPDemo/JuceLibraryCode/AppConfig.h index 13167bfc33..2dc9673d88 100644 --- a/examples/DSPDemo/JuceLibraryCode/AppConfig.h +++ b/examples/DSPDemo/JuceLibraryCode/AppConfig.h @@ -174,6 +174,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp b/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp index a8727331fc..83708c82d6 100644 --- a/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp +++ b/examples/DSPDemo/JuceLibraryCode/BinaryData.cpp @@ -1565,11 +1565,11 @@ static const unsigned char temp_binary_data_3[] = " if (cabinetTypeParameter->getCurrentSelectedID() == 2)\r\n" " convolution.loadImpulseResponse (BinaryData::guitar_amp_wav,\r\n" " BinaryData::guitar_amp_wavSize,\r\n" -" false, maxSize);\r\n" +" false, true, maxSize);\r\n" " else\r\n" " convolution.loadImpulseResponse (BinaryData::cassette_recorder_wav,\r\n" " BinaryData::cassette_recorder_wavSize,\r\n" -" false, maxSize);\r\n" +" false, true, maxSize);\r\n" " }\r\n" " }\r\n" " }\r\n" @@ -2325,7 +2325,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0x409ff6ec: numBytes = 37902; return cassette_recorder_wav; case 0x69523d16: numBytes = 628; return EditorColourScheme_xml; case 0x700ccf3c: numBytes = 90246; return guitar_amp_wav; - case 0x5922ccdf: numBytes = 2999; return ConvolutionDemo_cpp; + case 0x5922ccdf: numBytes = 3011; return ConvolutionDemo_cpp; case 0x14aa0aae: numBytes = 2674; return FIRFilterDemo_cpp; case 0xab621a06: numBytes = 1809; return GainDemo_cpp; case 0x06a7a4b1: numBytes = 2819; return IIRFilterDemo_cpp; diff --git a/examples/DSPDemo/JuceLibraryCode/BinaryData.h b/examples/DSPDemo/JuceLibraryCode/BinaryData.h index 51444ccfed..fe5ad62cfd 100644 --- a/examples/DSPDemo/JuceLibraryCode/BinaryData.h +++ b/examples/DSPDemo/JuceLibraryCode/BinaryData.h @@ -18,7 +18,7 @@ namespace BinaryData const int guitar_amp_wavSize = 90246; extern const char* ConvolutionDemo_cpp; - const int ConvolutionDemo_cppSize = 2999; + const int ConvolutionDemo_cppSize = 3011; extern const char* FIRFilterDemo_cpp; const int FIRFilterDemo_cppSize = 2674; diff --git a/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp b/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp index 148b55194f..36aa11b4ad 100644 --- a/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp +++ b/examples/DSPDemo/Source/Demos/ConvolutionDemo.cpp @@ -65,11 +65,11 @@ struct ConvolutionDemo if (cabinetTypeParameter->getCurrentSelectedID() == 2) convolution.loadImpulseResponse (BinaryData::guitar_amp_wav, BinaryData::guitar_amp_wavSize, - false, maxSize); + false, true, maxSize); else convolution.loadImpulseResponse (BinaryData::cassette_recorder_wav, BinaryData::cassette_recorder_wavSize, - false, maxSize); + false, true, maxSize); } } } diff --git a/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java b/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java index 4b248803c6..703e23abce 100644 --- a/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java +++ b/examples/Demo/Builds/Android/app/src/main/java/com/yourcompany/jucedemo/JuceDemo.java @@ -519,11 +519,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class JuceDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class JuceDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemo.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class JuceDemo extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class JuceDemo extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class JuceDemo extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class JuceDemo extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class JuceDemo extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class JuceDemo extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class JuceDemo extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class JuceDemo extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/Demo/JuceDemo.jucer b/examples/Demo/JuceDemo.jucer index 7cfc8cddde..6f91ac3866 100644 --- a/examples/Demo/JuceDemo.jucer +++ b/examples/Demo/JuceDemo.jucer @@ -1,7 +1,7 @@ diff --git a/examples/Demo/Source/Demos/GridDemo.cpp b/examples/Demo/Source/Demos/GridDemo.cpp index 56fe5a19fa..41c8e4d8d4 100644 --- a/examples/Demo/Source/Demos/GridDemo.cpp +++ b/examples/Demo/Source/Demos/GridDemo.cpp @@ -26,6 +26,8 @@ #include "../JuceDemoHeader.h" +// these classes are C++11-only +#if JUCE_HAS_CONSTEXPR struct GridDemo : public Component { @@ -116,3 +118,5 @@ struct GridDemo : public Component // This static object will register this demo type in a global list of demos.. static JuceDemoType demo ("10 Components: GridDemo"); + +#endif // JUCE_HAS_CONSTEXPR diff --git a/examples/Demo/Source/Demos/VideoDemo.cpp b/examples/Demo/Source/Demos/VideoDemo.cpp index 9ce757df03..66b7a9da33 100644 --- a/examples/Demo/Source/Demos/VideoDemo.cpp +++ b/examples/Demo/Source/Demos/VideoDemo.cpp @@ -26,7 +26,7 @@ #include "../JuceDemoHeader.h" -#if JUCE_MAC || JUCE_DIRECTSHOW +#if JUCE_MAC || (JUCE_WINDOWS && ! JUCE_MINGW) //============================================================================== // so that we can easily have two video windows each with a file browser, wrap this up as a class.. diff --git a/examples/Demo/Source/Demos/WidgetsDemo.cpp b/examples/Demo/Source/Demos/WidgetsDemo.cpp index 7e9b64088f..cb31f9f79a 100644 --- a/examples/Demo/Source/Demos/WidgetsDemo.cpp +++ b/examples/Demo/Source/Demos/WidgetsDemo.cpp @@ -105,10 +105,13 @@ struct SlidersPage : public Component : hintLabel ("hint", "Try right-clicking on a slider for an options menu. \n\n" "Also, holding down CTRL while dragging will turn on a slider's velocity-sensitive mode") { + Rectangle layoutArea { 20, 20, 580, 430 }; + auto sliderArea = layoutArea.removeFromTop (320); + Slider* s = createSlider (false); s->setSliderStyle (Slider::LinearVertical); s->setTextBoxStyle (Slider::TextBoxBelow, false, 100, 20); - s->setBounds (10, 25, 70, 200); + s->setBounds (sliderArea.removeFromLeft (70)); s->setDoubleClickReturnValue (true, 50.0); // double-clicking this slider will set it to 50.0 s->setTextValueSuffix (" units"); @@ -117,68 +120,85 @@ struct SlidersPage : public Component s->setVelocityBasedMode (true); s->setSkewFactor (0.5); s->setTextBoxStyle (Slider::TextBoxAbove, true, 100, 20); - s->setBounds (85, 25, 70, 200); + s->setBounds (sliderArea.removeFromLeft (70)); s->setTextValueSuffix (" rels"); + sliderArea.removeFromLeft (20); + auto horizonalSliderArea = sliderArea.removeFromLeft (180); + s = createSlider (true); s->setSliderStyle (Slider::LinearHorizontal); s->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20); - s->setBounds (180, 35, 150, 20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s = createSlider (false); s->setSliderStyle (Slider::LinearHorizontal); s->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - s->setBounds (180, 65, 150, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s->setPopupDisplayEnabled (true, false, this); s->setTextValueSuffix (" nuns required to change a lightbulb"); + s = createSlider (false); + s->setSliderStyle (Slider::LinearHorizontal); + s->setTextBoxStyle (Slider::TextEntryBoxPosition::TextBoxAbove, false, 70, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (50)); + s->setPopupDisplayEnabled (true, false, this); + s = createSlider (false); s->setSliderStyle (Slider::IncDecButtons); s->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20); - s->setBounds (180, 105, 100, 20); + horizonalSliderArea.removeFromTop (20); + s->setBounds (horizonalSliderArea.removeFromTop (20)); s->setIncDecButtonsMode (Slider::incDecButtonsDraggable_Vertical); s = createSlider (false); s->setSliderStyle (Slider::Rotary); s->setRotaryParameters (float_Pi * 1.2f, float_Pi * 2.8f, false); s->setTextBoxStyle (Slider::TextBoxRight, false, 70, 20); - s->setBounds (190, 145, 120, 40); + horizonalSliderArea.removeFromTop (15); + s->setBounds (horizonalSliderArea.removeFromTop (70)); s->setTextValueSuffix (" mm"); s = createSlider (false); s->setSliderStyle (Slider::LinearBar); - s->setBounds (180, 195, 100, 30); + horizonalSliderArea.removeFromTop (10); + s->setBounds (horizonalSliderArea.removeFromTop (30)); s->setTextValueSuffix (" gallons"); + sliderArea.removeFromLeft (20); + auto twoValueSliderArea = sliderArea.removeFromLeft (180); + s = createSlider (false); s->setSliderStyle (Slider::TwoValueHorizontal); - s->setBounds (360, 20, 160, 40); + s->setBounds (twoValueSliderArea.removeFromTop (40)); s = createSlider (false); - s->setSliderStyle (Slider::TwoValueVertical); - s->setBounds (360, 110, 40, 160); + s->setSliderStyle (Slider::ThreeValueHorizontal); + s->setPopupDisplayEnabled (true, false, this); + twoValueSliderArea.removeFromTop (10); + s->setBounds (twoValueSliderArea.removeFromTop (40)); s = createSlider (false); - s->setSliderStyle (Slider::ThreeValueHorizontal); - s->setBounds (360, 70, 160, 40); + s->setSliderStyle (Slider::TwoValueVertical); + twoValueSliderArea.removeFromLeft (30); + s->setBounds (twoValueSliderArea.removeFromLeft (40)); s = createSlider (false); s->setSliderStyle (Slider::ThreeValueVertical); - s->setBounds (440, 110, 40, 160); + s->setPopupDisplayEnabled (true, false, this); + twoValueSliderArea.removeFromLeft (30); + s->setBounds (twoValueSliderArea.removeFromLeft (40)); s = createSlider (false); s->setSliderStyle (Slider::LinearBarVertical); s->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - s->setBounds (540, 35, 20, 230); + sliderArea.removeFromLeft (20); + s->setBounds (sliderArea.removeFromLeft (20)); s->setPopupDisplayEnabled (true, true, this); s->setTextValueSuffix (" mickles in a muckle"); - for (int i = 7; i <= 10; ++i) - { - sliders.getUnchecked(i)->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); - sliders.getUnchecked(i)->setPopupDisplayEnabled (true, false, this); - } - /* Here, we'll create a Value object, and tell a bunch of our sliders to use it as their value source. By telling them all to share the same Value, they'll stay in sync with each other. @@ -188,7 +208,7 @@ struct SlidersPage : public Component */ Value sharedValue; sharedValue = Random::getSystemRandom().nextDouble() * 100; - for (int i = 0; i < 7; ++i) + for (int i = 0; i < 8; ++i) sliders.getUnchecked(i)->getValueObject().referTo (sharedValue); // ..and now we'll do the same for all our min/max slider values.. @@ -196,13 +216,15 @@ struct SlidersPage : public Component sharedValueMin = Random::getSystemRandom().nextDouble() * 40.0; sharedValueMax = Random::getSystemRandom().nextDouble() * 40.0 + 60.0; - for (int i = 7; i <= 10; ++i) + for (int i = 8; i <= 11; ++i) { - sliders.getUnchecked(i)->getMaxValueObject().referTo (sharedValueMax); - sliders.getUnchecked(i)->getMinValueObject().referTo (sharedValueMin); + auto* selectedSlider = sliders.getUnchecked(i); + selectedSlider->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); + selectedSlider->getMaxValueObject().referTo (sharedValueMax); + selectedSlider->getMinValueObject().referTo (sharedValueMin); } - hintLabel.setBounds (20, 245, 350, 150); + hintLabel.setBounds (layoutArea); addAndMakeVisible (hintLabel); } diff --git a/examples/HelloWorld/HelloWorld.jucer b/examples/HelloWorld/HelloWorld.jucer index c62cfb62a5..9c27df9b70 100644 --- a/examples/HelloWorld/HelloWorld.jucer +++ b/examples/HelloWorld/HelloWorld.jucer @@ -1,7 +1,7 @@ diff --git a/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt b/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt index 089a14d0b7..eedb74d85b 100644 --- a/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt +++ b/examples/InAppPurchase/Builds/Android/app/CMakeLists.txt @@ -8,7 +8,7 @@ SET(BINARY_NAME "juce_jni") add_library("cpufeatures" STATIC "${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c") set_source_files_properties("${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c" PROPERTIES COMPILE_FLAGS "-Wno-sign-conversion -Wno-gnu-statement-expression") -add_definitions("-DJUCE_ANDROID=1" "-DJUCE_ANDROID_API_VERSION=10" "-DJUCE_ANDROID_ACTIVITY_CLASSNAME=com_roli_juceinapppurchasesample_InAppPurchase" "-DJUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/roli/juceinapppurchasesample/InAppPurchase\"" "-DJUCER_ANDROIDSTUDIO_7F0E4A25=1" "-DJUCE_APP_VERSION=0.0.2" "-DJUCE_APP_VERSION_HEX=0x2") +add_definitions("-DJUCE_ANDROID=1" "-DJUCE_ANDROID_API_VERSION=10" "-DJUCE_ANDROID_ACTIVITY_CLASSNAME=com_roli_juceinapppurchasesample_InAppPurchase" "-DJUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/roli/juceinapppurchasesample/InAppPurchase\"" "-DJUCE_IN_APP_PURCHASES=1" "-DJUCER_ANDROIDSTUDIO_7F0E4A25=1" "-DJUCE_APP_VERSION=0.0.2" "-DJUCE_APP_VERSION_HEX=0x2") include_directories( AFTER "../../../JuceLibraryCode" diff --git a/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java b/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java index 3843d8fa1c..05a6ab9409 100644 --- a/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java +++ b/examples/InAppPurchase/Builds/Android/app/src/main/java/com/roli/juceinapppurchasesample/InAppPurchase.java @@ -519,11 +519,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class InAppPurchase extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + InAppPurchase.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class InAppPurchase extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); InAppPurchase.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class InAppPurchase extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class InAppPurchase extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class InAppPurchase extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class InAppPurchase extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class InAppPurchase extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class InAppPurchase extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class InAppPurchase extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class InAppPurchase extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj b/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj index 92aa55501a..e74d1b597e 100644 --- a/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj +++ b/examples/InAppPurchase/Builds/iOS/InAppPurchase.xcodeproj/project.pbxproj @@ -223,6 +223,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "_DEBUG=1", "DEBUG=1", + "JUCE_IN_APP_PURCHASES=1", "JUCER_XCODE_IPHONE_5BC26AE3=1", "JUCE_APP_VERSION=0.0.2", "JUCE_APP_VERSION_HEX=0x2", @@ -254,6 +255,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "_NDEBUG=1", "NDEBUG=1", + "JUCE_IN_APP_PURCHASES=1", "JUCER_XCODE_IPHONE_5BC26AE3=1", "JUCE_APP_VERSION=0.0.2", "JUCE_APP_VERSION_HEX=0x2", diff --git a/examples/InAppPurchase/InAppPurchase.jucer b/examples/InAppPurchase/InAppPurchase.jucer index 98e28db6ac..4f2cd498a0 100644 --- a/examples/InAppPurchase/InAppPurchase.jucer +++ b/examples/InAppPurchase/InAppPurchase.jucer @@ -3,7 +3,7 @@ diff --git a/examples/MPETest/MPETest.jucer b/examples/MPETest/MPETest.jucer index a7574f7f2a..26099e8141 100644 --- a/examples/MPETest/MPETest.jucer +++ b/examples/MPETest/MPETest.jucer @@ -2,7 +2,7 @@ diff --git a/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java b/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java index 9afbb4fa1d..5eeb94785f 100644 --- a/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java +++ b/examples/MidiTest/Builds/Android/app/src/main/java/com/yourcompany/miditest/MidiTest.java @@ -1448,11 +1448,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class MidiTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + MidiTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class MidiTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); MidiTest.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class MidiTest extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class MidiTest extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class MidiTest extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class MidiTest extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class MidiTest extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class MidiTest extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class MidiTest extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class MidiTest extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/MidiTest/MidiTest.jucer b/examples/MidiTest/MidiTest.jucer index 5e08b301f9..84d21167a9 100644 --- a/examples/MidiTest/MidiTest.jucer +++ b/examples/MidiTest/MidiTest.jucer @@ -2,7 +2,7 @@ diff --git a/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java b/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java index c8085c28d3..bac81b0d10 100644 --- a/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java +++ b/examples/NetworkGraphicsDemo/Builds/Android/app/src/main/java/com/juce/networkgraphicsdemo/JUCENetworkGraphicsDemo.java @@ -519,11 +519,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class JUCENetworkGraphicsDemo extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class JUCENetworkGraphicsDemo extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JUCENetworkGraphicsDemo.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class JUCENetworkGraphicsDemo extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class JUCENetworkGraphicsDemo extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class JUCENetworkGraphicsDemo extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class JUCENetworkGraphicsDemo extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class JUCENetworkGraphicsDemo extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class JUCENetworkGraphicsDemo extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class JUCENetworkGraphicsDemo extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class JUCENetworkGraphicsDemo extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer b/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer index fd89c51559..7954f7fc5b 100644 --- a/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer +++ b/examples/NetworkGraphicsDemo/NetworkGraphicsDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCMonitor/OSCMonitor.jucer b/examples/OSCMonitor/OSCMonitor.jucer index c3b0d1f571..c21aa3d0fe 100644 --- a/examples/OSCMonitor/OSCMonitor.jucer +++ b/examples/OSCMonitor/OSCMonitor.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCMonitor/Source/OSCLogListBox.h b/examples/OSCMonitor/Source/OSCLogListBox.h index 996a92fb7d..0fa9b3aa58 100644 --- a/examples/OSCMonitor/Source/OSCLogListBox.h +++ b/examples/OSCMonitor/Source/OSCLogListBox.h @@ -128,13 +128,12 @@ public: else if (arg.isBlob()) { typeAsString = "blob"; - const MemoryBlock& blob = arg.getBlob(); - valueAsString = String::fromUTF8( (const char*)blob.getData(), blob.getSize()); + auto& blob = arg.getBlob(); + valueAsString = String::fromUTF8 ((const char*) blob.getData(), (int) blob.getSize()); } else { typeAsString = "(unknown)"; - valueAsString = ""; } oscLogList.add (getIndentationString (level + 1) + "- " + typeAsString.paddedRight(' ', 12) + valueAsString); diff --git a/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java b/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java index a49408d60b..d08af129e5 100644 --- a/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java +++ b/examples/OSCReceiver/Builds/Android/app/src/main/java/com/yourcompany/oscreceiver/OSCReceiver.java @@ -519,11 +519,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class OSCReceiver extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCReceiver.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class OSCReceiver extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCReceiver.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class OSCReceiver extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class OSCReceiver extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class OSCReceiver extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class OSCReceiver extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class OSCReceiver extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class OSCReceiver extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class OSCReceiver extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class OSCReceiver extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/OSCReceiver/OSCReceiver.jucer b/examples/OSCReceiver/OSCReceiver.jucer index 6624a3879e..d27c37dc7c 100644 --- a/examples/OSCReceiver/OSCReceiver.jucer +++ b/examples/OSCReceiver/OSCReceiver.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java b/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java index fa138371bf..b22efadf57 100644 --- a/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java +++ b/examples/OSCSender/Builds/Android/app/src/main/java/com/yourcompany/oscsender/OSCSender.java @@ -519,11 +519,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -538,11 +545,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 1); } }) @@ -550,7 +564,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -564,11 +578,18 @@ public class OSCSender extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + OSCSender.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 1); } }) @@ -576,7 +597,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 2); } }) @@ -584,7 +605,7 @@ public class OSCSender extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); OSCSender.this.alertDismissed (callback, 0); } }); @@ -982,13 +1003,75 @@ public class OSCSender extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1011,19 +1094,12 @@ public class OSCSender extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1031,6 +1107,89 @@ public class OSCSender extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1068,9 +1227,16 @@ public class OSCSender extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1173,13 +1339,20 @@ public class OSCSender extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1201,89 +1374,15 @@ public class OSCSender extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1309,7 +1408,14 @@ public class OSCSender extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1404,7 +1510,7 @@ public class OSCSender extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/OSCSender/OSCSender.jucer b/examples/OSCSender/OSCSender.jucer index 8fdfe0c582..0c5de38ba1 100644 --- a/examples/OSCSender/OSCSender.jucer +++ b/examples/OSCSender/OSCSender.jucer @@ -2,7 +2,7 @@ diff --git a/examples/OpenGLAppExample/OpenGLAppExample.jucer b/examples/OpenGLAppExample/OpenGLAppExample.jucer index ef137b42cd..b8e5d5e68e 100644 --- a/examples/OpenGLAppExample/OpenGLAppExample.jucer +++ b/examples/OpenGLAppExample/OpenGLAppExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/PluckedStringsDemo/PluckedStringsDemo.jucer b/examples/PluckedStringsDemo/PluckedStringsDemo.jucer index d214cac8f6..1661329a13 100644 --- a/examples/PluckedStringsDemo/PluckedStringsDemo.jucer +++ b/examples/PluckedStringsDemo/PluckedStringsDemo.jucer @@ -2,7 +2,7 @@ diff --git a/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer b/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer index 4eeb120eb7..a76785c114 100644 --- a/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer +++ b/examples/PlugInSamples/Arpeggiator/Arpeggiator.jucer @@ -9,7 +9,7 @@ pluginIsMidiEffectPlugin="1" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="ArpeggiatorAU" pluginRTASCategory="" aaxIdentifier="com.roli.Arpeggiator" pluginAAXCategory="AAX_EPlugInCategory_Effect" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.juce.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.juce.com" companyEmail="info@juce.com" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h index 4ba9b277d6..984b506b5e 100644 --- a/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/Arpeggiator/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer b/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer index f38d22c649..9ecefdf286 100644 --- a/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer +++ b/examples/PlugInSamples/GainPlugIn/GainPlugIn.jucer @@ -8,7 +8,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="1" pluginEditorRequiresKeys="0" pluginAUExportPrefix="GainPlugInAU" pluginRTASCategory="" aaxIdentifier="com.roli.GainPlugIn" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h index 9eeb582360..8b6c39d9d7 100644 --- a/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/GainPlugIn/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer b/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer index cde05c83aa..b0f27099ec 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer +++ b/examples/PlugInSamples/InterAppAudioEffect/InterAppAudioEffect.jucer @@ -9,7 +9,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="InterAppAudioEffectAU" pluginRTASCategory="" aaxIdentifier="com.yourcompany.InterAppAudioEffect" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" companyName="ROLI Ltd." buildStandalone="1" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h index 00ca4dc56d..8a2c4147d4 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/InterAppAudioEffect/JuceLibraryCode/AppConfig.h @@ -101,6 +101,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h index f3129e896f..b85169f2a9 100644 --- a/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/MultiOutSynth/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer b/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer index bab2d8948a..8a61647ea6 100644 --- a/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer +++ b/examples/PlugInSamples/MultiOutSynth/MultiOutSynth.jucer @@ -9,7 +9,7 @@ pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="MultiOutSynthAU" pluginRTASCategory="" aaxIdentifier="com.roli.MultiOutSynth" pluginAAXCategory="AAX_ePlugInCategory_SWGenerators" - jucerVersion="5.1.1" companyName="ROLI Ltd." companyWebsite="www.roli.com" + jucerVersion="5.1.2" companyName="ROLI Ltd." companyWebsite="www.roli.com" companyEmail="info@juce.com" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h index 26d20c4805..e3b8d9543f 100644 --- a/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/NoiseGate/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/NoiseGate/NoiseGate.jucer b/examples/PlugInSamples/NoiseGate/NoiseGate.jucer index 753184be60..a763194384 100644 --- a/examples/PlugInSamples/NoiseGate/NoiseGate.jucer +++ b/examples/PlugInSamples/NoiseGate/NoiseGate.jucer @@ -8,7 +8,7 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="NoiseGateAU" pluginRTASCategory="" aaxIdentifier="com.roli.NoiseGate" - pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.1" + pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="5.1.2" pluginIsMidiEffectPlugin="0" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h b/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h index a0827d057e..1338202d52 100644 --- a/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h +++ b/examples/PlugInSamples/Surround/JuceLibraryCode/AppConfig.h @@ -103,6 +103,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/PlugInSamples/Surround/Surround.jucer b/examples/PlugInSamples/Surround/Surround.jucer index 98ec9f8070..7a228fe8c2 100644 --- a/examples/PlugInSamples/Surround/Surround.jucer +++ b/examples/PlugInSamples/Surround/Surround.jucer @@ -9,7 +9,7 @@ pluginIsMidiEffectPlugin="0" pluginSilenceInIsSilenceOut="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="SurroundAU" pluginRTASCategory="" aaxIdentifier="com.roli.Surround" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" - jucerVersion="5.1.1" buildAUv3="0" buildStandalone="0" enableIAA="0" + jucerVersion="5.1.2" buildAUv3="0" buildStandalone="0" enableIAA="0" displaySplashScreen="0" reportAppUsage="0" splashScreenColour="Dark" companyName="ROLI Ltd." cppLanguageStandard="11"> diff --git a/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h b/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h index fbf0224517..15b507e338 100644 --- a/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h +++ b/examples/SimpleFFTExample/JuceLibraryCode/AppConfig.h @@ -174,6 +174,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/examples/SimpleFFTExample/SimpleFFTExample.jucer b/examples/SimpleFFTExample/SimpleFFTExample.jucer index 7e712fb522..e3c909f46f 100644 --- a/examples/SimpleFFTExample/SimpleFFTExample.jucer +++ b/examples/SimpleFFTExample/SimpleFFTExample.jucer @@ -2,7 +2,7 @@ diff --git a/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java b/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java index c76005c03c..59ac9dc0cf 100644 --- a/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java +++ b/examples/audio plugin demo/Builds/Android/app/src/main/java/com/juce/jucedemoplugin/JuceDemoPlugin.java @@ -1448,11 +1448,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class JuceDemoPlugin extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceDemoPlugin.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class JuceDemoPlugin extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceDemoPlugin.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class JuceDemoPlugin extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class JuceDemoPlugin extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class JuceDemoPlugin extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class JuceDemoPlugin extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class JuceDemoPlugin extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class JuceDemoPlugin extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class JuceDemoPlugin extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class JuceDemoPlugin extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist b/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist index 10cbd2bb3a..e953c8ba86 100644 --- a/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist +++ b/examples/audio plugin demo/Builds/iOS/Info-AUv3_AppExtension.plist @@ -5,6 +5,8 @@ LSRequiresIPhoneOS + NSMicrophoneUsageDescription + This app requires microphone input. CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier diff --git a/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist b/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist index c5c93b2e42..114168eac4 100644 --- a/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist +++ b/examples/audio plugin demo/Builds/iOS/Info-Standalone_Plugin.plist @@ -5,6 +5,8 @@ LSRequiresIPhoneOS + NSMicrophoneUsageDescription + This app requires microphone input. UIViewControllerBasedStatusBarAppearance CFBundleExecutable diff --git a/examples/audio plugin demo/JuceDemoPlugin.jucer b/examples/audio plugin demo/JuceDemoPlugin.jucer index b51c35ae3d..d3c69da7cb 100644 --- a/examples/audio plugin demo/JuceDemoPlugin.jucer +++ b/examples/audio plugin demo/JuceDemoPlugin.jucer @@ -8,7 +8,7 @@ pluginProducesMidiOut="1" pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="1" pluginAUExportPrefix="JuceDemoProjectAU" pluginAUViewClass="JuceDemoProjectAU_V1" pluginRTASCategory="" - bundleIdentifier="com.juce.JuceDemoPlugin" jucerVersion="5.1.1" + bundleIdentifier="com.juce.JuceDemoPlugin" jucerVersion="5.1.2" companyName="ROLI Ltd." aaxIdentifier="com.yourcompany.JuceDemoPlugin" buildAAX="0" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" includeBinaryInAppConfig="1" buildVST3="0" pluginManufacturerEmail="support@yourcompany.com" @@ -107,7 +107,7 @@ + iosBackgroundBle="1" microphonePermissionNeeded="1"> diff --git a/examples/audio plugin demo/JuceLibraryCode/AppConfig.h b/examples/audio plugin demo/JuceLibraryCode/AppConfig.h index b15271f4ea..a97a7a6e3c 100644 --- a/examples/audio plugin demo/JuceLibraryCode/AppConfig.h +++ b/examples/audio plugin demo/JuceLibraryCode/AppConfig.h @@ -101,6 +101,10 @@ //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 1 #endif +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 1 +#endif + #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif diff --git a/examples/audio plugin demo/Source/PluginEditor.cpp b/examples/audio plugin demo/Source/PluginEditor.cpp index b784080a2b..75634d9630 100644 --- a/examples/audio plugin demo/Source/PluginEditor.cpp +++ b/examples/audio plugin demo/Source/PluginEditor.cpp @@ -42,13 +42,7 @@ public: updateSliderPos(); } - void valueChanged() override - { - if (isMouseButtonDown()) - param.setValueNotifyingHost ((float) Slider::getValue()); - else - param.setValue ((float) Slider::getValue()); - } + void valueChanged() override { param.setValueNotifyingHost ((float) Slider::getValue()); } void timerCallback() override { updateSliderPos(); } @@ -63,7 +57,7 @@ public: const float newValue = param.getValue(); if (newValue != (float) Slider::getValue() && ! isMouseButtonDown()) - Slider::setValue (newValue); + Slider::setValue (newValue, NotificationType::dontSendNotification); } AudioProcessorParameter& param; diff --git a/examples/audio plugin demo/Source/PluginProcessor.cpp b/examples/audio plugin demo/Source/PluginProcessor.cpp index f8c06d9de8..6e791763ea 100644 --- a/examples/audio plugin demo/Source/PluginProcessor.cpp +++ b/examples/audio plugin demo/Source/PluginProcessor.cpp @@ -26,137 +26,11 @@ #include "PluginProcessor.h" #include "PluginEditor.h" +#include "SinewaveSynth.h" AudioProcessor* JUCE_CALLTYPE createPluginFilter(); -//============================================================================== -/** A demo synth sound that's just a basic sine wave.. */ -class SineWaveSound : public SynthesiserSound -{ -public: - SineWaveSound() {} - - bool appliesToNote (int /*midiNoteNumber*/) override { return true; } - bool appliesToChannel (int /*midiChannel*/) override { return true; } -}; - -//============================================================================== -/** A simple demo synth voice that just plays a sine wave.. */ -class SineWaveVoice : public SynthesiserVoice -{ -public: - SineWaveVoice() - { - } - - bool canPlaySound (SynthesiserSound* sound) override - { - return dynamic_cast (sound) != nullptr; - } - - void startNote (int midiNoteNumber, float velocity, - SynthesiserSound* /*sound*/, - int /*currentPitchWheelPosition*/) override - { - currentAngle = 0.0; - level = velocity * 0.15; - tailOff = 0.0; - - double cyclesPerSecond = MidiMessage::getMidiNoteInHertz (midiNoteNumber); - double cyclesPerSample = cyclesPerSecond / getSampleRate(); - - angleDelta = cyclesPerSample * 2.0 * double_Pi; - } - - void stopNote (float /*velocity*/, bool allowTailOff) override - { - if (allowTailOff) - { - // start a tail-off by setting this flag. The render callback will pick up on - // this and do a fade out, calling clearCurrentNote() when it's finished. - - if (tailOff == 0.0) // we only need to begin a tail-off if it's not already doing so - the - // stopNote method could be called more than once. - tailOff = 1.0; - } - else - { - // we're being told to stop playing immediately, so reset everything.. - - clearCurrentNote(); - angleDelta = 0.0; - } - } - - void pitchWheelMoved (int /*newValue*/) override - { - // can't be bothered implementing this for the demo! - } - - void controllerMoved (int /*controllerNumber*/, int /*newValue*/) override - { - // not interested in controllers in this case. - } - - void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override - { - processBlock (outputBuffer, startSample, numSamples); - } - - void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override - { - processBlock (outputBuffer, startSample, numSamples); - } - -private: - template - void processBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) - { - if (angleDelta != 0.0) - { - if (tailOff > 0) - { - while (--numSamples >= 0) - { - auto currentSample = static_cast (std::sin (currentAngle) * level * tailOff); - - for (int i = outputBuffer.getNumChannels(); --i >= 0;) - outputBuffer.addSample (i, startSample, currentSample); - - currentAngle += angleDelta; - ++startSample; - - tailOff *= 0.99; - - if (tailOff <= 0.005) - { - clearCurrentNote(); - - angleDelta = 0.0; - break; - } - } - } - else - { - while (--numSamples >= 0) - { - auto currentSample = static_cast (std::sin (currentAngle) * level); - - for (int i = outputBuffer.getNumChannels(); --i >= 0;) - outputBuffer.addSample (i, startSample, currentSample); - - currentAngle += angleDelta; - ++startSample; - } - } - } - } - - double currentAngle = 0, angleDelta = 0, level = 0, tailOff = 0; -}; - //============================================================================== JuceDemoPluginAudioProcessor::JuceDemoPluginAudioProcessor() : AudioProcessor (getBusesProperties()) diff --git a/examples/audio plugin host/Plugin Host.jucer b/examples/audio plugin host/Plugin Host.jucer index 9d147f89b5..b291a47c01 100644 --- a/examples/audio plugin host/Plugin Host.jucer +++ b/examples/audio plugin host/Plugin Host.jucer @@ -2,7 +2,7 @@ diff --git a/examples/audio plugin host/Source/MainHostWindow.cpp b/examples/audio plugin host/Source/MainHostWindow.cpp index 37c96af1ed..906564544d 100644 --- a/examples/audio plugin host/Source/MainHostWindow.cpp +++ b/examples/audio plugin host/Source/MainHostWindow.cpp @@ -213,7 +213,12 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster* changed) StringArray MainHostWindow::getMenuBarNames() { - return { "File", "Plugins", "Options", "Windows" }; + StringArray names; + names.add ("File"); + names.add ("Plugins"); + names.add ("Options"); + names.add ("Windows"); + return names; } PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/) diff --git a/extras/AudioPerformanceTest/AudioPerformanceTest.jucer b/extras/AudioPerformanceTest/AudioPerformanceTest.jucer index 8893078e29..0b0d218a99 100644 --- a/extras/AudioPerformanceTest/AudioPerformanceTest.jucer +++ b/extras/AudioPerformanceTest/AudioPerformanceTest.jucer @@ -2,7 +2,7 @@ diff --git a/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java b/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java index 5feced2ee7..5f1a6c3451 100644 --- a/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java +++ b/extras/AudioPerformanceTest/Builds/Android/app/src/main/java/com/juce/audioperformancetest/AudioPerformanceTest.java @@ -1448,11 +1448,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1467,11 +1474,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 1); } }) @@ -1479,7 +1493,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1493,11 +1507,18 @@ public class AudioPerformanceTest extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + AudioPerformanceTest.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 1); } }) @@ -1505,7 +1526,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 2); } }) @@ -1513,7 +1534,7 @@ public class AudioPerformanceTest extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); AudioPerformanceTest.this.alertDismissed (callback, 0); } }); @@ -1911,13 +1932,75 @@ public class AudioPerformanceTest extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -1940,19 +2023,12 @@ public class AudioPerformanceTest extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -1960,6 +2036,89 @@ public class AudioPerformanceTest extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -1997,9 +2156,16 @@ public class AudioPerformanceTest extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -2102,13 +2268,20 @@ public class AudioPerformanceTest extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -2130,89 +2303,15 @@ public class AudioPerformanceTest extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); - - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -2238,7 +2337,14 @@ public class AudioPerformanceTest extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -2333,7 +2439,7 @@ public class AudioPerformanceTest extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/extras/Projucer/Builds/LinuxMakefile/Makefile b/extras/Projucer/Builds/LinuxMakefile/Makefile index 4f27f8d945..cc718ff446 100644 --- a/extras/Projucer/Builds/LinuxMakefile/Makefile +++ b/extras/Projucer/Builds/LinuxMakefile/Makefile @@ -33,7 +33,7 @@ ifeq ($(CONFIG),Debug) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.1 -DJUCE_APP_VERSION_HEX=0x50101 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DDEBUG=1 -D_DEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.2 -DJUCE_APP_VERSION_HEX=0x50102 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 JUCE_TARGET_APP := Projucer @@ -54,7 +54,7 @@ ifeq ($(CONFIG),Release) TARGET_ARCH := -march=native endif - JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.1 -DJUCE_APP_VERSION_HEX=0x50101 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) + JUCE_CPPFLAGS := $(DEPFLAGS) -DLINUX=1 -DNDEBUG=1 -DJUCER_LINUX_MAKE_6D53C8B4=1 -DJUCE_APP_VERSION=5.1.2 -DJUCE_APP_VERSION_HEX=0x50102 $(shell pkg-config --cflags freetype2 libcurl x11 xext xinerama webkit2gtk-4.0 gtk+-x11-3.0) -pthread -I../../JuceLibraryCode -I../../../../modules $(CPPFLAGS) JUCE_CPPFLAGS_APP := -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=0 -DJucePlugin_Build_AU=0 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=0 JUCE_TARGET_APP := Projucer diff --git a/extras/Projucer/Builds/MacOSX/Info-App.plist b/extras/Projucer/Builds/MacOSX/Info-App.plist index 9eec9db917..e5c569a0cc 100644 --- a/extras/Projucer/Builds/MacOSX/Info-App.plist +++ b/extras/Projucer/Builds/MacOSX/Info-App.plist @@ -33,9 +33,9 @@ CFBundleSignature ???? CFBundleShortVersionString - 5.1.1 + 5.1.2 CFBundleVersion - 5.1.1 + 5.1.2 NSHumanReadableCopyright ROLI Ltd. NSHighResolutionCapable diff --git a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj index d22dc08488..e6199c459a 100644 --- a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj +++ b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj @@ -738,8 +738,8 @@ "_DEBUG=1", "DEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=5.1.1", - "JUCE_APP_VERSION_HEX=0x50101", + "JUCE_APP_VERSION=5.1.2", + "JUCE_APP_VERSION_HEX=0x50102", "JucePlugin_Build_VST=0", "JucePlugin_Build_VST3=0", "JucePlugin_Build_AU=0", @@ -771,8 +771,8 @@ "_NDEBUG=1", "NDEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=5.1.1", - "JUCE_APP_VERSION_HEX=0x50101", + "JUCE_APP_VERSION=5.1.2", + "JUCE_APP_VERSION_HEX=0x50102", "JucePlugin_Build_VST=0", "JucePlugin_Build_VST3=0", "JucePlugin_Build_AU=0", diff --git a/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj index 1dcb17b056..5398caf988 100644 --- a/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2013/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebugDLL true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2013_78A5020=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2013/resources.rc b/extras/Projucer/Builds/VisualStudio2013/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2013/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2013/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj index 4f3a2a8936..0bc3af50d4 100644 --- a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebugDLL true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2015/resources.rc b/extras/Projucer/Builds/VisualStudio2015/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2015/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2015/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj index 35d04e7107..4016040ec2 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj @@ -73,7 +73,7 @@ Disabled ProgramDatabase ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreadedDebug true @@ -113,7 +113,7 @@ Full ..\..\JuceLibraryCode;..\..\..\..\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.1;JUCE_APP_VERSION_HEX=0x50101;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2017_78A5024=1;JUCE_APP_VERSION=5.1.2;JUCE_APP_VERSION_HEX=0x50102;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;%(PreprocessorDefinitions) MultiThreaded true diff --git a/extras/Projucer/Builds/VisualStudio2017/resources.rc b/extras/Projucer/Builds/VisualStudio2017/resources.rc index 871b0544aa..09499a2f88 100644 --- a/extras/Projucer/Builds/VisualStudio2017/resources.rc +++ b/extras/Projucer/Builds/VisualStudio2017/resources.rc @@ -7,7 +7,7 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,1,1,0 +FILEVERSION 5,1,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -15,9 +15,9 @@ BEGIN BEGIN VALUE "CompanyName", "ROLI Ltd.\0" VALUE "FileDescription", "Projucer\0" - VALUE "FileVersion", "5.1.1\0" + VALUE "FileVersion", "5.1.2\0" VALUE "ProductName", "Projucer\0" - VALUE "ProductVersion", "5.1.1\0" + VALUE "ProductVersion", "5.1.2\0" END END diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.cpp b/extras/Projucer/JuceLibraryCode/BinaryData.cpp index 4b70bc30e4..543a94bc05 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Projucer/JuceLibraryCode/BinaryData.cpp @@ -1540,9 +1540,9 @@ static const unsigned char temp_binary_data_8[] = " #endif\r\n" "}\r\n" "\r\n" -"bool FILTERCLASSNAME::isMidiEffect () const\r\n" +"bool FILTERCLASSNAME::isMidiEffect() const\r\n" "{\r\n" -" #ifdef JucePlugin_IsMidiEffect\r\n" +" #if JucePlugin_IsMidiEffect\r\n" " return true;\r\n" " #else\r\n" " return false;\r\n" @@ -1617,6 +1617,7 @@ static const unsigned char temp_binary_data_8[] = "\r\n" "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" "{\r\n" +" ScopedNoDenormals noDenormals;\r\n" " const int totalNumInputChannels = getTotalNumInputChannels();\r\n" " const int totalNumOutputChannels = getTotalNumOutputChannels();\r\n" "\r\n" @@ -7028,7 +7029,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0xafccbd3f: numBytes = 3141; return jucer_AudioComponentTemplate_cpp; case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: numBytes = 938; return jucer_AudioPluginEditorTemplate_h; - case 0x51b49ac5: numBytes = 5615; return jucer_AudioPluginFilterTemplate_cpp; + case 0x51b49ac5: numBytes = 5647; return jucer_AudioPluginFilterTemplate_cpp; case 0x488afa0a: numBytes = 2245; return jucer_AudioPluginFilterTemplate_h; case 0xabad7041: numBytes = 2151; return jucer_ComponentTemplate_cpp; case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.h b/extras/Projucer/JuceLibraryCode/BinaryData.h index 8c93be578b..798ca25825 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.h +++ b/extras/Projucer/JuceLibraryCode/BinaryData.h @@ -33,7 +33,7 @@ namespace BinaryData const int jucer_AudioPluginEditorTemplate_hSize = 938; extern const char* jucer_AudioPluginFilterTemplate_cpp; - const int jucer_AudioPluginFilterTemplate_cppSize = 5615; + const int jucer_AudioPluginFilterTemplate_cppSize = 5647; extern const char* jucer_AudioPluginFilterTemplate_h; const int jucer_AudioPluginFilterTemplate_hSize = 2245; diff --git a/extras/Projucer/JuceLibraryCode/JuceHeader.h b/extras/Projucer/JuceLibraryCode/JuceHeader.h index dc53643137..02c8a12178 100644 --- a/extras/Projucer/JuceLibraryCode/JuceHeader.h +++ b/extras/Projucer/JuceLibraryCode/JuceHeader.h @@ -34,7 +34,7 @@ namespace ProjectInfo { const char* const projectName = "Projucer"; - const char* const versionString = "5.1.1"; - const int versionNumber = 0x50101; + const char* const versionString = "5.1.2"; + const int versionNumber = 0x50102; } #endif diff --git a/extras/Projucer/Projucer.jucer b/extras/Projucer/Projucer.jucer index 69c9b27a7a..09554746e6 100644 --- a/extras/Projucer/Projucer.jucer +++ b/extras/Projucer/Projucer.jucer @@ -1,7 +1,7 @@ diff --git a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp index d84df3f16d..bec4e61204 100644 --- a/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp +++ b/extras/Projucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp @@ -54,9 +54,9 @@ bool FILTERCLASSNAME::producesMidi() const #endif } -bool FILTERCLASSNAME::isMidiEffect () const +bool FILTERCLASSNAME::isMidiEffect() const { - #ifdef JucePlugin_IsMidiEffect + #if JucePlugin_IsMidiEffect return true; #else return false; @@ -131,6 +131,7 @@ bool FILTERCLASSNAME::isBusesLayoutSupported (const BusesLayout& layouts) const void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { + ScopedNoDenormals noDenormals; const int totalNumInputChannels = getTotalNumInputChannels(); const int totalNumOutputChannels = getTotalNumOutputChannels(); diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h index 81f6d1b069..ba8c6e7513 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -1236,6 +1236,9 @@ private: defines.set ("JUCE_ANDROID_ACTIVITY_CLASSNAME", getJNIActivityClassName().replaceCharacter ('/', '_')); defines.set ("JUCE_ANDROID_ACTIVITY_CLASSPATH", "\"" + getJNIActivityClassName() + "\""); + if (androidInAppBillingPermission.get()) + defines.set ("JUCE_IN_APP_PURCHASES", "1"); + if (supportsGLv3()) defines.set ("JUCE_ANDROID_GL_ES_VERSION_3_0", "1"); diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index eff6772e31..350e46440a 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -80,12 +80,10 @@ public: void addWindowsTargetPlatformProperties (PropertyListBuilder& props) { - static const char* targetPlatformNames[] = { "(default)", "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" }; - static const var targetPlatforms[] = { var(), "8.1", "10.0.10240.0", "10.0.10586.0", "10.0.14393.0", "10.0.15063.0" }; + if (getWindowsTargetPlatformVersionValue() == Value()) + getWindowsTargetPlatformVersionValue() = getDefaultWindowsTargetPlatformVersion(); - props.add (new ChoicePropertyComponent (getWindowsTargetPlatformVersionValue(), "Windows Target Platform", - StringArray (targetPlatformNames, numElementsInArray (targetPlatformNames)), - Array (targetPlatforms, numElementsInArray (targetPlatforms))), + props.add (new TextPropertyComponent (getWindowsTargetPlatformVersionValue(), "Windows Target Platform", 20, false), "Specifies the version of the Windows SDK that will be used when building this project. " "The default value for this exporter is " + getDefaultWindowsTargetPlatformVersion()); } diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h index f376e70eb6..3d18e12c8f 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -1040,6 +1040,9 @@ public: s.add ("SEPARATE_STRIP = YES"); } + if (owner.iOS && owner.isInAppPurchasesEnabled()) + defines.set ("JUCE_IN_APP_PURCHASES", "1"); + defines = mergePreprocessorDefs (defines, owner.getAllPreprocessorDefs (config, type)); StringArray defsList; diff --git a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h index a7d5e3a042..172f978a69 100644 --- a/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h +++ b/extras/UnitTestRunner/JuceLibraryCode/AppConfig.h @@ -180,6 +180,10 @@ //#define JUCE_DSP_USE_STATIC_FFTW 1 #endif +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + //============================================================================== // juce_events flags: diff --git a/extras/UnitTestRunner/UnitTestRunner.jucer b/extras/UnitTestRunner/UnitTestRunner.jucer index c99d591238..f3ecfd90b9 100644 --- a/extras/UnitTestRunner/UnitTestRunner.jucer +++ b/extras/UnitTestRunner/UnitTestRunner.jucer @@ -2,7 +2,7 @@ diff --git a/extras/binarybuilder/BinaryBuilder.jucer b/extras/binarybuilder/BinaryBuilder.jucer index 6639199173..0e7cc17a1d 100644 --- a/extras/binarybuilder/BinaryBuilder.jucer +++ b/extras/binarybuilder/BinaryBuilder.jucer @@ -1,7 +1,7 @@ diff --git a/extras/windows dll/jucedll.jucer b/extras/windows dll/jucedll.jucer index 9c310e7527..ddd1fbc219 100644 --- a/extras/windows dll/jucedll.jucer +++ b/extras/windows dll/jucedll.jucer @@ -1,7 +1,7 @@ diff --git a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h index b8c3b0f520..16e729db2b 100644 --- a/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h +++ b/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -46,14 +46,15 @@ public: /** Frame rate types. */ enum FrameRateType { - fps24 = 0, - fps25 = 1, - fps2997 = 2, - fps30 = 3, - fps2997drop = 4, - fps30drop = 5, - fps60 = 6, - fps60drop = 7, + fps23976 = 0, + fps24 = 1, + fps25 = 2, + fps2997 = 3, + fps30 = 4, + fps2997drop = 5, + fps30drop = 6, + fps60 = 7, + fps60drop = 8, fpsUnknown = 99 }; @@ -70,12 +71,12 @@ public: /** Time signature denominator, e.g. the 4 of a 3/4 time sig */ int timeSigDenominator; - /** The current play position, in samples from the start of the edit. */ + /** The current play position, in samples from the start of the timeline. */ int64 timeInSamples; - /** The current play position, in seconds from the start of the edit. */ + /** The current play position, in seconds from the start of the timeline. */ double timeInSeconds; - /** For timecode, the position of the start of the edit, in seconds from 00:00:00:00. */ + /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */ double editOriginTime; /** The current play position, in pulses-per-quarter-note. */ @@ -83,7 +84,7 @@ public: /** The position of the start of the last bar, in pulses-per-quarter-note. - This is the time from the start of the edit to the start of the current + This is the time from the start of the timeline to the start of the current bar, in ppq units. Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If @@ -150,3 +151,5 @@ public: /** Rewinds the audio. */ virtual void transportRewind() {} }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp index e75f90b4e9..754291d5bf 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioChannelSet::AudioChannelSet (uint32 c) : channels (c) {} AudioChannelSet::AudioChannelSet (const Array& c) { @@ -414,3 +417,5 @@ int32 AudioChannelSet::getWaveChannelMask() const noexcept return (channels.toInteger() >> 1); } + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h index 14c0ff900a..bb99cff93e 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h +++ b/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -388,3 +388,5 @@ private: explicit AudioChannelSet (uint32); explicit AudioChannelSet (const Array&); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index de705a8d36..3f31379dd8 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; @@ -309,7 +312,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const float scale = 1.0f / 0x7fffffff; + const auto scale = 1.0f / (float) 0x7fffffff; const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) @@ -334,7 +337,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const float scale = 1.0f / 0x7fffffff; + const auto scale = 1.0f / (float) 0x7fffffff; const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) @@ -596,3 +599,5 @@ public: static AudioConversionTests audioConversionUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h index 91907c0285..6af6822009 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -708,3 +708,5 @@ private: AudioDataConverters(); JUCE_DECLARE_NON_COPYABLE (AudioDataConverters) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 04dc758135..ac9addd564 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -184,11 +184,19 @@ public: : numChannels (other.numChannels), size (other.size), allocatedBytes (other.allocatedBytes), - channels (other.channels), allocatedData (static_cast&&> (other.allocatedData)), isClear (other.isClear) { - memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) + { + channels = preallocatedChannelSpace; + memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace)); + } + else + { + channels = other.channels; + } + other.numChannels = 0; other.size = 0; other.allocatedBytes = 0; @@ -200,10 +208,19 @@ public: numChannels = other.numChannels; size = other.size; allocatedBytes = other.allocatedBytes; - channels = other.channels; allocatedData = static_cast&&> (other.allocatedData); isClear = other.isClear; - memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + + if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) + { + channels = preallocatedChannelSpace; + memcpy (preallocatedChannelSpace, other.channels, sizeof (preallocatedChannelSpace)); + } + else + { + channels = other.channels; + } + other.numChannels = 0; other.size = 0; other.allocatedBytes = 0; @@ -332,7 +349,7 @@ public: auto numSamplesToCopy = (size_t) jmin (newNumSamples, size); - auto newChannels = reinterpret_cast (newData.getData()); + auto newChannels = reinterpret_cast (newData.get()); auto newChan = reinterpret_cast (newData + channelListSize); for (int j = 0; j < newNumChannels; ++j) @@ -364,7 +381,7 @@ public: { allocatedBytes = newTotalBytes; allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); } auto* chan = reinterpret_cast (allocatedData + channelListSize); @@ -629,7 +646,7 @@ public: jassert (isPositiveAndBelow (channel, numChannels)); jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size); - const auto increment = (endGain - startGain) / numSamples; + const auto increment = (endGain - startGain) / (float) numSamples; auto* d = channels[channel] + startSample; while (--numSamples >= 0) @@ -1051,7 +1068,7 @@ private: auto channelListSize = sizeof (Type*) * (size_t) (numChannels + 1); allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32; allocatedData.malloc (allocatedBytes); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); auto* chan = (Type*) (allocatedData + channelListSize); for (int i = 0; i < numChannels; ++i) @@ -1076,7 +1093,7 @@ private: else { allocatedData.malloc ((size_t) numChannels + 1, sizeof (Type*)); - channels = reinterpret_cast (allocatedData.getData()); + channels = reinterpret_cast (allocatedData.get()); } for (int i = 0; i < numChannels; ++i) @@ -1105,3 +1122,5 @@ private: @see AudioBuffer */ typedef AudioBuffer AudioSampleBuffer; + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index cbf6fb2554..5523a4a2f7 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace FloatVectorHelpers { #define JUCE_INCREMENT_SRC_DEST dest += (16 / sizeof (*dest)); src += (16 / sizeof (*dest)); @@ -874,7 +877,7 @@ void JUCE_CALLTYPE FloatVectorOperations::convertFixedToFloat (float* dest, cons vmulq_n_f32 (vcvtq_f32_s32 (vld1q_s32 (src)), multiplier), JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, ) #else - JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier, + JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = (float) src[i] * multiplier, Mode::mul (mult, _mm_cvtepi32_ps (_mm_loadu_si128 ((const __m128i*) src))), JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, const Mode::ParallelType mult = Mode::load1 (multiplier);) @@ -1068,9 +1071,9 @@ public: #else // These tests deliberately operate on misaligned memory and will be flagged up by // checks for undefined behavior! - ValueType* const data1 = addBytesToPointer (buffer1.getData(), random.nextInt (16)); - ValueType* const data2 = addBytesToPointer (buffer2.getData(), random.nextInt (16)); - int* const int1 = addBytesToPointer (buffer3.getData(), random.nextInt (16)); + ValueType* const data1 = addBytesToPointer (buffer1.get(), random.nextInt (16)); + ValueType* const data2 = addBytesToPointer (buffer2.get(), random.nextInt (16)); + int* const int1 = addBytesToPointer (buffer3.get(), random.nextInt (16)); #endif fillRandomly (random, data1, num); @@ -1158,7 +1161,7 @@ public: static void convertFixed (float* d, const int* s, ValueType multiplier, int num) { while (--num >= 0) - *d++ = *s++ * multiplier; + *d++ = (float) *s++ * multiplier; } static bool areAllValuesEqual (const ValueType* d, int num, ValueType target) @@ -1200,3 +1203,5 @@ public: static FloatVectorOperationsTests vectorOpTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 9cb7895fcf..c44bbd800f 100644 --- a/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_INTEL #define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0; @@ -219,3 +220,35 @@ public: */ static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept; }; + +//============================================================================== +/** + Helper class providing an RAII-based mechanism for temporarily disabling + denormals on your CPU. +*/ +class ScopedNoDenormals +{ +public: + inline ScopedNoDenormals() noexcept + { + #if JUCE_USE_SSE_INTRINSICS + mxcsr = _mm_getcsr(); + _mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits + #endif + } + + + inline ~ScopedNoDenormals() noexcept + { + #if JUCE_USE_SSE_INTRINSICS + _mm_setcsr (mxcsr); + #endif + } + +private: + #if JUCE_USE_SSE_INTRINSICS + unsigned int mxcsr; + #endif +}; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp index 11f996b023..3d210938c6 100644 --- a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct CatmullRomAlgorithm { static forcedinline float valueAtOffset (const float* const inputs, const float offset) noexcept @@ -58,3 +61,5 @@ int CatmullRomInterpolator::processAdding (double actualRatio, const float* in, { return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain); } + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h index 75eaeeca4b..3876ae612e 100644 --- a/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h +++ b/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** Interpolator for resampling a stream of floats using Catmull-Rom interpolation. @@ -84,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CatmullRomInterpolator) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_Decibels.h b/modules/juce_audio_basics/effects/juce_Decibels.h index e144f11e09..4fc2d2fdbf 100644 --- a/modules/juce_audio_basics/effects/juce_Decibels.h +++ b/modules/juce_audio_basics/effects/juce_Decibels.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: Decibels(); // This class can't be instantiated, it's just a holder for static methods.. JUCE_DECLARE_NON_COPYABLE (Decibels) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilter.cpp b/modules/juce_audio_basics/effects/juce_IIRFilter.cpp index 39def04d38..01338c8d9d 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilter.cpp +++ b/modules/juce_audio_basics/effects/juce_IIRFilter.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + IIRCoefficients::IIRCoefficients() noexcept { zeromem (coefficients, sizeof (coefficients)); @@ -335,3 +337,5 @@ void IIRFilter::processSamples (float* const samples, const int numSamples) noex } #undef JUCE_SNAP_TO_ZERO + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilter.h b/modules/juce_audio_basics/effects/juce_IIRFilter.h index b0ef1fa11f..9db85b5828 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilter.h +++ b/modules/juce_audio_basics/effects/juce_IIRFilter.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class IIRFilter; @@ -205,3 +206,5 @@ protected: IIRFilter& operator= (const IIRFilter&); JUCE_LEAK_DETECTOR (IIRFilter) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp b/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp index 25ab4f14ed..f8d5ee3bc9 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp +++ b/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp @@ -28,6 +28,9 @@ #define JUCE_SNAP_TO_ZERO(n) #endif +namespace juce +{ + //============================================================================== IIRFilterOld::IIRFilterOld() : active (false), v1 (0), v2 (0) @@ -237,3 +240,5 @@ void IIRFilterOld::setCoefficients (double c1, double c2, double c3, } #undef JUCE_SNAP_TO_ZERO + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_IIRFilterOld.h b/modules/juce_audio_basics/effects/juce_IIRFilterOld.h index 8c929c5843..c6332171fe 100644 --- a/modules/juce_audio_basics/effects/juce_IIRFilterOld.h +++ b/modules/juce_audio_basics/effects/juce_IIRFilterOld.h @@ -26,6 +26,9 @@ #define __JUCE_IIRFILTER_OLD_JUCEHEADER__ +namespace juce +{ + //============================================================================== /** An IIR filter that can perform low, high, or band-pass filtering on an @@ -145,4 +148,6 @@ protected: }; +} // namespace juce + #endif // __JUCE_IIRFILTER_OLD_JUCEHEADER__ diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index ecd892d722..eca8e98e62 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { static forcedinline void pushInterpolationSample (float* lastInputSamples, const float newValue) noexcept @@ -196,3 +199,5 @@ int LagrangeInterpolator::processAdding (double actualRatio, const float* in, fl { return interpolateAdding (lastInputSamples, subSamplePos, actualRatio, in, out, numOut, gain); } + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h index 7143842e3a..d527574513 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** Interpolator for resampling a stream of floats using 4-point lagrange interpolation. @@ -84,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LagrangeInterpolator) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h b/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h index d39dc91734..3dc342c418 100644 --- a/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h +++ b/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -182,3 +182,5 @@ private: FloatType currentValue = 0, target = 0, step = 0; int countdown = 0, stepsToTarget = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/effects/juce_Reverb.h b/modules/juce_audio_basics/effects/juce_Reverb.h index 375fda0903..02b95b3c31 100644 --- a/modules/juce_audio_basics/effects/juce_Reverb.h +++ b/modules/juce_audio_basics/effects/juce_Reverb.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -316,3 +316,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Reverb) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/juce_audio_basics.cpp b/modules/juce_audio_basics/juce_audio_basics.cpp index fae5bff83e..9ee676fb36 100644 --- a/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/modules/juce_audio_basics/juce_audio_basics.cpp @@ -76,9 +76,6 @@ #include #endif -namespace juce -{ - #include "buffers/juce_AudioDataConverters.cpp" #include "buffers/juce_FloatVectorOperations.cpp" #include "buffers/juce_AudioChannelSet.cpp" @@ -110,5 +107,3 @@ namespace juce #include "sources/juce_ReverbAudioSource.cpp" #include "sources/juce_ToneGeneratorAudioSource.cpp" #include "synthesisers/juce_Synthesiser.cpp" - -} diff --git a/modules/juce_audio_basics/juce_audio_basics.h b/modules/juce_audio_basics/juce_audio_basics.h index ce6c8f45ce..bcce98b41a 100644 --- a/modules/juce_audio_basics/juce_audio_basics.h +++ b/modules/juce_audio_basics/juce_audio_basics.h @@ -31,7 +31,7 @@ ID: juce_audio_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio and MIDI data classes description: Classes for audio buffer manipulation, midi message handling, synthesis, etc. website: http://www.juce.com/juce @@ -51,9 +51,7 @@ #include -namespace juce -{ - +//============================================================================== #undef Complex // apparently some C libraries actually define these symbols (!) #undef Factor @@ -95,5 +93,3 @@ namespace juce #include "sources/juce_ToneGeneratorAudioSource.h" #include "synthesisers/juce_Synthesiser.h" #include "audio_play_head/juce_AudioPlayHead.h" - -} diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp index cc71ff0bc8..94d19898f7 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiBufferHelpers { inline int getEventTime (const void* const d) noexcept @@ -34,7 +37,7 @@ namespace MidiBufferHelpers inline uint16 getEventTotalSize (const void* const d) noexcept { - return getEventDataSize (d) + sizeof (int32) + sizeof (uint16); + return (uint16) (getEventDataSize (d) + sizeof (int32) + sizeof (uint16)); } static int findActualEventLength (const uint8* const data, const int maxBytes) noexcept @@ -225,3 +228,5 @@ bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, int& samplePositio return true; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/modules/juce_audio_basics/midi/juce_MidiBuffer.h index b69d8796cf..e856bfbd2b 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -160,8 +160,8 @@ public: /** Used to iterate through the events in a MidiBuffer. - Note that altering the buffer while an iterator is using it isn't a - safe operation. + Note that altering the buffer while an iterator is using it will produce + undefined behaviour. @see MidiBuffer */ @@ -172,6 +172,9 @@ public: /** Creates an Iterator for this MidiBuffer. */ Iterator (const MidiBuffer&) noexcept; + /** Creates a copy of an iterator. */ + Iterator (const Iterator&) noexcept = default; + /** Destructor. */ ~Iterator() noexcept; @@ -214,8 +217,6 @@ public: //============================================================================== const MidiBuffer& buffer; const uint8* data; - - JUCE_DECLARE_NON_COPYABLE (Iterator) }; /** The raw data holding this buffer. @@ -227,3 +228,5 @@ public: private: JUCE_LEAK_DETECTOR (MidiBuffer) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiFile.cpp b/modules/juce_audio_basics/midi/juce_MidiFile.cpp index 727f9f62d0..6a67a0890f 100644 --- a/modules/juce_audio_basics/midi/juce_MidiFile.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiFileHelpers { static void writeVariableLengthInt (OutputStream& out, unsigned int v) @@ -443,3 +446,5 @@ bool MidiFile::writeTrack (OutputStream& mainOut, const int trackNum) return true; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiFile.h b/modules/juce_audio_basics/midi/juce_MidiFile.h index 47a1fab983..b06589d299 100644 --- a/modules/juce_audio_basics/midi/juce_MidiFile.h +++ b/modules/juce_audio_basics/midi/juce_MidiFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -178,3 +178,5 @@ private: JUCE_LEAK_DETECTOR (MidiFile) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp index 9f093628b8..ad52ceb8fd 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiKeyboardState::MidiKeyboardState() { zerostruct (noteStates); @@ -179,3 +182,5 @@ void MidiKeyboardState::removeListener (MidiKeyboardStateListener* const listene const ScopedLock sl (lock); listeners.removeFirstMatchingValue (listener); } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h index ef9a8f43c4..b3fc4e61e0 100644 --- a/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h +++ b/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MidiKeyboardState; @@ -197,3 +198,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardState) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index e9e6c1be3a..bf2eb56cd3 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace MidiHelpers { inline uint8 initialByte (const int type, const int channel) noexcept @@ -1119,3 +1122,5 @@ const char* MidiMessage::getControllerName (const int n) return isPositiveAndBelow (n, numElementsInArray (names)) ? names[n] : nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.h b/modules/juce_audio_basics/midi/juce_MidiMessage.h index aea8d42079..7fcefe2a2e 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -936,3 +936,5 @@ private: inline uint8* getData() const noexcept { return isHeapAllocated() ? packedData.allocatedData : (uint8*) packedData.asBytes; } uint8* allocateSpace (int); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index 6a3f851cbf..fe8b2c083d 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ MidiMessageSequence::MidiEventHolder::MidiEventHolder (const MidiMessage& mm) : message (mm) {} MidiMessageSequence::MidiEventHolder::MidiEventHolder (MidiMessage&& mm) : message (static_cast (mm)) {} @@ -334,3 +336,5 @@ void MidiMessageSequence::createControllerUpdatesForTime (int channelNumber, dou } } } + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h index 916431b986..8f5e3f6994 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -294,3 +294,5 @@ private: JUCE_LEAK_DETECTOR (MidiMessageSequence) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiRPN.cpp b/modules/juce_audio_basics/midi/juce_MidiRPN.cpp index a5189566c4..9e2c2df329 100644 --- a/modules/juce_audio_basics/midi/juce_MidiRPN.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiRPN.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiRPNDetector::MidiRPNDetector() noexcept { } @@ -369,3 +372,5 @@ private: static MidiRPNGeneratorTests MidiRPNGeneratorUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/midi/juce_MidiRPN.h b/modules/juce_audio_basics/midi/juce_MidiRPN.h index 53219c1f9e..e8a74d1071 100644 --- a/modules/juce_audio_basics/midi/juce_MidiRPN.h +++ b/modules/juce_audio_basics/midi/juce_MidiRPN.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Represents a MIDI RPN (registered parameter number) or NRPN (non-registered @@ -144,3 +144,5 @@ public: bool isNRPN = false, bool use14BitValue = true); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 70aee29fde..24bfd2e260 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { const uint8 noLSBValueReceived = 0xff; @@ -2148,3 +2151,5 @@ private: static MPEInstrumentTests MPEInstrumentUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h index 8fe26ae919..b6d05ea843 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /* @@ -374,3 +374,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPEInstrument) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp b/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp index 09939a1045..ebdc68993c 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiBuffer MPEMessages::addZone (MPEZone zone) { MidiBuffer buffer (MidiRPNGenerator::generate (zone.getFirstNoteChannel(), @@ -193,3 +196,5 @@ private: static MPEMessagesTests MPEMessagesUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEMessages.h b/modules/juce_audio_basics/mpe/juce_MPEMessages.h index 87b12f09d7..76b58b2013 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEMessages.h +++ b/modules/juce_audio_basics/mpe/juce_MPEMessages.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -87,3 +87,5 @@ public: */ static const int zoneLayoutMessagesRpnNumber = 6; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPENote.cpp b/modules/juce_audio_basics/mpe/juce_MPENote.cpp index 1f47cec021..dad3ab6028 100644 --- a/modules/juce_audio_basics/mpe/juce_MPENote.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPENote.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { uint16 generateNoteID (int midiChannel, int midiNoteNumber) noexcept @@ -128,3 +131,5 @@ private: static MPENoteTests MPENoteUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPENote.h b/modules/juce_audio_basics/mpe/juce_MPENote.h index 874a03f3e9..8d549ddd9e 100644 --- a/modules/juce_audio_basics/mpe/juce_MPENote.h +++ b/modules/juce_audio_basics/mpe/juce_MPENote.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -172,3 +172,5 @@ struct JUCE_API MPENote /** Returns true if two notes are different notes, determined by their unique ID. */ bool operator!= (const MPENote& other) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index 3e965f434b..94763f1bc7 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiser::MPESynthesiser() { } @@ -352,3 +355,5 @@ void MPESynthesiser::renderNextSubBlock (AudioBuffer& buffer, int startS voice->renderNextBlock (buffer, startSample, numSamples); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h index 73dcc9772f..408970e6c5 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -305,3 +305,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp index 671249a307..7759eea5e2 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiserBase::MPESynthesiserBase() : instrument (new MPEInstrument), sampleRate (0), @@ -178,3 +181,5 @@ void MPESynthesiserBase::setMinimumRenderingSubdivisionSize (int numSamples, boo minimumSubBlockSize = numSamples; subBlockSubdivisionIsStrict = shouldBeStrict; } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h index 649abc884d..b2b787a58d 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -204,3 +204,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserBase) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp index cdd35cfc04..6ac688eba9 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPESynthesiserVoice::MPESynthesiserVoice() : currentSampleRate (0), noteStartTime (0) { @@ -49,3 +52,5 @@ void MPESynthesiserVoice::clearCurrentNote() noexcept { currentlyPlayingNote = MPENote(); } + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h index 9f8205e638..142c963783 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -183,3 +184,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEValue.cpp b/modules/juce_audio_basics/mpe/juce_MPEValue.cpp index 9413057542..d9fbd7db39 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEValue.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEValue.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPEValue::MPEValue() noexcept : normalisedValue (8192) { } @@ -166,3 +169,5 @@ private: static MPEValueTests MPEValueUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEValue.h b/modules/juce_audio_basics/mpe/juce_MPEValue.h index 5743410058..4bb5afc966 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEValue.h +++ b/modules/juce_audio_basics/mpe/juce_MPEValue.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: MPEValue (int normalisedValue); int normalisedValue; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZone.cpp b/modules/juce_audio_basics/mpe/juce_MPEZone.cpp index 912a86c3c5..5b97f0677f 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZone.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEZone.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { void checkAndLimitZoneParameters (int minValue, @@ -312,3 +315,5 @@ private: static MPEZoneTests MPEZoneUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZone.h b/modules/juce_audio_basics/mpe/juce_MPEZone.h index 9fdfb5548e..7284398267 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZone.h +++ b/modules/juce_audio_basics/mpe/juce_MPEZone.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -138,3 +138,5 @@ private: int perNotePitchbendRange; int masterPitchbendRange; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp index 450dc09f6b..f0d525ad35 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MPEZoneLayout::MPEZoneLayout() noexcept { } @@ -378,3 +381,5 @@ static MPEZoneLayoutTests MPEZoneLayoutUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h index 0b08eb5618..5b0337c113 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: void processZoneLayoutRpnMessage (MidiRPNMessage); void processPitchbendRangeRpnMessage (MidiRPNMessage); }; + +} // namespace juce diff --git a/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h b/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h index 1bf5cda274..0aaf6f6664 100644 --- a/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h +++ b/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || JUCE_IOS @@ -304,3 +305,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_AudioSource.h b/modules/juce_audio_basics/sources/juce_AudioSource.h index e58f93b297..6e5ddba5df 100644 --- a/modules/juce_audio_basics/sources/juce_AudioSource.h +++ b/modules/juce_audio_basics/sources/juce_AudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -173,3 +173,5 @@ public: */ virtual void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp index 1cf4718393..ae33bea0db 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* s, TimeSliceThread& thread, const bool deleteSourceWhenDeleted, @@ -307,3 +310,5 @@ int BufferingAudioSource::useTimeSlice() { return readNextBufferChunk() ? 1 : 100; } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 803695ea44..5624f5ceb7 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -113,3 +113,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp index a70fe866e1..3cec22131c 100644 --- a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChannelRemappingAudioSource::ChannelRemappingAudioSource (AudioSource* const source_, const bool deleteSourceWhenDeleted) : source (source_, deleteSourceWhenDeleted), @@ -180,3 +183,5 @@ void ChannelRemappingAudioSource::restoreFromXml (const XmlElement& e) remappedOutputs.add (outs[i].getIntValue()); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h index 1ed44d8244..b5a5cf058b 100644 --- a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -135,3 +135,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelRemappingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp index be4479fbb5..cbea3b8c29 100644 --- a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + IIRFilterAudioSource::IIRFilterAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted) : input (inputSource, deleteInputWhenDeleted) @@ -73,3 +76,5 @@ void IIRFilterAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& buff ->processSamples (bufferToFill.buffer->getWritePointer (i, bufferToFill.startSample), bufferToFill.numSamples); } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h index 9f38d1ce80..38faf285bc 100644 --- a/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -62,3 +62,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IIRFilterAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp index 220debfd1f..6adec04448 100644 --- a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + MemoryAudioSource::MemoryAudioSource (AudioBuffer& bufferToUse, bool copyMemory, bool shouldLoop) : isLooping (shouldLoop) { @@ -64,3 +66,5 @@ void MemoryAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferT if (pos < m) dst.clear (bufferToFill.startSample + pos, m - pos); } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h index 1a6fabf1b8..50b11c7b93 100644 --- a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -59,3 +59,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index 70b2658652..b3f1d148c0 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MixerAudioSource::MixerAudioSource() : currentSampleRate (0.0), bufferSizeExpected (0) { @@ -151,3 +154,5 @@ void MixerAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info) info.clearActiveBufferRegion(); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h index 5a3883f8e9..0c2b6e22c7 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MixerAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h b/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h index c9195dc90e..5908bb82bd 100644 --- a/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -70,3 +70,5 @@ public: /** Tells the source whether you'd like it to play in a loop. */ virtual void setLooping (bool shouldLoop) { ignoreUnused (shouldLoop); } }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp index 386f894ca4..67ff49ccd4 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ResamplingAudioSource::ResamplingAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted, const int channels) @@ -259,3 +262,5 @@ void ResamplingAudioSource::applyFilter (float* samples, int num, FilterState& f *samples++ = (float) out; } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h index 72134f9837..9f8fcd239a 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResamplingAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp index 86e54eaf96..dd4e7ab03f 100644 --- a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted) : input (inputSource, deleteInputWhenDeleted), bypass (false) @@ -76,3 +79,5 @@ void ReverbAudioSource::setBypassed (bool b) noexcept reverb.reset(); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h index fbdf48c943..1d2591b649 100644 --- a/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -68,3 +68,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ReverbAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp index b0f24d3901..b33a922494 100644 --- a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ToneGeneratorAudioSource::ToneGeneratorAudioSource() : frequency (1000.0), sampleRate (44100.0), @@ -71,3 +74,5 @@ void ToneGeneratorAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info.buffer->setSample (j, info.startSample + i, sample); } } + +} // namespace juce diff --git a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h index a5fc03b4f1..9c8e939d94 100644 --- a/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -65,3 +65,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneGeneratorAudioSource) }; + +} // namespace juce diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 4df64603e0..cb2eaf904d 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + SynthesiserSound::SynthesiserSound() {} SynthesiserSound::~SynthesiserSound() {} @@ -305,8 +308,8 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice, voice->noteOnTime = ++lastNoteOnCounter; voice->currentlyPlayingSound = sound; voice->setKeyDown (true); - voice->sostenutoPedalDown = false; - voice->sustainPedalDown = sustainPedalsDown[midiChannel]; + voice->setSostenutoPedalDown (false); + voice->setSustainPedalDown (sustainPedalsDown[midiChannel]); voice->startNote (midiNoteNumber, velocity, sound, lastPitchWheelValues [midiChannel - 1]); @@ -340,11 +343,11 @@ void Synthesiser::noteOff (const int midiChannel, if (sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) { - jassert (! voice->keyIsDown || voice->sustainPedalDown == sustainPedalsDown [midiChannel]); + jassert (! voice->keyIsDown || voice->isSustainPedalDown() == sustainPedalsDown [midiChannel]); voice->setKeyDown (false); - if (! (voice->sustainPedalDown || voice->sostenutoPedalDown)) + if (! (voice->isSustainPedalDown() || voice->isSostenutoPedalDown())) stopVoice (voice, velocity, allowTailOff); } } @@ -421,7 +424,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) for (auto* voice : voices) if (voice->isPlayingChannel (midiChannel) && voice->isKeyDown()) - voice->sustainPedalDown = true; + voice->setSustainPedalDown (true); } else { @@ -429,7 +432,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) { if (voice->isPlayingChannel (midiChannel)) { - voice->sustainPedalDown = false; + voice->setSustainPedalDown (false); if (! (voice->isKeyDown() || voice->isSostenutoPedalDown())) stopVoice (voice, 1.0f, true); @@ -450,8 +453,8 @@ void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown) if (voice->isPlayingChannel (midiChannel)) { if (isDown) - voice->sostenutoPedalDown = true; - else if (voice->sostenutoPedalDown) + voice->setSostenutoPedalDown (true); + else if (voice->isSostenutoPedalDown()) stopVoice (voice, 1.0f, true); } } @@ -567,3 +570,5 @@ SynthesiserVoice* Synthesiser::findVoiceToSteal (SynthesiserSound* soundToPlay, return low; } + +} // namespace juce diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index cad5ac393f..b8e50876f0 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -224,9 +224,15 @@ public: /** Returns true if the sustain pedal is currently active for this voice. */ bool isSustainPedalDown() const noexcept { return sustainPedalDown; } + /** Modifies the sustain pedal flag. */ + void setSustainPedalDown (bool isNowDown) noexcept { sustainPedalDown = isNowDown; } + /** Returns true if the sostenuto pedal is currently active for this voice. */ bool isSostenutoPedalDown() const noexcept { return sostenutoPedalDown; } + /** Modifies the sostenuto pedal flag. */ + void setSostenutoPedalDown (bool isNowDown) noexcept { sostenutoPedalDown = isNowDown; } + /** Returns true if a voice is sounding in its release phase **/ bool isPlayingButReleased() const noexcept { @@ -514,15 +520,15 @@ public: with timestamps outside the specified region will be ignored. */ inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } /** Returns the current target sample rate at which rendering is being done. @@ -639,3 +645,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Synthesiser) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 89eb7cf9fa..cc8cd4e65b 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioDeviceManager::AudioDeviceSetup::AudioDeviceSetup() : sampleRate (0), bufferSize (0), @@ -929,7 +932,7 @@ void AudioDeviceManager::LevelMeter::updateLevel (const float* const* channelDat for (int i = 0; i < numChannels; ++i) s += std::abs (channelData[i][j]); - s /= numChannels; + s /= (float) numChannels; const double decayFactor = 0.99992; @@ -1000,3 +1003,5 @@ double AudioDeviceManager::getCurrentOutputLevel() const noexcept { return out void AudioDeviceManager::enableInputLevelMeasurement (bool enable) noexcept { inputLevelMeter.setEnabled (enable); } void AudioDeviceManager::enableOutputLevelMeasurement (bool enable) noexcept { outputLevelMeter.setEnabled (enable); } + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index f4169644c6..5d7ae84038 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -518,3 +518,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceManager) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp index 0fd48370f1..935de58d07 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioIODevice::AudioIODevice (const String& deviceName, const String& deviceTypeName) : name (deviceName), typeName (deviceTypeName) { @@ -30,6 +33,7 @@ AudioIODevice::~AudioIODevice() {} void AudioIODeviceCallback::audioDeviceError (const String&) {} bool AudioIODevice::setAudioPreprocessingEnabled (bool) { return false; } bool AudioIODevice::hasControlPanel() const { return false; } +int AudioIODevice::getXRunCount() const noexcept { return -1; } bool AudioIODevice::showControlPanel() { @@ -37,3 +41,5 @@ bool AudioIODevice::showControlPanel() // their hasControlPanel() method. return false; } + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index 6c3b8300f1..a1599f4d2b 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class AudioIODevice; @@ -292,6 +293,19 @@ public: */ virtual bool setAudioPreprocessingEnabled (bool shouldBeEnabled); + //============================================================================== + /** Returns the number of under- or over runs reported by the OS since + playback/recording has started. + + This number may be different than determining the Xrun count manually (by + measuring the time spent in the audio callback) as the OS may be doing + some buffering internally - especially on mobile devices. + + Returns -1 if playback/recording has not started yet or if getting the underrun + count is not supported for this device (Android SDK 23 and lower). + */ + virtual int getXRunCount() const noexcept; + //============================================================================== protected: /** Creates a device, setting its name and type member variables. */ @@ -301,3 +315,5 @@ protected: /** @internal */ String name, typeName; }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp index aef772d0a3..838aaa6547 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioIODeviceType::AudioIODeviceType (const String& name) : typeName (name) { @@ -74,3 +77,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() #if ! (JUCE_ANDROID && JUCE_USE_ANDROID_OPENSLES) AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() { return nullptr; } #endif + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h index eaba0080e0..c11f711a41 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -174,3 +174,5 @@ private: JUCE_DECLARE_NON_COPYABLE (AudioIODeviceType) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h b/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h index 592215c9d6..bf5c44c6af 100644 --- a/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h +++ b/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -53,3 +53,5 @@ private: SystemAudioVolume(); // Don't instantiate this class, just call its static fns. JUCE_DECLARE_NON_COPYABLE (SystemAudioVolume) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/juce_audio_devices.cpp b/modules/juce_audio_devices/juce_audio_devices.cpp index 33c6fe0c92..6bdd8fe06e 100644 --- a/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/modules/juce_audio_devices/juce_audio_devices.cpp @@ -155,9 +155,6 @@ #endif -namespace juce -{ - #include "audio_io/juce_AudioDeviceManager.cpp" #include "audio_io/juce_AudioIODevice.cpp" #include "audio_io/juce_AudioIODeviceType.cpp" @@ -214,14 +211,15 @@ namespace juce #if JUCE_USE_ANDROID_OPENSLES #include "native/juce_android_OpenSL.cpp" #endif - #endif #if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED - // None of these methods are available. (On Windows you might need to enable WASAPI for this) - float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; } - bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; } - bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; } - bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } -#endif +namespace juce +{ + // None of these methods are available. (On Windows you might need to enable WASAPI for this) + float JUCE_CALLTYPE SystemAudioVolume::getGain() { jassertfalse; return 0.0f; } + bool JUCE_CALLTYPE SystemAudioVolume::setGain (float) { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { jassertfalse; return false; } + bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } } +#endif diff --git a/modules/juce_audio_devices/juce_audio_devices.h b/modules/juce_audio_devices/juce_audio_devices.h index 533bcd1af3..9b26405daf 100644 --- a/modules/juce_audio_devices/juce_audio_devices.h +++ b/modules/juce_audio_devices/juce_audio_devices.h @@ -31,7 +31,7 @@ ID: juce_audio_devices vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio and MIDI I/O device classes description: Classes to play and record from audio and MIDI I/O devices website: http://www.juce.com/juce @@ -140,9 +140,6 @@ //============================================================================== -namespace juce -{ - #include "midi_io/juce_MidiInput.h" #include "midi_io/juce_MidiMessageCollector.h" #include "midi_io/juce_MidiOutput.h" @@ -156,5 +153,3 @@ namespace juce #if JUCE_IOS #include "native/juce_ios_Audio.h" #endif - -} diff --git a/modules/juce_audio_devices/midi_io/juce_MidiInput.h b/modules/juce_audio_devices/midi_io/juce_MidiInput.h index 54cd0e4e77..52edd9fe09 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiInput.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiInput.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MidiInput; @@ -171,3 +172,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiInput) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp index 66bab1f852..50ca20569a 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp +++ b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MidiMessageCollector::MidiMessageCollector() { } @@ -151,3 +154,5 @@ void MidiMessageCollector::handleIncomingMidiMessage (MidiInput*, const MidiMess { addMessageToQueue (message); } + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h index 97f2dd6bb5..aa8bcdbeb6 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiMessageCollector) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp b/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp index f364b31cd9..36b7cf6409 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp +++ b/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MidiOutput::PendingMessage { PendingMessage (const void* const data, const int len, const double timeStamp) @@ -169,3 +172,5 @@ void MidiOutput::run() clearAllPendingMessages(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/midi_io/juce_MidiOutput.h b/modules/juce_audio_devices/midi_io/juce_MidiOutput.h index f71553dc7e..f05dc32f14 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiOutput.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiOutput.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiOutput) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h index 0cf7e285d1..1df491240a 100644 --- a/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h +++ b/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -31,9 +32,8 @@ class MidiDataConcatenator { public: //============================================================================== - MidiDataConcatenator (const int initialBufferSize) - : pendingData ((size_t) initialBufferSize), - pendingDataTime (0), pendingBytes (0), runningStatus (0) + MidiDataConcatenator (int initialBufferSize) + : pendingData ((size_t) initialBufferSize) { } @@ -181,9 +181,11 @@ private: } MemoryBlock pendingData; - double pendingDataTime; - int pendingBytes; - uint8 runningStatus; + double pendingDataTime = 0; + int pendingBytes = 0; + uint8 runningStatus = 0; JUCE_DECLARE_NON_COPYABLE (MidiDataConcatenator) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_Audio.cpp b/modules/juce_audio_devices/native/juce_android_Audio.cpp index a22f0619fa..66634137f0 100644 --- a/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_android_Audio.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (getMinBufferSize, "getMinBufferSize", "(III)I") \ STATICMETHOD (getNativeOutputSampleRate, "getNativeOutputSampleRate", "(I)I") \ @@ -31,6 +33,7 @@ METHOD (release, "release", "()V") \ METHOD (flush, "flush", "()V") \ METHOD (write, "write", "([SII)I") \ + METHOD (getUnderrunCount, "getUnderrunCount", "()I") \ DECLARE_JNI_CLASS (AudioTrack, "android/media/AudioTrack"); #undef JNI_CLASS_MEMBERS @@ -279,6 +282,14 @@ public: String getLastError() override { return lastError; } bool isPlaying() override { return isRunning && callback != 0; } + int getXRunCount() const noexcept override + { + if (outputDevice != nullptr) + return getEnv()->CallIntMethod (outputDevice, AudioTrack.getUnderrunCount); + + return -1; + } + void start (AudioIODeviceCallback* newCallback) override { if (isRunning && callback != newCallback) @@ -472,3 +483,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() return new AndroidAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_Midi.cpp b/modules/juce_audio_devices/native/juce_android_Midi.cpp index c968982cb3..5afe6562c3 100644 --- a/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_android_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getJuceAndroidMidiInputDevices, "getJuceAndroidMidiInputDevices", "()[Ljava/lang/String;") \ METHOD (getJuceAndroidMidiOutputDevices, "getJuceAndroidMidiOutputDevices", "()[Ljava/lang/String;") \ @@ -89,9 +92,9 @@ public: jbyte* data = getEnv()->GetByteArrayElements (byteArray, nullptr); HeapBlock buffer (static_cast (len)); - std::memcpy (buffer.getData(), data + offset, static_cast (len)); + std::memcpy (buffer.get(), data + offset, static_cast (len)); - midiConcatenator.pushMidiData (buffer.getData(), + midiConcatenator.pushMidiData (buffer.get(), len, static_cast (timestamp) * 1.0e-9, juceMidiInput, *callback); @@ -357,3 +360,5 @@ MidiInput::~MidiInput() { delete reinterpret_cast (internal); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index d1dd6be331..9da627fe0d 100644 --- a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICFIELD (SDK_INT, "SDK_INT", "I") \ @@ -289,12 +291,32 @@ public: nextBlock (0), numBlocksOut (0) {} + ~OpenSLQueueRunner() + { + if (config != nullptr && javaProxy != nullptr) + { + javaProxy.clear(); + (*config)->ReleaseJavaProxy (config, SL_ANDROID_JAVA_PROXY_ROUTING); + } + } + bool init() { runner = crtp().createPlayerOrRecorder(); if (runner == nullptr) return false; + // may return nullptr on some platforms - that's ok + config = SlRef::cast (runner); + if (config != nullptr) + { + jobject audioRoutingJni; + auto status = (*config)->AcquireJavaProxy (config, SL_ANDROID_JAVA_PROXY_ROUTING, &audioRoutingJni); + + if (status == SL_RESULT_SUCCESS && audioRoutingJni != 0) + javaProxy = GlobalRef (audioRoutingJni); + } + queue = SlRef::cast (runner); if (queue == nullptr) return false; @@ -308,7 +330,7 @@ public: nextBlock.set (0); numBlocksOut.set (0); - zeromem (nativeBuffer.getData(), static_cast (owner.bufferSize * numChannels * owner.numBuffers) * sizeof (T)); + zeromem (nativeBuffer.get(), static_cast (owner.bufferSize * numChannels * owner.numBuffers) * sizeof (T)); scratchBuffer.clear(); (*queue)->Clear (queue); } @@ -321,7 +343,7 @@ public: bool isBufferAvailable() const { return (numBlocksOut.get() < owner.numBuffers); } T* getNextBuffer() { nextBlock.set((nextBlock.get() + 1) % owner.numBuffers); return getCurrentBuffer(); } - T* getCurrentBuffer() { return nativeBuffer.getData() + (static_cast (nextBlock.get()) * getBufferSizeInSamples()); } + T* getCurrentBuffer() { return nativeBuffer.get() + (static_cast (nextBlock.get()) * getBufferSizeInSamples()); } size_t getBufferSizeInSamples() const { return static_cast (owner.bufferSize * numChannels); } void finished (SLAndroidSimpleBufferQueueItf) @@ -345,6 +367,8 @@ public: SlRef runner; SlRef queue; + SlRef config; + GlobalRef javaProxy; int numChannels; @@ -377,12 +401,12 @@ public: SLDataSource source = {&queueLocator, &dataFormat}; SLDataSink sink = {&outputMix, nullptr}; - SLInterfaceID queueInterfaces[] = { &IntfIID::iid }; - SLboolean trueFlag = SL_BOOLEAN_TRUE; + SLInterfaceID queueInterfaces[] = { &IntfIID::iid, &IntfIID::iid }; + SLboolean interfaceRequired[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE}; SLObjectItf obj = nullptr; - SLresult status = (*Base::owner.engine)->CreateAudioPlayer (Base::owner.engine, &obj, &source, &sink, 1, queueInterfaces, &trueFlag); + SLresult status = (*Base::owner.engine)->CreateAudioPlayer (Base::owner.engine, &obj, &source, &sink, 2, queueInterfaces, interfaceRequired); if (status != SL_RESULT_SUCCESS || obj == nullptr || (*obj)->Realize (obj, 0) != SL_RESULT_SUCCESS) { if (obj != nullptr) @@ -435,15 +459,12 @@ public: SlRef recorder = SlRef::cast (SlObjectRef (obj)); - // may return nullptr on some platforms - that's ok - config = SlRef::cast (recorder); - return recorder; } bool setAudioPreprocessingEnabled (bool shouldEnable) { - if (config != nullptr) + if (Base::config != nullptr) { const bool supportsUnprocessed = (getEnv()->GetStaticIntField (AndroidBuildVersion, AndroidBuildVersion.SDK_INT) >= 25); const SLuint32 recordingPresetValue @@ -451,8 +472,8 @@ public: : (supportsUnprocessed ? SL_ANDROID_RECORDING_PRESET_UNPROCESSED : SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION)); - SLresult status = (*config)->SetConfiguration (config, SL_ANDROID_KEY_RECORDING_PRESET, - &recordingPresetValue, sizeof (recordingPresetValue)); + SLresult status = (*Base::config)->SetConfiguration (Base::config, SL_ANDROID_KEY_RECORDING_PRESET, + &recordingPresetValue, sizeof (recordingPresetValue)); return (status == SL_RESULT_SUCCESS); } @@ -461,8 +482,6 @@ public: } void setState (bool running) { (*Base::runner)->SetRecordState (Base::runner, running ? SL_RECORDSTATE_RECORDING : SL_RECORDSTATE_STOPPED); } - - SlRef config; }; //============================================================================== @@ -519,6 +538,7 @@ public: virtual void stop() { running = false; } virtual bool setAudioPreprocessingEnabled (bool shouldEnable) = 0; virtual bool supportsFloatingPoint() const noexcept = 0; + virtual int getXRunCount() const noexcept = 0; void setCallback (AudioIODeviceCallback* callbackToUse) { @@ -676,6 +696,14 @@ public: return true; } + int getXRunCount() const noexcept override + { + if (player != nullptr && player->javaProxy != nullptr) + return getEnv()->CallIntMethod (player->javaProxy, AudioTrack.getUnderrunCount); + + return -1; + } + bool supportsFloatingPoint() const noexcept override { return (BufferHelpers::isFloatingPoint != 0); } void doSomeWorkOnAudioThread() @@ -890,6 +918,7 @@ public: BigInteger getActiveInputChannels() const override { return activeInputChans; } String getLastError() override { return lastError; } bool isPlaying() override { return callback != nullptr; } + int getXRunCount() const noexcept override { return (session != nullptr ? session->getXRunCount() : -1); } int getDefaultBufferSize() override { @@ -1203,11 +1232,11 @@ public: pthread_t startThread (void* (*entry) (void*), void* userPtr) { - memset (buffer.getData(), 0, static_cast (sizeof (int16) * static_cast (bufferSize * numBuffers))); + memset (buffer.get(), 0, static_cast (sizeof (int16) * static_cast (bufferSize * numBuffers))); for (int i = 0; i < numBuffers; ++i) { - int16* dst = buffer.getData() + (bufferSize * i); + int16* dst = buffer.get() + (bufferSize * i); (*queue)->Enqueue (queue, dst, static_cast (static_cast (bufferSize) * sizeof (int16))); } @@ -1283,3 +1312,5 @@ pthread_t juce_createRealtimeAudioThread (void* (*entry) (void*), void* userPtr) return threadID; } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/modules/juce_audio_devices/native/juce_ios_Audio.cpp index ad69dad3c8..432bb228bd 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_ios_Audio.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class iOSAudioIODevice; static const char* const iOSAudioDeviceName = "iOS Audio"; @@ -183,6 +186,10 @@ bool getNotificationValueForKey (NSNotification* notification, NSString* key, NS @end //============================================================================== +#if JUCE_MODULE_AVAILABLE_juce_graphics + #include +#endif + namespace juce { #ifndef JUCE_IOS_AUDIO_LOGGING @@ -206,10 +213,6 @@ static void logNSError (NSError* e) #define JUCE_NSERROR_CHECK(X) { NSError* error = nil; X; logNSError (error); } -#if JUCE_MODULE_AVAILABLE_juce_graphics -#include -#endif - //============================================================================== struct iOSAudioIODevice::Pimpl : public AudioPlayHead, public AsyncUpdater @@ -310,6 +313,9 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, { close(); + firstHostTime = true; + lastNumFrames = 0; + xrun = 0; lastError.clear(); preferredBufferSize = bufferSize <= 0 ? defaultBufferSize : bufferSize; @@ -711,6 +717,8 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, { OSStatus err = noErr; + recordXruns (time, numFrames); + if (audioInputIsAvailable && numInputChannels > 0) err = AudioUnitRender (audioUnit, flags, time, 1, numFrames, data); @@ -796,6 +804,26 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, updateSampleRateAndAudioInput(); } + void recordXruns (const AudioTimeStamp* time, UInt32 numFrames) + { + if (time != nullptr && (time->mFlags & kAudioTimeStampSampleTimeValid) != 0) + { + if (! firstHostTime) + { + if ((time->mSampleTime - lastSampleTime) != lastNumFrames) + xrun++; + } + else + firstHostTime = false; + + lastSampleTime = time->mSampleTime; + } + else + firstHostTime = true; + + lastNumFrames = numFrames; + } + //============================================================================== static OSStatus processStatic (void* client, AudioUnitRenderActionFlags* flags, const AudioTimeStamp* time, UInt32 /*busNumber*/, UInt32 numFrames, AudioBufferList* data) @@ -1060,6 +1088,11 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, float* outputChannels[3]; bool monoInputChannelNumber, monoOutputChannelNumber; + bool firstHostTime; + Float64 lastSampleTime; + unsigned int lastNumFrames; + int xrun; + JUCE_DECLARE_NON_COPYABLE (Pimpl) }; @@ -1105,6 +1138,7 @@ BigInteger iOSAudioIODevice::getActiveInputChannels() const { return pim int iOSAudioIODevice::getOutputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].outputLatency); } int iOSAudioIODevice::getInputLatencyInSamples() { return roundToInt (pimpl->sampleRate * [AVAudioSession sharedInstance].inputLatency); } +int iOSAudioIODevice::getXRunCount() const noexcept { return pimpl->xrun; } void iOSAudioIODevice::setMidiMessageCollector (MidiMessageCollector* collector) { pimpl->messageCollector = collector; } AudioPlayHead* iOSAudioIODevice::getAudioPlayHead() const { return pimpl; } @@ -1168,3 +1202,5 @@ void AudioSessionHolder::handleRouteChange (const char* reason) } #undef JUCE_NSERROR_CHECK + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_ios_Audio.h b/modules/juce_audio_devices/native/juce_ios_Audio.h index bab7573845..b06be4d97d 100644 --- a/modules/juce_audio_devices/native/juce_ios_Audio.h +++ b/modules/juce_audio_devices/native/juce_ios_Audio.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct iOSAudioIODeviceType; @@ -61,6 +62,8 @@ public: int getOutputLatencyInSamples() override; int getInputLatencyInSamples() override; + int getXRunCount() const noexcept override; + //============================================================================== void setMidiMessageCollector (MidiMessageCollector*); AudioPlayHead* getAudioPlayHead() const; @@ -86,3 +89,5 @@ private: JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 0912f4e462..7a521f468f 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { @@ -75,7 +78,7 @@ static void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, uns JUCE_ALSA_LOG ("getDeviceNumChannels: " << (int) *minChans << " " << (int) *maxChans); // some virtual devices (dmix for example) report 10000 channels , we have to clamp these values - *maxChans = jmin (*maxChans, 32u); + *maxChans = jmin (*maxChans, 256u); *minChans = jmin (*minChans, *maxChans); } else @@ -155,7 +158,7 @@ public: isInput (forInput), isInterleaved (true) { - JUCE_ALSA_LOG ("snd_pcm_open (" << deviceID.toUTF8().getAddress() << ", forInput=" << forInput << ")"); + JUCE_ALSA_LOG ("snd_pcm_open (" << deviceID.toUTF8().getAddress() << ", forInput=" << (int) forInput << ")"); int err = snd_pcm_open (&handle, deviceID.toUTF8(), forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, @@ -241,7 +244,8 @@ public: (type & isFloatBit) != 0, (type & isLittleEndianBit) != 0, (type & onlyUseLower24Bits) != 0, - numChannels); + numChannels, + isInterleaved); break; } } @@ -329,8 +333,14 @@ public: numDone = snd_pcm_writen (handle, (void**) data, (snd_pcm_uframes_t) numSamples); } - if (numDone < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) numDone, 1 /* silent */))) - return false; + if (numDone < 0) + { + if (numDone == -(EPIPE)) + underrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) numDone, 1 /* silent */))) + return false; + } if (numDone < numSamples) JUCE_ALSA_LOG ("Did not write all samples: numDone: " << numDone << ", numSamples: " << numSamples); @@ -350,8 +360,15 @@ public: snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), (snd_pcm_uframes_t) numSamples); - if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) - return false; + if (num < 0) + { + if (num == -(EPIPE)) + overrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) + return false; + } + if (num < numSamples) JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); @@ -363,8 +380,14 @@ public: { snd_pcm_sframes_t num = snd_pcm_readn (handle, (void**) data, (snd_pcm_uframes_t) numSamples); - if (num < 0 && JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) - return false; + if (num < 0) + { + if (num == -(EPIPE)) + overrunCount++; + + if (JUCE_ALSA_FAILED (snd_pcm_recover (handle, (int) num, 1 /* silent */))) + return false; + } if (num < numSamples) JUCE_ALSA_LOG ("Did not read all samples: num: " << num << ", numSamples: " << numSamples); @@ -380,6 +403,7 @@ public: snd_pcm_t* handle; String error; int bitDepth, numChannelsRunning, latency; + int underrunCount = 0, overrunCount = 0; private: //============================================================================== @@ -393,44 +417,55 @@ private: template struct ConverterHelper { - static AudioData::Converter* createConverter (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels) + static AudioData::Converter* createConverter (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels, bool interleaved) + { + if (interleaved) + return create (forInput, isLittleEndian, numInterleavedChannels); + + return create (forInput, isLittleEndian, numInterleavedChannels); + } + + private: + template + static AudioData::Converter* create (const bool forInput, const bool isLittleEndian, const int numInterleavedChannels) { if (forInput) { typedef AudioData::Pointer DestType; if (isLittleEndian) - return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); + return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); - return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); + return new AudioData::ConverterInstance , DestType> (numInterleavedChannels, 1); } typedef AudioData::Pointer SourceType; if (isLittleEndian) - return new AudioData::ConverterInstance > (1, numInterleavedChannels); + return new AudioData::ConverterInstance > (1, numInterleavedChannels); - return new AudioData::ConverterInstance > (1, numInterleavedChannels); + return new AudioData::ConverterInstance > (1, numInterleavedChannels); } }; static AudioData::Converter* createConverter (bool forInput, int bitDepth, bool isFloat, bool isLittleEndian, bool useOnlyLower24Bits, - int numInterleavedChannels) + int numInterleavedChannels, + bool interleaved) { - JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" << isFloat - << ", isLittleEndian=" << isLittleEndian << ", numChannels=" << numInterleavedChannels); + JUCE_ALSA_LOG ("format: bitDepth=" << bitDepth << ", isFloat=" << (int) isFloat + << ", isLittleEndian=" << (int) isLittleEndian << ", numChannels=" << numInterleavedChannels); - if (isFloat) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); - if (bitDepth == 16) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); - if (bitDepth == 24) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + if (isFloat) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); + if (bitDepth == 16) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); + if (bitDepth == 24) return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); jassert (bitDepth == 32); if (useOnlyLower24Bits) - return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); - return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels); + return ConverterHelper ::createConverter (forInput, isLittleEndian, numInterleavedChannels, interleaved); } //============================================================================== @@ -734,6 +769,19 @@ public: return 16; } + int getXRunCount() const noexcept + { + int result = 0; + + if (outputDevice != nullptr) + result += outputDevice->underrunCount; + + if (inputDevice != nullptr) + result += inputDevice->overrunCount; + + return result; + } + //============================================================================== String error; double sampleRate; @@ -893,6 +941,8 @@ public: int getOutputLatencyInSamples() override { return internal.outputLatency; } int getInputLatencyInSamples() override { return internal.inputLatency; } + int getXRunCount() const noexcept override { return internal.getXRunCount(); } + void start (AudioIODeviceCallback* callback) override { if (! isOpen_) @@ -1037,7 +1087,7 @@ private: if ((isInput || isOutput) && rates.size() > 0) { JUCE_ALSA_LOG ("testDevice: '" << id.toUTF8().getAddress() << "' -> isInput: " - << isInput << ", isOutput: " << isOutput); + << (int) isInput << ", isOutput: " << (int) isOutput); if (isInput) { @@ -1128,7 +1178,8 @@ private: } JUCE_ALSA_LOG ("Soundcard ID: " << id << ", name: '" << name - << ", isInput:" << isInput << ", isOutput:" << isOutput << "\n"); + << ", isInput:" << (int) isInput + << ", isOutput:" << (int) isOutput << "\n"); if (isInput) { @@ -1259,3 +1310,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { return createAudioIODeviceType_ALSA_PCMDevices(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp index 482437e893..35302a3160 100644 --- a/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp +++ b/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + static void* juce_libjackHandle = nullptr; static void* juce_loadJackFunction (const char* const name) @@ -67,6 +69,7 @@ JUCE_DECL_JACK_FUNCTION (void*, jack_set_port_connect_callback, (jack_client_t* JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_by_id, (jack_client_t* client, jack_port_id_t port_id), (client, port_id)); JUCE_DECL_JACK_FUNCTION (int, jack_port_connected, (const jack_port_t* port), (port)); JUCE_DECL_JACK_FUNCTION (int, jack_port_connected_to, (const jack_port_t* port, const char* port_name), (port, port_name)); +JUCE_DECL_JACK_FUNCTION (int, jack_set_xrun_callback, (jack_client_t* client, JackXRunCallback xrun_callback, void* arg), (client, xrun_callback, arg)); #if JUCE_DEBUG #define JACK_LOGGING_ENABLED 1 @@ -256,9 +259,11 @@ public: lastError.clear(); close(); + xruns = 0; juce::jack_set_process_callback (client, processCallback, this); juce::jack_set_port_connect_callback (client, portConnectCallback, this); juce::jack_on_shutdown (client, shutdownCallback, this); + juce::jack_set_xrun_callback (client, xrunCallback, this); juce::jack_activate (client); deviceIsOpen = true; @@ -300,6 +305,8 @@ public: if (client != nullptr) { juce::jack_deactivate (client); + + juce::jack_set_xrun_callback (client, xrunCallback, nullptr); juce::jack_set_process_callback (client, processCallback, nullptr); juce::jack_set_port_connect_callback (client, portConnectCallback, nullptr); juce::jack_on_shutdown (client, shutdownCallback, nullptr); @@ -336,6 +343,7 @@ public: bool isPlaying() override { return callback != nullptr; } int getCurrentBitDepth() override { return 32; } String getLastError() override { return lastError; } + int getXRunCount() const noexcept override { return xruns; } BigInteger getActiveOutputChannels() const override { return activeOutputChannels; } BigInteger getActiveInputChannels() const override { return activeInputChannels; } @@ -406,6 +414,14 @@ private: return 0; } + static int xrunCallback (void* callbackArgument) + { + if (callbackArgument != nullptr) + ((JackAudioIODevice*) callbackArgument)->xruns++; + + return 0; + } + void updateActivePorts() { BigInteger newOutputChannels, newInputChannels; @@ -475,6 +491,8 @@ private: int totalNumberOfOutputChannels; Array inputPorts, outputPorts; BigInteger activeInputChannels, activeOutputChannels; + + int xruns; }; @@ -602,3 +620,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() { return new JackAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 74bbe4131b..ef4dfade87 100644 --- a/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_ALSA // You can define these strings in your app if you want to override the default names: @@ -137,7 +140,7 @@ public: numBytes -= numSent; data += numSent; - snd_seq_ev_set_source (&event, portId); + snd_seq_ev_set_source (&event, (unsigned char) portId); snd_seq_ev_set_subs (&event); snd_seq_ev_set_direct (&event); @@ -610,3 +613,5 @@ MidiInput* MidiInput::openDevice (int, MidiInputCallback*) { re MidiInput* MidiInput::createNewDevice (const String&, MidiInputCallback*) { return nullptr; } #endif + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 80758de9f3..0bd8f3fbcb 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_COREAUDIO_LOGGING_ENABLED #define JUCE_COREAUDIOLOG(a) { String camsg ("CoreAudio: "); camsg << a; Logger::writeToLog (camsg); } #else @@ -228,7 +231,7 @@ public: for (int i = 0; i < numStreams; ++i) { - const ::AudioBuffer& b = bufList->mBuffers[i]; + auto& b = bufList->mBuffers[i]; for (unsigned int j = 0; j < b.mNumberChannels; ++j) { @@ -578,6 +581,8 @@ public: stop (false); + updateDetailsFromDevice(); + activeInputChans = inputChannels; activeInputChans.setRange (inChanNames.size(), activeInputChans.getHighestBit() + 1 - inChanNames.size(), @@ -733,7 +738,7 @@ public: } } - callback->audioDeviceIOCallback (const_cast (tempInputBuffers.getData()), + callback->audioDeviceIOCallback (const_cast (tempInputBuffers.get()), numInputChans, tempOutputBuffers, numOutputChans, @@ -791,6 +796,7 @@ public: int inputLatency = 0; int outputLatency = 0; int bitDepth = 32; + int xruns = 0; BigInteger activeInputChans, activeOutputChans; StringArray inChanNames, outChanNames; Array sampleRates; @@ -832,6 +838,9 @@ private: switch (pa->mSelector) { + case kAudioDeviceProcessorOverload: + intern->xruns++; + break; case kAudioDevicePropertyBufferSize: case kAudioDevicePropertyBufferFrameSize: case kAudioDevicePropertyNominalSampleRate: @@ -957,6 +966,7 @@ public: double getCurrentSampleRate() override { return internal->getSampleRate(); } int getCurrentBitDepth() override { return internal->bitDepth; } int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); } + int getXRunCount() const noexcept override { return internal->xruns; } int getDefaultBufferSize() override { @@ -977,6 +987,7 @@ public: { isOpen_ = true; + internal->xruns = 0; if (bufferSizeSamples <= 0) bufferSizeSamples = getDefaultBufferSize(); @@ -2058,3 +2069,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() } #undef JUCE_COREAUDIOLOG + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 4abff0f094..cd98d478e6 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_LOG_COREMIDI_ERRORS #define JUCE_LOG_COREMIDI_ERRORS 1 #endif @@ -555,3 +558,5 @@ void MidiInput::stop() } #undef CHECK_ERROR + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index e6d88aa13f..2c11bdd230 100644 --- a/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/modules/juce_audio_devices/native/juce_win32_ASIO.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #undef WINDOWS /* The ASIO SDK *should* declare its callback functions as being __cdecl, but different versions seem @@ -406,6 +409,8 @@ public: Array getAvailableBufferSizes() override { return bufferSizes; } int getDefaultBufferSize() override { return preferredBufferSize; } + int getXRunCount() const noexcept override { return xruns; } + String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sr, int bufferSizeSamples) override @@ -461,6 +466,9 @@ public: err = asioObject->getChannels (&totalNumInputChans, &totalNumOutputChans); jassert (err == ASE_OK); + if (asioObject->future (kAsioCanReportOverload, nullptr) != ASE_OK) + xruns = -1; + inBuffers.calloc (totalNumInputChans + 8); outBuffers.calloc (totalNumOutputChans + 8); @@ -786,6 +794,7 @@ private: bool volatile littleEndian, postOutput, needToReset; bool volatile insideControlPanelModalLoop; bool volatile shouldUsePreferredSize; + int xruns = 0; //============================================================================== static String convertASIOString (char* const text, int length) @@ -1177,6 +1186,7 @@ private: totalNumOutputChans = 0; numActiveInputChans = 0; numActiveOutputChans = 0; + xruns = 0; currentCallback = nullptr; error.clear(); @@ -1346,7 +1356,7 @@ private: { case kAsioSelectorSupported: if (value == kAsioResetRequest || value == kAsioEngineVersion || value == kAsioResyncRequest - || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor) + || value == kAsioLatenciesChanged || value == kAsioSupportsInputMonitor || value == kAsioOverload) return 1; break; @@ -1357,7 +1367,8 @@ private: case kAsioEngineVersion: return 2; case kAsioSupportsTimeInfo: - case kAsioSupportsTimeCode: return 0; + case kAsioSupportsTimeCode: return 0; + case kAsioOverload: xruns++; return 1; } return 0; @@ -1643,3 +1654,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return new ASIOAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 031be1892c..10ea41abae 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -20,8 +20,6 @@ ============================================================================== */ -} // (juce namespace) - extern "C" { // Declare just the minimum number of interfaces for the DSound objects that we need.. @@ -268,6 +266,10 @@ public: pDirectSound = nullptr; pOutputBuffer = nullptr; writeOffset = 0; + xruns = 0; + + firstPlayTime = true; + lastPlayTime = 0; String error; HRESULT hr = E_NOINTERFACE; @@ -278,6 +280,7 @@ public: if (SUCCEEDED (hr)) { bytesPerBuffer = (bufferSizeSamples * (bitDepth >> 2)) & ~15; + ticksPerBuffer = bytesPerBuffer * Time::getHighResolutionTicksPerSecond() / (sampleRate * (bitDepth >> 2)); totalBytesPerBuffer = (blocksPerOverallBuffer * bytesPerBuffer) & ~15; const int numChannels = 2; @@ -399,6 +402,18 @@ public: return true; } + auto currentPlayTime = Time::getHighResolutionTicks (); + if (! firstPlayTime) + { + auto expectedBuffers = (currentPlayTime - lastPlayTime) / ticksPerBuffer; + + playCursor += static_cast (expectedBuffers * bytesPerBuffer); + } + else + firstPlayTime = false; + + lastPlayTime = currentPlayTime; + int playWriteGap = (int) (writeCursor - playCursor); if (playWriteGap < 0) playWriteGap += totalBytesPerBuffer; @@ -411,6 +426,9 @@ public: { writeOffset = writeCursor; bytesEmpty = totalBytesPerBuffer - playWriteGap; + + // buffer underflow + xruns++; } if (bytesEmpty >= bytesPerBuffer) @@ -482,7 +500,7 @@ public: } } - int bitDepth; + int bitDepth, xruns; bool doneFlag; private: @@ -498,6 +516,9 @@ private: int totalBytesPerBuffer, bytesPerBuffer; unsigned int lastPlayCursor; + bool firstPlayTime; + int64 lastPlayTime, ticksPerBuffer; + static inline int convertInputValues (const float l, const float r) noexcept { return jlimit (-32768, 32767, roundToInt (32767.0f * r)) << 16 @@ -856,6 +877,11 @@ public: bool isPlaying() override { return isStarted && isOpen_ && isThreadRunning(); } String getLastError() override { return lastError; } + int getXRunCount () const noexcept override + { + return (outChans[0] != nullptr ? outChans[0]->xruns : -1); + } + //============================================================================== StringArray inChannels, outChannels; int outputDeviceIndex, inputDeviceIndex; @@ -1271,3 +1297,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() { return new DSoundAudioIODeviceType(); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/modules/juce_audio_devices/native/juce_win32_Midi.cpp index b614f71387..c45ab2dc53 100644 --- a/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MidiServiceType { struct InputWrapper @@ -27,7 +30,6 @@ struct MidiServiceType virtual ~InputWrapper() {} virtual String getDeviceName() = 0; - virtual void start() = 0; virtual void stop() = 0; }; @@ -37,7 +39,6 @@ struct MidiServiceType virtual ~OutputWrapper() {} virtual String getDeviceName() = 0; - virtual void sendMessageNow (const MidiMessage&) = 0; }; @@ -47,10 +48,8 @@ struct MidiServiceType virtual StringArray getDevices (bool) = 0; virtual int getDefaultDeviceIndex (bool) = 0; - virtual InputWrapper* createInputWrapper (MidiInput* const, - const int, - MidiInputCallback* const callback) = 0; - virtual OutputWrapper* createOutputWrapper (const int) = 0; + virtual InputWrapper* createInputWrapper (MidiInput*, int, MidiInputCallback*) = 0; + virtual OutputWrapper* createOutputWrapper (int) = 0; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiServiceType) }; @@ -510,14 +509,12 @@ public: : WindowsOutputWrapper::getDefaultDeviceIndex(); } - InputWrapper* createInputWrapper (MidiInput* const input, - const int index, - MidiInputCallback* const callback) override + InputWrapper* createInputWrapper (MidiInput* input, int index, MidiInputCallback* callback) override { return new WindowsInputWrapper (*this, input, index, callback); } - OutputWrapper* createOutputWrapper (const int index) override + OutputWrapper* createOutputWrapper (int index) override { return new WindowsOutputWrapper (*this, index); } @@ -1001,7 +998,7 @@ private: if (bufferFactory == nullptr) throw std::runtime_error ("Failed to create output buffer factory"); - HRESULT hr = bufferFactory->Create (static_cast (256), buffer.resetAndGetPointerAddress()); + HRESULT hr = bufferFactory->Create (static_cast (65536), buffer.resetAndGetPointerAddress()); if (FAILED (hr)) throw std::runtime_error ("Failed to create output buffer"); @@ -1081,14 +1078,12 @@ public: : outputDeviceWatcher->getDefaultDeviceIndex(); } - InputWrapper* createInputWrapper (MidiInput* const input, - const int index, - MidiInputCallback* const callback) override + InputWrapper* createInputWrapper (MidiInput* input, int index, MidiInputCallback* callback) override { return new WinRTInputWrapper (*this, input, index, *callback); } - OutputWrapper* createOutputWrapper (const int index) override + OutputWrapper* createOutputWrapper (int index) override { return new WinRTOutputWrapper (*this, index); } @@ -1169,8 +1164,9 @@ MidiInput* MidiInput::openDevice (const int index, MidiInputCallback* const call if (callback == nullptr) return nullptr; - ScopedPointer in (new MidiInput ("")); + ScopedPointer in (new MidiInput ({})); ScopedPointer wrapper; + try { wrapper = MidiService::getInstance()->getService()->createInputWrapper (in, index, callback); @@ -1207,6 +1203,7 @@ int MidiOutput::getDefaultDeviceIndex() MidiOutput* MidiOutput::openDevice (const int index) { ScopedPointer wrapper; + try { wrapper = MidiService::getInstance()->getService()->createOutputWrapper (index); @@ -1229,6 +1226,7 @@ MidiOutput::~MidiOutput() void MidiOutput::sendMessageNow (const MidiMessage& message) { - auto* const wrapper = static_cast (internal); - wrapper->sendMessageNow (message); + static_cast (internal)->sendMessageNow (message); } + +} // namespace juce diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 7fb96aaee3..d0380d7897 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_WASAPI_LOGGING #define JUCE_WASAPI_LOGGING 0 #endif @@ -125,7 +128,12 @@ enum EDataFlow enum { - DEVICE_STATE_ACTIVE = 1, + DEVICE_STATE_ACTIVE = 1 +}; + +enum +{ + AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY = 1, AUDCLNT_BUFFERFLAGS_SILENT = 2 }; @@ -739,6 +747,7 @@ public: reservoirMask = nextPowerOfTwo (reservoirSize) - 1; reservoir.setSize ((reservoirMask + 1) * bytesPerFrame, true); reservoirReadPos = reservoirWritePos = 0; + xruns = 0; if (! check (client->Start())) return false; @@ -771,6 +780,9 @@ public: while (check (captureClient->GetBuffer (&inputData, &numSamplesAvailable, &flags, nullptr, nullptr)) && numSamplesAvailable > 0) { + if ((flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) + xruns++; + int samplesLeft = (int) numSamplesAvailable; while (samplesLeft > 0) @@ -835,7 +847,7 @@ public: ComSmartPtr captureClient; MemoryBlock reservoir; - int reservoirSize, reservoirMask; + int reservoirSize, reservoirMask, xruns; volatile int reservoirReadPos, reservoirWritePos; ScopedPointer converter; @@ -1072,7 +1084,7 @@ public: BigInteger getActiveOutputChannels() const override { return outputDevice != nullptr ? outputDevice->channels : BigInteger(); } BigInteger getActiveInputChannels() const override { return inputDevice != nullptr ? inputDevice->channels : BigInteger(); } String getLastError() override { return lastError; } - + int getXRunCount () const noexcept override { return inputDevice != nullptr ? inputDevice->xruns : -1; } String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double sampleRate, int bufferSizeSamples) override @@ -1715,3 +1727,5 @@ float JUCE_CALLTYPE SystemAudioVolume::getGain() { return WasapiCla bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return WasapiClasses::MMDeviceMasterVolume().setGain (gain); } bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { return WasapiClasses::MMDeviceMasterVolume().isMuted(); } bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool mute) { return WasapiClasses::MMDeviceMasterVolume().setMuted (mute); } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp index 90525e01b8..b03ca9a93f 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AudioSourcePlayer::AudioSourcePlayer() : source (nullptr), sampleRate (0), @@ -178,3 +181,5 @@ void AudioSourcePlayer::audioDeviceStopped() tempBuffer.setSize (2, 8); } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h index 8ef1760679..d624b0a578 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer) }; + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp index 31610633b0..bbc3d8ae48 100644 --- a/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp @@ -20,22 +20,10 @@ ============================================================================== */ +namespace juce +{ + AudioTransportSource::AudioTransportSource() - : source (nullptr), - resamplerSource (nullptr), - bufferingSource (nullptr), - positionableSource (nullptr), - masterSource (nullptr), - gain (1.0f), - lastGain (1.0f), - playing (false), - stopped (true), - sampleRate (44100.0), - sourceSampleRate (0.0), - blockSize (128), - readAheadBufferSize (0), - isPrepared (false), - inputStreamEOF (false) { } @@ -159,7 +147,7 @@ void AudioTransportSource::setPosition (double newPosition) double AudioTransportSource::getCurrentPosition() const { if (sampleRate > 0.0) - return getNextReadPosition() / sampleRate; + return (double) getNextReadPosition() / sampleRate; return 0.0; } @@ -167,7 +155,7 @@ double AudioTransportSource::getCurrentPosition() const double AudioTransportSource::getLengthInSeconds() const { if (sampleRate > 0.0) - return getTotalLength() / sampleRate; + return (double) getTotalLength() / sampleRate; return 0.0; } @@ -177,7 +165,7 @@ void AudioTransportSource::setNextReadPosition (int64 newPosition) if (positionableSource != nullptr) { if (sampleRate > 0 && sourceSampleRate > 0) - newPosition = (int64) (newPosition * sourceSampleRate / sampleRate); + newPosition = (int64) ((double) newPosition * sourceSampleRate / sampleRate); positionableSource->setNextReadPosition (newPosition); @@ -193,7 +181,7 @@ int64 AudioTransportSource::getNextReadPosition() const if (positionableSource != nullptr) { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return (int64) (positionableSource->getNextReadPosition() * ratio); + return (int64) ((double) positionableSource->getNextReadPosition() * ratio); } return 0; @@ -206,7 +194,7 @@ int64 AudioTransportSource::getTotalLength() const if (positionableSource != nullptr) { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return (int64) (positionableSource->getTotalLength() * ratio); + return (int64) ((double) positionableSource->getTotalLength() * ratio); } return 0; @@ -294,3 +282,5 @@ void AudioTransportSource::getNextAudioBlock (const AudioSourceChannelInfo& info lastGain = gain; } + +} // namespace juce diff --git a/modules/juce_audio_devices/sources/juce_AudioTransportSource.h b/modules/juce_audio_devices/sources/juce_AudioTransportSource.h index 36cb8f5a2a..90103dad6b 100644 --- a/modules/juce_audio_devices/sources/juce_AudioTransportSource.h +++ b/modules/juce_audio_devices/sources/juce_AudioTransportSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -155,20 +155,22 @@ public: private: //============================================================================== - PositionableAudioSource* source; - ResamplingAudioSource* resamplerSource; - BufferingAudioSource* bufferingSource; - PositionableAudioSource* positionableSource; - AudioSource* masterSource; + PositionableAudioSource* source = nullptr; + ResamplingAudioSource* resamplerSource = nullptr; + BufferingAudioSource* bufferingSource = nullptr; + PositionableAudioSource* positionableSource = nullptr; + AudioSource* masterSource = nullptr; CriticalSection callbackLock; - float volatile gain, lastGain; - bool volatile playing, stopped; - double sampleRate, sourceSampleRate; - int blockSize, readAheadBufferSize; - bool volatile isPrepared, inputStreamEOF; + float volatile gain = 1.0f, lastGain = 1.0f; + bool volatile playing = false, stopped = true; + double sampleRate = 44100.0, sourceSampleRate = 0; + int blockSize = 128, readAheadBufferSize = 0; + bool volatile isPrepared = false, inputStreamEOF = false; void releaseMasterResources(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioTransportSource) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/flac/compat.h b/modules/juce_audio_formats/codecs/flac/compat.h index 543f49e83a..f97b1939e6 100644 --- a/modules/juce_audio_formats/codecs/flac/compat.h +++ b/modules/juce_audio_formats/codecs/flac/compat.h @@ -161,7 +161,7 @@ extern "C" { int flac_snprintf(char *str, size_t size, const char *fmt, ...); int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va); #ifdef __cplusplus -}; +} #endif #endif /* FLAC__SHARE__COMPAT_H */ diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 40619c54c8..f3c8c8053d 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static const char* const aiffFormatName = "AIFF file"; //============================================================================== @@ -1015,3 +1018,5 @@ AudioFormatWriter* AiffAudioFormat::createWriterFor (OutputStream* out, return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h index efafaa73ad..cd4c5f43a6 100644 --- a/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== /** Reads and Writes AIFF format audio files. @@ -85,3 +88,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AiffAudioFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 4808fd85fc..72d0aa9740 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp @@ -28,6 +28,9 @@ #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" +namespace juce +{ + //============================================================================== namespace { @@ -389,11 +392,11 @@ public: caLayout.malloc (1, static_cast (sizeOfLayout)); status = AudioFileGetProperty (audioFileID, kAudioFilePropertyChannelLayout, - &sizeOfLayout, caLayout.getData()); + &sizeOfLayout, caLayout.get()); if (status == noErr) { - auto fileLayout = CoreAudioLayouts::fromCoreAudio (*caLayout.getData()); + auto fileLayout = CoreAudioLayouts::fromCoreAudio (*caLayout.get()); if (fileLayout.size() == static_cast (numChannels)) { @@ -697,7 +700,7 @@ private: //============================================================================== const Array& getAllKnownLayoutTags() const { - static Array knownTags ({ + static CoreAudioChannelLayoutTag tags[] = { DEFINE_CHANNEL_LAYOUT_TAG_ENTRY (kAudioChannelLayoutTag_Mono, AudioChannelSet::mono()), DEFINE_CHANNEL_LAYOUT_TAG_ENTRY (kAudioChannelLayoutTag_Stereo, AudioChannelSet::stereo()), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_StereoHeadphones), @@ -821,7 +824,8 @@ private: DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_A), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_8_1_B), DEFINE_CHANNEL_LAYOUT_DFL_ENTRY (kAudioChannelLayoutTag_DTS_6_1_D) - }); + }; + static Array knownTags (tags, sizeof (tags) / sizeof (CoreAudioChannelLayoutTag)); return knownTags; } @@ -830,4 +834,7 @@ private: static CoreAudioLayoutsUnitTest coreAudioLayoutsUnitTest; #endif + +} // namespace juce + #endif diff --git a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h index dd5b54ab8b..878d84e0f6 100644 --- a/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC || JUCE_IOS || DOXYGEN //============================================================================== @@ -77,3 +80,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 0c6b267595..05c3c44eac 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_FLAC } @@ -449,14 +452,14 @@ public: if (samplesToWrite[i] == nullptr) break; - int* const destData = temp.getData() + i * (size_t) numSamples; + int* const destData = temp.get() + i * (size_t) numSamples; channels[i] = destData; for (int j = 0; j < numSamples; ++j) destData[j] = (samplesToWrite[i][j] >> bitsToShift); } - samplesToWrite = const_cast (channels.getData()); + samplesToWrite = const_cast (channels.get()); } return FLAC__stream_encoder_process (encoder, (const FLAC__int32**) samplesToWrite, (unsigned) numSamples) != 0; @@ -621,3 +624,5 @@ StringArray FlacAudioFormat::getQualityOptions() } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h index 8b3c43e4fd..fe61e3c59e 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_FLAC || defined (DOXYGEN) //============================================================================== @@ -65,3 +68,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 78b61d9045..01b39ea247 100644 --- a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_LAME_AUDIO_FORMAT class LAMEEncoderAudioFormat::Writer : public AudioFormatWriter @@ -225,3 +228,5 @@ AudioFormatWriter* LAMEEncoderAudioFormat::createWriterFor (OutputStream* stream } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h index dc0290d944..45b578842d 100644 --- a/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_LAME_AUDIO_FORMAT || defined (DOXYGEN) //============================================================================== @@ -71,3 +74,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index bfc987db3d..238eb4f3ea 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* IMPORTANT DISCLAIMER: By choosing to enable the JUCE_USE_MP3AUDIOFORMAT flag and to compile this MP3 code into your software, you do so AT YOUR OWN RISK! By doing so, @@ -3161,3 +3164,5 @@ AudioFormatWriter* MP3AudioFormat::createWriterFor (OutputStream*, double /*samp } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h index 5d952d42f7..cde3298ec7 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_MP3AUDIOFORMAT || DOXYGEN //============================================================================== @@ -64,3 +67,5 @@ public: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 34a83caba8..0a2737bcab 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_OGGVORBIS #if JUCE_MAC && ! defined (__MACOSX__) @@ -537,3 +540,5 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source) } #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h index 416ecad200..c8f4704e54 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_OGGVORBIS || defined (DOXYGEN) //============================================================================== @@ -93,3 +96,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 9021d68142..565fecb6b5 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static const char* const wavFormatName = "WAV file"; //============================================================================== @@ -892,7 +895,7 @@ namespace WavFileHelpers return xml.getMemoryBlock(); } - }; + } //============================================================================== struct ExtensibleWavSubFormat @@ -1867,3 +1870,5 @@ private: static const WaveAudioFormatTests waveAudioFormatTests; #endif + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h index e18e8e207a..85580208f3 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== /** Reads and Writes WAV format audio files. @@ -218,3 +221,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WavAudioFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 6e75610d34..3167ff3d0d 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace WindowsMediaCodec { @@ -353,3 +356,5 @@ AudioFormatWriter* WindowsMediaAudioFormat::createWriterFor (OutputStream* /*str jassertfalse; // not yet implemented! return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h index 39566f9ef9..97c746e299 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_WINDOWS || DOXYGEN //============================================================================== @@ -53,3 +56,5 @@ public: }; #endif + +} diff --git a/modules/juce_audio_formats/format/juce_AudioFormat.cpp b/modules/juce_audio_formats/format/juce_AudioFormat.cpp index a1cacb4b4a..5bad00afe9 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormat.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormat::AudioFormat (String name, StringArray extensions) : formatName (name), fileExtensions (extensions) { @@ -85,3 +88,5 @@ AudioFormatWriter* AudioFormat::createWriterFor (OutputStream* streamToWriteTo, return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormat.h b/modules/juce_audio_formats/format/juce_AudioFormat.h index 1db42e9797..bd8113fa31 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormat.h +++ b/modules/juce_audio_formats/format/juce_AudioFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -216,3 +216,5 @@ private: String formatName; StringArray fileExtensions; }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp index 62406fea64..33f26d4370 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatManager::AudioFormatManager() : defaultFormatIndex (0) {} AudioFormatManager::~AudioFormatManager() {} @@ -177,3 +180,5 @@ AudioFormatReader* AudioFormatManager::createReaderFor (InputStream* audioFileSt return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.h b/modules/juce_audio_formats/format/juce_AudioFormatManager.h index 7c2f9d4f58..246908a415 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index ccd002a0f3..7f29c83770 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatReader::AudioFormatReader (InputStream* const in, const String& name) : sampleRate (0), bitsPerSample (0), @@ -262,8 +265,8 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, HeapBlock tempSpace (bufferSize * 2 + 64); int* tempBuffer[3]; - tempBuffer[0] = tempSpace.getData(); - tempBuffer[1] = tempSpace.getData() + bufferSize; + tempBuffer[0] = tempSpace.get(); + tempBuffer[1] = tempSpace.get() + bufferSize; tempBuffer[2] = 0; int consecutive = 0; @@ -419,3 +422,5 @@ void MemoryMappedAudioFormatReader::touchSample (int64 sample) const noexcept else jassertfalse; // you must make sure that the window contains all the samples you're going to attempt to read. } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 8af863a8f2..5486892eea 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -24,7 +24,10 @@ ============================================================================== */ -#pragma once +namespace juce +{ + +class AudioFormat; //============================================================================== @@ -299,3 +302,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp index 38c589304c..9e6c567570 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatReaderSource::AudioFormatReaderSource (AudioFormatReader* const r, const bool deleteReaderWhenThisIsDeleted) : reader (r, deleteReaderWhenThisIsDeleted), @@ -85,3 +88,5 @@ void AudioFormatReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& i } } } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h index a44709ced7..3ad72c3601 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReaderSource) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index febf8a3259..c7ba031033 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioFormatWriter::AudioFormatWriter (OutputStream* const out, const String& formatName_, const double rate, @@ -358,3 +361,5 @@ void AudioFormatWriter::ThreadedWriter::setFlushInterval (int numSamplesPerFlush { buffer->setFlushInterval (numSamplesPerFlush); } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h index de89989314..c817e0bc06 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -294,3 +294,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatWriter) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp index 2ad71689dc..0fc827297a 100644 --- a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioSubsectionReader::AudioSubsectionReader (AudioFormatReader* const source_, const int64 startSample_, const int64 length_, @@ -66,3 +69,5 @@ void AudioSubsectionReader::readMaxLevels (int64 startSampleInFile, int64 numSam source->readMaxLevels (startSampleInFile + startSample, numSamples, results, numChannelsToRead); } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h index 63936138f1..523fb59cbf 100644 --- a/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h +++ b/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -80,3 +80,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSubsectionReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index da87e650d2..0980c00b23 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BufferingAudioReader::BufferingAudioReader (AudioFormatReader* sourceReader, TimeSliceThread& timeSliceThread, int samplesToBuffer) @@ -173,3 +176,5 @@ bool BufferingAudioReader::readNextBufferChunk() return true; } + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h index 5bdd312186..c8a4e1d8e5 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -89,3 +90,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferingAudioReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h index 93deee3862..4b9454c953 100644 --- a/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -108,3 +108,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedAudioFormatReader) }; + +} // namespace juce diff --git a/modules/juce_audio_formats/juce_audio_formats.cpp b/modules/juce_audio_formats/juce_audio_formats.cpp index ab3464dfc8..7f930e7e09 100644 --- a/modules/juce_audio_formats/juce_audio_formats.cpp +++ b/modules/juce_audio_formats/juce_audio_formats.cpp @@ -53,9 +53,6 @@ #endif //============================================================================== -namespace juce -{ - #include "format/juce_AudioFormat.cpp" #include "format/juce_AudioFormatManager.cpp" #include "format/juce_AudioFormatReader.cpp" @@ -75,5 +72,3 @@ namespace juce #if JUCE_WINDOWS && JUCE_USE_WINDOWS_MEDIA_FORMAT #include "codecs/juce_WindowsMediaAudioFormat.cpp" #endif - -} diff --git a/modules/juce_audio_formats/juce_audio_formats.h b/modules/juce_audio_formats/juce_audio_formats.h index deabf519ce..c1664704b2 100644 --- a/modules/juce_audio_formats/juce_audio_formats.h +++ b/modules/juce_audio_formats/juce_audio_formats.h @@ -35,7 +35,7 @@ ID: juce_audio_formats vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio file format codecs description: Classes for reading and writing various audio file formats. website: http://www.juce.com/juce @@ -110,10 +110,6 @@ #endif //============================================================================== -namespace juce -{ - -class AudioFormat; #include "format/juce_AudioFormatReader.h" #include "format/juce_AudioFormatWriter.h" #include "format/juce_MemoryMappedAudioFormatReader.h" @@ -131,5 +127,3 @@ class AudioFormat; #include "codecs/juce_WavAudioFormat.h" #include "codecs/juce_WindowsMediaAudioFormat.h" #include "sampler/juce_Sampler.h" - -} diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index eab9b01c5b..cb9aa5cf60 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SamplerSound::SamplerSound (const String& soundName, AudioFormatReader& source, const BigInteger& notes, @@ -224,3 +227,5 @@ void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSa } } } + +} // namespace juce diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.h b/modules/juce_audio_formats/sampler/juce_Sampler.h index 77df8e891a..68482d86be 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/modules/juce_audio_formats/sampler/juce_Sampler.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -142,3 +142,5 @@ private: JUCE_LEAK_DETECTOR (SamplerVoice) }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h b/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h index 7f2bb43815..bc73e38117 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Modifier_Injector.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct ModifierKeyProvider { @@ -38,3 +39,5 @@ struct ModifierKeyReceiver virtual void setModifierKeyProvider (ModifierKeyProvider*) = 0; virtual void removeModifierKeyProvider() = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 6f390c9f5d..c2b6820ded 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -32,6 +32,7 @@ #include "../utility/juce_IncludeSystemHeaders.h" #include "../utility/juce_IncludeModuleHeaders.h" #include "../utility/juce_WindowsHooks.h" +#include "../utility/juce_FakeMouseMoveGenerator.h" #ifdef __clang__ #pragma clang diagnostic push @@ -95,10 +96,9 @@ #undef check -namespace juce -{ - #include "juce_AAX_Modifier_Injector.h" -} +#include "juce_AAX_Modifier_Injector.h" + +using namespace juce; const int32_t juceChunkType = 'juce'; const int maxAAXChannels = 8; @@ -469,6 +469,8 @@ namespace AAXClasses setBounds (pluginEditor->getLocalBounds()); pluginEditor->addMouseListener (this, true); } + + ignoreUnused (fakeMouseGenerator); } ~ContentWrapperComponent() @@ -526,6 +528,7 @@ namespace AAXClasses #if JUCE_WINDOWS WindowsHooks hooks; #endif + FakeMouseMoveGenerator fakeMouseGenerator; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentWrapperComponent) }; @@ -900,7 +903,7 @@ namespace AAXClasses case AAX_eFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 30.0 * 1000.0 / 1001.0; break; case AAX_eFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; case AAX_eFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; - case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 24.0 * 1000.0 / 1001.0; break; + case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps23976; framesPerSec = 24.0 * 1000.0 / 1001.0; break; default: break; } @@ -1344,8 +1347,14 @@ namespace AAXClasses const int parameterNumSteps = audioProcessor.getParameterNumSteps (parameterIndex); parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps); + + #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous : AAX_eParameterType_Discrete); + #else + parameter->SetType (audioProcessor.isParameterDiscrete (parameterIndex) ? AAX_eParameterType_Discrete + : AAX_eParameterType_Continuous); + #endif parameter->SetOrientation (audioProcessor.isParameterOrientationInverted (parameterIndex) ? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index f3d9a0e8e9..19b4ed209c 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -23,7 +23,6 @@ ============================================================================== */ - #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -51,6 +50,7 @@ #include #include #include +#include #include "CoreAudioUtilityClasses/MusicDeviceBase.h" /** The BUILD_AU_CARBON_UI flag lets you specify whether old-school carbon hosts are supported as @@ -84,10 +84,14 @@ #include "../../juce_audio_processors/format_types/juce_AU_Shared.h" //============================================================================== +using namespace juce; + static Array activePlugins, activeUIs; static const AudioUnitPropertyID juceFilterObjectPropertyID = 0x1a45ffe9; +template <> struct ContainerDeletePolicy { static void destroy (const __CFString* o) { if (o != nullptr) CFRelease (o); } }; + // make sure the audio processor is initialized before the AUBase class struct AudioProcessorHolder { @@ -525,7 +529,7 @@ public: const String text (String::fromCFString (pv->inString)); if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - pv->outValue = param->getValueForText (text); + pv->outValue = param->getValueForText (text) * getMaximumParameterValue (paramID); else pv->outValue = text.getFloatValue(); @@ -546,11 +550,12 @@ public: String text; if (AudioProcessorParameter* param = juceFilter->getParameters() [paramID]) - text = param->getText (value, 0); + text = param->getText (value / getMaximumParameterValue (paramID), 0); else text = String (value); pv->outString = text.toCFString(); + return noErr; } } @@ -803,6 +808,17 @@ public: } //============================================================================== + // When parameters are discrete we need to use integer values. + float getMaximumParameterValue (int parameterIndex) + { + #if JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + ignoreUnused (parameterIndex); + return 1.0f; + #else + return juceFilter->isParameterDiscrete (parameterIndex) ? (float) (juceFilter->getParameterNumSteps (parameterIndex) - 1) : 1.0f; + #endif + } + ComponentResult GetParameterInfo (AudioUnitScope inScope, AudioUnitParameterID inParameterID, AudioUnitParameterInfo& outParameterInfo) override @@ -811,7 +827,7 @@ public: if (inScope == kAudioUnitScope_Global && juceFilter != nullptr - && index < juceFilter->getNumParameters()) + && isPositiveAndBelow (index, juceFilter->getNumParameters())) { outParameterInfo.unit = kAudioUnitParameterUnit_Generic; outParameterInfo.flags = (UInt32) (kAudioUnitParameterFlag_IsWritable @@ -819,31 +835,43 @@ public: | kAudioUnitParameterFlag_HasCFNameString | kAudioUnitParameterFlag_ValuesHaveStrings); - #if JucePlugin_AUHighResolutionParameters + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE outParameterInfo.flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif const String name (juceFilter->getParameterName (index)); - // set whether the param is automatable (unnamed parameters aren't allowed to be automated) + // Set whether the param is automatable (unnamed parameters aren't allowed to be automated) if (name.isEmpty() || ! juceFilter->isParameterAutomatable (index)) outParameterInfo.flags |= kAudioUnitParameterFlag_NonRealTime; + const bool isParameterDiscrete = juceFilter->isParameterDiscrete (index); + + if (! isParameterDiscrete) + outParameterInfo.flags |= kAudioUnitParameterFlag_CanRamp; + if (juceFilter->isMetaParameter (index)) outParameterInfo.flags |= kAudioUnitParameterFlag_IsGlobalMeta; - // is this a meter? + // Is this a meter? if (((juceFilter->getParameterCategory (index) & 0xffff0000) >> 16) == 2) { outParameterInfo.flags &= ~kAudioUnitParameterFlag_IsWritable; outParameterInfo.flags |= kAudioUnitParameterFlag_MeterReadOnly | kAudioUnitParameterFlag_DisplayLogarithmic; outParameterInfo.unit = kAudioUnitParameterUnit_LinearGain; } + else + { + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + outParameterInfo.unit = isParameterDiscrete ? kAudioUnitParameterUnit_Indexed + : kAudioUnitParameterUnit_Generic; + #endif + } MusicDeviceBase::FillInParameterName (outParameterInfo, name.toCFString(), true); outParameterInfo.minValue = 0.0f; - outParameterInfo.maxValue = 1.0f; + outParameterInfo.maxValue = getMaximumParameterValue (index); outParameterInfo.defaultValue = juceFilter->getParameterDefaultValue (index); jassert (outParameterInfo.defaultValue >= outParameterInfo.minValue && outParameterInfo.defaultValue <= outParameterInfo.maxValue); @@ -854,6 +882,34 @@ public: return kAudioUnitErr_InvalidParameter; } + ComponentResult GetParameterValueStrings (AudioUnitScope inScope, + AudioUnitParameterID inParameterID, + CFArrayRef *outStrings) override + { + if (outStrings == nullptr) + return noErr; + + const int index = getJuceIndexForAUParameterID (inParameterID); + + if (inScope == kAudioUnitScope_Global + && juceFilter != nullptr + && isPositiveAndBelow (index, juceFilter->getNumParameters()) + && juceFilter->isParameterDiscrete (index)) + { + if (auto* valueStrings = parameterValueStringArrays[index]) + { + *outStrings = CFArrayCreate (NULL, + (const void **) valueStrings->getRawDataPointer(), + valueStrings->size(), + NULL); + + return noErr; + } + } + + return kAudioUnitErr_InvalidParameter; + } + ComponentResult GetParameter (AudioUnitParameterID inID, AudioUnitScope inScope, AudioUnitElement inElement, @@ -861,9 +917,10 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - const int index = getJuceIndexForAUParameterID (inID); + const auto index = getJuceIndexForAUParameterID (inID); + const auto normValue = juceFilter->getParameter (index); - outValue = juceFilter->getParameter (index); + outValue = normValue * getMaximumParameterValue (index); return noErr; } @@ -878,9 +935,8 @@ public: { if (inScope == kAudioUnitScope_Global && juceFilter != nullptr) { - const int index = getJuceIndexForAUParameterID (inID); - - juceFilter->setParameter (index, inValue); + const auto index = getJuceIndexForAUParameterID (inID); + juceFilter->setParameter (index, inValue / getMaximumParameterValue (index)); return noErr; } @@ -932,6 +988,7 @@ public: switch (lastTimeStamp.mSMPTETime.mType) { + case kSMPTETimeType2398: info.frameRate = AudioPlayHead::fps23976; break; case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break; case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break; case kSMPTETimeType30Drop: info.frameRate = AudioPlayHead::fps30drop; break; @@ -1295,8 +1352,15 @@ public: r.origin.y = r.origin.y + r.size.height - component.getHeight(); r.size.width = component.getWidth(); r.size.height = component.getHeight(); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [[view superview] setFrame: r]; [view setFrame: makeNSRect (component.getLocalBounds())]; + + [CATransaction commit]; + [view setNeedsDisplay: YES]; } @@ -1364,8 +1428,14 @@ public: NSRect r = [[view superview] frame]; r.size.width = editor->getWidth(); r.size.height = editor->getHeight(); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [[view superview] setFrame: r]; [view setFrame: makeNSRect (editor->getLocalBounds())]; + [CATransaction commit]; + [view setNeedsDisplay: YES]; } } @@ -1571,6 +1641,9 @@ private: //============================================================================== AudioUnitHelpers::ChannelRemapper mapper; + //============================================================================== + OwnedArray> parameterValueStringArrays; + //============================================================================== void pullInputAudio (AudioUnitRenderActionFlags& flags, const AudioTimeStamp& timestamp, const UInt32 nFrames) noexcept { @@ -1705,9 +1778,7 @@ private: if (usingManagedParameter) { - const int n = juceFilter->getNumParameters(); - - for (int i = 0; i < n; ++i) + for (int i = 0; i < numParams; ++i) { const AudioUnitParameterID auParamID = generateAUParameterIDForIndex (i); @@ -1726,6 +1797,40 @@ private: { Globals()->UseIndexedParameters (numParams); } + + #if JUCE_DEBUG + // Some hosts can't handle the huge numbers of discrete parameter values created when + // using the default number of steps. + for (auto* param : juceFilter->getParameters()) + if (param->isDiscrete()) + jassert (param->getNumSteps() != juceFilter->getDefaultNumParameterSteps()); + #endif + + parameterValueStringArrays.ensureStorageAllocated (numParams); + + for (int index = 0; index < numParams; ++index) + { + OwnedArray* stringValues = nullptr; + + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + if (juceFilter->isParameterDiscrete (index)) + { + if (auto* param = juceFilter->getParameters()[index]) + { + const auto numSteps = juceFilter->getParameterNumSteps (index); + stringValues = new OwnedArray(); + stringValues->ensureStorageAllocated (numSteps); + + const auto maxValue = getMaximumParameterValue (index); + + for (int i = 0; i < numSteps; ++i) + stringValues->add (CFStringCreateCopy (nullptr, (param->getText ((float) i / maxValue, 0)).toCFString())); ; + } + } + #endif + + parameterValueStringArrays.add (stringValues); + } } //============================================================================== diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index 56afdb4c0f..e12653f3d8 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -57,9 +57,10 @@ #error AUv3 needs Objective-C 2 support (compile with 64-bit) #endif +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 + #include "../utility/juce_IncludeSystemHeaders.h" #include "../utility/juce_IncludeModuleHeaders.h" -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" #include "../../juce_graphics/native/juce_mac_CoreGraphicsHelpers.h" #include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" @@ -82,7 +83,9 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" -// TODO: ask Timur: use SFINAE to automatically generate this for all NSObjects +using namespace juce; + +// TODO: use SFINAE to automatically generate this for all NSObjects template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy > { static void destroy (NSObject* o) { [o release]; } }; @@ -884,6 +887,7 @@ public: switch (lastTimeStamp.mSMPTETime.mType) { + case kSMPTETimeType2398: info.frameRate = AudioPlayHead::fps23976; break; case kSMPTETimeType24: info.frameRate = AudioPlayHead::fps24; break; case kSMPTETimeType25: info.frameRate = AudioPlayHead::fps25; break; case kSMPTETimeType2997: info.frameRate = AudioPlayHead::fps2997; break; @@ -1098,7 +1102,7 @@ private: | kAudioUnitParameterFlag_HasCFNameString | kAudioUnitParameterFlag_ValuesHaveStrings); - #if JucePlugin_AUHighResolutionParameters + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE flags |= (UInt32) kAudioUnitParameterFlag_IsHighResolution; #endif @@ -1383,7 +1387,7 @@ private: void valueChangedForObserver(AUParameterAddress, AUValue) { - // this will have already been handled bny valueChangedFromHost + // this will have already been handled by valueChangedFromHost } //============================================================================== diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp index 8aa575d254..7cc182dff9 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode1.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -75,3 +78,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp index fb11cdffb6..be77d203eb 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode2.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -63,3 +66,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp index 725d412a82..83f8b5e92a 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode3.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -78,3 +81,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h index 5e2a3094c7..d67f4e37e8 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_DigiCode_Header.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JucePlugin_Build_RTAS #ifdef _MSC_VER @@ -67,3 +68,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp index 5317d09a17..ce6bce646c 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_WinUtilities.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -151,3 +154,5 @@ void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow) #endif #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index 5be7565929..42c4f3f9f5 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #include "../../juce_core/system/juce_TargetPlatform.h" #include "../utility/juce_CheckSettingMacros.h" @@ -764,7 +767,7 @@ public: case ficFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 30.0 * 1000.0 / 1001.0; break; case ficFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break; case ficFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break; - case ficFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 24.0 * 1000.0 / 1001.0; break; + case ficFrameRate_23976: info.frameRate = AudioPlayHead::fps23976; framesPerSec = 24.0 * 1000.0 / 1001.0; break; default: info.frameRate = AudioPlayHead::fpsUnknown; break; } @@ -1043,3 +1046,5 @@ CProcessGroupInterface* CProcessGroup::CreateProcessGroup() } #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp index 7b8934b4c8..866c02afeb 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterApp.cpp @@ -41,16 +41,12 @@ // set it then by default we'll just create a simple one as below. #if ! JUCE_USE_CUSTOM_PLUGIN_STANDALONE_APP -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); +extern juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + +#include "juce_StandaloneFilterWindow.h" namespace juce { - #if JucePlugin_Enable_IAA && JUCE_IOS - #include "../../juce_audio_devices/native/juce_ios_Audio.h" - #endif - - #include "juce_StandaloneFilterWindow.h" -} //============================================================================== class StandaloneFilterApp : public JUCEApplication @@ -116,7 +112,16 @@ public: //============================================================================== void systemRequestedQuit() override { - quit(); + if (ModalComponentManager::getInstance()->cancelAllModalComponents()) + { + Timer::callAfterDelay (100, []() + { + if (auto app = JUCEApplicationBase::getInstance()) + app->systemRequestedQuit(); + }); + } + else + quit(); } protected: @@ -151,4 +156,6 @@ Image JUCE_CALLTYPE juce_getIAAHostIcon (int size) #endif #endif +} // namespace juce + #endif diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 45dafcd28a..06cb07599d 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -255,7 +256,7 @@ public: totalInChannels, totalOutChannels, totalOutChannels)); - o.content->setSize (500, 450); + o.content->setSize (500, 550); o.dialogTitle = TRANS("Audio/MIDI Settings"); o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId); @@ -787,9 +788,13 @@ private: shouldShowNotification = newInputMutedValue; notification.setVisible (shouldShowNotification); + #if JUCE_IOS || JUCE_ANDROID + resized(); + #else setSize (editor->getWidth(), editor->getHeight() + (shouldShowNotification ? NotificationArea::height : 0)); + #endif } void valueChanged (Value& value) override { inputMutedChanged (value.getValue()); } @@ -841,3 +846,5 @@ StandalonePluginHolder* StandalonePluginHolder::getInstance() return nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h b/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h index b08d8557f3..4a00dd3e20 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h +++ b/modules/juce_audio_plugin_client/VST/juce_VSTCallbackHandler.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** An interface to allow an AudioProcessor to receive VST specific calls from the host. @@ -41,3 +42,5 @@ struct VSTCallbackHandler void* ptr, float opt) = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index e0418dd5bf..37172c5673 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -59,6 +59,7 @@ #pragma warning (disable : 4458) #endif +#include #include "../../juce_audio_processors/format_types/juce_VSTInterface.h" #include "../../juce_audio_processors/format_types/juce_VSTMidiEventList.h" @@ -654,6 +655,7 @@ public: switch (ti->smpteRate) { + case vstSmpteRateFps239: rate = AudioPlayHead::fps23976; fps = 24.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps24: rate = AudioPlayHead::fps24; fps = 24.0; break; case vstSmpteRateFps25: rate = AudioPlayHead::fps25; fps = 25.0; break; case vstSmpteRateFps2997: rate = AudioPlayHead::fps2997; fps = 30.0 * 1000.0 / 1001.0; break; @@ -664,7 +666,6 @@ public: case vstSmpteRate16mmFilm: case vstSmpteRate35mmFilm: fps = 24.0; break; - case vstSmpteRateFps239: fps = 24.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps249: fps = 25.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps599: fps = 60.0 * 1000.0 / 1001.0; break; case vstSmpteRateFps60: fps = 60; break; @@ -1263,7 +1264,9 @@ public: { ed->setTopLeftPosition (0, 0); ed->setBounds (ed->getLocalArea (this, getLocalBounds())); - updateWindowSize(); + + if (! getHostType().isBitwigStudio()) + updateWindowSize(); } #if JUCE_MAC && ! JUCE_64BIT diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index f68244ca0e..11d91f39f5 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -204,17 +204,26 @@ public: Param (AudioProcessor& p, int index, Vst::ParamID paramID) : owner (p), paramIndex (index) { info.id = paramID; + toString128 (info.title, p.getParameterName (index)); toString128 (info.shortTitle, p.getParameterName (index, 8)); toString128 (info.units, p.getParameterLabel (index)); - const int numSteps = p.getParameterNumSteps (index); - info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); + info.stepCount = (Steinberg::int32) 0; + + #if ! JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + if (p.isParameterDiscrete (index)) + #endif + { + const int numSteps = p.getParameterNumSteps (index); + info.stepCount = (Steinberg::int32) (numSteps > 0 && numSteps < 0x7fffffff ? numSteps - 1 : 0); + } + info.defaultNormalizedValue = p.getParameterDefaultValue (index); jassert (info.defaultNormalizedValue >= 0 && info.defaultNormalizedValue <= 1.0f); info.unitId = Vst::kRootUnitId; - // is this a meter? + // Is this a meter? if (((p.getParameterCategory (index) & 0xffff0000) >> 16) == 2) info.flags = Vst::ParameterInfo::kIsReadOnly; else @@ -872,28 +881,22 @@ private: { if (rectToCheck != nullptr && component != nullptr) { - // checkSizeConstraint - auto juceRect = Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, - rectToCheck->right, rectToCheck->bottom); - if (auto* editor = component->pluginEditor.get()) { + // checkSizeConstraint + auto juceRect = editor->getLocalArea (component, Rectangle::leftTopRightBottom (rectToCheck->left, rectToCheck->top, + rectToCheck->right, rectToCheck->bottom)); if (auto* constrainer = editor->getConstrainer()) { - auto scaledMin = component->getLocalArea (editor, Rectangle (constrainer->getMinimumWidth(), - constrainer->getMinimumHeight())); - - auto scaledMax = component->getLocalArea (editor, Rectangle (constrainer->getMaximumWidth(), - constrainer->getMaximumHeight())); + Rectangle limits (0, 0, constrainer->getMaximumWidth(), constrainer->getMaximumHeight()); + constrainer->checkBounds (juceRect, editor->getBounds(), limits, false, false, false, false); - juceRect.setSize (jlimit (scaledMin.getWidth(), scaledMax.getWidth(), juceRect.getWidth()), - jlimit (scaledMin.getHeight(), scaledMax.getHeight(), juceRect.getHeight())); + juceRect = component->getLocalArea (editor, juceRect); + rectToCheck->right = rectToCheck->left + juceRect.getWidth(); + rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); } } - rectToCheck->right = rectToCheck->left + juceRect.getWidth(); - rectToCheck->bottom = rectToCheck->top + juceRect.getHeight(); - return kResultTrue; } @@ -1020,7 +1023,7 @@ private: #if JUCE_WINDOWS setSize (w, h); #else - if (owner.macHostWindow != nullptr && ! (host.isWavelab() || host.isReaper())) + if (owner.macHostWindow != nullptr && ! (host.isWavelab() || host.isReaper() || host.isBitwigStudio())) juce::setNativeHostWindowSizeVST (owner.macHostWindow, this, w, h, owner.isNSView); #endif @@ -1651,7 +1654,7 @@ public: bool getCurrentPosition (CurrentPositionInfo& info) override { info.timeInSamples = jmax ((juce::int64) 0, processContext.projectTimeSamples); - info.timeInSeconds = processContext.systemTime / 1000000000.0; + info.timeInSeconds = static_cast (info.timeInSamples) / processContext.sampleRate; info.bpm = jmax (1.0, processContext.tempo); info.timeSigNumerator = jmax (1, (int) processContext.timeSigNumerator); info.timeSigDenominator = jmax (1, (int) processContext.timeSigDenominator); @@ -1669,7 +1672,14 @@ public: { switch (processContext.frameRate.framesPerSecond) { - case 24: info.frameRate = AudioPlayHead::fps24; break; + case 24: + { + if ((processContext.frameRate.flags & Vst::FrameRate::kPullDownRate) != 0) + info.frameRate = AudioPlayHead::fps23976; + else + info.frameRate = AudioPlayHead::fps24; + } + break; case 25: info.frameRate = AudioPlayHead::fps25; break; case 29: info.frameRate = AudioPlayHead::fps30drop; break; @@ -1835,12 +1845,20 @@ public: auto numOutputBuses = pluginInstance->getBusCount (false); for (int i = 0; i < numInputBuses; ++i) - if (pluginInstance->getChannelLayoutOfBus (true, i).isDiscreteLayout()) + { + auto layout = pluginInstance->getChannelLayoutOfBus (true, i); + + if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; + } for (int i = 0; i < numOutputBuses; ++i) - if (pluginInstance->getChannelLayoutOfBus (false, i).isDiscreteLayout()) + { + auto layout = pluginInstance->getChannelLayoutOfBus (false, i); + + if (layout.isDiscreteLayout() && ! layout.isDisabled()) return false; + } return true; } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h index f30ac91462..c9e017bf71 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client.h +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client.h @@ -35,7 +35,7 @@ ID: juce_audio_plugin_client vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio plugin wrapper classes description: Classes for building VST, VST3, AudioUnit, AAX and RTAS plugins. website: http://www.juce.com/juce @@ -65,21 +65,31 @@ #define JUCE_FORCE_USE_LEGACY_PARAM_IDS 0 #endif +/** Config: JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + + Enable this if you want to force JUCE to use a legacy scheme for + identifying plug-in parameters as either continuous or discrete. + DAW projects with automation data written by an AudioUnit, VST3 or + AAX plug-in built with JUCE version 5.1.1 or earlier may load + incorrectly when opened by an AudioUnit, VST3 or AAX plug-in built + with JUCE version 5.1.2 and later. +*/ +#ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE + #define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 +#endif + /** Config: JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS Enable this if you want JUCE to use parameter ids which are compatible - to Studio One. Studio One ignores any parameter ids which are negative. + with Studio One. Studio One ignores any parameter ids which are negative. Enabling this option will make JUCE generate only positive parameter ids. - Note that if you have already released a plug-in prio to JUCE 4.3.0 then + Note that if you have already released a plug-in prior to JUCE 4.3.0 then enabling this will change your parameter ids making your plug-in incompatible to old automation data. - */ +*/ #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS #define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 #endif -namespace juce -{ - #include "utility/juce_PluginHostType.h" - #include "VST/juce_VSTCallbackHandler.h" -} +#include "utility/juce_PluginHostType.h" +#include "VST/juce_VSTCallbackHandler.h" diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp index 614cdbe52c..bd8ad92284 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp @@ -38,7 +38,7 @@ #endif #else - JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp); + JUCE_CREATE_APPLICATION_DEFINE(juce::StandaloneFilterApp) #endif JUCE_MAIN_FUNCTION_DEFINITION diff --git a/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h b/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h index b3e4b18474..0d0f8aa99f 100644 --- a/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h +++ b/modules/juce_audio_plugin_client/utility/juce_CarbonVisibility.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== #if JUCE_SUPPORT_CARBON && JUCE_MAC_WINDOW_VISIBITY_BODGE @@ -76,3 +77,5 @@ inline void removeWindowHidingHooks (Component* comp) inline void attachWindowHidingHooks (void*, void*, void*) {} inline void removeWindowHidingHooks (void*) {} #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h index c9559cc725..299ca4ceb3 100644 --- a/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h +++ b/modules/juce_audio_plugin_client/utility/juce_FakeMouseMoveGenerator.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC @@ -41,26 +42,52 @@ public: void timerCallback() override { // Workaround for windows not getting mouse-moves... - const Point screenPos (Desktop::getInstance().getMainMouseSource().getScreenPosition()); + auto screenPos = Desktop::getInstance().getMainMouseSource().getScreenPosition(); if (screenPos != lastScreenPos) { lastScreenPos = screenPos; - const ModifierKeys mods (ModifierKeys::getCurrentModifiers()); + auto mods = ModifierKeys::getCurrentModifiers(); if (! mods.isAnyMouseButtonDown()) - if (Component* const comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt())) - if (ComponentPeer* const peer = comp->getPeer()) + { + if (auto* comp = Desktop::getInstance().findComponentAt (screenPos.roundToInt())) + { + safeOldComponent = comp; + + if (auto* peer = comp->getPeer()) + { if (! peer->isFocused()) + { peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, peer->globalToLocal (screenPos), mods, MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis()); + } + } + } + else + { + if (safeOldComponent != nullptr) + { + if (auto* peer = safeOldComponent->getPeer()) + { + peer->handleMouseEvent (MouseInputSource::InputSourceType::mouse, { -1.0f, -1.0f }, mods, + MouseInputSource::invalidPressure, MouseInputSource::invalidOrientation, Time::currentTimeMillis()); + } + } + + safeOldComponent = nullptr; + } + } } } private: Point lastScreenPos; + WeakReference safeOldComponent; }; #else struct FakeMouseMoveGenerator {}; #endif + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h index f2e9efde84..701c4df909 100644 --- a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h +++ b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h @@ -24,12 +24,8 @@ ============================================================================== */ -#pragma once - #include "../juce_audio_plugin_client.h" -using namespace juce; - namespace juce { #define Component juce::Component @@ -47,4 +43,4 @@ namespace juce } } -extern AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType); +extern juce::AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (juce::AudioProcessor::WrapperType); diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h index b4963cd702..9835e8ad85 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h +++ b/modules/juce_audio_plugin_client/utility/juce_PluginHostType.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + //============================================================================== class PluginHostType { @@ -65,6 +68,8 @@ public: SteinbergCubase6, SteinbergCubase7, SteinbergCubase8, + SteinbergCubase8_5, + SteinbergCubase9, SteinbergCubaseGeneric, SteinbergNuendo3, SteinbergNuendo4, @@ -91,7 +96,7 @@ public: bool isAdobeAudition() const noexcept { return type == AdobeAudition; } bool isArdour() const noexcept { return type == Ardour; } bool isBitwigStudio() const noexcept { return type == BitwigStudio; } - bool isCubase() const noexcept { return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase5Bridged || type == SteinbergCubase6 || type == SteinbergCubase7 || type == SteinbergCubase8 || type == SteinbergCubaseGeneric; } + bool isCubase() const noexcept { return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase5Bridged || type == SteinbergCubase6 || type == SteinbergCubase7 || type == SteinbergCubase8 || type == SteinbergCubase8_5 || type == SteinbergCubase9 || type == SteinbergCubaseGeneric; } bool isCubase7orLater() const noexcept { return isCubase() && ! (type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubase6); } bool isCubaseBridged() const noexcept { return type == SteinbergCubase5Bridged; } bool isDaVinciResolve() const noexcept { return type == DaVinciResolve; } @@ -151,6 +156,8 @@ public: case SteinbergCubase6: return "Steinberg Cubase 6"; case SteinbergCubase7: return "Steinberg Cubase 7"; case SteinbergCubase8: return "Steinberg Cubase 8"; + case SteinbergCubase8_5: return "Steinberg Cubase 8.5"; + case SteinbergCubase9: return "Steinberg Cubase 9"; case SteinbergCubaseGeneric: return "Steinberg Cubase"; case SteinbergNuendo3: return "Steinberg Nuendo 3"; case SteinbergNuendo4: return "Steinberg Nuendo 4"; @@ -229,13 +236,15 @@ private: if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; if (hostFilename.containsIgnoreCase ("Cubase 6")) return SteinbergCubase6; if (hostFilename.containsIgnoreCase ("Cubase 7")) return SteinbergCubase7; - if (hostFilename.containsIgnoreCase ("Cubase 8")) return SteinbergCubase8; + if (hostPath.containsIgnoreCase ("Cubase 8.app")) return SteinbergCubase8; + if (hostPath.containsIgnoreCase ("Cubase 8.5.app")) return SteinbergCubase8_5; + if (hostPath.containsIgnoreCase ("Cubase 9.app")) return SteinbergCubase9; if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; if (hostPath.containsIgnoreCase ("Wavelab 8")) return SteinbergWavelab8; if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; if (hostFilename.containsIgnoreCase ("WaveBurner")) return WaveBurner; - if (hostFilename.contains ("Digital Performer")) return DigitalPerformer; + if (hostPath.containsIgnoreCase ("Digital Performer")) return DigitalPerformer; if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; if (hostPath.containsIgnoreCase ("Studio One")) return StudioOne; if (hostFilename.startsWithIgnoreCase ("Waveform")) return TracktionWaveform; @@ -259,13 +268,16 @@ private: if (hostFilename.startsWithIgnoreCase ("Waveform")) return TracktionWaveform; if (hostPath.containsIgnoreCase ("Tracktion 3")) return Tracktion3; if (hostFilename.containsIgnoreCase ("Tracktion")) return TracktionGeneric; - if (hostFilename.containsIgnoreCase ("Tracktion")) return TracktionGeneric; if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; if (hostFilename.containsIgnoreCase ("Cubase6")) return SteinbergCubase6; if (hostFilename.containsIgnoreCase ("Cubase7")) return SteinbergCubase7; - if (hostFilename.containsIgnoreCase ("Cubase8")) return SteinbergCubase8; + if (hostFilename.containsIgnoreCase ("Cubase8.exe")) return SteinbergCubase8; + if (hostFilename.containsIgnoreCase ("Cubase8.5.exe")) return SteinbergCubase8_5; + // Cubase 9 scans plug-ins with a separate executable "vst2xscanner" + if (hostFilename.containsIgnoreCase ("Cubase9.exe") + || hostPath.containsIgnoreCase ("Cubase 9")) return SteinbergCubase9; if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; if (hostPath.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; @@ -302,3 +314,5 @@ private: return UnknownHost; } }; + +} // namespace juce diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp index 757feae340..25ec16a99e 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp +++ b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp @@ -31,14 +31,13 @@ #include "../../juce_core/system/juce_TargetPlatform.h" #include "juce_IncludeModuleHeaders.h" -namespace juce -{ - AudioProcessor::WrapperType PluginHostType::jucePlugInClientCurrentWrapperType = AudioProcessor::wrapperType_Undefined; -} +using namespace juce; -//============================================================================== namespace juce { + +AudioProcessor::WrapperType PluginHostType::jucePlugInClientCurrentWrapperType = AudioProcessor::wrapperType_Undefined; + #ifndef JUCE_VST3_CAN_REPLACE_VST2 #define JUCE_VST3_CAN_REPLACE_VST2 1 #endif @@ -142,7 +141,7 @@ bool JUCE_API handleManufacturerSpecificVST2Opcode (int32 index, pointer_sized_i } #endif -} // namespace juce +} // namespace juce //============================================================================== /** Somewhere in the codebase of your plugin, you need to implement this function diff --git a/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h b/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h index 70f5503b1a..9407e7e710 100644 --- a/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h +++ b/modules/juce_audio_plugin_client/utility/juce_WindowsHooks.h @@ -28,9 +28,9 @@ namespace juce { - // This function is in juce_win32_Windowing.cpp - extern bool offerKeyMessageToJUCEWindow (MSG&); -} + +// This function is in juce_win32_Windowing.cpp +extern bool offerKeyMessageToJUCEWindow (MSG&); namespace { @@ -44,11 +44,11 @@ namespace if (numHookUsers++ == 0) { mouseWheelHook = SetWindowsHookEx (WH_MOUSE, mouseWheelHookCallback, - (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + (HINSTANCE) juce::Process::getCurrentModuleInstanceHandle(), GetCurrentThreadId()); keyboardHook = SetWindowsHookEx (WH_GETMESSAGE, keyboardHookCallback, - (HINSTANCE) Process::getCurrentModuleInstanceHandle(), + (HINSTANCE) juce::Process::getCurrentModuleInstanceHandle(), GetCurrentThreadId()); } } @@ -78,9 +78,9 @@ namespace // using a local copy of this struct to support old mingw libraries struct MOUSEHOOKSTRUCTEX_ : public MOUSEHOOKSTRUCT { DWORD mouseData; }; - const MOUSEHOOKSTRUCTEX_& hs = *(MOUSEHOOKSTRUCTEX_*) lParam; + auto& hs = *(MOUSEHOOKSTRUCTEX_*) lParam; - if (Component* const comp = Desktop::getInstance().findComponentAt (Point (hs.pt.x, hs.pt.y))) + if (auto* comp = Desktop::getInstance().findComponentAt ({ hs.pt.x, hs.pt.y })) if (comp->getWindowHandle() != 0) return PostMessage ((HWND) comp->getWindowHandle(), WM_MOUSEWHEEL, hs.mouseData & 0xffff0000, (hs.pt.x & 0xffff) | (hs.pt.y << 16)); @@ -106,4 +106,6 @@ namespace }; } +} // juce namespace + #endif diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 720260de4c..8b33d4d043 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace AudioPluginFormatHelpers { struct CallbackInvoker @@ -207,3 +210,5 @@ void AudioPluginFormat::createPluginInstanceOnMessageThread (const PluginDescrip createPluginInstance (description, initialSampleRate, initialBufferSize, completion, AudioPluginFormatHelpers::CallbackInvoker::staticCompletionCallback); } + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormat.h b/modules/juce_audio_processors/format/juce_AudioPluginFormat.h index f820257898..6eb08eb324 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormat.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -164,3 +164,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormat) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index d9e5551ce1..ceedf1705d 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PluginFormatManagerHelpers { struct ErrorCallbackOnMessageThread : public CallbackMessage @@ -176,3 +179,5 @@ bool AudioPluginFormatManager::doesPluginStillExist (const PluginDescription& de return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index 0be2c06b54..495c222919 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -134,3 +134,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormatManager) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/modules/juce_audio_processors/format_types/juce_AU_Shared.h index 71768e3b47..434326ff28 100644 --- a/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/modules/juce_audio_processors/format_types/juce_AU_Shared.h @@ -29,6 +29,9 @@ #define JUCE_STATE_DICTIONARY_KEY "jucePluginState" #endif +namespace juce +{ + struct AudioUnitHelpers { class ChannelRemapper @@ -84,12 +87,12 @@ struct AudioUnitHelpers layoutMapPtrStorage.calloc (static_cast (numBuses)); layoutMapStorage.calloc (static_cast (isInput ? totalInChannels : totalOutChannels)); - layoutMap = layoutMapPtrStorage. getData(); + layoutMap = layoutMapPtrStorage. get(); int ch = 0; for (int busIdx = 0; busIdx < numBuses; ++busIdx) { - layoutMap[busIdx] = layoutMapStorage.getData() + ch; + layoutMap[busIdx] = layoutMapStorage.get() + ch; ch += processor.getChannelCountOfBus (isInput, busIdx); } } @@ -138,7 +141,7 @@ struct AudioUnitHelpers { pushIdx = 0; popIdx = 0; - zeromem (channels.getData(), sizeof(float*) * static_cast (scratch.getNumChannels())); + zeromem (channels.get(), sizeof(float*) * static_cast (scratch.getNumChannels())); } //============================================================================== @@ -342,102 +345,102 @@ struct AudioUnitHelpers info.inChannels = 0; info.outChannels = 0; - return {&info, 1}; + return { &info, 1 }; } - else - { - auto layout = processor.getBusesLayout(); - auto maxNumChanToCheckFor = 9; - auto defaultInputs = processor.getChannelCountOfBus (true, 0); - auto defaultOutputs = processor.getChannelCountOfBus (false, 0); + auto layout = processor.getBusesLayout(); + auto maxNumChanToCheckFor = 9; + + auto defaultInputs = processor.getChannelCountOfBus (true, 0); + auto defaultOutputs = processor.getChannelCountOfBus (false, 0); - SortedSet supportedChannels; + SortedSet supportedChannels; - // add the current configuration - if (defaultInputs != 0 || defaultOutputs != 0) - supportedChannels.add ((defaultInputs << 16) | defaultOutputs); + // add the current configuration + if (defaultInputs != 0 || defaultOutputs != 0) + supportedChannels.add ((defaultInputs << 16) | defaultOutputs); - for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + { + auto inLayout = layout; + + if (auto* inBus = processor.getBus (true, 0)) + if (! isNumberOfChannelsSupported (inBus, inChanNum, inLayout)) + continue; + + for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) { - auto inLayout = layout; + auto outLayout = inLayout; - if (auto* inBus = processor.getBus (true, 0)) - if (! isNumberOfChannelsSupported (inBus, inChanNum, inLayout)) + if (auto* outBus = processor.getBus (false, 0)) + if (! isNumberOfChannelsSupported (outBus, outChanNum, outLayout)) continue; - for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) - { - auto outLayout = inLayout; + supportedChannels.add (((hasMainInputBus ? outLayout.getMainInputChannels() : 0) << 16) + | (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0)); + } + } - if (auto* outBus = processor.getBus (false, 0)) - if (! isNumberOfChannelsSupported (outBus, outChanNum, outLayout)) - continue; + auto hasInOutMismatch = false; - supportedChannels.add (((hasMainInputBus ? outLayout.getMainInputChannels() : 0) << 16) - | (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0)); - } - } + for (auto supported : supportedChannels) + { + auto numInputs = (supported >> 16) & 0xffff; + auto numOutputs = (supported >> 0) & 0xffff; - auto hasInOutMismatch = false; - for (auto supported : supportedChannels) + if (numInputs != numOutputs) { - auto numInputs = (supported >> 16) & 0xffff; - auto numOutputs = (supported >> 0) & 0xffff; - - if (numInputs != numOutputs) - { - hasInOutMismatch = true; - break; - } + hasInOutMismatch = true; + break; } + } - auto hasUnsupportedInput = ! hasMainInputBus, hasUnsupportedOutput = ! hasMainOutputBus; - for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) - { - auto channelConfiguration = (inChanNum << 16) | (hasInOutMismatch ? defaultOutputs : inChanNum); + auto hasUnsupportedInput = ! hasMainInputBus, hasUnsupportedOutput = ! hasMainOutputBus; - if (! supportedChannels.contains (channelConfiguration)) - { - hasUnsupportedInput = true; - break; - } - } + for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum) + { + auto channelConfiguration = (inChanNum << 16) | (hasInOutMismatch ? defaultOutputs : inChanNum); - for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) + if (! supportedChannels.contains (channelConfiguration)) { - auto channelConfiguration = ((hasInOutMismatch ? defaultInputs : outChanNum) << 16) | outChanNum; - - if (! supportedChannels.contains (channelConfiguration)) - { - hasUnsupportedOutput = true; - break; - } + hasUnsupportedInput = true; + break; } + } - for (auto supported : supportedChannels) + for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum) + { + auto channelConfiguration = ((hasInOutMismatch ? defaultInputs : outChanNum) << 16) | outChanNum; + + if (! supportedChannels.contains (channelConfiguration)) { - auto numInputs = (supported >> 16) & 0xffff; - auto numOutputs = (supported >> 0) & 0xffff; + hasUnsupportedOutput = true; + break; + } + } + + for (auto supported : supportedChannels) + { + auto numInputs = (supported >> 16) & 0xffff; + auto numOutputs = (supported >> 0) & 0xffff; - AUChannelInfo info; + AUChannelInfo info; - // see here: https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html - info.inChannels = static_cast (hasMainInputBus ? (hasUnsupportedInput ? numInputs : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0); - info.outChannels = static_cast (hasMainOutputBus ? (hasUnsupportedOutput ? numOutputs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0); + // see here: https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html + info.inChannels = static_cast (hasMainInputBus ? (hasUnsupportedInput ? numInputs : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0); + info.outChannels = static_cast (hasMainOutputBus ? (hasUnsupportedOutput ? numOutputs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0); - if (info.inChannels == -2 && info.outChannels == -2) - info.inChannels = -1; + if (info.inChannels == -2 && info.outChannels == -2) + info.inChannels = -1; - int j; - for (j = 0; j < channelInfo.size(); ++j) - if (info.inChannels == channelInfo.getReference (j).inChannels - && info.outChannels == channelInfo.getReference (j).outChannels) - break; + int j; + for (j = 0; j < channelInfo.size(); ++j) + if (info.inChannels == channelInfo.getReference (j).inChannels + && info.outChannels == channelInfo.getReference (j).outChannels) + break; - if (j >= channelInfo.size()) - channelInfo.add (info); - } + if (j >= channelInfo.size()) + channelInfo.add (info); } return channelInfo; @@ -447,7 +450,6 @@ struct AudioUnitHelpers { auto potentialSets = AudioChannelSet::channelSetsWithNumberOfChannels (static_cast (numChannels)); - for (auto set : potentialSets) { auto copy = inOutCurrentLayout; @@ -517,7 +519,7 @@ struct AudioUnitHelpers const int actualBuses = juceFilter->getBusCount (isInput); const int auNumBuses = getBusCount (juceFilter, isInput); - Array& buses = (isInput ? layout.inputBuses : layout.outputBuses); + auto& buses = (isInput ? layout.inputBuses : layout.outputBuses); for (int i = auNumBuses; i < actualBuses; ++i) buses.removeLast(); @@ -529,3 +531,5 @@ struct AudioUnitHelpers #endif } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h index 9ade640df8..a4d0e1b169 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)) || DOXYGEN //============================================================================== @@ -72,3 +75,5 @@ enum kAudioUnitProperty_SupportsMPE = 58 }; #endif + +} diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index ed05018b44..65b364950f 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -26,9 +26,6 @@ #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS) -} // (juce namespace) - -#include #if JUCE_MAC #include #include @@ -55,22 +52,13 @@ #include #endif -#include +#include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" +#include "../../juce_audio_devices/native/juce_MidiDataConcatenator.h" +#include "juce_AU_Shared.h" namespace juce { -#include "../../juce_audio_devices/native/juce_MidiDataConcatenator.h" - -#if JUCE_SUPPORT_CARBON - #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" -#endif - -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" - -#include "../../juce_audio_basics/native/juce_mac_CoreAudioLayouts.h" -#include "juce_AU_Shared.h" - // Change this to disable logging of various activities #ifndef AU_LOGGING #define AU_LOGGING 1 @@ -581,7 +569,7 @@ public: dataSize = expectedSize; err = AudioUnitGetProperty (audioUnit, kAudioUnitProperty_AudioChannelLayout, scope, - static_cast (i), layoutBuffer.getData(), &dataSize); + static_cast (i), layoutBuffer.get(), &dataSize); if (err != noErr || dataSize < expectedSize) return false; @@ -834,7 +822,7 @@ public: AudioUnitRenderActionFlags flags = 0; if (AUBuffer* buf = outputBufferList[i]) - AudioUnitRender (audioUnit, &flags, &timeStamp, static_cast (i), (UInt32) numSamples, buf->bufferList.getData()); + AudioUnitRender (audioUnit, &flags, &timeStamp, static_cast (i), (UInt32) numSamples, buf->bufferList.get()); } timeStamp.mSampleTime += numSamples; @@ -986,6 +974,22 @@ public: const String getParameterText (int index) override { return String (getParameter (index)); } + int getParameterNumSteps (int index) override + { + if (auto* p = parameters[index]) + return p->numSteps; + + return AudioProcessor::getDefaultNumParameterSteps(); + } + + bool isParameterDiscrete (int index) const override + { + if (auto* p = parameters[index]) + return p->discrete; + + return false; + } + bool isParameterAutomatable (int index) const override { if (auto* p = parameters[index]) @@ -1174,10 +1178,12 @@ public: ParamInfo* const param = new ParamInfo(); parameters.add (param); param->paramID = ids[i]; - paramIDToIndex[ids[i]] = i; + paramIDToIndex.getReference (ids[i]) = i; param->minValue = info.minValue; param->maxValue = info.maxValue; param->automatable = (info.flags & kAudioUnitParameterFlag_NonRealTime) == 0; + param->discrete = (info.unit == kAudioUnitParameterUnit_Indexed); + param->numSteps = param->discrete ? (int) (info.maxValue + 1.0f) : AudioProcessor::getDefaultNumParameterSteps(); if ((info.flags & kAudioUnitParameterFlag_HasCFNameString) != 0) { @@ -1232,14 +1238,14 @@ private: AUBuffer (size_t numBuffers) { bufferList.calloc (1, (sizeof (AudioBufferList) - sizeof (::AudioBuffer)) + (sizeof (::AudioBuffer) * numBuffers)); - AudioBufferList& buffer = *bufferList.getData(); + AudioBufferList& buffer = *bufferList.get(); buffer.mNumberBuffers = static_cast (numBuffers); } operator AudioBufferList&() { - return *bufferList.getData(); + return *bufferList.get(); } HeapBlock bufferList; @@ -1263,11 +1269,12 @@ private: UInt32 paramID; String name; AudioUnitParameterValue minValue, maxValue; - bool automatable; + bool automatable, discrete; + int numSteps; }; OwnedArray parameters; - std::unordered_map paramIDToIndex; + HashMap paramIDToIndex; MidiDataConcatenator midiConcatenator; CriticalSection midiInLock; @@ -1353,10 +1360,12 @@ private: || event.mEventType == kAudioUnitEvent_BeginParameterChangeGesture || event.mEventType == kAudioUnitEvent_EndParameterChangeGesture) { - auto it = paramIDToIndex.find (event.mArgument.mParameter.mParameterID); + auto paramID = event.mArgument.mParameter.mParameterID; - if (it != paramIDToIndex.end()) - paramIndex = (int) it->second; + if (! paramIDToIndex.contains (paramID)) + return; + + paramIndex = static_cast (paramIDToIndex [paramID]); if (! isPositiveAndBelow (paramIndex, parameters.size())) return; @@ -1721,7 +1730,7 @@ private: propertySize = static_cast (sizeof (AudioChannelLayoutTag) * numElements); if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedChannelLayoutTags, scope, - static_cast (busIdx), layoutTags.getData(), &propertySize) == noErr) + static_cast (busIdx), layoutTags.get(), &propertySize) == noErr) { for (int j = 0; j < static_cast (numElements); ++j) { @@ -1757,15 +1766,15 @@ private: channelInfos.malloc (static_cast (numChannelInfos)); propertySize = static_cast (sizeof (AUChannelInfo) * static_cast (numChannelInfos)); - if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, 0, channelInfos.getData(), &propertySize) != noErr) + if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, 0, channelInfos.get(), &propertySize) != noErr) numChannelInfos = 0; } else { numChannelInfos = 1; channelInfos.malloc (static_cast (numChannelInfos)); - channelInfos.getData()->inChannels = -1; - channelInfos.getData()->outChannels = -1; + channelInfos.get()->inChannels = -1; + channelInfos.get()->outChannels = -1; } } } @@ -2444,9 +2453,11 @@ bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc) FileSearchPath AudioUnitPluginFormat::getDefaultLocationsToSearch() { - return FileSearchPath(); + return {}; } #undef JUCE_AU_LOG +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 945f27263c..85f307ca2a 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -26,8 +26,6 @@ #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX -} // (juce namespace) - #include "ladspa.h" namespace juce @@ -715,4 +713,6 @@ FileSearchPath LADSPAPluginFormat::getDefaultLocationsToSearch() .replace (":", ";")); } +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h index 27f91276df..7002c51814 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_PLUGINHOST_LADSPA && JUCE_LINUX) || DOXYGEN //============================================================================== @@ -63,3 +66,5 @@ private: #endif + +} diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index 02a4b8a834..8df5f36ffa 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== #define JUCE_DECLARE_VST3_COM_REF_METHODS \ @@ -620,3 +621,5 @@ template <> struct VST3FloatAndDoubleBusMapCompositeHelper { static inline VST3BufferExchange::BusMap& get (VST3FloatAndDoubleBusMapComposite& impl) { return impl.doubleVersion; } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VST3Headers.h b/modules/juce_audio_processors/format_types/juce_VST3Headers.h index fc782e21f1..6a68bc210d 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Headers.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Headers.h @@ -24,8 +24,6 @@ ============================================================================== */ -#pragma once - // Wow, those Steinberg guys really don't worry too much about compiler warnings. #if _MSC_VER #pragma warning (disable: 4505) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index ae028b6900..48ade86b5c 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -26,16 +26,13 @@ #if JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS) -} // namespace juce - #include #include "juce_VST3Headers.h" +#include "juce_VST3Common.h" namespace juce { -#include "juce_VST3Common.h" - using namespace Steinberg; //============================================================================== @@ -207,6 +204,7 @@ static void toProcessContext (Vst::ProcessContext& context, AudioPlayHead* playH switch (position.frameRate) { + case AudioPlayHead::fps23976: fr.framesPerSecond = 24; fr.flags = FrameRate::kPullDownRate; break; case AudioPlayHead::fps24: fr.framesPerSecond = 24; fr.flags = 0; break; case AudioPlayHead::fps25: fr.framesPerSecond = 25; fr.flags = 0; break; case AudioPlayHead::fps2997: fr.framesPerSecond = 30; fr.flags = FrameRate::kPullDownRate; break; @@ -2186,14 +2184,16 @@ struct VST3PluginInstance : public AudioPluginInstance bool isInputChannelStereoPair (int channelIndex) const override { - return isPositiveAndBelow (channelIndex, getTotalNumInputChannels()) - && getBusInfo (true, true).channelCount == 2; + int busIdx; + return getOffsetInBusBufferForAbsoluteChannelIndex (true, channelIndex, busIdx) >= 0 + && getBusInfo (true, true, busIdx).channelCount == 2; } bool isOutputChannelStereoPair (int channelIndex) const override { - return isPositiveAndBelow (channelIndex, getTotalNumOutputChannels()) - && getBusInfo (false, true).channelCount == 2; + int busIdx; + return getOffsetInBusBufferForAbsoluteChannelIndex (false, channelIndex, busIdx) >= 0 + && getBusInfo (false, true, busIdx).channelCount == 2; } bool acceptsMidi() const override { return getBusInfo (true, false).channelCount > 0; } @@ -2247,30 +2247,54 @@ struct VST3PluginInstance : public AudioPluginInstance return toString (getParameterInfoForIndex (parameterIndex).title); } - float getParameter (int parameterIndex) override + const String getParameterText (int parameterIndex) override { if (editController != nullptr) { auto id = getParameterInfoForIndex (parameterIndex).id; - return (float) editController->getParamNormalized (id); + + Vst::String128 result; + warnOnFailure (editController->getParamStringByValue (id, editController->getParamNormalized (id), result)); + + return toString (result); } - return 0.0f; + return {}; } - const String getParameterText (int parameterIndex) override + int getParameterNumSteps (int parameterIndex) override { if (editController != nullptr) { - auto id = getParameterInfoForIndex (parameterIndex).id; + const auto numSteps = getParameterInfoForIndex (parameterIndex).stepCount; - Vst::String128 result; - warnOnFailure (editController->getParamStringByValue (id, editController->getParamNormalized (id), result)); + if (numSteps > 0) + return numSteps; + } - return toString (result); + return AudioProcessor::getDefaultNumParameterSteps(); + } + + bool isParameterDiscrete (int parameterIndex) const override + { + if (editController != nullptr) + { + const auto numSteps = getParameterInfoForIndex (parameterIndex).stepCount; + return numSteps > 0; } - return {}; + return false; + } + + float getParameter (int parameterIndex) override + { + if (editController != nullptr) + { + auto id = getParameterInfoForIndex (parameterIndex).id; + return (float) editController->getParamNormalized (id); + } + + return 0.0f; } void setParameter (int parameterIndex, float newValue) override @@ -2954,4 +2978,6 @@ FileSearchPath VST3PluginFormat::getDefaultLocationsToSearch() #endif } -#endif //JUCE_PLUGINHOST_VST3 +} // namespace juce + +#endif // JUCE_PLUGINHOST_VST3 diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h index 4adbcefafa..4c3f140b57 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if (JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS)) || DOXYGEN @@ -65,4 +66,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VST3PluginFormat) }; -#endif // JUCE_PLUGINHOST_VST3 +#endif // JUCE_PLUGINHOST_VST3 + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VSTCommon.h b/modules/juce_audio_processors/format_types/juce_VSTCommon.h index bda9ec84af..50494a7484 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTCommon.h +++ b/modules/juce_audio_processors/format_types/juce_VSTCommon.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== struct SpeakerMappings : private AudioChannelSet // (inheritance only to give easier access to items in the namespace) @@ -171,7 +172,7 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e return *this; } - const VstSpeakerConfiguration& get() const { return *storage.getData(); } + const VstSpeakerConfiguration& get() const { return *storage.get(); } private: JUCE_LEAK_DETECTOR (VstSpeakerConfigurationHolder) @@ -184,7 +185,7 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e + sizeof (VstIndividualSpeakerInfo) * static_cast (jmax (8, numChannels) - 8); storage.malloc (1, arrangementSize); - return storage.getData(); + return storage.get(); } void clear() @@ -293,3 +294,5 @@ struct SpeakerMappings : private AudioChannelSet // (inheritance only to give e return AudioChannelSet::unknown; } }; + +} // namespace juce diff --git a/modules/juce_audio_processors/format_types/juce_VSTInterface.h b/modules/juce_audio_processors/format_types/juce_VSTInterface.h index c8310a0022..4d31c312a0 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTInterface.h +++ b/modules/juce_audio_processors/format_types/juce_VSTInterface.h @@ -24,11 +24,8 @@ ============================================================================== */ -#pragma once #define JUCE_VSTINTERFACE_H_INCLUDED -#include "../../juce_core/juce_core.h" - using namespace juce; #if JUCE_MSVC diff --git a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h index d78d7e0db6..6665cb9ae3 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h +++ b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h @@ -27,7 +27,8 @@ // NB: this must come first, *before* the header-guard. #ifdef JUCE_VSTINTERFACE_H_INCLUDED -#pragma once +namespace juce +{ //============================================================================== /** Holds a set of VSTMidiEvent objects and makes it easy to add @@ -169,8 +170,8 @@ private: static VstEvent* allocateVSTEvent() { - VstEvent* const e = (VstEvent*) std::calloc (1, sizeof (VstMidiEvent) > sizeof (VstSysExEvent) ? sizeof (VstMidiEvent) - : sizeof (VstSysExEvent)); + auto e = (VstEvent*) std::calloc (1, sizeof (VstMidiEvent) > sizeof (VstSysExEvent) ? sizeof (VstMidiEvent) + : sizeof (VstSysExEvent)); e->type = vstMidiEventType; e->size = sizeof (VstMidiEvent); return e; @@ -185,4 +186,6 @@ private: } }; +} // namespace juce + #endif // JUCE_VSTINTERFACE_H_INCLUDED diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 11e311d684..716b274016 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -26,11 +26,6 @@ #if JUCE_PLUGINHOST_VST -//============================================================================== -#if JUCE_MAC && JUCE_SUPPORT_CARBON - #include "../../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" -#endif - //============================================================================== #undef PRAGMA_ALIGN_SUPPORTED @@ -55,7 +50,6 @@ using namespace Vst2; #pragma warning (disable: 4355) // ("this" used in initialiser list warning) #endif -//============================================================================== #include "juce_VSTMidiEventList.h" #if JUCE_MINGW @@ -78,6 +72,10 @@ using namespace Vst2; #define JUCE_VST_WRAPPER_INVOKE_MAIN effect = module->moduleMain (&audioMaster); #endif +//============================================================================== +namespace juce +{ + //============================================================================== namespace { @@ -228,38 +226,8 @@ static pointer_sized_int VSTINTERFACECALL audioMaster (VstEffectInterface*, int3 namespace { - static bool xErrorTriggered = false; - - static int temporaryErrorHandler (::Display*, XErrorEvent*) - { - xErrorTriggered = true; - return 0; - } - typedef void (*EventProcPtr) (XEvent* ev); - static EventProcPtr getPropertyFromXWindow (Window handle, Atom atom) - { - XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); - xErrorTriggered = false; - - int userSize; - unsigned long bytes, userCount; - unsigned char* data; - Atom userType; - - { - ScopedXDisplay xDisplay; - - XGetWindowProperty (xDisplay.display, handle, atom, 0, 1, false, AnyPropertyType, - &userType, &userSize, &userCount, &bytes, &data); - } - - XSetErrorHandler (oldErrorHandler); - - return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) : nullptr; - } - Window getChildWindow (Window windowToCheck) { Window rootWindow, parentWindow; @@ -276,55 +244,6 @@ namespace return 0; } - - static void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) - { - ev.xbutton.button = Button1; - ev.xbutton.state |= Button1Mask; - } - else if (e.mods.isRightButtonDown()) - { - ev.xbutton.button = Button3; - ev.xbutton.state |= Button3Mask; - } - else if (e.mods.isMiddleButtonDown()) - { - ev.xbutton.button = Button2; - ev.xbutton.state |= Button2Mask; - } - } - - static void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask; - } - - static void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) noexcept - { - if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask; - } - - static void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) noexcept - { - ignoreUnused (e); - - if (increment < 0) - { - ev.xbutton.button = Button5; - ev.xbutton.state |= Button5Mask; - } - else if (increment > 0) - { - ev.xbutton.button = Button4; - ev.xbutton.state |= Button4Mask; - } - } } #endif @@ -1626,8 +1545,8 @@ private: HeapBlock inArrBlock (1, true), outArrBlock (1, true); - auto* inArr = inArrBlock.getData(); - auto* outArr = outArrBlock.getData(); + auto* inArr = inArrBlock.get(); + auto* outArr = outArrBlock.get(); if (! getSpeakerArrangementWrapper (effect, inArr, outArr)) inArr = outArr = nullptr; @@ -1690,8 +1609,8 @@ private: { HeapBlock inArrBlock (1, true), outArrBlock (1, true); - auto* inArr = inArrBlock.getData(); - auto* outArr = outArrBlock.getData(); + auto* inArr = inArrBlock.get(); + auto* outArr = outArrBlock.get(); if (getSpeakerArrangementWrapper (effect, inArr, outArr)) return true; @@ -1782,6 +1701,7 @@ private: case AudioPlayHead::fps30: setHostTimeFrameRate (vstSmpteRateFps30, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps60: setHostTimeFrameRate (vstSmpteRateFps60, 60.0, position.timeInSeconds); break; + case AudioPlayHead::fps23976: setHostTimeFrameRateDrop (vstSmpteRateFps239, 24.0, position.timeInSeconds); break; case AudioPlayHead::fps2997: setHostTimeFrameRateDrop (vstSmpteRateFps2997, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps2997drop: setHostTimeFrameRateDrop (vstSmpteRateFps2997drop, 30.0, position.timeInSeconds); break; case AudioPlayHead::fps30drop: setHostTimeFrameRateDrop (vstSmpteRateFps30drop, 30.0, position.timeInSeconds); break; @@ -1824,7 +1744,7 @@ private: // always ensure that the buffer is at least as large as the maximum number of channels auto maxChannels = jmax (vstEffect->numInputChannels, vstEffect->numOutputChannels); - auto channels = channelBuffer.getData(); + auto channels = channelBuffer.get(); if (numChannels < maxChannels) { @@ -3050,4 +2970,6 @@ pointer_sized_int JUCE_CALLTYPE VSTPluginFormat::dispatcher (AudioPluginInstance void VSTPluginFormat::aboutToScanVSTShellPlugin (const PluginDescription&) {} +} // namespace juce + #endif diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h index c6793a20be..1edeb83e1e 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h @@ -26,6 +26,9 @@ #if (JUCE_PLUGINHOST_VST || DOXYGEN) +namespace juce +{ + //============================================================================== /** Implements a plugin format manager for VSTs. @@ -124,5 +127,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginFormat) }; +} // namespace juce #endif diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp index 5d1376f594..675784f1c2 100644 --- a/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/modules/juce_audio_processors/juce_audio_processors.cpp @@ -34,6 +34,7 @@ #endif #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 #include "juce_audio_processors.h" #include @@ -44,6 +45,7 @@ && ((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)) #include + #include "../juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h" #endif #endif @@ -58,6 +60,10 @@ #define JUCE_PLUGINHOST_VST3 0 #endif +#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS) + #include +#endif + //============================================================================== namespace juce { @@ -65,8 +71,8 @@ namespace juce static inline bool arrayContainsPlugin (const OwnedArray& list, const PluginDescription& desc) { - for (int i = list.size(); --i >= 0;) - if (list.getUnchecked(i)->isDuplicateOf (desc)) + for (auto* p : list) + if (p->isDuplicateOf (desc)) return true; return false; @@ -153,6 +159,8 @@ void AutoResizingNSViewComponentWithParent::timerCallback() override } #endif +} // namespace juce + #if JUCE_CLANG #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif @@ -175,5 +183,3 @@ void AutoResizingNSViewComponentWithParent::timerCallback() override #include "scanning/juce_PluginListComponent.cpp" #include "utilities/juce_AudioProcessorParameters.cpp" #include "utilities/juce_AudioProcessorValueTreeState.cpp" - -} diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index fb8e13e0bf..ff0b4f730e 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -35,7 +35,7 @@ ID: juce_audio_processors vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE audio processor classes description: Classes for loading and playing VST, AU, or internally-generated audio processors. website: http://www.juce.com/juce @@ -56,7 +56,6 @@ #include #include - //============================================================================== /** Config: JUCE_PLUGINHOST_VST Enables the VST audio plugin hosting classes. @@ -99,11 +98,6 @@ #endif //============================================================================== -//============================================================================== -namespace juce -{ - -class AudioProcessor; #include "processors/juce_AudioProcessorEditor.h" #include "processors/juce_AudioProcessorListener.h" #include "processors/juce_AudioProcessorParameter.h" @@ -128,5 +122,3 @@ class AudioProcessor; #include "utilities/juce_AudioParameterBool.h" #include "utilities/juce_AudioParameterChoice.h" #include "utilities/juce_AudioProcessorValueTreeState.h" - -} diff --git a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h index 8acc557922..5e5c21c50a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h +++ b/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginInstance) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 9db4d04124..8d695c79fb 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static ThreadLocalValue wrapperTypeBeingCreated; void JUCE_CALLTYPE AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::WrapperType type) @@ -627,6 +630,14 @@ int AudioProcessor::getDefaultNumParameterSteps() noexcept return 0x7fffffff; } +bool AudioProcessor::isParameterDiscrete (int index) const +{ + if (auto* p = managedParameters[index]) + return p->isDiscrete(); + + return false; +} + String AudioProcessor::getParameterLabel (int index) const { if (auto* p = managedParameters[index]) @@ -1405,11 +1416,12 @@ void AudioProcessorParameter::endChangeGesture() processor->endParameterChangeGesture (parameterIndex); } -bool AudioProcessorParameter::isOrientationInverted() const { return false; } -bool AudioProcessorParameter::isAutomatable() const { return true; } -bool AudioProcessorParameter::isMetaParameter() const { return false; } -AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; } -int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); } +bool AudioProcessorParameter::isOrientationInverted() const { return false; } +bool AudioProcessorParameter::isAutomatable() const { return true; } +bool AudioProcessorParameter::isMetaParameter() const { return false; } +AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; } +int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); } +bool AudioProcessorParameter::isDiscrete() const { return false; } String AudioProcessorParameter::getText (float value, int /*maximumStringLength*/) const { @@ -1446,3 +1458,5 @@ void AudioPlayHead::CurrentPositionInfo::resetToDefault() timeSigDenominator = 4; bpm = 120; } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 85054fbcbb..f1838bf662 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ struct PluginBusUtilities; @@ -1022,13 +1023,22 @@ public: virtual String getParameterText (int parameterIndex, int maximumStringLength); /** Returns the number of discrete steps that this parameter can represent. + The default return value if you don't implement this method is AudioProcessor::getDefaultNumParameterSteps(). + If your parameter is boolean, then you may want to make this return 2. + + If you want the host to display stepped automation values, rather than a + continuous interpolation between successive values, you should ensure that + isParameterDiscrete returns true. + The value that is returned may or may not be used, depending on the host. NOTE! This method will eventually be deprecated! It's recommended that you use AudioProcessorParameter::getNumSteps() instead. + + @see isParameterDiscrete */ virtual int getParameterNumSteps (int parameterIndex); @@ -1036,10 +1046,26 @@ public: NOTE! This method will eventually be deprecated! It's recommended that you use AudioProcessorParameter::getNumSteps() instead. + @see getParameterNumSteps */ static int getDefaultNumParameterSteps() noexcept; + /** Returns true if the parameter should take discrete, rather than continuous + values. + + If the parameter is boolean, this should return true (with getParameterNumSteps + returning 2). + + The value that is returned may or may not be used, depending on the host. + + NOTE! This method will eventually be deprecated! It's recommended that you use + AudioProcessorParameter::isDiscrete() instead. + + @see getParameterNumSteps + */ + virtual bool isParameterDiscrete (int parameterIndex) const; + /** Returns the default value for the parameter. By default, this just returns 0. The value that is returned may or may not be used, depending on the host. @@ -1120,8 +1146,8 @@ public: By default, this returns the "generic" category. NOTE! This method will eventually be deprecated! It's recommended that you use - AudioProcessorParameter::isMetaParameter() instead. - */ + AudioProcessorParameter::getCategory() instead. + */ virtual AudioProcessorParameter::Category getParameterCategory (int parameterIndex) const; /** Sends a signal to the host to tell it that the user is about to start changing this @@ -1611,3 +1637,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 60f5fcd7df..e7a3ace6f0 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioProcessorEditor::AudioProcessorEditor (AudioProcessor& p) noexcept : processor (p) { initialise(); @@ -182,3 +185,5 @@ void AudioProcessorEditor::setScaleFactor (float newScale) setTransform (AffineTransform::scale (newScale)); editorResized (true); } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index 672fea8fac..7017bd053c 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -24,9 +24,12 @@ ============================================================================== */ -#pragma once +namespace juce +{ +class AudioProcessor; class AudioProcessorEditorListener; + //============================================================================== /** Base class for the component that acts as the GUI for an AudioProcessor. @@ -184,6 +187,8 @@ private: void componentParentHierarchyChanged (Component&) override { ed.updatePeer(); } AudioProcessorEditor& ed; + + JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditorListener) }; //============================================================================== @@ -200,3 +205,5 @@ private: JUCE_DECLARE_NON_COPYABLE (AudioProcessorEditor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 046ef66725..ef59bc470e 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int AudioProcessorGraph::midiChannelIndex = 0x1000; //============================================================================== @@ -1695,3 +1698,5 @@ void AudioProcessorGraph::AudioGraphIOProcessor::setParentGraph (AudioProcessorG updateHostDisplay(); } } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index 432a6fa258..bfd21d1187 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -406,3 +407,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorGraph) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h b/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h index 7b6ef71e5e..7781af1fec 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ public: virtual void audioProcessorParameterChangeGestureEnd (AudioProcessor* processor, int parameterIndex); }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index 3abccb795a..8dc6e5eb0a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An abstract base class for parameter objects that can be added to an @@ -106,16 +106,32 @@ public: */ virtual String getLabel() const = 0; - /** Returns the number of discrete interval steps that this parameter's range - should be quantised into. + /** Returns the number of steps that this parameter's range should be quantised into. If you want a continuous range of values, don't override this method, and allow the default implementation to return AudioProcessor::getDefaultNumParameterSteps(). + If your parameter is boolean, then you may want to make this return 2. - The value that is returned may or may not be used, depending on the host. + + The value that is returned may or may not be used, depending on the host. If you + want the host to display stepped automation values, rather than a continuous + interpolation between successive values, you should override isDiscrete to return true. + + @see isDiscrete */ virtual int getNumSteps() const; + /** Returns whether the parameter uses discrete values, based on the result of + getNumSteps, or allows the host to select values continuously. + + This information may or may not be used, depending on the host. If you + want the host to display stepped automation values, rather than a continuous + interpolation between successive values, override this method to return true. + + @see getNumSteps + */ + virtual bool isDiscrete() const; + /** Returns a textual version of the supplied parameter value. The default implementation just returns the floating point value as a string, but this could do anything you need for a custom type @@ -152,9 +168,10 @@ public: outputGain = (1 << 16) | 1, /** The following categories tell the host that this parameter is a meter level value - and therefore read-only. Most hosts will display these type of parameters as - a meter in the generic view of your plug-in. Pro-Tools will also show the meter - in the mixer view. */ + and therefore read-only. Most hosts will display these type of parameters as + a meter in the generic view of your plug-in. Pro-Tools will also show the meter + in the mixer view. + */ inputMeter = (2 << 16) | 0, outputMeter = (2 << 16) | 1, compressorLimiterGainReductionMeter = (2 << 16) | 2, @@ -176,3 +193,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameter) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 32a2db8549..08f160932c 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ProcessorParameterPropertyComp : public PropertyComponent, private AudioProcessorListener, private Timer @@ -185,3 +188,5 @@ void GenericAudioProcessorEditor::resized() { panel.setBounds (getLocalBounds()); } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h index e5d54e5fa7..611d62129a 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GenericAudioProcessorEditor) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_PluginDescription.cpp b/modules/juce_audio_processors/processors/juce_PluginDescription.cpp index 445ca73f2a..6d885d722b 100644 --- a/modules/juce_audio_processors/processors/juce_PluginDescription.cpp +++ b/modules/juce_audio_processors/processors/juce_PluginDescription.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PluginDescription::PluginDescription() : uid (0), isInstrument (false), @@ -144,3 +147,5 @@ bool PluginDescription::loadFromXml (const XmlElement& xml) return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_PluginDescription.h b/modules/juce_audio_processors/processors/juce_PluginDescription.h index 046626a505..7642545a10 100644 --- a/modules/juce_audio_processors/processors/juce_PluginDescription.h +++ b/modules/juce_audio_processors/processors/juce_PluginDescription.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -152,3 +152,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (PluginDescription) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index 352b6c1c0b..f7c0bf71e0 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KnownPluginList::KnownPluginList() {} KnownPluginList::~KnownPluginList() {} @@ -580,3 +583,5 @@ bool KnownPluginList::CustomScanner::shouldExit() const noexcept return false; } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 9095873bd0..17ce28fb31 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -221,3 +221,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownPluginList) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp index 680e17edd3..1c68861b6a 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static StringArray readDeadMansPedalFile (const File& file) { StringArray lines; @@ -129,3 +132,5 @@ void PluginDirectoryScanner::applyBlacklistingsFromDeadMansPedal (KnownPluginLis for (auto& crashedPlugin : readDeadMansPedalFile (file)) list.addToBlacklist (crashedPlugin); } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h index c22ccf300c..200835a1e7 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h +++ b/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginDirectoryScanner) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index dd18d45e81..733842ffbe 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class PluginListComponent::TableModel : public TableListBoxModel { public: @@ -586,3 +589,5 @@ void PluginListComponent::scanFinished (const StringArray& failedFiles) + ":\n\n" + shortNames.joinIntoString (", ")); } + +} // namespace juce diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h index da60cd0ea9..df3ec367c8 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h index ff65cff8be..c664ce8014 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used as a boolean value. @@ -58,8 +61,11 @@ private: void setValue (float newValue) override; float getDefaultValue() const override; int getNumSteps() const override; + bool isDiscrete() const override; String getText (float, int) const override; float getValueForText (const String&) const override; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterBool) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h index c12432db07..dc711d5830 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used to select an indexed, named choice from a list. @@ -69,6 +72,7 @@ private: void setValue (float newValue) override; float getDefaultValue() const override; int getNumSteps() const override; + bool isDiscrete() const override; String getText (float, int) const override; float getValueForText (const String&) const override; @@ -78,3 +82,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterChoice) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h b/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h index e4c27e2ba5..c422749edf 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** A subclass of AudioProcessorParameter that provides an easy way to create a parameter which maps onto a given NormalisableRange. @@ -80,3 +83,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterFloat) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h b/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h index 91f0579769..4c2f02c33b 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h +++ b/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides a class of AudioProcessorParameter that can be used as an integer value with a given range. @@ -77,3 +80,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioParameterInt) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h index 2569c4d06e..d5d0052349 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** This abstract base class is used by some AudioProcessorParameter helper classes. @@ -62,3 +65,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorParameterWithID) }; + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp index eecd0cc6d3..88da76bc00 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // This file contains the implementations of the various AudioParameter[XYZ] classes.. @@ -124,6 +127,7 @@ float AudioParameterBool::getValue() const { retur void AudioParameterBool::setValue (float newValue) { value = newValue; } float AudioParameterBool::getDefaultValue() const { return defaultValue; } int AudioParameterBool::getNumSteps() const { return 2; } +bool AudioParameterBool::isDiscrete() const { return true; } float AudioParameterBool::getValueForText (const String& text) const { return text.getIntValue() != 0 ? 1.0f : 0.0f; } String AudioParameterBool::getText (float v, int /*length*/) const { return String ((int) (v > 0.5f ? 1 : 0)); } @@ -156,6 +160,7 @@ float AudioParameterChoice::getValue() const { retur void AudioParameterChoice::setValue (float newValue) { value = (float) convertFrom0to1 (newValue); } float AudioParameterChoice::getDefaultValue() const { return defaultValue; } int AudioParameterChoice::getNumSteps() const { return choices.size(); } +bool AudioParameterChoice::isDiscrete() const { return true; } float AudioParameterChoice::getValueForText (const String& text) const { return convertTo0to1 (choices.indexOf (text)); } String AudioParameterChoice::getText (float v, int /*length*/) const { return choices [convertFrom0to1 (v)]; } @@ -166,3 +171,5 @@ AudioParameterChoice& AudioParameterChoice::operator= (int newValue) return *this; } + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index 4c7fb00547..055b1566c4 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParameterWithID, private ValueTree::Listener { @@ -33,12 +35,16 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete NormalisableRange r, float defaultVal, std::function valueToText, std::function textToValue, - bool meta) + bool meta, + bool automatable, + bool discrete) : AudioProcessorParameterWithID (parameterID, paramName, labelText), owner (s), valueToTextFunction (valueToText), textToValueFunction (textToValue), range (r), value (defaultVal), defaultValue (defaultVal), listenersNeedCalling (true), - isMeta (meta) + isMetaParam (meta), + isAutomatableParam (automatable), + isDiscreteParam (discrete) { state.addListener (this); needsUpdate.set (1); @@ -146,7 +152,9 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete return nullptr; } - bool isMetaParameter() const override { return isMeta; } + bool isMetaParameter() const override { return isMetaParam; } + bool isAutomatable() const override { return isAutomatableParam; } + bool isDiscrete() const override { return isDiscreteParam; } AudioProcessorValueTreeState& owner; ValueTree state; @@ -157,7 +165,7 @@ struct AudioProcessorValueTreeState::Parameter : public AudioProcessorParamete float value, defaultValue; Atomic needsUpdate; bool listenersNeedCalling; - bool isMeta; + const bool isMetaParam, isAutomatableParam, isDiscreteParam; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Parameter) }; @@ -181,7 +189,9 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet const String& labelText, NormalisableRange r, float defaultVal, std::function valueToTextFunction, std::function textToValueFunction, - bool isMetaParameter) + bool isMetaParameter, + bool isAutomatableParameter, + bool isDiscreteParameter) { // All parameters must be created before giving this manager a ValueTree state! jassert (! state.isValid()); @@ -191,7 +201,8 @@ AudioProcessorParameterWithID* AudioProcessorValueTreeState::createAndAddParamet Parameter* p = new Parameter (*this, paramID, paramName, labelText, r, defaultVal, valueToTextFunction, textToValueFunction, - isMetaParameter); + isMetaParameter, isAutomatableParameter, + isDiscreteParameter); processor.addParameter (p); return p; } @@ -561,3 +572,5 @@ AudioProcessorValueTreeState::ButtonAttachment::ButtonAttachment (AudioProcessor } AudioProcessorValueTreeState::ButtonAttachment::~ButtonAttachment() {} + +} // namespace juce diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index b3a129fef3..13ace95955 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** This class contains a ValueTree which is used to manage an AudioProcessor's entire state. @@ -66,16 +67,20 @@ public: Calling this will create and add a special type of AudioProcessorParameter to the AudioProcessor to which this state is attached. - @param parameterID A unique string ID for the new parameter - @param parameterName The name that the parameter will return from AudioProcessorParameter::getName() - @param labelText The label that the parameter will return from AudioProcessorParameter::getLabel() - @param valueRange A mapping that will be used to determine the value range which this parameter uses - @param defaultValue A default value for the parameter (in non-normalised units) - @param valueToTextFunction A function that will convert a non-normalised value to a string for the - AudioProcessorParameter::getText() method. This can be nullptr to use the - default implementation - @param textToValueFunction The inverse of valueToTextFunction - @param isMetaParameter Set this value to true if this should be a meta parameter + @param parameterID A unique string ID for the new parameter + @param parameterName The name that the parameter will return from AudioProcessorParameter::getName() + @param labelText The label that the parameter will return from AudioProcessorParameter::getLabel() + @param valueRange A mapping that will be used to determine the value range which this parameter uses + @param defaultValue A default value for the parameter (in non-normalised units) + @param valueToTextFunction A function that will convert a non-normalised value to a string for the + AudioProcessorParameter::getText() method. This can be nullptr to use the + default implementation + @param textToValueFunction The inverse of valueToTextFunction + @param isMetaParameter Set this value to true if this should be a meta parameter + @param isAutomatableParameter Set this value to false if this parameter should not be automatable + @param isDiscrete Set this value to true to make this parameter take discrete values in a host. + @see AudioProcessorParameter::isDiscrete + @returns the parameter object that was created */ AudioProcessorParameterWithID* createAndAddParameter (const String& parameterID, @@ -85,7 +90,9 @@ public: float defaultValue, std::function valueToTextFunction, std::function textToValueFunction, - bool isMetaParameter = false); + bool isMetaParameter = false, + bool isAutomatableParameter = true, + bool isDiscrete = false); /** Returns a parameter by its ID string. */ AudioProcessorParameterWithID* getParameter (StringRef parameterID) const noexcept; @@ -227,3 +234,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorValueTreeState) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h b/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h index e8d541a90a..ad583d4c6e 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDBurner.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CDBURNER || DOXYGEN @@ -167,3 +168,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp index c5f293835f..f632d65bff 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_CDREADER int AudioCDReader::getNumTracks() const @@ -57,3 +60,5 @@ int AudioCDReader::getCDDBId() } #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h index ca94e101eb..540754c6c4 100644 --- a/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h +++ b/modules/juce_audio_utils/audio_cd/juce_AudioCDReader.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CDREADER || DOXYGEN @@ -172,3 +173,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp index df27b7d103..19dd48d241 100644 --- a/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioAppComponent::AudioAppComponent() { } @@ -50,3 +53,5 @@ void AudioAppComponent::shutdownAudio() deviceManager.removeAudioCallback (&audioSourcePlayer); deviceManager.closeAudioDevice(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioAppComponent.h b/modules/juce_audio_utils/gui/juce_AudioAppComponent.h index 98005c9198..d4bec5d046 100644 --- a/modules/juce_audio_utils/gui/juce_AudioAppComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -113,3 +113,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioAppComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 5e4c83afb6..f2cb5350c7 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SimpleDeviceManagerInputLevelMeter : public Component, public Timer { @@ -1217,3 +1220,5 @@ ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexc { return midiInputsList; } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h index a52d0526cd..ca2d8df76c 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -120,3 +120,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index 46f8dbac74..1e3ea0eea6 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct AudioThumbnail::MinMaxValue { MinMaxValue() noexcept @@ -830,3 +833,5 @@ void AudioThumbnail::drawChannels (Graphics& g, const Rectangle& area, doub startTimeSeconds, endTimeSeconds, i, verticalZoomFactor); } } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h index 2ba8359780..ecfc42a40e 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -223,3 +223,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioThumbnail) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h b/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h index 452179c6f9..2ee81e4a44 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailBase.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class AudioThumbnailCache; @@ -152,3 +153,5 @@ public: /** Returns the hash code that was set by setSource() or setReader(). */ virtual int64 getHashCode() const = 0; }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp index 853fe333d2..7157cfbe21 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class AudioThumbnailCache::ThumbnailCacheEntry { public: @@ -191,3 +194,5 @@ bool AudioThumbnailCache::loadNewThumb (AudioThumbnailBase&, int64) { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h index bae7bc78b0..60057a6480 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnailCache.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -114,3 +114,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioThumbnailCache) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp index e7635cb81d..596c467174 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct AudioVisualiserComponent::ChannelInfo { ChannelInfo (AudioVisualiserComponent& o, int bufferSize) @@ -220,3 +223,5 @@ void AudioVisualiserComponent::paintChannel (Graphics& g, Rectangle area, 0.0f, 1.0f, area.getX(), area.getBottom(), (float) numLevels, -1.0f, area.getRight(), area.getY())); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h index 19448db2b8..8abd76704a 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioVisualiserComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h b/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h index cf7e7bb984..a048d52f71 100644 --- a/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h +++ b/modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -74,3 +75,5 @@ public: */ static bool isAvailable(); }; + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index c35ada229e..d6edfe25e3 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MidiKeyboardUpDownButton : public Button { public: @@ -936,3 +939,5 @@ void MidiKeyboardComponent::focusLost (FocusChangeType) { resetAnyKeysInUse(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index 47ccd8df62..7d40fc10f3 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -420,3 +420,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiKeyboardComponent) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/juce_audio_utils.cpp b/modules/juce_audio_utils/juce_audio_utils.cpp index 36a3d4e364..e0169121a9 100644 --- a/modules/juce_audio_utils/juce_audio_utils.cpp +++ b/modules/juce_audio_utils/juce_audio_utils.cpp @@ -33,8 +33,10 @@ #error "Incorrect use of JUCE cpp file" #endif -#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 +#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 +#define JUCE_CORE_INCLUDE_COM_SMART_PTR 1 #include "juce_audio_utils.h" @@ -55,9 +57,6 @@ #endif #endif -namespace juce -{ - #include "gui/juce_AudioDeviceSelectorComponent.cpp" #include "gui/juce_AudioThumbnail.cpp" #include "gui/juce_AudioThumbnailCache.cpp" @@ -69,9 +68,7 @@ namespace juce #include "audio_cd/juce_AudioCDReader.cpp" #if JUCE_MAC - #include "native/juce_mac_BluetoothMidiDevicePairingDialogue.mm" - #include "../juce_core/native/juce_osx_ObjCHelpers.h" #if JUCE_USE_CDREADER #include "native/juce_mac_AudioCDReader.mm" @@ -82,15 +79,12 @@ namespace juce #endif #elif JUCE_IOS - #include "native/juce_ios_BluetoothMidiDevicePairingDialogue.mm" #elif JUCE_ANDROID - #include "native/juce_android_BluetoothMidiDevicePairingDialogue.cpp" #elif JUCE_LINUX - #if JUCE_USE_CDREADER #include "native/juce_linux_AudioCDReader.cpp" #endif @@ -98,9 +92,7 @@ namespace juce #include "native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp" #elif JUCE_WINDOWS - #include "native/juce_win_BluetoothMidiDevicePairingDialogue.cpp" - #include "../juce_core/native/juce_win32_ComSmartPtr.h" #if JUCE_USE_CDREADER #include "native/juce_win32_AudioCDReader.cpp" @@ -111,5 +103,3 @@ namespace juce #endif #endif - -} diff --git a/modules/juce_audio_utils/juce_audio_utils.h b/modules/juce_audio_utils/juce_audio_utils.h index 2ba9532ab2..0707c72b16 100644 --- a/modules/juce_audio_utils/juce_audio_utils.h +++ b/modules/juce_audio_utils/juce_audio_utils.h @@ -35,7 +35,7 @@ ID: juce_audio_utils vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE extra audio utility classes description: Classes for audio-related GUI and miscellaneous tasks. website: http://www.juce.com/juce @@ -74,9 +74,6 @@ #endif //============================================================================== -namespace juce -{ - #include "gui/juce_AudioDeviceSelectorComponent.h" #include "gui/juce_AudioThumbnailBase.h" #include "gui/juce_AudioThumbnail.h" @@ -89,5 +86,3 @@ namespace juce #include "players/juce_AudioProcessorPlayer.h" #include "audio_cd/juce_AudioCDBurner.h" #include "audio_cd/juce_AudioCDReader.h" - -} diff --git a/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp index e9b03bab04..82681e77a8 100644 --- a/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getMidiBluetoothAddresses, "getMidiBluetoothAddresses", "()[Ljava/lang/String;") \ METHOD (pairBluetoothMidiDevice, "pairBluetoothMidiDevice", "(Ljava/lang/String;)Z") \ @@ -482,3 +484,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() jobject btManager (android.activity.callObjectMethod (JuceAppActivity.getAndroidBluetoothManager)); return btManager != nullptr; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm index f0dabef5ce..befb3a0269 100644 --- a/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm +++ b/modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm @@ -31,8 +31,6 @@ // It is also not available in the iPhone/iPad simulator. #if JUCE_MODULE_AVAILABLE_juce_gui_extra && ! TARGET_IPHONE_SIMULATOR -} // (juce namespace) - #include namespace juce @@ -118,14 +116,20 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() return NSClassFromString ([NSString stringWithUTF8String: "CABTMIDICentralViewController"]) != nil; } +} // namespace juce + //============================================================================== #else -bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) +namespace juce { - ScopedPointer cb (exitCallback); - return false; + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) + { + ScopedPointer cb (exitCallback); + return false; + } + + bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } } -bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } #endif diff --git a/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp b/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp index 018ab26b8b..3af5291666 100644 --- a/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp +++ b/modules/juce_audio_utils/native/juce_linux_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioCDReader::AudioCDReader() : AudioFormatReader (0, "CD Audio") { @@ -77,3 +80,5 @@ Array AudioCDReader::findIndexesInTrack (const int) { return Array(); } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp index 5f52be49e7..fc876dcbef 100644 --- a/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -38,3 +41,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm index 1d4f14e7a4..bad7206d6c 100644 --- a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm +++ b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int kilobytesPerSecond1x = 176; struct AudioTrackProducerClass : public ObjCClass @@ -32,7 +35,13 @@ struct AudioTrackProducerClass : public ObjCClass { addIvar ("source"); + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundeclared-selector" addMethod (@selector (initWithAudioSourceHolder:), initWithAudioSourceHolder, "@@:^v"); + addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), + produceDataForTrack, "I@:@^cIQI^I"); + #pragma clang diagnostic pop + addMethod (@selector (cleanupTrackAfterBurn:), cleanupTrackAfterBurn, "v@:@"); addMethod (@selector (cleanupTrackAfterVerification:), cleanupTrackAfterVerification, "c@:@"); addMethod (@selector (estimateLengthOfTrack:), estimateLengthOfTrack, "Q@:@"); @@ -42,8 +51,6 @@ struct AudioTrackProducerClass : public ObjCClass produceDataForTrack, "I@:@^cIQI^I"); addMethod (@selector (producePreGapForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), produceDataForTrack, "I@:@^cIQI^I"); - addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), - produceDataForTrack, "I@:@^cIQI^I"); registerClass(); } @@ -182,8 +189,11 @@ struct OpenDiskDevice static AudioTrackProducerClass cls; + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundeclared-selector" NSObject* producer = [cls.createInstance() performSelector: @selector (initWithAudioSourceHolder:) withObject: (id) new AudioTrackProducerClass::AudioSourceHolder (source, numFrames)]; + #pragma clang diagnostic pop DRTrack* track = [[DRTrack alloc] initWithProducer: producer]; { @@ -455,3 +465,5 @@ String AudioCDBurner::burn (AudioCDBurner::BurnProgressListener* listener, return "Couldn't open or write to the CD device"; } + +} diff --git a/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm b/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm index e0dd0a8a92..4066369713 100644 --- a/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm +++ b/modules/juce_audio_utils/native/juce_mac_AudioCDReader.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDReaderHelpers { inline const XmlElement* getElementForKey (const XmlElement& xml, const String& key) @@ -258,5 +261,7 @@ int AudioCDReader::getLastIndex() const Array AudioCDReader::findIndexesInTrack (const int /*trackNumber*/) { - return Array(); + return {}; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm b/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm index ccdab0375b..65d0395ec9 100644 --- a/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm +++ b/modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -37,3 +40,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp index 8977773f9c..89e6ec4e5a 100644 --- a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp +++ b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDBurnerHelpers { IDiscRecorder* enumCDBurners (StringArray* list, int indexToOpen, IDiscMaster** master) @@ -411,3 +414,5 @@ bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples) hr = pimpl->redbook->CloseAudioTrack(); return ok && hr == S_OK; } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp b/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp index 534268555d..bdcef8cf47 100644 --- a/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp +++ b/modules/juce_audio_utils/native/juce_win32_AudioCDReader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace CDReaderHelpers { @@ -1176,7 +1179,7 @@ int AudioCDReader::getLastIndex() const int AudioCDReader::getIndexAt (int samplePos) { using namespace CDReaderHelpers; - CDDeviceWrapper* const device = static_cast (handle); + auto* device = static_cast (handle); const int frameNeeded = samplePos / samplesPerFrame; @@ -1210,7 +1213,7 @@ int AudioCDReader::getIndexAt (int samplePos) Array AudioCDReader::findIndexesInTrack (const int trackNumber) { using namespace CDReaderHelpers; - Array indexes; + Array indexes; const int trackStart = getPositionOfTrackStart (trackNumber); const int trackEnd = getPositionOfTrackStart (trackNumber + 1); @@ -1257,7 +1260,7 @@ Array AudioCDReader::findIndexesInTrack (const int trackNumber) if (needToScan) { - CDDeviceWrapper* const device = static_cast (handle); + auto* device = static_cast (handle); int pos = trackStart; int last = -1; @@ -1309,3 +1312,5 @@ void AudioCDReader::ejectDisk() using namespace CDReaderHelpers; static_cast (handle)->deviceHandle.openDrawer (true); } + +} // namespace juce diff --git a/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp b/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp index e051e42fd0..ee17d80744 100644 --- a/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp +++ b/modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) { ScopedPointer cb (exitCallback); @@ -38,3 +41,5 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index c10a8f4c98..9bfe2ca23c 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AudioProcessorPlayer::AudioProcessorPlayer (bool doDoublePrecisionProcessing) : isDoublePrecision (doDoublePrecisionProcessing) { @@ -214,3 +217,5 @@ void AudioProcessorPlayer::handleIncomingMidiMessage (MidiInput*, const MidiMess { messageCollector.addMessageToQueue (message); } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h index 10f62abb13..d93956474a 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -107,3 +108,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorPlayer) }; + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp index 1623eba09c..29a270d637 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + // This is an AudioTransportSource which will own it's assigned source struct AudioSourceOwningTransportSource : public AudioTransportSource { @@ -273,3 +275,5 @@ void SoundPlayer::audioDeviceError (const String& errorMessage) { player.audioDeviceError (errorMessage); } + +} // namespace juce diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.h b/modules/juce_audio_utils/players/juce_SoundPlayer.h index b436c6316e..535c936ae4 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.h +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -130,3 +131,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SoundPlayer) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_Block.cpp b/modules/juce_blocks_basics/blocks/juce_Block.cpp index 6b4093899b..4336a92f90 100644 --- a/modules/juce_blocks_basics/blocks/juce_Block.cpp +++ b/modules/juce_blocks_basics/blocks/juce_Block.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ static Block::UID getBlockUIDFromSerialNumber (const uint8* serial) noexcept { @@ -104,3 +106,5 @@ LEDRow::~LEDRow() {} //============================================================================== StatusLight::StatusLight (Block& b) : block (b) {} StatusLight::~StatusLight() {} + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_Block.h b/modules/juce_blocks_basics/blocks/juce_Block.h index 1332dc3828..b7460746b9 100644 --- a/modules/juce_blocks_basics/blocks/juce_Block.h +++ b/modules/juce_blocks_basics/blocks/juce_Block.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents an individual BLOCKS device. @@ -431,3 +433,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Block) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h index ad1d70b585..f24540ded4 100644 --- a/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h +++ b/modules/juce_blocks_basics/blocks/juce_BlockConfigManager.h @@ -28,7 +28,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ // This file provides interfaces for managing the internal configuration of Blocks // and synchronises with the connected Block @@ -49,7 +50,7 @@ struct BlockConfigManager options }; - static constexpr uint32 numConfigItems = 59; + static constexpr uint32 numConfigItems = 61; struct ConfigDescription { @@ -92,6 +93,7 @@ struct BlockConfigManager { fixedVelocityValue, 127, 1, 127, false, "Fixed Velocity Value", ConfigType::integer, {}, "5D Touch" }, { pianoMode, 0, 0, 1, false, "Piano Mode", ConfigType::boolean, {}, "Play mode" }, { glideLock, 0, 0, 127, false, "Glide Rate", ConfigType::integer, {}, "Play mode" }, + { glideLockEnable, 0, 0, 1, false, "Glidelock Enable", ConfigType::boolean, {}, "Play mode" }, { mode, 4, 1, 5, false, "Mode", ConfigType::integer, {}, "Play mode" }, { volume, 100, 0, 127, false, "Volume", ConfigType::integer, {}, "Play mode" }, { scale, 0, 0, 18, false, "Scale", ConfigType::integer, {}, "Play mode" }, // NOTE: Should be options @@ -115,6 +117,9 @@ struct BlockConfigManager "Lowest", "Disabled", "Hardest" }, "Play mode" }, + + { gammaCorrection, 0, 0, 1, false, "Gamma Correction", ConfigType::boolean, {}, {} }, + // These can be defined for unique usage for a given Littlefoot script { user0, 0, 0, 127, false, {}, ConfigType::integer, {}, {} }, { user1, 0, 0, 127, false, {}, ConfigType::integer, {}, {} }, @@ -251,8 +256,8 @@ struct BlockConfigManager void resetConfigListActiveStatus() { - for (uint32 i = 0; i < numConfigItems; ++i) - configList[i].isActive = false; + for (auto& i : configList) + i.isActive = false; } //============================================================================== @@ -344,3 +349,5 @@ private: TopologyIndex deviceIndex; PhysicalTopologySource::DeviceConnection* deviceConnection; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_ControlButton.h b/modules/juce_blocks_basics/blocks/juce_ControlButton.h index 2117e2cb60..4925747a8c 100644 --- a/modules/juce_blocks_basics/blocks/juce_ControlButton.h +++ b/modules/juce_blocks_basics/blocks/juce_ControlButton.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a button on a block device. @@ -132,3 +134,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlButton) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_LEDGrid.h b/modules/juce_blocks_basics/blocks/juce_LEDGrid.h index 51eec3e32a..6340fb303a 100644 --- a/modules/juce_blocks_basics/blocks/juce_LEDGrid.h +++ b/modules/juce_blocks_basics/blocks/juce_LEDGrid.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** A simple ARGB colour class for setting LEDs. @@ -94,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LEDGrid) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_LEDRow.h b/modules/juce_blocks_basics/blocks/juce_LEDRow.h index 244133fd36..e32083985e 100644 --- a/modules/juce_blocks_basics/blocks/juce_LEDRow.h +++ b/modules/juce_blocks_basics/blocks/juce_LEDRow.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents an LED strip on a device. @@ -56,3 +58,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LEDRow) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_StatusLight.h b/modules/juce_blocks_basics/blocks/juce_StatusLight.h index d452d5b9b8..79d13ca54a 100644 --- a/modules/juce_blocks_basics/blocks/juce_StatusLight.h +++ b/modules/juce_blocks_basics/blocks/juce_StatusLight.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a status LED on a device. @@ -45,3 +47,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StatusLight) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_TouchList.h b/modules/juce_blocks_basics/blocks/juce_TouchList.h index 84eb45845c..81a4a4680d 100644 --- a/modules/juce_blocks_basics/blocks/juce_TouchList.h +++ b/modules/juce_blocks_basics/blocks/juce_TouchList.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Utility class to hold a list of TouchSurface::Touch objects with different @@ -137,3 +139,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TouchList) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/blocks/juce_TouchSurface.h b/modules/juce_blocks_basics/blocks/juce_TouchSurface.h index 82d2a849d0..0a8d71e96f 100644 --- a/modules/juce_blocks_basics/blocks/juce_TouchSurface.h +++ b/modules/juce_blocks_basics/blocks/juce_TouchSurface.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Represents the touch surface of a BLOCKS device. @@ -129,3 +131,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TouchSurface) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/juce_blocks_basics.cpp b/modules/juce_blocks_basics/juce_blocks_basics.cpp index 140a88136a..27a5dd1b40 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.cpp +++ b/modules/juce_blocks_basics/juce_blocks_basics.cpp @@ -23,21 +23,15 @@ #include "juce_blocks_basics.h" -namespace juce -{ - namespace BlocksProtocol - { - #include "protocol/juce_BitPackingUtilities.h" - #include "protocol/juce_BlocksProtocolDefinitions.h" - #include "protocol/juce_HostPacketDecoder.h" - #include "protocol/juce_HostPacketBuilder.h" - #include "protocol/juce_BlockModels.h" - } - - #include "blocks/juce_BlockConfigManager.h" - #include "blocks/juce_Block.cpp" - #include "topology/juce_PhysicalTopologySource.cpp" - #include "topology/juce_RuleBasedTopologySource.cpp" - #include "visualisers/juce_DrumPadLEDProgram.cpp" - #include "visualisers/juce_BitmapLEDProgram.cpp" -} +#include "protocol/juce_BitPackingUtilities.h" +#include "protocol/juce_BlocksProtocolDefinitions.h" +#include "protocol/juce_HostPacketDecoder.h" +#include "protocol/juce_HostPacketBuilder.h" +#include "protocol/juce_BlockModels.h" + +#include "blocks/juce_BlockConfigManager.h" +#include "blocks/juce_Block.cpp" +#include "topology/juce_PhysicalTopologySource.cpp" +#include "topology/juce_RuleBasedTopologySource.cpp" +#include "visualisers/juce_DrumPadLEDProgram.cpp" +#include "visualisers/juce_BitmapLEDProgram.cpp" diff --git a/modules/juce_blocks_basics/juce_blocks_basics.h b/modules/juce_blocks_basics/juce_blocks_basics.h index 9a5587c213..07df52e68c 100644 --- a/modules/juce_blocks_basics/juce_blocks_basics.h +++ b/modules/juce_blocks_basics/juce_blocks_basics.h @@ -31,7 +31,7 @@ ID: juce_blocks_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: Provides low-level control over ROLI BLOCKS devices description: JUCE wrapper for low-level control over ROLI BLOCKS devices. website: http://developer.roli.com @@ -52,27 +52,31 @@ namespace juce { - class TouchSurface; - class LEDGrid; - class LEDRow; - class StatusLight; - class LightRing; - class ControlButton; - - #include "blocks/juce_Block.h" - #include "blocks/juce_TouchSurface.h" - #include "blocks/juce_LEDGrid.h" - #include "blocks/juce_LEDRow.h" - #include "blocks/juce_ControlButton.h" - #include "blocks/juce_TouchList.h" - #include "blocks/juce_StatusLight.h" - #include "topology/juce_Topology.h" - #include "topology/juce_TopologySource.h" - #include "topology/juce_PhysicalTopologySource.h" - #include "topology/juce_RuleBasedTopologySource.h" - #include "littlefoot/juce_LittleFootRunner.h" - #include "littlefoot/juce_LittleFootCompiler.h" - #include "littlefoot/juce_LittleFootRemoteHeap.h" - #include "visualisers/juce_DrumPadLEDProgram.h" - #include "visualisers/juce_BitmapLEDProgram.h" + class TouchSurface; + class LEDGrid; + class LEDRow; + class StatusLight; + class LightRing; + class ControlButton; +} + +#include "blocks/juce_Block.h" +#include "blocks/juce_TouchSurface.h" +#include "blocks/juce_LEDGrid.h" +#include "blocks/juce_LEDRow.h" +#include "blocks/juce_ControlButton.h" +#include "blocks/juce_TouchList.h" +#include "blocks/juce_StatusLight.h" +#include "topology/juce_Topology.h" +#include "topology/juce_TopologySource.h" +#include "topology/juce_PhysicalTopologySource.h" +#include "topology/juce_RuleBasedTopologySource.h" +#include "visualisers/juce_DrumPadLEDProgram.h" +#include "visualisers/juce_BitmapLEDProgram.h" + +namespace juce +{ + #include "littlefoot/juce_LittleFootRunner.h" + #include "littlefoot/juce_LittleFootCompiler.h" + #include "littlefoot/juce_LittleFootRemoteHeap.h" } diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h index 09b79da4bf..56aea22488 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h @@ -28,8 +28,6 @@ namespace littlefoot { -using namespace juce; - /** This class compiles littlefoot source code into a littlefoot::Program object which can be executed by a littlefoot::Runner. diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h index 143b05099c..40d07c103d 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRemoteHeap.h @@ -23,8 +23,6 @@ namespace littlefoot { -using namespace juce; - //============================================================================== /** This class manages the synchronisation of a remote block of heap memory used diff --git a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h index 7acc4d9691..4d122d6486 100644 --- a/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h +++ b/modules/juce_blocks_basics/protocol/juce_BitPackingUtilities.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** All sysex messages to or from a BLOCKS device begin with these header bytes. @@ -270,3 +274,6 @@ private: const uint8* data; int totalBits, bitsReadInCurrentByte = 0; }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_BlockModels.h b/modules/juce_blocks_basics/protocol/juce_BlockModels.h index e83b1458b3..e809c880d1 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlockModels.h +++ b/modules/juce_blocks_basics/protocol/juce_BlockModels.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ // This file isn't part of the public API, it's where we encode the knowledge base // of all the different types of block we know about.. @@ -312,3 +316,6 @@ static const char* getButtonNameForFunction (ControlButton::ButtonFunction fn) n jassertfalse; return nullptr; } + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h index 6a7934f8b6..ed0f7d5f36 100644 --- a/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h +++ b/modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** This value is incremented when the format of the API changes in a way which breaks compatibility. @@ -210,6 +214,7 @@ enum ConfigItemId fixedVelocityValue = 16, pianoMode = 17, glideLock = 18, + glideLockEnable = 19, // Live mode = 20, volume = 21, @@ -222,6 +227,8 @@ enum ConfigItemId xTrackingMode = 30, yTrackingMode = 31, zTrackingMode = 32, + // Graphics + gammaCorrection = 33, // User user0 = 64, user1 = 65, @@ -415,10 +422,10 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "mod/iii", "getRandomFloat/f", "getRandomInt/ii", - "getMillisecondCounter/i", - "getFirmwareVersion/i", "log/vi", "logHex/vi", + "getMillisecondCounter/i", + "getFirmwareVersion/i", "getTimeInCurrentFunctionCall/i", "getBatteryLevel/f", "isBatteryCharging/b", @@ -470,6 +477,9 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "sendPitchBend/vii", "sendPitchBend/viii", "sendChannelPressure/vii", + "addPitchCorrectionPad/viiffff", + "setPitchCorrectionEnabled/vb", + "getPitchCorrectionPitchBend/iii", "setChannelRange/vbii", "assignChannel/ii", "deassignChannel/vii", @@ -489,5 +499,13 @@ static constexpr const char* ledProgramLittleFootFunctions[] = "onControlPress/vi", "onControlRelease/vi", "initControl/viiiiiiiii", + "setButtonMode/vii", + "setButtonType/viii", + "setButtonMinMaxDefault/viiii", + "setButtonColours/viii", + "setButtonTriState/vii", nullptr }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h b/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h index 84f9bf4963..2a2841651e 100644 --- a/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h +++ b/modules/juce_blocks_basics/protocol/juce_HostPacketBuilder.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** Helper class for constructing a packet for sending to a BLOCKS device @@ -314,3 +318,6 @@ private: data << MessageType ((uint32) type); } }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h b/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h index cd1b39c023..16142ae793 100644 --- a/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h +++ b/modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h @@ -20,6 +20,10 @@ ============================================================================== */ +namespace juce +{ +namespace BlocksProtocol +{ /** Parses data packets from a BLOCKS device, and translates them into callbacks @@ -352,3 +356,6 @@ struct HostPacketDecoder return true; } }; + +} // namespace BlocksProtocol +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp index ae88a60ee6..6099cc8530 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED \ jassert (juce::MessageManager::getInstance()->currentThreadHasLockedMessageManager()); @@ -2353,3 +2356,5 @@ bool BlockDeviceConnection::operator!= (const BlockDeviceConnection& other) cons { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h index e809175e0b..442e78e28a 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** This topology source manages the topology of the physical Blocks devices @@ -80,3 +82,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PhysicalTopologySource) }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp index 476223f841..33ff36c286 100644 --- a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ struct RuleBasedTopologySource::Internal : public TopologySource::Listener, private juce::AsyncUpdater @@ -100,3 +102,5 @@ BlockTopology RuleBasedTopologySource::getCurrentTopology() const { void RuleBasedTopologySource::clearRules() { internal->clearRules(); } void RuleBasedTopologySource::addRule (Rule* r) { internal->addRule (r); } + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h index b25292f87d..7b155a1d89 100644 --- a/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_RuleBasedTopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** This topology source holds and applies a set of rules for transforming one device topology into another one that may involve virtual and/or @@ -74,3 +76,5 @@ private: struct Internal; juce::ScopedPointer internal; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_Topology.h b/modules/juce_blocks_basics/topology/juce_Topology.h index e132ca38c4..2c846a036f 100644 --- a/modules/juce_blocks_basics/topology/juce_Topology.h +++ b/modules/juce_blocks_basics/topology/juce_Topology.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Describes a phyiscal connection between two ports of two block devices. */ struct BlockDeviceConnection @@ -41,3 +43,5 @@ struct BlockTopology bool operator== (const BlockTopology&) const noexcept; bool operator!= (const BlockTopology&) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/topology/juce_TopologySource.h b/modules/juce_blocks_basics/topology/juce_TopologySource.h index f3f06a7476..f0b5bdbc6c 100644 --- a/modules/juce_blocks_basics/topology/juce_TopologySource.h +++ b/modules/juce_blocks_basics/topology/juce_TopologySource.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** Base class for an entity that provides access to a blocks topology. */ class TopologySource @@ -49,3 +51,5 @@ protected: //========================================================================== juce::ListenerList listeners; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp index fa2e89b244..e2df561f27 100644 --- a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp +++ b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ BitmapLEDProgram::BitmapLEDProgram (Block& b) : Program (b) {} @@ -81,3 +83,5 @@ juce::String BitmapLEDProgram::getLittleFootProgram() jassertfalse; return {}; } + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h index 113569d840..795c7eca7c 100644 --- a/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h +++ b/modules/juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ /** A simple Program to set the colours of individual LEDs. @@ -34,3 +36,5 @@ struct BitmapLEDProgram : public Block::Program private: juce::String getLittleFootProgram() override; }; + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp index 263561a066..cc559789c5 100644 --- a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp +++ b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.cpp @@ -20,6 +20,8 @@ ============================================================================== */ +namespace juce +{ DrumPadGridProgram::DrumPadGridProgram (Block& b) : Program (b) {} @@ -870,3 +872,5 @@ juce::String DrumPadGridProgram::getLittleFootProgramPost25() const )littlefoot"; } + +} // namespace juce diff --git a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h index a92e82e635..b45f235734 100644 --- a/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h +++ b/modules/juce_blocks_basics/visualisers/juce_DrumPadLEDProgram.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /** */ struct DrumPadGridProgram : public Block::Program @@ -118,3 +121,5 @@ private: juce::String getLittleFootProgramPre25() const; juce::String getLittleFootProgramPost25() const; }; + +} // namespace juce diff --git a/modules/juce_box2d/juce_box2d.cpp b/modules/juce_box2d/juce_box2d.cpp index e3ab3e0ec4..5fa5497a7a 100644 --- a/modules/juce_box2d/juce_box2d.cpp +++ b/modules/juce_box2d/juce_box2d.cpp @@ -87,10 +87,7 @@ #include "box2d/Dynamics/Joints/b2WheelJoint.cpp" #include "box2d/Rope/b2Rope.cpp" -namespace juce -{ #include "utils/juce_Box2DRenderer.cpp" -} #if JUCE_CLANG #pragma clang diagnostic pop diff --git a/modules/juce_box2d/juce_box2d.h b/modules/juce_box2d/juce_box2d.h index 095c84f1b4..7c2902e472 100644 --- a/modules/juce_box2d/juce_box2d.h +++ b/modules/juce_box2d/juce_box2d.h @@ -35,7 +35,7 @@ ID: juce_box2d vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE wrapper for the Box2D physics engine description: The Box2D physics engine and some utility classes. website: http://www.juce.com/juce @@ -66,8 +66,5 @@ #endif #ifndef DOXYGEN // for some reason, Doxygen sees this as a re-definition of Box2DRenderer -namespace juce -{ - #include "utils/juce_Box2DRenderer.h" -} + #include "utils/juce_Box2DRenderer.h" #endif // DOXYGEN diff --git a/modules/juce_box2d/utils/juce_Box2DRenderer.cpp b/modules/juce_box2d/utils/juce_Box2DRenderer.cpp index c2dcb11bc5..0988f0f07b 100644 --- a/modules/juce_box2d/utils/juce_Box2DRenderer.cpp +++ b/modules/juce_box2d/utils/juce_Box2DRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Box2DRenderer::Box2DRenderer() noexcept : graphics (nullptr) { SetFlags (e_shapeBit); @@ -105,3 +108,5 @@ void Box2DRenderer::DrawSegment (const b2Vec2& p1, const b2Vec2& p2, const b2Col void Box2DRenderer::DrawTransform (const b2Transform&) { } + +} // namespace juce diff --git a/modules/juce_box2d/utils/juce_Box2DRenderer.h b/modules/juce_box2d/utils/juce_Box2DRenderer.h index 063f26fba2..89d56db9a2 100644 --- a/modules/juce_box2d/utils/juce_Box2DRenderer.h +++ b/modules/juce_box2d/utils/juce_Box2DRenderer.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** A simple implementation of the b2Draw class, used to draw a Box2D world. @@ -73,3 +74,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Box2DRenderer) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_AbstractFifo.cpp b/modules/juce_core/containers/juce_AbstractFifo.cpp index 03d61396b5..d33f7f85b1 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + AbstractFifo::AbstractFifo (const int capacity) noexcept : bufferSize (capacity) { @@ -227,3 +230,5 @@ public: static AbstractFifoTests fifoUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_AbstractFifo.h b/modules/juce_core/containers/juce_AbstractFifo.h index 5412a20202..0d41d6d9b9 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.h +++ b/modules/juce_core/containers/juce_AbstractFifo.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -208,3 +208,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AbstractFifo) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Array.h b/modules/juce_core/containers/juce_Array.h index 4e66a70eaa..8f7380b1ea 100644 --- a/modules/juce_core/containers/juce_Array.h +++ b/modules/juce_core/containers/juce_Array.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -358,12 +358,12 @@ public: int indexOf (ParameterType elementToLookFor) const { const ScopedLockType lock (getLock()); - const ElementType* e = data.elements.getData(); + const ElementType* e = data.elements.get(); const ElementType* const end_ = e + numUsed; for (; e != end_; ++e) if (elementToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); return -1; } @@ -376,7 +376,7 @@ public: bool contains (ParameterType elementToLookFor) const { const ScopedLockType lock (getLock()); - const ElementType* e = data.elements.getData(); + const ElementType* e = data.elements.get(); const ElementType* const end_ = e + numUsed; for (; e != end_; ++e) @@ -719,8 +719,8 @@ public: void resize (const int targetNumItems) { jassert (targetNumItems >= 0); + auto numToAdd = targetNumItems - numUsed; - const int numToAdd = targetNumItems - numUsed; if (numToAdd > 0) insertMultiple (numUsed, ElementType(), numToAdd); else if (numToAdd < 0) @@ -743,7 +743,7 @@ public: int addSorted (ElementComparator& comparator, ParameterType newElement) { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed); + auto index = findInsertIndexInSortedArray (comparator, data.elements.get(), newElement, 0, numUsed); insert (index, newElement); return index; } @@ -1197,7 +1197,7 @@ public: const ScopedLockType lock (getLock()); ignoreUnused (comparator); // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== @@ -1265,3 +1265,5 @@ private: addAssumingCapacityIsReady (otherElements...); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ArrayAllocationBase.h b/modules/juce_core/containers/juce_ArrayAllocationBase.h index a4c3d89f1d..5ab3ce00f9 100644 --- a/modules/juce_core/containers/juce_ArrayAllocationBase.h +++ b/modules/juce_core/containers/juce_ArrayAllocationBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -124,3 +124,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE (ArrayAllocationBase) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_DynamicObject.cpp b/modules/juce_core/containers/juce_DynamicObject.cpp index 697205bfa8..4d299ac0cc 100644 --- a/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/modules/juce_core/containers/juce_DynamicObject.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + DynamicObject::DynamicObject() { } @@ -125,3 +128,5 @@ void DynamicObject::writeAsJSON (OutputStream& out, const int indentLevel, const out << '}'; } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_DynamicObject.h b/modules/juce_core/containers/juce_DynamicObject.h index 20c4e7608b..83ee6ccf0e 100644 --- a/modules/juce_core/containers/juce_DynamicObject.h +++ b/modules/juce_core/containers/juce_DynamicObject.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ private: JUCE_LEAK_DETECTOR (DynamicObject) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ElementComparator.h b/modules/juce_core/containers/juce_ElementComparator.h index 3f5881c1d1..aa30b194a5 100644 --- a/modules/juce_core/containers/juce_ElementComparator.h +++ b/modules/juce_core/containers/juce_ElementComparator.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef DOXYGEN @@ -183,3 +184,5 @@ public: return (first < second) ? -1 : ((second < first) ? 1 : 0); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_HashMap.h b/modules/juce_core/containers/juce_HashMap.h index 019e5b41d5..ab04728d7d 100644 --- a/modules/juce_core/containers/juce_HashMap.h +++ b/modules/juce_core/containers/juce_HashMap.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -496,3 +496,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HashMap) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_HashMap_test.cpp b/modules/juce_core/containers/juce_HashMap_test.cpp index 428bdc8071..76dcd87e0a 100644 --- a/modules/juce_core/containers/juce_HashMap_test.cpp +++ b/modules/juce_core/containers/juce_HashMap_test.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct HashMapTest : public UnitTest { HashMapTest() : UnitTest ("HashMap", "Containers") {} @@ -269,3 +272,5 @@ template <> String HashMapTest::RandomKeys::generateRandomKey (Random& r } static HashMapTest hashMapTest; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_LinkedListPointer.h b/modules/juce_core/containers/juce_LinkedListPointer.h index d8ddc7ed05..00994bc958 100644 --- a/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/modules/juce_core/containers/juce_LinkedListPointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -357,3 +357,5 @@ private: JUCE_DECLARE_NON_COPYABLE (LinkedListPointer) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ListenerList.cpp b/modules/juce_core/containers/juce_ListenerList.cpp index f0885171b0..972122e0a0 100644 --- a/modules/juce_core/containers/juce_ListenerList.cpp +++ b/modules/juce_core/containers/juce_ListenerList.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS struct ListenerBase @@ -182,3 +185,5 @@ public: static ListenerListTests listenerListTests; #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ListenerList.h b/modules/juce_core/containers/juce_ListenerList.h index 36ca27e3c9..7986b74ecd 100644 --- a/modules/juce_core/containers/juce_ListenerList.h +++ b/modules/juce_core/containers/juce_ListenerList.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -540,3 +540,5 @@ private: #undef LL_TEMPLATE #undef LL_PARAM }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_NamedValueSet.cpp b/modules/juce_core/containers/juce_NamedValueSet.cpp index b33ea1da9e..45bfff11d4 100644 --- a/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/modules/juce_core/containers/juce_NamedValueSet.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + NamedValueSet::NamedValueSet() noexcept { } @@ -241,3 +243,5 @@ void NamedValueSet::copyToXmlAttributes (XmlElement& xml) const } } } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_NamedValueSet.h b/modules/juce_core/containers/juce_NamedValueSet.h index 0916052585..4e6ea7ab43 100644 --- a/modules/juce_core/containers/juce_NamedValueSet.h +++ b/modules/juce_core/containers/juce_NamedValueSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Holds a set of named var objects. @@ -171,3 +171,5 @@ private: //============================================================================== Array values; }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 4bb502814c..ccfacb0436 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An array designed for holding objects. @@ -233,12 +233,12 @@ public: int indexOf (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.getData(); + ObjectClass* const* e = data.elements.get(); ObjectClass* const* const end_ = e + numUsed; for (; e != end_; ++e) if (objectToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); return -1; } @@ -251,7 +251,7 @@ public: bool contains (const ObjectClass* objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass* const* e = data.elements.getData(); + ObjectClass* const* e = data.elements.get(); ObjectClass* const* const end_ = e + numUsed; for (; e != end_; ++e) @@ -526,7 +526,7 @@ public: ignoreUnused (comparator); // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); insert (index, newObject); return index; } @@ -648,7 +648,7 @@ public: void removeObject (const ObjectClass* objectToRemove, bool deleteObject = true) { const ScopedLockType lock (getLock()); - ObjectClass** const e = data.elements.getData(); + ObjectClass** const e = data.elements.get(); for (int i = 0; i < numUsed; ++i) { @@ -858,7 +858,7 @@ public: // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== @@ -892,3 +892,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_PropertySet.cpp b/modules/juce_core/containers/juce_PropertySet.cpp index ce28d140c6..b1938de478 100644 --- a/modules/juce_core/containers/juce_PropertySet.cpp +++ b/modules/juce_core/containers/juce_PropertySet.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + PropertySet::PropertySet (const bool ignoreCaseOfKeyNames) : properties (ignoreCaseOfKeyNames), fallbackProperties (nullptr), @@ -211,3 +214,5 @@ void PropertySet::restoreFromXml (const XmlElement& xml) void PropertySet::propertyChanged() { } + +} // namespace juce diff --git a/modules/juce_core/containers/juce_PropertySet.h b/modules/juce_core/containers/juce_PropertySet.h index b8e934fce2..26a2cad525 100644 --- a/modules/juce_core/containers/juce_PropertySet.h +++ b/modules/juce_core/containers/juce_PropertySet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -199,3 +199,5 @@ private: JUCE_LEAK_DETECTOR (PropertySet) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.h b/modules/juce_core/containers/juce_ReferenceCountedArray.h index 64eb2d5312..aaee953955 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -274,13 +274,13 @@ public: int indexOf (const ObjectClass* const objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass** e = data.elements.getData(); + ObjectClass** e = data.elements.get(); ObjectClass** const endPointer = e + numUsed; while (e != endPointer) { if (objectToLookFor == *e) - return static_cast (e - data.elements.getData()); + return static_cast (e - data.elements.get()); ++e; } @@ -296,7 +296,7 @@ public: bool contains (const ObjectClass* const objectToLookFor) const noexcept { const ScopedLockType lock (getLock()); - ObjectClass** e = data.elements.getData(); + ObjectClass** e = data.elements.get(); ObjectClass** const endPointer = e + numUsed; while (e != endPointer) @@ -483,7 +483,7 @@ public: int addSorted (ElementComparator& comparator, ObjectClass* newObject) noexcept { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); insert (index, newObject); return index; } @@ -498,7 +498,7 @@ public: ObjectClass* newObject) noexcept { const ScopedLockType lock (getLock()); - const int index = findInsertIndexInSortedArray (comparator, data.elements.getData(), newObject, 0, numUsed); + const int index = findInsertIndexInSortedArray (comparator, data.elements.get(), newObject, 0, numUsed); if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0) set (index - 1, newObject); // replace an existing object that matches @@ -843,7 +843,7 @@ public: // avoids getting warning messages about the parameter being unused const ScopedLockType lock (getLock()); - sortArray (comparator, data.elements.getData(), 0, size() - 1, retainOrderOfEquivalentItems); + sortArray (comparator, data.elements.get(), 0, size() - 1, retainOrderOfEquivalentItems); } //============================================================================== @@ -909,3 +909,5 @@ private: ContainerDeletePolicy::destroy (o); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_ScopedValueSetter.h b/modules/juce_core/containers/juce_ScopedValueSetter.h index eeb3426509..f5e03345a8 100644 --- a/modules/juce_core/containers/juce_ScopedValueSetter.h +++ b/modules/juce_core/containers/juce_ScopedValueSetter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedValueSetter) }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_SortedSet.h b/modules/juce_core/containers/juce_SortedSet.h index 632b659d2b..04d096a020 100644 --- a/modules/juce_core/containers/juce_SortedSet.h +++ b/modules/juce_core/containers/juce_SortedSet.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MSVC #pragma warning (push) @@ -55,19 +56,22 @@ class SortedSet public: //============================================================================== /** Creates an empty set. */ - SortedSet() noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet() noexcept {} /** Creates a copy of another set. */ SortedSet (const SortedSet&) = default; /** Creates a copy of another set. */ - SortedSet (SortedSet&&) noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet (SortedSet&& other) noexcept : data (static_cast (other.data)) {} /** Makes a copy of another set. */ SortedSet& operator= (const SortedSet&) = default; /** Makes a copy of another set. */ - SortedSet& operator= (SortedSet&&) noexcept = default; + // VS2013 doesn't allow defaulted noexcept constructors. + SortedSet& operator= (SortedSet&& other) noexcept { data = static_cast (other.data); return *this; } /** Destructor. */ ~SortedSet() noexcept {} @@ -478,3 +482,5 @@ private: #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/containers/juce_SparseSet.h b/modules/juce_core/containers/juce_SparseSet.h index 1b4e478e73..37efeb4f78 100644 --- a/modules/juce_core/containers/juce_SparseSet.h +++ b/modules/juce_core/containers/juce_SparseSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -285,3 +285,5 @@ private: values.removeRange (--i, 2); } }; + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index 2d79e22bd8..7a2f3c3c0a 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum VariantStreamMarkers { varMarker_Int = 1, @@ -237,7 +240,7 @@ public: void writeToStream (const ValueUnion& data, OutputStream& output) const override { - const String* const s = getString (data); + auto* s = getString (data); const size_t len = s->getNumBytesAsUTF8() + 1; HeapBlock temp (len); s->copyToUTF8 (temp, len); @@ -279,7 +282,7 @@ public: var clone (const var& original) const override { - if (DynamicObject* d = original.getDynamicObject()) + if (auto* d = original.getDynamicObject()) return d->clone().get(); jassertfalse; // can only clone DynamicObjects! @@ -314,8 +317,8 @@ public: bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override { - const Array* const thisArray = toArray (data); - const Array* const otherArray = otherType.toArray (otherData); + auto* thisArray = toArray (data); + auto* otherArray = otherType.toArray (otherData); return thisArray == otherArray || (thisArray != nullptr && otherArray != nullptr && *otherArray == *thisArray); } @@ -324,8 +327,12 @@ public: Array arrayCopy; if (auto* array = toArray (original.value)) - for (int i = 0; i < array->size(); ++i) - arrayCopy.add (array->getReference(i).clone()); + { + arrayCopy.ensureStorageAllocated (array->size()); + + for (auto& i : *array) + arrayCopy.add (i.clone()); + } return var (arrayCopy); } @@ -335,11 +342,10 @@ public: if (auto* array = toArray (data)) { MemoryOutputStream buffer (512); - const int numItems = array->size(); - buffer.writeCompressedInt (numItems); + buffer.writeCompressedInt (array->size()); - for (int i = 0; i < numItems; ++i) - array->getReference(i).writeToStream (buffer); + for (auto& i : *array) + i.writeToStream (buffer); output.writeCompressedInt (1 + (int) buffer.getDataSize()); output.writeByte (varMarker_Array); @@ -454,12 +460,12 @@ var::var (const MemoryBlock& v) : type (&VariantType_Binary::instance) { v var::var (const StringArray& v) : type (&VariantType_Array::instance) { Array strings; + strings.ensureStorageAllocated (v.size()); - const int n = v.size(); - for (int i = 0; i < n; ++i) - strings.add (var (v[i])); + for (auto& i : v) + strings.add (var (i)); - value.objectValue = new VariantType_Array::RefCountedArray(strings); + value.objectValue = new VariantType_Array::RefCountedArray (strings); } var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance) @@ -604,6 +610,14 @@ var var::getProperty (const Identifier& propertyName, const var& defaultReturnVa return defaultReturnValue; } +bool var::hasProperty (const Identifier& propertyName) const noexcept +{ + if (auto* o = getDynamicObject()) + return o->hasProperty (propertyName); + + return false; +} + var::NativeFunction var::getNativeFunction() const { return isMethod() && (value.methodValue != nullptr) ? *value.methodValue : nullptr; @@ -785,3 +799,5 @@ var var::readFromStream (InputStream& input) var::NativeFunctionArgs::NativeFunctionArgs (const var& t, const var* args, int numArgs) noexcept : thisObject (t), arguments (args), numArguments (numArgs) {} + +} // namespace juce diff --git a/modules/juce_core/containers/juce_Variant.h b/modules/juce_core/containers/juce_Variant.h index d227a6a046..3a9cb7d24d 100644 --- a/modules/juce_core/containers/juce_Variant.h +++ b/modules/juce_core/containers/juce_Variant.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -243,6 +243,8 @@ public: /** If this variant is an object, this returns one of its properties, or a default fallback value if the property is not set. */ var getProperty (const Identifier& propertyName, const var& defaultReturnValue) const; + /** Returns true if this variant is an object and if it has the given property. */ + bool hasProperty (const Identifier& propertyName) const noexcept; /** Invokes a named method call with no arguments. */ var call (const Identifier& method) const; @@ -334,3 +336,5 @@ struct VariantConverter static String fromVar (const var& v) { return v.toString(); } static var toVar (const String& s) { return s; } }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_DirectoryIterator.cpp b/modules/juce_core/files/juce_DirectoryIterator.cpp index c32ae7b519..a0f8aaa38e 100644 --- a/modules/juce_core/files/juce_DirectoryIterator.cpp +++ b/modules/juce_core/files/juce_DirectoryIterator.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryIterator::DirectoryIterator (const File& directory, bool recursive, const String& pattern, const int type) : wildCards (parseWildcards (pattern)), @@ -158,3 +161,5 @@ float DirectoryIterator::getEstimatedProgress() const return jlimit (0.0f, 1.0f, detailedIndex / totalNumFiles); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_DirectoryIterator.h b/modules/juce_core/files/juce_DirectoryIterator.h index 83e579bcd9..a9b576f249 100644 --- a/modules/juce_core/files/juce_DirectoryIterator.h +++ b/modules/juce_core/files/juce_DirectoryIterator.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -148,3 +148,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryIterator) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index c5bd5b8be6..ef96be662c 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + File::File (const String& fullPathName) : fullPath (parseAbsolutePath (fullPathName)) { @@ -1205,3 +1208,5 @@ public: static FileTests fileUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h index de3a7d9e9f..36b58f3f35 100644 --- a/modules/juce_core/files/juce_File.h +++ b/modules/juce_core/files/juce_File.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1043,3 +1043,5 @@ private: bool setFileReadOnlyInternal (bool) const; bool setFileExecutableInternal (bool) const; }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileFilter.cpp b/modules/juce_core/files/juce_FileFilter.cpp index 3fe61708a4..2d0cb624a1 100644 --- a/modules/juce_core/files/juce_FileFilter.cpp +++ b/modules/juce_core/files/juce_FileFilter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileFilter::FileFilter (const String& filterDescription) : description (filterDescription) { @@ -33,3 +36,5 @@ const String& FileFilter::getDescription() const noexcept { return description; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileFilter.h b/modules/juce_core/files/juce_FileFilter.h index d40da458c5..e1e241c7f9 100644 --- a/modules/juce_core/files/juce_FileFilter.h +++ b/modules/juce_core/files/juce_FileFilter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -65,3 +65,5 @@ protected: //============================================================================== String description; }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileInputStream.cpp b/modules/juce_core/files/juce_FileInputStream.cpp index f136cf0907..638abf9831 100644 --- a/modules/juce_core/files/juce_FileInputStream.cpp +++ b/modules/juce_core/files/juce_FileInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 juce_fileSetPosition (void* handle, int64 pos); @@ -76,3 +79,5 @@ bool FileInputStream::setPosition (int64 pos) return currentPosition == pos; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileInputStream.h b/modules/juce_core/files/juce_FileInputStream.h index 8354b20d59..9fd84b0251 100644 --- a/modules/juce_core/files/juce_FileInputStream.h +++ b/modules/juce_core/files/juce_FileInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileOutputStream.cpp b/modules/juce_core/files/juce_FileOutputStream.cpp index 31d013b113..495104380d 100644 --- a/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/modules/juce_core/files/juce_FileOutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 juce_fileSetPosition (void* handle, int64 pos); //============================================================================== @@ -126,3 +129,5 @@ bool FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes) return OutputStream::writeRepeatedByte (byte, numBytes); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileOutputStream.h b/modules/juce_core/files/juce_FileOutputStream.h index 75b14bc49a..3e1100ce76 100644 --- a/modules/juce_core/files/juce_FileOutputStream.h +++ b/modules/juce_core/files/juce_FileOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileOutputStream) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileSearchPath.cpp b/modules/juce_core/files/juce_FileSearchPath.cpp index 8219de13a3..baa2539f6f 100644 --- a/modules/juce_core/files/juce_FileSearchPath.cpp +++ b/modules/juce_core/files/juce_FileSearchPath.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileSearchPath::FileSearchPath() {} FileSearchPath::~FileSearchPath() {} @@ -165,3 +168,5 @@ bool FileSearchPath::isFileInPath (const File& fileToCheck, return false; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_FileSearchPath.h b/modules/juce_core/files/juce_FileSearchPath.h index 94cde68c93..91011c093a 100644 --- a/modules/juce_core/files/juce_FileSearchPath.h +++ b/modules/juce_core/files/juce_FileSearchPath.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_LEAK_DETECTOR (FileSearchPath) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_MemoryMappedFile.h b/modules/juce_core/files/juce_MemoryMappedFile.h index cd8a4b3ca6..1afc083122 100644 --- a/modules/juce_core/files/juce_MemoryMappedFile.h +++ b/modules/juce_core/files/juce_MemoryMappedFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedFile) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_TemporaryFile.cpp b/modules/juce_core/files/juce_TemporaryFile.cpp index a3c17ef63e..7010677920 100644 --- a/modules/juce_core/files/juce_TemporaryFile.cpp +++ b/modules/juce_core/files/juce_TemporaryFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static File createTempFile (const File& parentDirectory, String name, const String& suffix, const int optionFlags) { @@ -109,3 +112,5 @@ bool TemporaryFile::deleteTemporaryFile() const return false; } + +} // namespace juce diff --git a/modules/juce_core/files/juce_TemporaryFile.h b/modules/juce_core/files/juce_TemporaryFile.h index 8663f0cde9..a781a101b3 100644 --- a/modules/juce_core/files/juce_TemporaryFile.h +++ b/modules/juce_core/files/juce_TemporaryFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -158,3 +158,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TemporaryFile) }; + +} // namespace juce diff --git a/modules/juce_core/files/juce_WildcardFileFilter.cpp b/modules/juce_core/files/juce_WildcardFileFilter.cpp index 82ffe9645e..8db43f34e7 100644 --- a/modules/juce_core/files/juce_WildcardFileFilter.cpp +++ b/modules/juce_core/files/juce_WildcardFileFilter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static void parseWildcard (const String& pattern, StringArray& result) { result.addTokens (pattern.toLowerCase(), ";,", "\"'"); @@ -68,3 +71,5 @@ bool WildcardFileFilter::isDirectorySuitable (const File& file) const { return matchWildcard (file, directoryWildcards); } + +} // namespace juce diff --git a/modules/juce_core/files/juce_WildcardFileFilter.h b/modules/juce_core/files/juce_WildcardFileFilter.h index 5492bdaaa4..b49c498988 100644 --- a/modules/juce_core/files/juce_WildcardFileFilter.h +++ b/modules/juce_core/files/juce_WildcardFileFilter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -70,3 +70,5 @@ private: JUCE_LEAK_DETECTOR (WildcardFileFilter) }; + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_JSON.cpp b/modules/juce_core/javascript/juce_JSON.cpp index 749d1067c2..494da5a83d 100644 --- a/modules/juce_core/javascript/juce_JSON.cpp +++ b/modules/juce_core/javascript/juce_JSON.cpp @@ -20,9 +20,11 @@ ============================================================================== */ -class JSONParser +namespace juce +{ + +struct JSONParser { -public: static Result parseObjectOrArray (String::CharPointerType t, var& result) { t = t.findEndOfWhitespace(); @@ -319,9 +321,8 @@ private: }; //============================================================================== -class JSONFormatter +struct JSONFormatter { -public: static void write (OutputStream& out, const var& v, const int indentLevel, const bool allOnOneLine, int maximumDecimalPlaces) @@ -648,3 +649,5 @@ public: static JSONTests JSONUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_JSON.h b/modules/juce_core/javascript/juce_JSON.h index 1cbe1a1d62..c185442be6 100644 --- a/modules/juce_core/javascript/juce_JSON.h +++ b/modules/juce_core/javascript/juce_JSON.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: //============================================================================== JSON() JUCE_DELETED_FUNCTION; // This class can't be instantiated - just use its static methods. }; + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_Javascript.cpp b/modules/juce_core/javascript/juce_Javascript.cpp index 72b059de27..9ef8305160 100644 --- a/modules/juce_core/javascript/juce_Javascript.cpp +++ b/modules/juce_core/javascript/juce_Javascript.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #define JUCE_JS_OPERATORS(X) \ X(semicolon, ";") X(dot, ".") X(comma, ",") \ X(openParen, "(") X(closeParen, ")") X(openBrace, "{") X(closeBrace, "}") \ @@ -1891,3 +1894,5 @@ const NamedValueSet& JavascriptEngine::getRootObjectProperties() const noexcept #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/javascript/juce_Javascript.h b/modules/juce_core/javascript/juce_Javascript.h index 93a55a405f..1a95998a5b 100644 --- a/modules/juce_core/javascript/juce_Javascript.h +++ b/modules/juce_core/javascript/juce_Javascript.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JavascriptEngine) }; + +} // namespace juce diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index 7d10dfa25e..136dd284e7 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -32,6 +32,7 @@ #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1 #define JUCE_CORE_INCLUDE_COM_SMART_PTR 1 #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1 +#define JUCE_CORE_INCLUDE_JNI_HELPERS 1 #include "juce_core.h" @@ -60,6 +61,8 @@ #if JUCE_MINGW #include + #include + #include #endif #else @@ -114,9 +117,6 @@ #endif //============================================================================== -namespace juce -{ - #include "containers/juce_AbstractFifo.cpp" #include "containers/juce_NamedValueSet.cpp" #include "containers/juce_ListenerList.cpp" @@ -179,10 +179,6 @@ namespace juce #include "files/juce_WildcardFileFilter.cpp" //============================================================================== -#if JUCE_ANDROID -#include "native/juce_android_JNIHelpers.h" -#endif - #if ! JUCE_WINDOWS #include "native/juce_posix_SharedCode.h" #include "native/juce_posix_NamedPipe.cpp" @@ -238,6 +234,8 @@ namespace juce #endif //============================================================================== +namespace juce +{ /* As the very long class names here try to explain, the purpose of this code is to cause a linker error if not all of your compile units are consistent in the options that they @@ -253,5 +251,4 @@ namespace juce this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode ::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept {} #endif - } diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index c6aead166c..f340710800 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -32,7 +32,7 @@ ID: juce_core vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE core classes description: The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality. website: http://www.juce.com/juce @@ -175,20 +175,19 @@ namespace juce { - -class StringRef; -class MemoryBlock; -class File; -class InputStream; -class OutputStream; -class DynamicObject; -class FileInputStream; -class FileOutputStream; -class XmlElement; -class JSONFormatter; - -extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept; -extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; + class StringRef; + class MemoryBlock; + class File; + class InputStream; + class OutputStream; + class DynamicObject; + class FileInputStream; + class FileOutputStream; + class XmlElement; + + extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept; + extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept; +} #include "memory/juce_Memory.h" #include "maths/juce_MathsFunctions.h" @@ -319,11 +318,13 @@ extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noe #endif #if JUCE_CORE_INCLUDE_JNI_HELPERS && JUCE_ANDROID + #include #include "native/juce_android_JNIHelpers.h" #endif - #ifndef DOXYGEN +namespace juce +{ /* As the very long class names here try to explain, the purpose of this code is to cause a linker error if not all of your compile units are consistent in the options that they @@ -341,9 +342,8 @@ extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noe { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept; }; static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode compileUnitMismatchSentinel; #endif -#endif - } +#endif #if JUCE_MSVC #pragma warning (pop) diff --git a/modules/juce_core/logging/juce_FileLogger.cpp b/modules/juce_core/logging/juce_FileLogger.cpp index 9a92d383a8..7ec9dba6df 100644 --- a/modules/juce_core/logging/juce_FileLogger.cpp +++ b/modules/juce_core/logging/juce_FileLogger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileLogger::FileLogger (const File& file, const String& welcomeMessage, const int64 maxInitialFileSizeBytes) @@ -126,3 +129,5 @@ FileLogger* FileLogger::createDateStampedLogger (const String& logFileSubDirecto .getNonexistentSibling(), welcomeMessage, 0); } + +} // namespace juce diff --git a/modules/juce_core/logging/juce_FileLogger.h b/modules/juce_core/logging/juce_FileLogger.h index c9846f81d8..ac29683ca8 100644 --- a/modules/juce_core/logging/juce_FileLogger.h +++ b/modules/juce_core/logging/juce_FileLogger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileLogger) }; + +} // namespace juce diff --git a/modules/juce_core/logging/juce_Logger.cpp b/modules/juce_core/logging/juce_Logger.cpp index b69d69dc6f..3cb0d89631 100644 --- a/modules/juce_core/logging/juce_Logger.cpp +++ b/modules/juce_core/logging/juce_Logger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Logger::Logger() {} Logger::~Logger() @@ -55,3 +58,5 @@ void JUCE_API JUCE_CALLTYPE logAssertion (const char* const filename, const int #endif } #endif + +} // namespace juce diff --git a/modules/juce_core/logging/juce_Logger.h b/modules/juce_core/logging/juce_Logger.h index 45b5949b8c..bb38c565bd 100644 --- a/modules/juce_core/logging/juce_Logger.h +++ b/modules/juce_core/logging/juce_Logger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: private: static Logger* currentLogger; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_BigInteger.cpp b/modules/juce_core/maths/juce_BigInteger.cpp index 14a9354394..78634ed2ff 100644 --- a/modules/juce_core/maths/juce_BigInteger.cpp +++ b/modules/juce_core/maths/juce_BigInteger.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace { inline uint32 bitToMask (const int bit) noexcept { return (uint32) 1 << (bit & 31); } @@ -1370,3 +1373,5 @@ public: static BigIntegerTests bigIntegerTests; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_BigInteger.h b/modules/juce_core/maths/juce_BigInteger.h index 01a0965e3d..54726e7fe4 100644 --- a/modules/juce_core/maths/juce_BigInteger.h +++ b/modules/juce_core/maths/juce_BigInteger.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -342,3 +342,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const BigInteger& // For backwards compatibility, BitArray is defined as an alias for BigInteger. typedef BigInteger BitArray; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 639d85a1df..afab1ae9d6 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class Expression::Term : public SingleThreadedReferenceCountedObject { public: @@ -1167,3 +1170,5 @@ String Expression::Scope::getScopeUID() const { return {}; } + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Expression.h b/modules/juce_core/maths/juce_Expression.h index 189a4f03d9..a3a4af7a4e 100644 --- a/modules/juce_core/maths/juce_Expression.h +++ b/modules/juce_core/maths/juce_Expression.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -249,3 +249,5 @@ private: explicit Expression (Term*); }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 7361ea71f0..7e6b348f8e 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* @@ -661,5 +662,4 @@ namespace TypeHelpers template <> struct UnsignedTypeWithSize<8> { typedef uint64 type; }; } - -//============================================================================== +} // namespace juce diff --git a/modules/juce_core/maths/juce_NormalisableRange.h b/modules/juce_core/maths/juce_NormalisableRange.h index 3f3794e151..cf5b3e7a11 100644 --- a/modules/juce_core/maths/juce_NormalisableRange.h +++ b/modules/juce_core/maths/juce_NormalisableRange.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -266,3 +266,5 @@ private: convertTo0To1Function = nullptr, snapToLegalValueFunction = nullptr; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Random.cpp b/modules/juce_core/maths/juce_Random.cpp index 9fa81369e4..219e1b40c8 100644 --- a/modules/juce_core/maths/juce_Random.cpp +++ b/modules/juce_core/maths/juce_Random.cpp @@ -20,7 +20,10 @@ ============================================================================== */ -Random::Random (const int64 seedValue) noexcept : seed (seedValue) +namespace juce +{ + +Random::Random (int64 seedValue) noexcept : seed (seedValue) { } @@ -181,3 +184,5 @@ public: static RandomTests randomTests; #endif + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Random.h b/modules/juce_core/maths/juce_Random.h index fa97413f3b..f3d7d490cf 100644 --- a/modules/juce_core/maths/juce_Random.h +++ b/modules/juce_core/maths/juce_Random.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -131,3 +131,5 @@ private: JUCE_LEAK_DETECTOR (Random) }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_Range.h b/modules/juce_core/maths/juce_Range.h index bdb388530f..bbdfa765f6 100644 --- a/modules/juce_core/maths/juce_Range.h +++ b/modules/juce_core/maths/juce_Range.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A general-purpose range object, that simply represents any linear range with @@ -301,3 +301,5 @@ private: //============================================================================== ValueType start, end; }; + +} // namespace juce diff --git a/modules/juce_core/maths/juce_StatisticsAccumulator.h b/modules/juce_core/maths/juce_StatisticsAccumulator.h index 31be08e4d3..4d1b61f4ba 100644 --- a/modules/juce_core/maths/juce_StatisticsAccumulator.h +++ b/modules/juce_core/maths/juce_StatisticsAccumulator.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -133,3 +133,5 @@ private: KahanSum sum, sumSquares; FloatType minimum, maximum; }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index 65408b4c01..585b135504 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef DOXYGEN namespace AtomicHelpers @@ -44,7 +45,7 @@ Atomic() noexcept : value (0) {} /** Creates a new value, with a given initial value. */ - Atomic (const Type initialValue) noexcept : value (initialValue) {} + Atomic (Type initialValue) noexcept : value (initialValue) {} /** Copies another value (atomically). */ Atomic (const Atomic& other) noexcept : value (other.get()) {} @@ -53,7 +54,7 @@ ~Atomic() noexcept { #if __cpp_lib_atomic_is_always_lock_free - static_assert (std::atomic::is_always_lock_free(), + static_assert (std::atomic::is_always_lock_free, "This class can only be used for lock-free types"); #endif } @@ -104,7 +105,7 @@ } /** Copies another value into this one (atomically). */ - Atomic& operator= (const Type newValue) noexcept + Atomic& operator= (Type newValue) noexcept { value = newValue; return *this; @@ -127,7 +128,7 @@ Internally this calls std::atomic_thread_fence with memory_order_seq_cst (the strictest std::memory_order). */ - void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } + void memoryBarrier() noexcept { atomic_thread_fence (std::memory_order_seq_cst); } /** The std::atomic object that this class operates on. */ std::atomic value; @@ -472,3 +473,5 @@ #endif #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ByteOrder.h b/modules/juce_core/memory/juce_ByteOrder.h index 49c79c181a..f2e53d5cb4 100644 --- a/modules/juce_core/memory/juce_ByteOrder.h +++ b/modules/juce_core/memory/juce_ByteOrder.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Contains static methods for converting the byte order between different @@ -233,3 +233,5 @@ inline int ByteOrder::littleEndian24Bit (const void* const bytes) noexcept inline int ByteOrder::bigEndian24Bit (const void* const bytes) noexcept { return (int) ((((unsigned int) static_cast (bytes)[0]) << 16) | (((unsigned int) static_cast (bytes)[1]) << 8) | ((unsigned int) static_cast (bytes)[2])); } inline void ByteOrder::littleEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast (destBytes)[0] = (uint8) value; static_cast (destBytes)[1] = (uint8) (value >> 8); static_cast (destBytes)[2] = (uint8) (value >> 16); } inline void ByteOrder::bigEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast (destBytes)[0] = (uint8) (value >> 16); static_cast (destBytes)[1] = (uint8) (value >> 8); static_cast (destBytes)[2] = (uint8) value; } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ContainerDeletePolicy.h b/modules/juce_core/memory/juce_ContainerDeletePolicy.h index 156feafa5c..26d1497382 100644 --- a/modules/juce_core/memory/juce_ContainerDeletePolicy.h +++ b/modules/juce_core/memory/juce_ContainerDeletePolicy.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -51,3 +52,5 @@ struct ContainerDeletePolicy delete object; } }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_HeapBlock.h b/modules/juce_core/memory/juce_HeapBlock.h index 5bb5aa9657..a469d58905 100644 --- a/modules/juce_core/memory/juce_HeapBlock.h +++ b/modules/juce_core/memory/juce_HeapBlock.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if ! (defined (DOXYGEN) || JUCE_EXCEPTIONS_DISABLED) namespace HeapBlockHelper @@ -307,3 +308,5 @@ private: JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point! #endif }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_LeakedObjectDetector.h b/modules/juce_core/memory/juce_LeakedObjectDetector.h index 293ab18daf..d48be309eb 100644 --- a/modules/juce_core/memory/juce_LeakedObjectDetector.h +++ b/modules/juce_core/memory/juce_LeakedObjectDetector.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -134,3 +134,5 @@ private: #define JUCE_LEAK_DETECTOR(OwnerClass) #endif #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Memory.h b/modules/juce_core/memory/juce_Memory.h index ab9d833082..83b81117a9 100644 --- a/modules/juce_core/memory/juce_Memory.h +++ b/modules/juce_core/memory/juce_Memory.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** Fills a block of memory with zeros. */ @@ -72,7 +73,6 @@ inline Type readUnaligned (const void* srcPtr) noexcept { Type value; memcpy (&value, srcPtr, sizeof (Type)); - return value; } @@ -80,7 +80,7 @@ inline Type readUnaligned (const void* srcPtr) noexcept template inline void writeUnaligned (void* dstPtr, Type value) noexcept { - memcpy (dstPtr, &value, sizeof(Type)); + memcpy (dstPtr, &value, sizeof (Type)); } //============================================================================== @@ -140,3 +140,5 @@ inline void writeUnaligned (void* dstPtr, Type value) noexcept #ifndef juce_UseDebuggingNewOperator #define juce_UseDebuggingNewOperator #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_MemoryBlock.cpp b/modules/juce_core/memory/juce_MemoryBlock.cpp index 85d3e20d91..8bf8b76672 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/modules/juce_core/memory/juce_MemoryBlock.cpp @@ -20,8 +20,10 @@ ============================================================================== */ -MemoryBlock::MemoryBlock() noexcept - : size (0) +namespace juce +{ + +MemoryBlock::MemoryBlock() noexcept : size (0) { } @@ -405,3 +407,5 @@ bool MemoryBlock::fromBase64Encoding (StringRef s) } } } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_MemoryBlock.h b/modules/juce_core/memory/juce_MemoryBlock.h index ad70739a17..888449a4be 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.h +++ b/modules/juce_core/memory/juce_MemoryBlock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -256,3 +256,5 @@ private: JUCE_LEAK_DETECTOR (MemoryBlock) }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_OptionalScopedPointer.h b/modules/juce_core/memory/juce_OptionalScopedPointer.h index 6d6ad66c3e..898c95ca56 100644 --- a/modules/juce_core/memory/juce_OptionalScopedPointer.h +++ b/modules/juce_core/memory/juce_OptionalScopedPointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -180,3 +180,5 @@ private: // myPointer.setOwned (myScopedPointer.release()) void setOwned (const ScopedPointer&) JUCE_DELETED_FUNCTION; }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ReferenceCountedObject.h b/modules/juce_core/memory/juce_ReferenceCountedObject.h index ba4b893c61..052e136dc3 100644 --- a/modules/juce_core/memory/juce_ReferenceCountedObject.h +++ b/modules/juce_core/memory/juce_ReferenceCountedObject.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -407,3 +407,5 @@ bool operator!= (ReferenceCountedObjectClass* object1, const ReferenceCountedObj { return object1 != object2.get(); } + +} // namespace juce diff --git a/modules/juce_core/memory/juce_ScopedPointer.h b/modules/juce_core/memory/juce_ScopedPointer.h index d0c5cee701..8c7499ec8a 100644 --- a/modules/juce_core/memory/juce_ScopedPointer.h +++ b/modules/juce_core/memory/juce_ScopedPointer.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -249,3 +250,5 @@ template void deleteAndZero (ScopedPointer&) { static_assert (sizeof (Type) == 12345, "Attempt to call deleteAndZero() on a ScopedPointer"); } #endif + +} // namespace juce diff --git a/modules/juce_core/memory/juce_SharedResourcePointer.h b/modules/juce_core/memory/juce_SharedResourcePointer.h index 181f93fc6f..89de47a64b 100644 --- a/modules/juce_core/memory/juce_SharedResourcePointer.h +++ b/modules/juce_core/memory/juce_SharedResourcePointer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -158,3 +158,5 @@ private: JUCE_LEAK_DETECTOR (SharedResourcePointer) }; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_Singleton.h b/modules/juce_core/memory/juce_Singleton.h index 9bcaa34eb5..e9567e4615 100644 --- a/modules/juce_core/memory/juce_Singleton.h +++ b/modules/juce_core/memory/juce_Singleton.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -279,3 +279,5 @@ #define juce_ImplementSingleton_SingleThreaded(classname) \ \ classname* classname::_singletonInstance = nullptr; + +} // namespace juce diff --git a/modules/juce_core/memory/juce_WeakReference.h b/modules/juce_core/memory/juce_WeakReference.h index 1751cecc72..c743fc6c9b 100644 --- a/modules/juce_core/memory/juce_WeakReference.h +++ b/modules/juce_core/memory/juce_WeakReference.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: return (o != nullptr) ? o->masterReference.getSharedPointer (o) : nullptr; } }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Result.cpp b/modules/juce_core/misc/juce_Result.cpp index 678af8747c..f94e0f2688 100644 --- a/modules/juce_core/misc/juce_Result.cpp +++ b/modules/juce_core/misc/juce_Result.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Result::Result() noexcept {} Result::Result (const String& message) noexcept @@ -73,3 +76,5 @@ bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); } Result::operator bool() const noexcept { return errorMessage.isEmpty(); } bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); } bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); } + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Result.h b/modules/juce_core/misc/juce_Result.h index 0eda20c38c..5f08bfc4d6 100644 --- a/modules/juce_core/misc/juce_Result.h +++ b/modules/juce_core/misc/juce_Result.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -110,3 +110,5 @@ private: operator int() const; operator void*() const; }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_RuntimePermissions.cpp b/modules/juce_core/misc/juce_RuntimePermissions.cpp index e15a071935..bf7306b554 100644 --- a/modules/juce_core/misc/juce_RuntimePermissions.cpp +++ b/modules/juce_core/misc/juce_RuntimePermissions.cpp @@ -20,23 +20,17 @@ ============================================================================== */ +namespace juce +{ + #if ! JUCE_ANDROID // We currently don't request runtime permissions on any other platform // than Android, so this file contains a dummy implementation for those. // This may change in the future. -void RuntimePermissions::request (PermissionID /*permission*/, Callback callback) -{ - callback (true); -} - -bool RuntimePermissions::isRequired (PermissionID /*permission*/) -{ - return false; -} - -bool RuntimePermissions::isGranted (PermissionID /*permission*/) -{ - return true; -} +void RuntimePermissions::request (PermissionID, Callback callback) { callback (true); } +bool RuntimePermissions::isRequired (PermissionID) { return false; } +bool RuntimePermissions::isGranted (PermissionID) { return true; } #endif + +} // namespace juce diff --git a/modules/juce_core/misc/juce_RuntimePermissions.h b/modules/juce_core/misc/juce_RuntimePermissions.h index bb170eea33..4de84c678f 100644 --- a/modules/juce_core/misc/juce_RuntimePermissions.h +++ b/modules/juce_core/misc/juce_RuntimePermissions.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -121,3 +122,5 @@ public: */ static bool isGranted (PermissionID permission); }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/modules/juce_core/misc/juce_StdFunctionCompat.cpp index cf548ef609..93bcf5c602 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/modules/juce_core/misc/juce_StdFunctionCompat.cpp @@ -28,12 +28,15 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS namespace FunctionTestsHelpers { - void incrementArgument (int& x) { x++; }; - double multiply (double x, double a) noexcept { return a * x; }; + void incrementArgument (int& x) { x++; } + double multiply (double x, double a) noexcept { return a * x; } struct BigData { @@ -252,3 +255,5 @@ public: static FunctionTests functionTests; #endif + +} // namespace juce diff --git a/modules/juce_core/misc/juce_StdFunctionCompat.h b/modules/juce_core/misc/juce_StdFunctionCompat.h index f1b262b760..3d5381a461 100644 --- a/modules/juce_core/misc/juce_StdFunctionCompat.h +++ b/modules/juce_core/misc/juce_StdFunctionCompat.h @@ -28,8 +28,6 @@ ============================================================================== */ -#pragma once - namespace std { /** diff --git a/modules/juce_core/misc/juce_Uuid.cpp b/modules/juce_core/misc/juce_Uuid.cpp index 03f911cbf2..807031d02b 100644 --- a/modules/juce_core/misc/juce_Uuid.cpp +++ b/modules/juce_core/misc/juce_Uuid.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Uuid::Uuid() { Random r; @@ -130,3 +133,5 @@ uint16 Uuid::getTimeHighAndVersion() const noexcept { return ByteOrder::bi uint8 Uuid::getClockSeqAndReserved() const noexcept { return uuid[8]; } uint8 Uuid::getClockSeqLow() const noexcept { return uuid[9]; } uint64 Uuid::getNode() const noexcept { return (((uint64) ByteOrder::bigEndianShort (uuid + 10)) << 32) + ByteOrder::bigEndianInt (uuid + 12); } + +} // namespace juce diff --git a/modules/juce_core/misc/juce_Uuid.h b/modules/juce_core/misc/juce_Uuid.h index cab55d8dc7..5eee6d67cc 100644 --- a/modules/juce_core/misc/juce_Uuid.h +++ b/modules/juce_core/misc/juce_Uuid.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_LEAK_DETECTOR (Uuid) }; + +} // namespace juce diff --git a/modules/juce_core/misc/juce_WindowsRegistry.h b/modules/juce_core/misc/juce_WindowsRegistry.h index 239849cc74..1c49ac32ae 100644 --- a/modules/juce_core/misc/juce_WindowsRegistry.h +++ b/modules/juce_core/misc/juce_WindowsRegistry.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || DOXYGEN @@ -131,3 +132,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_core/native/java/JuceAppActivity.java b/modules/juce_core/native/java/JuceAppActivity.java index 53c3ff0644..16b3eeabc1 100644 --- a/modules/juce_core/native/java/JuceAppActivity.java +++ b/modules/juce_core/native/java/JuceAppActivity.java @@ -436,11 +436,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("OK", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); @@ -455,11 +462,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton (okButtonText.isEmpty() ? "OK" : okButtonText, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 1); } }) @@ -467,7 +481,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); @@ -481,11 +495,18 @@ public class JuceAppActivity extends Activity builder.setTitle (title) .setMessage (message) .setCancelable (true) + .setOnCancelListener (new DialogInterface.OnCancelListener() + { + public void onCancel (DialogInterface dialog) + { + JuceAppActivity.this.alertDismissed (callback, 0); + } + }) .setPositiveButton ("Yes", new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 1); } }) @@ -493,7 +514,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 2); } }) @@ -501,7 +522,7 @@ public class JuceAppActivity extends Activity { public void onClick (DialogInterface dialog, int id) { - dialog.cancel(); + dialog.dismiss(); JuceAppActivity.this.alertDismissed (callback, 0); } }); @@ -899,13 +920,75 @@ public class JuceAppActivity extends Activity //============================================================================== public static class HTTPStream { - public HTTPStream (HttpURLConnection connection_, - int[] statusCode_, - StringBuffer responseHeaders_) + public HTTPStream (String address, boolean isPostToUse, byte[] postDataToUse, + String headersToUse, int timeOutMsToUse, + int[] statusCodeToUse, StringBuffer responseHeadersToUse, + int numRedirectsToFollowToUse, String httpRequestCmdToUse) throws IOException { - connection = connection_; - statusCode = statusCode_; - responseHeaders = responseHeaders_; + isPost = isPostToUse; + postData = postDataToUse; + headers = headersToUse; + timeOutMs = timeOutMsToUse; + statusCode = statusCodeToUse; + responseHeaders = responseHeadersToUse; + totalLength = -1; + numRedirectsToFollow = numRedirectsToFollowToUse; + httpRequestCmd = httpRequestCmdToUse; + + connection = createConnection (address, isPost, postData, headers, timeOutMs, httpRequestCmd); + } + + private final HttpURLConnection createConnection (String address, boolean isPost, byte[] postData, + String headers, int timeOutMs, String httpRequestCmdToUse) throws IOException + { + HttpURLConnection newConnection = (HttpURLConnection) (new URL(address).openConnection()); + + try + { + newConnection.setInstanceFollowRedirects (false); + newConnection.setConnectTimeout (timeOutMs); + newConnection.setReadTimeout (timeOutMs); + + // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. + // So convert headers string to an array, with an element for each line + String headerLines[] = headers.split("\\n"); + + // Set request headers + for (int i = 0; i < headerLines.length; ++i) + { + int pos = headerLines[i].indexOf (":"); + + if (pos > 0 && pos < headerLines[i].length()) + { + String field = headerLines[i].substring (0, pos); + String value = headerLines[i].substring (pos + 1); + + if (value.length() > 0) + newConnection.setRequestProperty (field, value); + } + } + + newConnection.setRequestMethod (httpRequestCmd); + + if (isPost) + { + newConnection.setDoOutput (true); + + if (postData != null) + { + OutputStream out = newConnection.getOutputStream(); + out.write(postData); + out.flush(); + } + } + + return newConnection; + } + catch (Throwable e) + { + newConnection.disconnect(); + throw new IOException ("Connection error"); + } } private final InputStream getCancellableStream (final boolean isInput) throws ExecutionException @@ -928,19 +1011,12 @@ public class JuceAppActivity extends Activity try { - if (connection.getConnectTimeout() > 0) - return streamFuture.get (connection.getConnectTimeout(), TimeUnit.MILLISECONDS); - else - return streamFuture.get(); + return streamFuture.get(); } catch (InterruptedException e) { return null; } - catch (TimeoutException e) - { - return null; - } catch (CancellationException e) { return null; @@ -948,6 +1024,89 @@ public class JuceAppActivity extends Activity } public final boolean connect() + { + boolean result = false; + int numFollowedRedirects = 0; + + while (true) + { + result = doConnect(); + + if (! result) + return false; + + if (++numFollowedRedirects > numRedirectsToFollow) + break; + + int status = statusCode[0]; + + if (status == 301 || status == 302 || status == 303 || status == 307) + { + // Assumes only one occurrence of "Location" + int pos1 = responseHeaders.indexOf ("Location:") + 10; + int pos2 = responseHeaders.indexOf ("\n", pos1); + + if (pos2 > pos1) + { + String currentLocation = connection.getURL().toString(); + String newLocation = responseHeaders.substring (pos1, pos2); + + try + { + // Handle newLocation whether it's absolute or relative + URL baseUrl = new URL (currentLocation); + URL newUrl = new URL (baseUrl, newLocation); + String transformedNewLocation = newUrl.toString(); + + if (transformedNewLocation != currentLocation) + { + // Clear responseHeaders before next iteration + responseHeaders.delete (0, responseHeaders.length()); + + synchronized (createStreamLock) + { + if (hasBeenCancelled.get()) + return false; + + connection.disconnect(); + + try + { + connection = createConnection (transformedNewLocation, isPost, + postData, headers, timeOutMs, + httpRequestCmd); + } + catch (Throwable e) + { + return false; + } + } + } + else + { + break; + } + } + catch (Throwable e) + { + return false; + } + } + else + { + break; + } + } + else + { + break; + } + } + + return result; + } + + private final boolean doConnect() { synchronized (createStreamLock) { @@ -985,9 +1144,16 @@ public class JuceAppActivity extends Activity {} for (java.util.Map.Entry> entry : connection.getHeaderFields().entrySet()) + { if (entry.getKey() != null && entry.getValue() != null) - responseHeaders.append (entry.getKey() + ": " - + android.text.TextUtils.join (",", entry.getValue()) + "\n"); + { + responseHeaders.append(entry.getKey() + ": " + + android.text.TextUtils.join(",", entry.getValue()) + "\n"); + + if (entry.getKey().compareTo ("Content-Length") == 0) + totalLength = Integer.decode (entry.getValue().get (0)); + } + } return true; } @@ -1090,13 +1256,20 @@ public class JuceAppActivity extends Activity } public final long getPosition() { return position; } - public final long getTotalLength() { return -1; } + public final long getTotalLength() { return totalLength; } public final boolean isExhausted() { return false; } public final boolean setPosition (long newPos) { return false; } + private boolean isPost; + private byte[] postData; + private String headers; + private int timeOutMs; + String httpRequestCmd; private HttpURLConnection connection; private int[] statusCode; private StringBuffer responseHeaders; + private int totalLength; + private int numRedirectsToFollow; private InputStream inputStream; private long position; private final ReentrantLock createStreamLock = new ReentrantLock(); @@ -1118,89 +1291,15 @@ public class JuceAppActivity extends Activity else if (timeOutMs == 0) timeOutMs = 30000; - // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines. - // So convert headers string to an array, with an element for each line - String headerLines[] = headers.split("\\n"); - for (;;) { try { - HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection()); - - if (connection != null) - { - try - { - connection.setInstanceFollowRedirects (false); - connection.setConnectTimeout (timeOutMs); - connection.setReadTimeout (timeOutMs); - - // Set request headers - for (int i = 0; i < headerLines.length; ++i) - { - int pos = headerLines[i].indexOf (":"); - - if (pos > 0 && pos < headerLines[i].length()) - { - String field = headerLines[i].substring (0, pos); - String value = headerLines[i].substring (pos + 1); - - if (value.length() > 0) - connection.setRequestProperty (field, value); - } - } - - connection.setRequestMethod (httpRequestCmd); - if (isPost) - { - connection.setDoOutput (true); - - if (postData != null) - { - OutputStream out = connection.getOutputStream(); - out.write(postData); - out.flush(); - } - } - - HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders); - - // Process redirect & continue as necessary - int status = statusCode[0]; - - if (--numRedirectsToFollow >= 0 - && (status == 301 || status == 302 || status == 303 || status == 307)) - { - // Assumes only one occurrence of "Location" - int pos1 = responseHeaders.indexOf ("Location:") + 10; - int pos2 = responseHeaders.indexOf ("\n", pos1); + HTTPStream httpStream = new HTTPStream (address, isPost, postData, headers, + timeOutMs, statusCode, responseHeaders, + numRedirectsToFollow, httpRequestCmd); - if (pos2 > pos1) - { - String newLocation = responseHeaders.substring(pos1, pos2); - // Handle newLocation whether it's absolute or relative - URL baseUrl = new URL (address); - URL newUrl = new URL (baseUrl, newLocation); - String transformedNewLocation = newUrl.toString(); - - if (transformedNewLocation != address) - { - address = transformedNewLocation; - // Clear responseHeaders before next iteration - responseHeaders.delete (0, responseHeaders.length()); - continue; - } - } - } - - return httpStream; - } - catch (Throwable e) - { - connection.disconnect(); - } - } + return httpStream; } catch (Throwable e) {} @@ -1226,7 +1325,14 @@ public class JuceAppActivity extends Activity return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath(); } - public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); } + public static final String getDocumentsFolder() + { + if (getAndroidSDKVersion() >= 19) + return getFileLocation ("Documents"); + + return Environment.getDataDirectory().getAbsolutePath(); + } + public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); } public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); } public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); } @@ -1321,7 +1427,7 @@ public class JuceAppActivity extends Activity return null; } - public final int getAndroidSDKVersion() + public static final int getAndroidSDKVersion() { return android.os.Build.VERSION.SDK_INT; } diff --git a/modules/juce_core/native/juce_android_Files.cpp b/modules/juce_core/native/juce_android_Files.cpp index 2b8f7ea998..5c0de20908 100644 --- a/modules/juce_core/native/juce_android_Files.cpp +++ b/modules/juce_core/native/juce_android_Files.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "(Landroid/content/Context;Landroid/media/MediaScannerConnection$MediaScannerConnectionClient;)V") \ METHOD (connect, "connect", "()V") \ @@ -105,7 +107,11 @@ File File::getSpecialLocation (const SpecialLocationType type) return File ("/system/app"); case tempDirectory: - return File (android.appDataDir).getChildFile (".temp"); + { + File tmp = File (android.appDataDir).getChildFile (".temp"); + tmp.createDirectory(); + return File (tmp.getFullPathName()); + } case invokedExecutableFile: case currentExecutableFile: @@ -186,3 +192,5 @@ void FileOutputStream::flushInternal() new SingleMediaScanner (file.getFullPathName()); } } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index a0e17e347e..ceb8dc3948 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if ! (defined (JUCE_ANDROID_ACTIVITY_CLASSNAME) && defined (JUCE_ANDROID_ACTIVITY_CLASSPATH)) #error "The JUCE_ANDROID_ACTIVITY_CLASSNAME and JUCE_ANDROID_ACTIVITY_CLASSPATH macros must be set!" @@ -305,7 +306,7 @@ extern AndroidSystem android; METHOD (getScreenSaver, "getScreenSaver", "()Z") \ METHOD (getAndroidMidiDeviceManager, "getAndroidMidiDeviceManager", "()L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$MidiDeviceManager;") \ METHOD (getAndroidBluetoothManager, "getAndroidBluetoothManager", "()L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$BluetoothManager;") \ - METHOD (getAndroidSDKVersion, "getAndroidSDKVersion", "()I") \ + STATICMETHOD (getAndroidSDKVersion, "getAndroidSDKVersion", "()I") \ METHOD (audioManagerGetProperty, "audioManagerGetProperty", "(Ljava/lang/String;)Ljava/lang/String;") \ METHOD (hasSystemFeature, "hasSystemFeature", "(Ljava/lang/String;)Z" ) \ METHOD (requestRuntimePermission, "requestRuntimePermission", "(IJ)V" ) \ @@ -429,3 +430,5 @@ LocalRef CreateJavaInterface (AndroidInterfaceImplementer* implementer, const StringArray& interfaceNames); LocalRef CreateJavaInterface (AndroidInterfaceImplementer* implementer, const String& interfaceName); + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Misc.cpp b/modules/juce_core/native/juce_android_Misc.cpp index 4a0f8189f7..8ad39bed56 100644 --- a/modules/juce_core/native/juce_android_Misc.cpp +++ b/modules/juce_core/native/juce_android_Misc.cpp @@ -20,7 +20,12 @@ ============================================================================== */ +namespace juce +{ + void Logger::outputDebugString (const String& text) { __android_log_print (ANDROID_LOG_INFO, "JUCE", "%s", text.toUTF8().getAddress()); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Network.cpp b/modules/juce_core/native/juce_android_Network.cpp index 55e33f8b2f..136ce47de3 100644 --- a/modules/juce_core/native/juce_android_Network.cpp +++ b/modules/juce_core/native/juce_android_Network.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "()V") \ METHOD (toString, "toString", "()Ljava/lang/String;") \ @@ -132,8 +134,8 @@ public: javaString (httpRequest).get())); } - if (stream != 0) - stream.callBooleanMethod (HTTPStream.connect); + if (stream != 0 && ! stream.callBooleanMethod (HTTPStream.connect)) + stream.clear(); jint* const statusCodeElements = env->GetIntArrayElements (statusCodeArray, 0); statusCode = statusCodeElements[0]; @@ -298,3 +300,5 @@ void IPAddress::findAllAddresses (Array& result, bool /*includeIPv6*/ ::close (sock); } } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_RuntimePermissions.cpp b/modules/juce_core/native/juce_android_RuntimePermissions.cpp index 155cffc746..6158271d64 100644 --- a/modules/juce_core/native/juce_android_RuntimePermissions.cpp +++ b/modules/juce_core/native/juce_android_RuntimePermissions.cpp @@ -20,27 +20,27 @@ ============================================================================== */ -namespace +namespace juce { - void handleAndroidCallback (bool permissionWasGranted, RuntimePermissions::Callback* callbackPtr) + +static void handleAndroidCallback (bool permissionWasGranted, RuntimePermissions::Callback* callbackPtr) +{ + if (callbackPtr == nullptr) { - if (callbackPtr == nullptr) - { - // got a nullptr passed in from java! this should never happen... - jassertfalse; - return; - } + // got a nullptr passed in from java! this should never happen... + jassertfalse; + return; + } - std::unique_ptr uptr (callbackPtr); + std::unique_ptr uptr (callbackPtr); - if (RuntimePermissions::Callback callbackObj = *uptr) - callbackObj (permissionWasGranted); - } + if (RuntimePermissions::Callback callbackObj = *uptr) + callbackObj (permissionWasGranted); } JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, androidRuntimePermissionsCallback, - void, (JNIEnv* env, jobject /*javaObjectHandle*/, jboolean permissionsGranted, jlong callbackPtr)) + void, (JNIEnv* env, jobject, jboolean permissionsGranted, jlong callbackPtr)) { setEnv (env); handleAndroidCallback (permissionsGranted != 0, @@ -84,3 +84,5 @@ bool RuntimePermissions::isGranted (PermissionID permission) { return android.activity.callBooleanMethod (JuceAppActivity.isPermissionGranted, permission); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_SystemStats.cpp b/modules/juce_core/native/juce_android_SystemStats.cpp index 762ce02f48..00d0c44c64 100644 --- a/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/modules/juce_core/native/juce_android_SystemStats.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ STATICMETHOD (newProxyInstance, "newProxyInstance", "(Ljava/lang/ClassLoader;[Ljava/lang/Class;Ljava/lang/reflect/InvocationHandler;)Ljava/lang/Object;") \ @@ -514,3 +516,5 @@ bool Time::setSystemTimeToThisTime() const jassertfalse; return false; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_android_Threads.cpp b/modules/juce_core/native/juce_android_Threads.cpp index 7a526e4503..be8780d232 100644 --- a/modules/juce_core/native/juce_android_Threads.cpp +++ b/modules/juce_core/native/juce_android_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -70,3 +73,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() {} JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() {} + +} // namespace juce diff --git a/modules/juce_core/native/juce_curl_Network.cpp b/modules/juce_core/native/juce_curl_Network.cpp index 9c14f69848..8781712c18 100644 --- a/modules/juce_core/native/juce_curl_Network.cpp +++ b/modules/juce_core/native/juce_curl_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class WebInputStream::Pimpl { public: @@ -552,3 +555,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra { return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_CommonFile.cpp b/modules/juce_core/native/juce_linux_CommonFile.cpp index 1166bd7b7a..c22f64f779 100644 --- a/modules/juce_core/native/juce_linux_CommonFile.cpp +++ b/modules/juce_core/native/juce_linux_CommonFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + bool File::copyInternal (const File& dest) const { FileInputStream in (*this); @@ -145,3 +148,5 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, { return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp index 3b239df28c..d022175a64 100644 --- a/modules/juce_core/native/juce_linux_Files.cpp +++ b/modules/juce_core/native/juce_linux_Files.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum { U_ISOFS_SUPER_MAGIC = 0x9660, // linux/iso_fs.h @@ -234,3 +237,5 @@ void File::revealToUser() const else if (getParentDirectory().exists()) getParentDirectory().startAsProcess(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Network.cpp b/modules/juce_core/native/juce_linux_Network.cpp index c2965a323e..2ca8d51200 100644 --- a/modules/juce_core/native/juce_linux_Network.cpp +++ b/modules/juce_core/native/juce_linux_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MACAddress::findAllAddresses (Array& result) { const int s = socket (AF_INET, SOCK_DGRAM, 0); @@ -578,3 +581,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_SystemStats.cpp b/modules/juce_core/native/juce_linux_SystemStats.cpp index 4b8f4bdfb9..40f19187fc 100644 --- a/modules/juce_core/native/juce_linux_SystemStats.cpp +++ b/modules/juce_core/native/juce_linux_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void Logger::outputDebugString (const String& text) { std::cerr << text << std::endl; @@ -199,3 +202,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept .getIntValue() > 0; #endif } + +} // namespace juce diff --git a/modules/juce_core/native/juce_linux_Threads.cpp b/modules/juce_core/native/juce_linux_Threads.cpp index d293a76e03..144fa05d95 100644 --- a/modules/juce_core/native/juce_linux_Threads.cpp +++ b/modules/juce_core/native/juce_linux_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -55,3 +58,5 @@ static bool swapUserAndEffectiveUser() JUCE_API void JUCE_CALLTYPE Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); } JUCE_API void JUCE_CALLTYPE Process::lowerPrivilege() { if (geteuid() == 0 && getuid() != 0) swapUserAndEffectiveUser(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index 18bf390d94..958238aa5c 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -236,7 +239,7 @@ File File::getSpecialLocation (const SpecialLocationType type) HeapBlock buffer; buffer.calloc (size + 8); - _NSGetExecutablePath (buffer.getData(), &size); + _NSGetExecutablePath (buffer.get(), &size); return File (String::fromUTF8 (buffer, (int) size)); } @@ -398,9 +401,6 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& #if JUCE_IOS ignoreUnused (parameters); - if (SystemStats::isRunningInAppExtensionSandbox()) - return false; - #if (! defined __IPHONE_OS_VERSION_MIN_REQUIRED) || (! defined __IPHONE_10_0) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) return [[UIApplication sharedApplication] openURL: filenameAsURL]; #else @@ -490,3 +490,5 @@ void File::addToDock() const } } #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 6410a8b223..f182a42b52 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MACAddress::findAllAddresses (Array& result) { ifaddrs* addrs = nullptr; @@ -1119,3 +1122,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Strings.mm b/modules/juce_core/native/juce_mac_Strings.mm index 62f9d8717b..b8a479ead8 100644 --- a/modules/juce_core/native/juce_mac_Strings.mm +++ b/modules/juce_core/native/juce_mac_Strings.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + String String::fromCFString (CFStringRef cfString) { if (cfString == 0) @@ -32,8 +35,8 @@ String String::fromCFString (CFStringRef cfString) HeapBlock utf8 ((size_t) bytesNeeded + 1); CFStringGetBytes (cfString, range, kCFStringEncodingUTF8, 0, false, utf8, bytesNeeded + 1, nullptr); - return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.getData()), - CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.getData() + bytesNeeded)); + return String (CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get()), + CharPointer_UTF8 ((const CharPointer_UTF8::CharType*) utf8.get() + bytesNeeded)); } CFStringRef String::toCFString() const @@ -89,7 +92,7 @@ String String::convertToPrecomposedUnicode() const bytesNeeded, &bytesRead, &outputBufferSize, tempOut) == noErr) { - result = String (CharPointer_UTF16 ((CharPointer_UTF16::CharType*) tempOut.getData())); + result = String (CharPointer_UTF16 ((CharPointer_UTF16::CharType*) tempOut.get())); } DisposeUnicodeToTextInfo (&conversionInfo); @@ -98,3 +101,5 @@ String String::convertToPrecomposedUnicode() const return result; #endif } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_SystemStats.mm b/modules/juce_core/native/juce_mac_SystemStats.mm index db81b1991b..81f62192ec 100644 --- a/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/modules/juce_core/native/juce_mac_SystemStats.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ScopedAutoReleasePool::ScopedAutoReleasePool() { pool = [[NSAutoreleasePool alloc] init]; @@ -144,7 +147,7 @@ String SystemStats::getDeviceDescription() { HeapBlock model (size); if (sysctlbyname ("hw.model", model, &size, nullptr, 0) >= 0) - return model.getData(); + return model.get(); } return {}; #endif @@ -313,3 +316,5 @@ int SystemStats::getPageSize() { return (int) NSPageSize(); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_mac_Threads.mm b/modules/juce_core/native/juce_mac_Threads.mm index a02403e178..8ac6c0ed52 100644 --- a/modules/juce_core/native/juce_mac_Threads.mm +++ b/modules/juce_core/native/juce_mac_Threads.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + /* Note that a lot of methods that you'd expect to find in this file actually live in juce_posix_SharedCode.h! @@ -82,3 +85,5 @@ JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept sysctl (m, 4, &info, &sz, 0, 0); return (info.kp_proc.p_flag & P_TRACED) != 0; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_osx_ObjCHelpers.h b/modules/juce_core/native/juce_osx_ObjCHelpers.h index 760803edfc..b335287cbe 100644 --- a/modules/juce_core/native/juce_osx_ObjCHelpers.h +++ b/modules/juce_core/native/juce_osx_ObjCHelpers.h @@ -20,92 +20,89 @@ ============================================================================== */ -#pragma once - - /* This file contains a few helper functions that are used internally but which need to be kept away from the public headers because they use obj-C symbols. */ -namespace +namespace juce { - //============================================================================== - static inline String nsStringToJuce (NSString* s) - { - return CharPointer_UTF8 ([s UTF8String]); - } - - static inline NSString* juceStringToNS (const String& s) - { - return [NSString stringWithUTF8String: s.toUTF8()]; - } - static inline NSString* nsStringLiteral (const char* const s) noexcept - { - return [NSString stringWithUTF8String: s]; - } +//============================================================================== +static inline String nsStringToJuce (NSString* s) +{ + return CharPointer_UTF8 ([s UTF8String]); +} - static inline NSString* nsEmptyString() noexcept - { - return [NSString string]; - } +static inline NSString* juceStringToNS (const String& s) +{ + return [NSString stringWithUTF8String: s.toUTF8()]; +} - static inline NSURL* createNSURLFromFile (const String& f) - { - return [NSURL fileURLWithPath: juceStringToNS (f)]; - } +static inline NSString* nsStringLiteral (const char* const s) noexcept +{ + return [NSString stringWithUTF8String: s]; +} - static inline NSURL* createNSURLFromFile (const File& f) - { - return createNSURLFromFile (f.getFullPathName()); - } +static inline NSString* nsEmptyString() noexcept +{ + return [NSString string]; +} - static inline NSArray* createNSArrayFromStringArray (const StringArray& strings) - { - auto* array = [[NSMutableArray alloc] init]; +static inline NSURL* createNSURLFromFile (const String& f) +{ + return [NSURL fileURLWithPath: juceStringToNS (f)]; +} - for (auto string: strings) - [array addObject:juceStringToNS (string)]; +static inline NSURL* createNSURLFromFile (const File& f) +{ + return createNSURLFromFile (f.getFullPathName()); +} - return [array autorelease]; - } +static inline NSArray* createNSArrayFromStringArray (const StringArray& strings) +{ + auto* array = [[NSMutableArray alloc] init]; - #if JUCE_MAC - template - static NSRect makeNSRect (const RectangleType& r) noexcept - { - return NSMakeRect (static_cast (r.getX()), - static_cast (r.getY()), - static_cast (r.getWidth()), - static_cast (r.getHeight())); - } - #endif - #if JUCE_MAC || JUCE_IOS - #if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES - - // This is necessary as on iOS builds, some arguments may be passed on registers - // depending on the argument type. The re-cast objc_msgSendSuper to a function - // take the same arguments as the target method. - template - static inline ReturnValue ObjCMsgSendSuper (struct objc_super* s, SEL sel, Params... params) - { - typedef ReturnValue (*SuperFn)(struct objc_super*, SEL, Params...); - SuperFn fn = reinterpret_cast (objc_msgSendSuper); - return fn (s, sel, params...); - } + for (auto string: strings) + [array addObject:juceStringToNS (string)]; - #endif + return [array autorelease]; +} - // These hacks are a workaround for newer Xcode builds which by default prevent calls to these objc functions.. - typedef id (*MsgSendSuperFn) (struct objc_super*, SEL, ...); - static inline MsgSendSuperFn getMsgSendSuperFn() noexcept { return (MsgSendSuperFn) (void*) objc_msgSendSuper; } +#if JUCE_MAC +template +static NSRect makeNSRect (const RectangleType& r) noexcept +{ + return NSMakeRect (static_cast (r.getX()), + static_cast (r.getY()), + static_cast (r.getWidth()), + static_cast (r.getHeight())); +} +#endif +#if JUCE_MAC || JUCE_IOS +#if JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES - #if ! JUCE_IOS - typedef double (*MsgSendFPRetFn) (id, SEL op, ...); - static inline MsgSendFPRetFn getMsgSendFPRetFn() noexcept { return (MsgSendFPRetFn) (void*) objc_msgSend_fpret; } - #endif - #endif +// This is necessary as on iOS builds, some arguments may be passed on registers +// depending on the argument type. The re-cast objc_msgSendSuper to a function +// take the same arguments as the target method. +template +static inline ReturnValue ObjCMsgSendSuper (struct objc_super* s, SEL sel, Params... params) +{ + typedef ReturnValue (*SuperFn)(struct objc_super*, SEL, Params...); + SuperFn fn = reinterpret_cast (objc_msgSendSuper); + return fn (s, sel, params...); } +#endif + +// These hacks are a workaround for newer Xcode builds which by default prevent calls to these objc functions.. +typedef id (*MsgSendSuperFn) (struct objc_super*, SEL, ...); +static inline MsgSendSuperFn getMsgSendSuperFn() noexcept { return (MsgSendSuperFn) (void*) objc_msgSendSuper; } + +#if ! JUCE_IOS +typedef double (*MsgSendFPRetFn) (id, SEL op, ...); +static inline MsgSendFPRetFn getMsgSendFPRetFn() noexcept { return (MsgSendFPRetFn) (void*) objc_msgSend_fpret; } +#endif +#endif + //============================================================================== template struct NSObjectRetainer @@ -236,3 +233,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_core/native/juce_posix_NamedPipe.cpp b/modules/juce_core/native/juce_posix_NamedPipe.cpp index 80bfa2e703..be948ffd4f 100644 --- a/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class NamedPipe::Pimpl { public: @@ -226,3 +229,5 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut ScopedReadLock sl (lock); return pimpl != nullptr ? pimpl->write (static_cast (sourceBuffer), numBytesToWrite, timeOutMilliseconds) : -1; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index ed43cb3923..67c884ab1d 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + CriticalSection::CriticalSection() noexcept { pthread_mutexattr_t atts; @@ -1535,3 +1538,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_ComSmartPtr.h b/modules/juce_core/native/juce_win32_ComSmartPtr.h index 09bfd5b7b5..0a6511c4c8 100644 --- a/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MINGW || (! (defined (_MSC_VER) || defined (__uuidof))) #ifdef __uuidof @@ -189,3 +190,5 @@ public: return ComBaseClassHelperBase::QueryInterface (refId, result); } }; + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 5185d12087..6534ba6a6a 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) #endif @@ -682,7 +685,7 @@ File File::getLinkedTarget() const CloseHandle (h); const StringRef prefix ("\\\\?\\"); - const String path (buffer); + const String path (buffer.get()); // It turns out that GetFinalPathNameByHandleW prepends \\?\ to the path. // This is not a bug, it's feature. See MSDN for more information. @@ -1071,3 +1074,5 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut ScopedReadLock sl (lock); return pimpl != nullptr ? pimpl->write (sourceBuffer, numBytesToWrite, timeOutMilliseconds) : -1; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 42f17d9db2..bdc7dc9c4d 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef INTERNET_FLAG_NEED_FILE #define INTERNET_FLAG_NEED_FILE 0x00000010 #endif @@ -500,6 +503,17 @@ namespace MACAddressHelpers } } } + + static void split (const sockaddr_in6* sa_in6, int off, uint8* split) + { + #if JUCE_MINGW + split[0] = sa_in6->sin6_addr._S6_un._S6_u8[off + 1]; + split[1] = sa_in6->sin6_addr._S6_un._S6_u8[off]; + #else + split[0] = sa_in6->sin6_addr.u.Byte[off + 1]; + split[1] = sa_in6->sin6_addr.u.Byte[off]; + #endif + } } void MACAddress::findAllAddresses (Array& result) @@ -538,9 +552,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } @@ -567,9 +579,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } @@ -596,9 +606,7 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) for (int i = 0; i < 8; ++i) { - temp.split[0] = sa_in6->sin6_addr.u.Byte[i * 2 + 1]; - temp.split[1] = sa_in6->sin6_addr.u.Byte[i * 2]; - + MACAddressHelpers::split (sa_in6, i * 2, temp.split); arr[i] = temp.combined; } @@ -655,3 +663,5 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra { return URL::DownloadTask::createFallbackDownloader (*this, targetLocation, extraHeaders, listener, shouldUsePost); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Registry.cpp b/modules/juce_core/native/juce_win32_Registry.cpp index 91b2c12570..e1b5f5b814 100644 --- a/modules/juce_core/native/juce_win32_Registry.cpp +++ b/modules/juce_core/native/juce_win32_Registry.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct RegistryKeyWrapper { RegistryKeyWrapper (String name, bool createForWriting, DWORD wow64Flags) @@ -244,3 +247,5 @@ bool JUCE_CALLTYPE WindowsRegistry::registerFileAssociation (const String& fileE String WindowsRegistry::getValueWow64 (const String& p, const String& defVal) { return getValue (p, defVal, WoW64_64bit); } bool WindowsRegistry::valueExistsWow64 (const String& p) { return valueExists (p, WoW64_64bit); } bool WindowsRegistry::keyExistsWow64 (const String& p) { return keyExists (p, WoW64_64bit); } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index b2ff9e9450..e2b4409350 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if ! JUCE_MINGW #pragma intrinsic (__cpuid) #pragma intrinsic (__rdtsc) @@ -104,6 +107,13 @@ String SystemStats::getCpuModel() static int findNumberOfPhysicalCores() noexcept { + #if JUCE_MINGW + // Not implemented in MinGW + jassertfalse; + + return 1; + #else + int numPhysicalCores = 0; DWORD bufferSize = 0; GetLogicalProcessorInformation (nullptr, &bufferSize); @@ -119,6 +129,7 @@ static int findNumberOfPhysicalCores() noexcept } return numPhysicalCores; + #endif // JUCE_MINGW } //============================================================================== @@ -479,3 +490,5 @@ String SystemStats::getDisplayLanguage() return mainLang; } + +} // namespace juce diff --git a/modules/juce_core/native/juce_win32_Threads.cpp b/modules/juce_core/native/juce_win32_Threads.cpp index d38b733b84..172e7019e5 100644 --- a/modules/juce_core/native/juce_win32_Threads.cpp +++ b/modules/juce_core/native/juce_win32_Threads.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + HWND juce_messageWindowHandle = 0; // (this is used by other parts of the codebase) void* getUser32Function (const char* functionName) @@ -534,7 +537,7 @@ bool ChildProcess::start (const StringArray& args, int streamFlags) //============================================================================== struct HighResolutionTimer::Pimpl { - Pimpl (HighResolutionTimer& t) noexcept : owner (t), periodMs (0) + Pimpl (HighResolutionTimer& t) noexcept : owner (t) { } @@ -568,7 +571,7 @@ struct HighResolutionTimer::Pimpl } HighResolutionTimer& owner; - int periodMs; + int periodMs = 0; private: unsigned int timerID; @@ -582,3 +585,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Pimpl) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_IPAddress.cpp b/modules/juce_core/network/juce_IPAddress.cpp index 92c68bab66..2b38499faa 100644 --- a/modules/juce_core/network/juce_IPAddress.cpp +++ b/modules/juce_core/network/juce_IPAddress.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + IPAddress::IPAddress (bool IPv6) noexcept : isIPv6 (IPv6) { for (int i = 0; i < 16; ++i) @@ -296,3 +299,5 @@ void IPAddress::findAllAddresses (Array& result, bool includeIPv6) freeifaddrs (ifaddr); } #endif + +} // namespace juce diff --git a/modules/juce_core/network/juce_IPAddress.h b/modules/juce_core/network/juce_IPAddress.h index a450ff7d18..ac29e0c41a 100644 --- a/modules/juce_core/network/juce_IPAddress.h +++ b/modules/juce_core/network/juce_IPAddress.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -108,3 +108,5 @@ private: address[i] = 0; } }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_MACAddress.cpp b/modules/juce_core/network/juce_MACAddress.cpp index 62b0e24eac..a2c7e1fb55 100644 --- a/modules/juce_core/network/juce_MACAddress.cpp +++ b/modules/juce_core/network/juce_MACAddress.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MACAddress::MACAddress() noexcept { zeromem (address, sizeof (address)); @@ -86,3 +89,5 @@ bool MACAddress::isNull() const noexcept { return bool MACAddress::operator== (const MACAddress& other) const noexcept { return memcmp (address, other.address, sizeof (address)) == 0; } bool MACAddress::operator!= (const MACAddress& other) const noexcept { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_MACAddress.h b/modules/juce_core/network/juce_MACAddress.h index 7a709b01cb..45a5a1a04a 100644 --- a/modules/juce_core/network/juce_MACAddress.h +++ b/modules/juce_core/network/juce_MACAddress.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -79,3 +79,5 @@ public: private: uint8 address[6]; }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_NamedPipe.cpp b/modules/juce_core/network/juce_NamedPipe.cpp index 434fdb6063..8d493488f0 100644 --- a/modules/juce_core/network/juce_NamedPipe.cpp +++ b/modules/juce_core/network/juce_NamedPipe.cpp @@ -20,9 +20,10 @@ ============================================================================== */ -NamedPipe::NamedPipe() +namespace juce { -} + +NamedPipe::NamedPipe() {} NamedPipe::~NamedPipe() { @@ -58,3 +59,5 @@ String NamedPipe::getName() const } // other methods for this class are implemented in the platform-specific files + +} // namespace juce diff --git a/modules/juce_core/network/juce_NamedPipe.h b/modules/juce_core/network/juce_NamedPipe.h index af09f49000..8ae0482086 100644 --- a/modules/juce_core/network/juce_NamedPipe.h +++ b/modules/juce_core/network/juce_NamedPipe.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -94,3 +94,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NamedPipe) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 19723b69b4..f850bad50f 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4127 4389 4018) @@ -130,7 +133,7 @@ namespace SocketHelpers // a chance to process before close is called. On Mac OS X shutdown // does not unblock a select call, so using a lock here will dead-lock // both threads. - #if JUCE_LINUX + #if JUCE_LINUX || JUCE_ANDROID CriticalSection::ScopedLockType lock (readLock); ::close (h); #else @@ -770,3 +773,5 @@ bool DatagramSocket::setEnablePortReuse (bool enabled) #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_core/network/juce_Socket.h b/modules/juce_core/network/juce_Socket.h index 66d259fdbe..6a6b7b5982 100644 --- a/modules/juce_core/network/juce_Socket.h +++ b/modules/juce_core/network/juce_Socket.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -74,7 +74,8 @@ public: This is useful if you need to know to which port the OS has actually bound your socket when calling the constructor or bindToPort with zero as the - localPortNumber argument. Returns -1 if the function fails. */ + localPortNumber argument. Returns -1 if the function fails. + */ int getBoundPort() const noexcept; /** Tries to connect the socket to hostname:port. @@ -348,3 +349,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DatagramSocket) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index 60c791a3a9..402aa62989 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct FallbackDownloadTask : public URL::DownloadTask, public Thread { @@ -61,18 +64,21 @@ struct FallbackDownloadTask : public URL::DownloadTask, const int max = jmin ((int) bufferSize, contentLength < 0 ? std::numeric_limits::max() : static_cast (contentLength - downloaded)); - const int actual = stream->read (buffer.getData(), max); + const int actual = stream->read (buffer.get(), max); if (actual < 0 || threadShouldExit() || stream->isError()) break; - if (! fileStream->write (buffer.getData(), static_cast (actual))) + if (! fileStream->write (buffer.get(), static_cast (actual))) { error = true; break; } downloaded += actual; + + if (downloaded == contentLength) + break; } fileStream->flush(); @@ -658,3 +664,5 @@ bool URL::launchInDefaultBrowser() const return Process::openDocument (u, String()); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index b2a3f592c8..fa2169ddf8 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -20,9 +20,11 @@ ============================================================================== */ -#pragma once +namespace juce +{ class WebInputStream; + //============================================================================== /** Represents a URL and has a bunch of useful functions to manipulate it. @@ -516,3 +518,5 @@ private: JUCE_LEAK_DETECTOR (URL) }; + +} // namespace juce diff --git a/modules/juce_core/network/juce_WebInputStream.cpp b/modules/juce_core/network/juce_WebInputStream.cpp index 4a7aafc1f9..c82b396a8f 100644 --- a/modules/juce_core/network/juce_WebInputStream.cpp +++ b/modules/juce_core/network/juce_WebInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + WebInputStream::WebInputStream (const URL& url, const bool usePost) : pimpl (new Pimpl (*this, url, usePost)), hasCalledConnect (false) {} @@ -79,3 +82,5 @@ void WebInputStream::createHeadersAndPostData (const URL& aURL, String& headers, { aURL.createHeadersAndPostData (headers, data); } + +} // namespace juce diff --git a/modules/juce_core/network/juce_WebInputStream.h b/modules/juce_core/network/juce_WebInputStream.h index 5d013ea4a4..fe6da1cfbd 100644 --- a/modules/juce_core/network/juce_WebInputStream.h +++ b/modules/juce_core/network/juce_WebInputStream.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -208,3 +209,5 @@ class JUCE_API WebInputStream : public InputStream JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_BufferedInputStream.cpp b/modules/juce_core/streams/juce_BufferedInputStream.cpp index b17c526915..8af122a694 100644 --- a/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/modules/juce_core/streams/juce_BufferedInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static inline int calcBufferStreamBufferSize (int requestedSize, InputStream* source) noexcept { // You need to supply a real stream when creating a BufferedInputStream @@ -180,3 +183,5 @@ String BufferedInputStream::readString() return InputStream::readString(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_BufferedInputStream.h b/modules/juce_core/streams/juce_BufferedInputStream.h index 5a51053858..8719b66c5b 100644 --- a/modules/juce_core/streams/juce_BufferedInputStream.h +++ b/modules/juce_core/streams/juce_BufferedInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wraps another input stream, and reads from it using an intermediate buffer @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferedInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_FileInputSource.cpp b/modules/juce_core/streams/juce_FileInputSource.cpp index ab777793ea..feb4081a8d 100644 --- a/modules/juce_core/streams/juce_FileInputSource.cpp +++ b/modules/juce_core/streams/juce_FileInputSource.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + FileInputSource::FileInputSource (const File& f, bool useFileTimeInHash) : file (f), useFileTimeInHashGeneration (useFileTimeInHash) { @@ -48,3 +51,5 @@ int64 FileInputSource::hashCode() const return h; } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_FileInputSource.h b/modules/juce_core/streams/juce_FileInputSource.h index 00f8bee369..d5f5942132 100644 --- a/modules/juce_core/streams/juce_FileInputSource.h +++ b/modules/juce_core/streams/juce_FileInputSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputSource) }; + +} diff --git a/modules/juce_core/streams/juce_InputSource.h b/modules/juce_core/streams/juce_InputSource.h index 14f3d96b49..925cdf30f6 100644 --- a/modules/juce_core/streams/juce_InputSource.h +++ b/modules/juce_core/streams/juce_InputSource.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (InputSource) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_InputStream.cpp b/modules/juce_core/streams/juce_InputStream.cpp index eb6bc57a7e..a27f5cfc1d 100644 --- a/modules/juce_core/streams/juce_InputStream.cpp +++ b/modules/juce_core/streams/juce_InputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + int64 InputStream::getNumBytesRemaining() { int64 len = getTotalLength(); @@ -227,3 +230,5 @@ void InputStream::skipNextBytes (int64 numBytesToSkip) numBytesToSkip -= read (temp, (int) jmin (numBytesToSkip, (int64) skipBufferSize)); } } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_InputStream.h b/modules/juce_core/streams/juce_InputStream.h index 3db0e9d71c..398615ad85 100644 --- a/modules/juce_core/streams/juce_InputStream.h +++ b/modules/juce_core/streams/juce_InputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** The base class for streams that read data. @@ -255,3 +255,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryInputStream.cpp b/modules/juce_core/streams/juce_MemoryInputStream.cpp index 3dfb1237c6..041b24ec8c 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MemoryInputStream::MemoryInputStream (const void* const sourceData, const size_t sourceDataSize, const bool keepInternalCopy) @@ -156,3 +159,5 @@ public: static MemoryStreamTests memoryInputStreamUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryInputStream.h b/modules/juce_core/streams/juce_MemoryInputStream.h index 3bfa985ac6..86373ca657 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.h +++ b/modules/juce_core/streams/juce_MemoryInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -86,3 +86,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 57226cb2ae..1b27e05dec 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MemoryOutputStream::MemoryOutputStream (const size_t initialSize) : blockToUse (&internalBlock), externalData (nullptr), position (0), size (0), availableSize (0) @@ -206,3 +209,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutput return stream; } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.h b/modules/juce_core/streams/juce_MemoryOutputStream.h index 794d78f86c..6f89c940ce 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -127,3 +127,5 @@ private: /** Copies all the data that has been written to a MemoryOutputStream into another stream. */ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead); + +} // namespace juce diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index a87e5b2fcc..499f532cf7 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_DEBUG struct DanglingStreamChecker @@ -343,3 +346,5 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const New { return stream << stream.getNewLineString(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_OutputStream.h b/modules/juce_core/streams/juce_OutputStream.h index 2b53107aa5..1ab0a0ce77 100644 --- a/modules/juce_core/streams/juce_OutputStream.h +++ b/modules/juce_core/streams/juce_OutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -265,3 +265,5 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, InputStre @see OutputStream::setNewLineString */ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const NewLine&); + +} // namespace juce diff --git a/modules/juce_core/streams/juce_SubregionStream.cpp b/modules/juce_core/streams/juce_SubregionStream.cpp index 5e74c28945..c7b67900cb 100644 --- a/modules/juce_core/streams/juce_SubregionStream.cpp +++ b/modules/juce_core/streams/juce_SubregionStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + SubregionStream::SubregionStream (InputStream* const sourceStream, const int64 start, const int64 length, const bool deleteSourceWhenDestroyed) @@ -74,3 +77,5 @@ bool SubregionStream::isExhausted() return source->isExhausted(); } + +} // namespace juce diff --git a/modules/juce_core/streams/juce_SubregionStream.h b/modules/juce_core/streams/juce_SubregionStream.h index 624d6b8a7f..998a2ccdb1 100644 --- a/modules/juce_core/streams/juce_SubregionStream.h +++ b/modules/juce_core/streams/juce_SubregionStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wraps another input stream, and reads from a specific part of it. @@ -77,3 +77,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream) }; + +} // namespace juce diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index d29b492371..32b9323596 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* This file defines miscellaneous macros for debugging, assertions, etc. @@ -81,7 +82,7 @@ #if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN) #if __has_feature (attribute_analyzer_noreturn) inline void __attribute__((analyzer_noreturn)) juce_assert_noreturn() {} - #define JUCE_ANALYZER_NORETURN juce_assert_noreturn(); + #define JUCE_ANALYZER_NORETURN juce::juce_assert_noreturn(); #endif #endif @@ -293,3 +294,5 @@ #else #define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS #endif + +} // namespace juce diff --git a/modules/juce_core/system/juce_StandardHeader.h b/modules/juce_core/system/juce_StandardHeader.h index c658514eb6..896d5b4da1 100644 --- a/modules/juce_core/system/juce_StandardHeader.h +++ b/modules/juce_core/system/juce_StandardHeader.h @@ -29,7 +29,7 @@ */ #define JUCE_MAJOR_VERSION 5 #define JUCE_MINOR_VERSION 1 -#define JUCE_BUILDNUMBER 1 +#define JUCE_BUILDNUMBER 2 /** Current Juce version number. @@ -114,6 +114,11 @@ #include "../misc/juce_StdFunctionCompat.h" #endif +// The live build fails to compile std::stringstream +#if ! JUCE_PROJUCER_LIVE_BUILD + #include +#endif + // Include std::atomic if it's supported by the compiler #if JUCE_ATOMIC_AVAILABLE #include diff --git a/modules/juce_core/system/juce_SystemStats.cpp b/modules/juce_core/system/juce_SystemStats.cpp index 7e05277429..c073331b97 100644 --- a/modules/juce_core/system/juce_SystemStats.cpp +++ b/modules/juce_core/system/juce_SystemStats.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + String SystemStats::getJUCEVersion() { // Some basic tests, to keep an eye on things and make sure these types work ok @@ -230,3 +233,5 @@ bool SystemStats::isRunningInAppExtensionSandbox() noexcept return false; #endif } + +} // namespace juce diff --git a/modules/juce_core/system/juce_SystemStats.h b/modules/juce_core/system/juce_SystemStats.h index 4bf4e0e13e..89d3854e33 100644 --- a/modules/juce_core/system/juce_SystemStats.h +++ b/modules/juce_core/system/juce_SystemStats.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -217,3 +217,5 @@ private: JUCE_DECLARE_NON_COPYABLE (SystemStats) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_Base64.cpp b/modules/juce_core/text/juce_Base64.cpp index bda7c3b669..14bcdeb795 100644 --- a/modules/juce_core/text/juce_Base64.cpp +++ b/modules/juce_core/text/juce_Base64.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + bool Base64::convertToBase64 (OutputStream& base64Result, const void* sourceData, size_t sourceDataSize) { static const char lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -157,3 +160,5 @@ public: static Base64Tests base64Tests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_Base64.h b/modules/juce_core/text/juce_Base64.h index 169c0e2ebb..c7eafa2212 100644 --- a/modules/juce_core/text/juce_Base64.h +++ b/modules/juce_core/text/juce_Base64.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Contains some static methods for converting between binary and the @@ -47,3 +47,5 @@ struct JUCE_API Base64 /** Converts a string's UTF-8 representation to a base-64 string. */ static String toBase64 (const String& textToEncode); }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_ASCII.h b/modules/juce_core/text/juce_CharPointer_ASCII.h index 0c9ed44ac7..2e6b2b808b 100644 --- a/modules/juce_core/text/juce_CharPointer_ASCII.h +++ b/modules/juce_core/text/juce_CharPointer_ASCII.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -374,3 +374,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF16.h b/modules/juce_core/text/juce_CharPointer_UTF16.h index 7d45f95208..2176482de0 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF16.h +++ b/modules/juce_core/text/juce_CharPointer_UTF16.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -516,3 +516,5 @@ private: return n; } }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF32.h b/modules/juce_core/text/juce_CharPointer_UTF32.h index 5367fbec84..41a9a7c251 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF32.h +++ b/modules/juce_core/text/juce_CharPointer_UTF32.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -369,3 +369,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index 639b5c2d1e..7b5a91df90 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -470,7 +471,7 @@ public: /** Parses this string as a 64-bit integer. */ int64 getIntValue64() const noexcept { - #if JUCE_WINDOWS + #if JUCE_WINDOWS && ! JUCE_MINGW return _atoi64 (data); #else return atoll (data); @@ -560,3 +561,5 @@ public: private: CharType* data; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharacterFunctions.cpp b/modules/juce_core/text/juce_CharacterFunctions.cpp index cd81957d95..9c10e8c38f 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4514 4996) @@ -280,3 +282,5 @@ public: static CharacterFunctionsTests characterFunctionsTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index e4b23378d1..d9cec4bac6 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== #if JUCE_WINDOWS && ! DOXYGEN @@ -60,6 +60,19 @@ #define T(stringLiteral) JUCE_T(stringLiteral) #endif +//============================================================================== +/** GNU libstdc++ does not have std::make_unsigned */ +namespace internal +{ + template struct make_unsigned { typedef Type type; }; + template <> struct make_unsigned { typedef unsigned char type; }; + template <> struct make_unsigned { typedef unsigned char type; }; + template <> struct make_unsigned { typedef unsigned short type; }; + template <> struct make_unsigned { typedef unsigned int type; }; + template <> struct make_unsigned { typedef unsigned long type; }; + template <> struct make_unsigned { typedef unsigned long long type; }; +} + //============================================================================== /** A collection of functions for manipulating characters and character strings. @@ -168,7 +181,7 @@ public: || ((numSigFigs == 0 && (! decimalPointFound)) && digit == 0)) continue; - *currentCharacter++ = '0' + (char) digit; + *currentCharacter++ = (char) ('0' + (char) digit); numSigFigs++; } else if ((! decimalPointFound) && *text == '.') @@ -206,7 +219,7 @@ public: if (digit != 0 || exponentMagnitude != 0) { - *currentCharacter++ = '0' + (char) digit; + *currentCharacter++ = (char) ('0' + (char) digit); exponentMagnitude = (exponentMagnitude * 10) + digit; } } @@ -218,17 +231,22 @@ public: *currentCharacter++ = '0'; } - #if JUCE_MSVC - static _locale_t locale = _create_locale (LC_ALL, "C"); - return _strtod_l (&buffer[0], nullptr, locale); - #else - static locale_t locale = newlocale (LC_ALL_MASK, "C", nullptr); - #if JUCE_ANDROID - return (double) strtold_l (&buffer[0], nullptr, locale); + #if JUCE_PROJUCER_LIVE_BUILD + // This will change with locale! + return strtod (&buffer[0], nullptr); #else - return strtod_l (&buffer[0], nullptr, locale); + double result = 0; + const size_t stringSize = (size_t) (currentCharacter - &buffer[0]) + 1; + + if (stringSize > 1) + { + std::istringstream is (std::string (&buffer[0], stringSize)); + is.imbue (std::locale ("C")); + is >> result; + } + + return result; #endif - #endif } /** Parses a character string, to read a floating-point value. */ @@ -243,7 +261,7 @@ public: template static IntType getIntValue (const CharPointerType text) noexcept { - typedef typename std::make_unsigned::type UIntType; + typedef typename internal::make_unsigned::type UIntType; UIntType v = 0; auto s = text.findEndOfWhitespace(); @@ -618,3 +636,5 @@ public: private: static double mulexp10 (double value, int exponent) noexcept; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_Identifier.cpp b/modules/juce_core/text/juce_Identifier.cpp index 513b921e5c..3ca2b45ff7 100644 --- a/modules/juce_core/text/juce_Identifier.cpp +++ b/modules/juce_core/text/juce_Identifier.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Identifier::Identifier() noexcept {} Identifier::~Identifier() noexcept {} @@ -67,3 +70,5 @@ bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept return possibleIdentifier.isNotEmpty() && possibleIdentifier.containsOnly ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:#@$%"); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_Identifier.h b/modules/juce_core/text/juce_Identifier.h index 1d960e586f..4c6d9bcd23 100644 --- a/modules/juce_core/text/juce_Identifier.h +++ b/modules/juce_core/text/juce_Identifier.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ public: private: String name; }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_LocalisedStrings.cpp b/modules/juce_core/text/juce_LocalisedStrings.cpp index 58533de91d..c5d091f640 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/modules/juce_core/text/juce_LocalisedStrings.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + LocalisedStrings::LocalisedStrings (const String& fileContents, bool ignoreCase) { loadFromText (fileContents, ignoreCase); @@ -201,3 +204,5 @@ JUCE_API String translate (const String& text, const String& resultIfNotFound) return resultIfNotFound; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_LocalisedStrings.h b/modules/juce_core/text/juce_LocalisedStrings.h index 71b6423fde..0cee6b3ad0 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.h +++ b/modules/juce_core/text/juce_LocalisedStrings.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -235,3 +235,5 @@ JUCE_API String translate (CharPointer_UTF8 stringLiteral); @see LocalisedStrings */ JUCE_API String translate (const String& stringLiteral, const String& resultIfNotFound); + +} // namespace juce diff --git a/modules/juce_core/text/juce_NewLine.h b/modules/juce_core/text/juce_NewLine.h index 885618a7a7..164f4b1c3f 100644 --- a/modules/juce_core/text/juce_NewLine.h +++ b/modules/juce_core/text/juce_NewLine.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** This class is used for represent a new-line character sequence. @@ -76,3 +76,5 @@ inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLi inline String operator+ (const NewLine&, const NewLine&) { return String (NewLine::getDefault()) + NewLine::getDefault(); } inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); } inline String operator+ (const NewLine&, const char* s2) { return String (NewLine::getDefault()) + s2; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index f1598f983d..3fb472299a 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4514 4996) @@ -68,7 +71,7 @@ public: static CharPointerType createUninitialisedBytes (size_t numBytes) { numBytes = (numBytes + 3) & ~(size_t) 3; - StringHolder* const s = reinterpret_cast (new char [sizeof (StringHolder) - sizeof (CharType) + numBytes]); + auto s = reinterpret_cast (new char [sizeof (StringHolder) - sizeof (CharType) + numBytes]); s->refCount.value = 0; s->allocatedNumBytes = numBytes; return CharPointerType (s->text); @@ -80,8 +83,8 @@ public: if (text.getAddress() == nullptr || text.isEmpty()) return CharPointerType (&(emptyString.text)); - const size_t bytesNeeded = sizeof (CharType) + CharPointerType::getBytesRequiredFor (text); - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto bytesNeeded = sizeof (CharType) + CharPointerType::getBytesRequiredFor (text); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeAll (text); return dest; } @@ -92,7 +95,7 @@ public: if (text.getAddress() == nullptr || text.isEmpty() || maxChars == 0) return CharPointerType (&(emptyString.text)); - CharPointer end (text); + auto end = text; size_t numChars = 0; size_t bytesNeeded = sizeof (CharType); @@ -102,7 +105,7 @@ public: ++numChars; } - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeWithCharLimit (text, (int) numChars + 1); return dest; } @@ -113,9 +116,9 @@ public: if (start.getAddress() == nullptr || start.isEmpty()) return CharPointerType (&(emptyString.text)); - CharPointer e (start); + auto e = start; int numChars = 0; - size_t bytesNeeded = sizeof (CharType); + auto bytesNeeded = sizeof (CharType); while (e < end && ! e.isEmpty()) { @@ -123,7 +126,7 @@ public: ++numChars; } - const CharPointerType dest (createUninitialisedBytes (bytesNeeded)); + auto dest = createUninitialisedBytes (bytesNeeded); CharPointerType (dest).writeWithCharLimit (start, numChars + 1); return dest; } @@ -133,9 +136,9 @@ public: if (start.getAddress() == nullptr || start.isEmpty()) return CharPointerType (&(emptyString.text)); - const size_t numBytes = (size_t) (reinterpret_cast (end.getAddress()) - - reinterpret_cast (start.getAddress())); - const CharPointerType dest (createUninitialisedBytes (numBytes + sizeof (CharType))); + auto numBytes = (size_t) (reinterpret_cast (end.getAddress()) + - reinterpret_cast (start.getAddress())); + auto dest = createUninitialisedBytes (numBytes + sizeof (CharType)); memcpy (dest.getAddress(), start, numBytes); dest.getAddress()[numBytes / sizeof (CharType)] = 0; return dest; @@ -143,7 +146,7 @@ public: static CharPointerType createFromFixedLength (const char* const src, const size_t numChars) { - const CharPointerType dest (createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType))); + auto dest = createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType)); CharPointerType (dest).writeWithCharLimit (CharPointer_UTF8 (src), (int) (numChars + 1)); return dest; } @@ -151,7 +154,7 @@ public: //============================================================================== static void retain (const CharPointerType text) noexcept { - StringHolder* const b = bufferFromText (text); + auto* b = bufferFromText (text); if (b != (StringHolder*) &emptyString) ++(b->refCount); @@ -177,11 +180,11 @@ public: //============================================================================== static CharPointerType makeUniqueWithByteSize (const CharPointerType text, size_t numBytes) { - StringHolder* const b = bufferFromText (text); + auto* b = bufferFromText (text); if (b == (StringHolder*) &emptyString) { - CharPointerType newText (createUninitialisedBytes (numBytes)); + auto newText = createUninitialisedBytes (numBytes); newText.writeNull(); return newText; } @@ -189,7 +192,7 @@ public: if (b->allocatedNumBytes >= numBytes && b->refCount.get() <= 0) return text; - CharPointerType newText (createUninitialisedBytes (jmax (b->allocatedNumBytes, numBytes))); + auto newText = createUninitialisedBytes (jmax (b->allocatedNumBytes, numBytes)); memcpy (newText.getAddress(), text.getAddress(), b->allocatedNumBytes); release (b); @@ -473,9 +476,9 @@ namespace NumberToStringConverters { if (numDecPlaces > 0 && numDecPlaces < 7 && n > -1.0e20 && n < 1.0e20) { - char* const end = buffer + numChars; - char* t = end; - int64 v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); + auto* end = buffer + numChars; + auto* t = end; + auto v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); *--t = (char) 0; while (numDecPlaces >= 0 || v > 0) @@ -506,8 +509,8 @@ namespace NumberToStringConverters static String::CharPointerType createFromInteger (const IntegerType number) { char buffer [charsNeededForInt]; - char* const end = buffer + numElementsInArray (buffer); - char* const start = numberToString (end, number); + auto* end = buffer + numElementsInArray (buffer); + auto* start = numberToString (end, number); return StringHolder::createFromFixedLength (start, (size_t) (end - start - 1)); } @@ -515,25 +518,25 @@ namespace NumberToStringConverters { char buffer [charsNeededForDouble]; size_t len; - char* const start = doubleToString (buffer, numElementsInArray (buffer), (double) number, numberOfDecimalPlaces, len); + auto start = doubleToString (buffer, numElementsInArray (buffer), (double) number, numberOfDecimalPlaces, len); return StringHolder::createFromFixedLength (start, len); } } //============================================================================== -String::String (const int number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {} -String::String (const unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {} -String::String (const int64 number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const uint64 number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const long number) : text (NumberToStringConverters::createFromInteger (number)) {} -String::String (const unsigned long number) : text (NumberToStringConverters::createFromInteger (number)) {} - -String::String (const float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {} -String::String (const double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {} -String::String (const float number, const int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble ((double) number, numberOfDecimalPlaces)) {} -String::String (const double number, const int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble (number, numberOfDecimalPlaces)) {} +String::String (int number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (unsigned int number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (short number) : text (NumberToStringConverters::createFromInteger ((int) number)) {} +String::String (unsigned short number) : text (NumberToStringConverters::createFromInteger ((unsigned int) number)) {} +String::String (int64 number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (uint64 number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (long number) : text (NumberToStringConverters::createFromInteger (number)) {} +String::String (unsigned long number) : text (NumberToStringConverters::createFromInteger (number)) {} + +String::String (float number) : text (NumberToStringConverters::createFromDouble ((double) number, 0)) {} +String::String (double number) : text (NumberToStringConverters::createFromDouble (number, 0)) {} +String::String (float number, int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble ((double) number, numberOfDecimalPlaces)) {} +String::String (double number, int numberOfDecimalPlaces) : text (NumberToStringConverters::createFromDouble (number, numberOfDecimalPlaces)) {} //============================================================================== int String::length() const noexcept @@ -630,11 +633,11 @@ static int stringCompareRight (String::CharPointerType s1, String::CharPointerTy { for (int bias = 0;;) { - const juce_wchar c1 = s1.getAndAdvance(); - const bool isDigit1 = CharacterFunctions::isDigit (c1); + auto c1 = s1.getAndAdvance(); + bool isDigit1 = CharacterFunctions::isDigit (c1); - const juce_wchar c2 = s2.getAndAdvance(); - const bool isDigit2 = CharacterFunctions::isDigit (c2); + auto c2 = s2.getAndAdvance(); + bool isDigit2 = CharacterFunctions::isDigit (c2); if (! (isDigit1 || isDigit2)) return bias; if (! isDigit1) return -1; @@ -651,11 +654,11 @@ static int stringCompareLeft (String::CharPointerType s1, String::CharPointerTyp { for (;;) { - const juce_wchar c1 = s1.getAndAdvance(); - const bool isDigit1 = CharacterFunctions::isDigit (c1); + auto c1 = s1.getAndAdvance(); + bool isDigit1 = CharacterFunctions::isDigit (c1); - const juce_wchar c2 = s2.getAndAdvance(); - const bool isDigit2 = CharacterFunctions::isDigit (c2); + auto c2 = s2.getAndAdvance(); + bool isDigit2 = CharacterFunctions::isDigit (c2); if (! (isDigit1 || isDigit2)) return 0; if (! isDigit1) return -1; @@ -691,8 +694,8 @@ static int naturalStringCompare (String::CharPointerType s1, String::CharPointer return result; } - juce_wchar c1 = s1.getAndAdvance(); - juce_wchar c2 = s2.getAndAdvance(); + auto c1 = s1.getAndAdvance(); + auto c2 = s2.getAndAdvance(); if (c1 != c2 && ! isCaseSensitive) { @@ -748,10 +751,10 @@ void String::appendCharPointer (const CharPointerType startOfTextToAppend, if (extraBytesNeeded > 0) { - const size_t byteOffsetOfNull = getByteOffsetOfEnd(); + auto byteOffsetOfNull = getByteOffsetOfEnd(); preallocateBytes (byteOffsetOfNull + (size_t) extraBytesNeeded); - CharPointerType::CharType* const newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull); + auto* newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull); memcpy (newStringStart, startOfTextToAppend.getAddress(), (size_t) extraBytesNeeded); CharPointerType (addBytesToPointer (newStringStart, extraBytesNeeded)).writeNull(); } @@ -813,8 +816,8 @@ namespace StringHelpers inline String& operationAddAssign (String& str, const T number) { char buffer [(sizeof(T) * 8) / 2]; - char* end = buffer + numElementsInArray (buffer); - char* start = NumberToStringConverters::numberToString (end, number); + auto* end = buffer + numElementsInArray (buffer); + auto* start = NumberToStringConverters::numberToString (end, number); #if JUCE_STRING_UTF_TYPE == 8 str.appendCharPointer (String::CharPointerType (start), String::CharPointerType (end)); @@ -858,8 +861,9 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t* const s2) JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const String& s2) { return s1 += s2; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, StringRef s2) { return s1 += s2; } -JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } +JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, uint8 number) { return s1 += (int) number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; } +JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const unsigned short number) { return s1 += (uint64) number; } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const long number) { return s1 += String (number); } JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const unsigned long number) { return s1 += String (number); } @@ -898,7 +902,7 @@ int String::indexOfChar (const juce_wchar character) const noexcept int String::indexOfChar (const int startIndex, const juce_wchar character) const noexcept { - CharPointerType t (text); + auto t = text; for (int i = 0; ! t.isEmpty(); ++i) { @@ -918,7 +922,7 @@ int String::indexOfChar (const int startIndex, const juce_wchar character) const int String::lastIndexOfChar (const juce_wchar character) const noexcept { - CharPointerType t (text); + auto t = text; int last = -1; for (int i = 0; ! t.isEmpty(); ++i) @@ -930,7 +934,7 @@ int String::lastIndexOfChar (const juce_wchar character) const noexcept int String::indexOfAnyOf (StringRef charactersToLookFor, const int startIndex, const bool ignoreCase) const noexcept { - CharPointerType t (text); + auto t = text; for (int i = 0; ! t.isEmpty(); ++i) { @@ -963,7 +967,7 @@ int String::indexOf (const int startIndex, StringRef other) const noexcept if (other.isEmpty()) return -1; - CharPointerType t (text); + auto t = text; for (int i = startIndex; --i >= 0;) { @@ -973,10 +977,8 @@ int String::indexOf (const int startIndex, StringRef other) const noexcept ++t; } - int found = t.indexOf (other.text); - if (found >= 0) - found += startIndex; - return found; + auto found = t.indexOf (other.text); + return found >= 0 ? found + startIndex : found; } int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noexcept @@ -984,7 +986,7 @@ int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noex if (other.isEmpty()) return -1; - CharPointerType t (text); + auto t = text; for (int i = startIndex; --i >= 0;) { @@ -994,22 +996,20 @@ int String::indexOfIgnoreCase (const int startIndex, StringRef other) const noex ++t; } - int found = CharacterFunctions::indexOfIgnoreCase (t, other.text); - if (found >= 0) - found += startIndex; - return found; + auto found = CharacterFunctions::indexOfIgnoreCase (t, other.text); + return found >= 0 ? found + startIndex : found; } int String::lastIndexOf (StringRef other) const noexcept { if (other.isNotEmpty()) { - const int len = other.length(); + auto len = other.length(); int i = length() - len; if (i >= 0) { - for (CharPointerType n (text + i); i >= 0; --i) + for (auto n = text + i; i >= 0; --i) { if (n.compareUpTo (other.text, len) == 0) return i; @@ -1026,12 +1026,12 @@ int String::lastIndexOfIgnoreCase (StringRef other) const noexcept { if (other.isNotEmpty()) { - const int len = other.length(); + auto len = other.length(); int i = length() - len; if (i >= 0) { - for (CharPointerType n (text + i); i >= 0; --i) + for (auto n = text + i; i >= 0; --i) { if (n.compareIgnoreCaseUpTo (other.text, len) == 0) return i; @@ -1046,7 +1046,7 @@ int String::lastIndexOfIgnoreCase (StringRef other) const noexcept int String::lastIndexOfAnyOf (StringRef charactersToLookFor, const bool ignoreCase) const noexcept { - CharPointerType t (text); + auto t = text; int last = -1; for (int i = 0; ! t.isEmpty(); ++i) @@ -1075,9 +1075,9 @@ int String::indexOfWholeWord (StringRef word) const noexcept { if (word.isNotEmpty()) { - CharPointerType t (text); - const int wordLen = word.length(); - const int end = (int) t.length() - wordLen; + auto t = text; + auto wordLen = word.length(); + auto end = (int) t.length() - wordLen; for (int i = 0; i <= end; ++i) { @@ -1097,9 +1097,9 @@ int String::indexOfWholeWordIgnoreCase (StringRef word) const noexcept { if (word.isNotEmpty()) { - CharPointerType t (text); - const int wordLen = word.length(); - const int end = (int) t.length() - wordLen; + auto t = text; + auto wordLen = word.length(); + auto end = (int) t.length() - wordLen; for (int i = 0; i <= end; ++i) { @@ -1133,7 +1133,7 @@ struct WildCardMatcher { for (;;) { - const juce_wchar wc = wildcard.getAndAdvance(); + auto wc = wildcard.getAndAdvance(); if (wc == '*') return wildcard.isEmpty() || matchesAnywhere (wildcard, test, ignoreCase); @@ -1174,7 +1174,7 @@ String String::repeatedString (StringRef stringToRepeat, int numberOfTimesToRepe return {}; String result (PreallocationBytes (findByteOffsetOfEnd (stringToRepeat) * (size_t) numberOfTimesToRepeat)); - CharPointerType n (result.text); + auto n = result.text; while (--numberOfTimesToRepeat >= 0) n.writeAll (stringToRepeat.text); @@ -1186,8 +1186,8 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con { jassert (padCharacter != 0); - int extraChars = minimumLength; - CharPointerType end (text); + auto extraChars = minimumLength; + auto end = text; while (! end.isEmpty()) { @@ -1198,9 +1198,9 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con if (extraChars <= 0 || padCharacter == 0) return *this; - const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); + auto currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); - CharPointerType n (result.text); + auto n = result.text; while (--extraChars >= 0) n.write (padCharacter); @@ -1213,7 +1213,7 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co { jassert (padCharacter != 0); - int extraChars = minimumLength; + auto extraChars = minimumLength; CharPointerType end (text); while (! end.isEmpty()) @@ -1225,9 +1225,9 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co if (extraChars <= 0 || padCharacter == 0) return *this; - const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); + auto currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); - CharPointerType n (result.text); + auto n = result.text; n.writeAll (text); @@ -1255,7 +1255,7 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin jassertfalse; } - CharPointerType insertPoint (text); + auto insertPoint = text; for (int i = 0; i < index; ++i) { @@ -1269,7 +1269,7 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin ++insertPoint; } - CharPointerType startOfRemainder (insertPoint); + auto startOfRemainder = insertPoint; for (int i = 0; i < numCharsToReplace && ! startOfRemainder.isEmpty(); ++i) ++startOfRemainder; @@ -1277,17 +1277,18 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin if (insertPoint == text && startOfRemainder.isEmpty()) return stringToInsert.text; - const size_t initialBytes = (size_t) (((char*) insertPoint.getAddress()) - (char*) text.getAddress()); - const size_t newStringBytes = findByteOffsetOfEnd (stringToInsert); - const size_t remainderBytes = (size_t) (((char*) startOfRemainder.findTerminatingNull().getAddress()) - (char*) startOfRemainder.getAddress()); + auto initialBytes = (size_t) (((char*) insertPoint.getAddress()) - (char*) text.getAddress()); + auto newStringBytes = findByteOffsetOfEnd (stringToInsert); + auto remainderBytes = (size_t) (((char*) startOfRemainder.findTerminatingNull().getAddress()) - (char*) startOfRemainder.getAddress()); + + auto newTotalBytes = initialBytes + newStringBytes + remainderBytes; - const size_t newTotalBytes = initialBytes + newStringBytes + remainderBytes; if (newTotalBytes <= 0) return {}; String result (PreallocationBytes ((size_t) newTotalBytes)); - char* dest = (char*) result.text.getAddress(); + auto* dest = (char*) result.text.getAddress(); memcpy (dest, text.getAddress(), initialBytes); dest += initialBytes; memcpy (dest, stringToInsert.text.getAddress(), newStringBytes); @@ -1301,8 +1302,8 @@ String String::replaceSection (int index, int numCharsToReplace, StringRef strin String String::replace (StringRef stringToReplace, StringRef stringToInsert, const bool ignoreCase) const { - const int stringToReplaceLen = stringToReplace.length(); - const int stringToInsertLen = stringToInsert.length(); + auto stringToReplaceLen = stringToReplace.length(); + auto stringToInsertLen = stringToInsert.length(); int i = 0; String result (*this); @@ -1319,9 +1320,9 @@ String String::replace (StringRef stringToReplace, StringRef stringToInsert, con String String::replaceFirstOccurrenceOf (StringRef stringToReplace, StringRef stringToInsert, const bool ignoreCase) const { - const int stringToReplaceLen = stringToReplace.length(); - const int index = ignoreCase ? indexOfIgnoreCase (stringToReplace) - : indexOf (stringToReplace); + auto stringToReplaceLen = stringToReplace.length(); + auto index = ignoreCase ? indexOfIgnoreCase (stringToReplace) + : indexOf (stringToReplace); if (index >= 0) return replaceSection (index, stringToReplaceLen, stringToInsert); @@ -1329,18 +1330,16 @@ String String::replaceFirstOccurrenceOf (StringRef stringToReplace, StringRef st return *this; } -class StringCreationHelper +struct StringCreationHelper { -public: - StringCreationHelper (const size_t initialBytes) - : source (nullptr), dest (nullptr), allocatedBytes (initialBytes), bytesWritten (0) + StringCreationHelper (size_t initialBytes) : allocatedBytes (initialBytes) { result.preallocateBytes (allocatedBytes); dest = result.getCharPointer(); } StringCreationHelper (const String::CharPointerType s) - : source (s), dest (nullptr), allocatedBytes (StringHolder::getAllocatedNumBytes (s)), bytesWritten (0) + : source (s), allocatedBytes (StringHolder::getAllocatedNumBytes (s)) { result.preallocateBytes (allocatedBytes); dest = result.getCharPointer(); @@ -1353,7 +1352,7 @@ public: if (bytesWritten > allocatedBytes) { allocatedBytes += jmax ((size_t) 8, allocatedBytes / 16); - const size_t destOffset = (size_t) (((char*) dest.getAddress()) - (char*) result.getCharPointer().getAddress()); + auto destOffset = (size_t) (((char*) dest.getAddress()) - (char*) result.getCharPointer().getAddress()); result.preallocateBytes (allocatedBytes); dest = addBytesToPointer (result.getCharPointer().getAddress(), (int) destOffset); } @@ -1361,12 +1360,11 @@ public: dest.write (c); } - String result; - String::CharPointerType source; + String&& get() noexcept { return static_cast (result); } -private: - String::CharPointerType dest; - size_t allocatedBytes, bytesWritten; + String result; + String::CharPointerType source { nullptr }, dest { nullptr }; + size_t allocatedBytes, bytesWritten = 0; }; String String::replaceCharacter (const juce_wchar charToReplace, const juce_wchar charToInsert) const @@ -1378,7 +1376,7 @@ String String::replaceCharacter (const juce_wchar charToReplace, const juce_wcha for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (c == charToReplace) c = charToInsert; @@ -1389,7 +1387,7 @@ String String::replaceCharacter (const juce_wchar charToReplace, const juce_wcha break; } - return builder.result; + return builder.get(); } String String::replaceCharacters (StringRef charactersToReplace, StringRef charactersToInsertInstead) const @@ -1402,9 +1400,9 @@ String String::replaceCharacters (StringRef charactersToReplace, StringRef chara for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); + auto index = charactersToReplace.text.indexOf (c); - const int index = charactersToReplace.text.indexOf (c); if (index >= 0) c = charactersToInsertInstead [index]; @@ -1414,7 +1412,7 @@ String String::replaceCharacters (StringRef charactersToReplace, StringRef chara break; } - return builder.result; + return builder.get(); } //============================================================================== @@ -1442,14 +1440,14 @@ bool String::endsWithChar (const juce_wchar character) const noexcept if (text.isEmpty()) return false; - CharPointerType t (text.findTerminatingNull()); + auto t = text.findTerminatingNull(); return *--t == character; } bool String::endsWith (StringRef other) const noexcept { - CharPointerType end (text.findTerminatingNull()); - CharPointerType otherEnd (other.text.findTerminatingNull()); + auto end = text.findTerminatingNull(); + auto otherEnd = other.text.findTerminatingNull(); while (end > text && otherEnd > other.text) { @@ -1465,8 +1463,8 @@ bool String::endsWith (StringRef other) const noexcept bool String::endsWithIgnoreCase (StringRef other) const noexcept { - CharPointerType end (text.findTerminatingNull()); - CharPointerType otherEnd (other.text.findTerminatingNull()); + auto end = text.findTerminatingNull(); + auto otherEnd = other.text.findTerminatingNull(); while (end > text && otherEnd > other.text) { @@ -1487,7 +1485,7 @@ String String::toUpperCase() const for (;;) { - const juce_wchar c = builder.source.toUpperCase(); + auto c = builder.source.toUpperCase(); builder.write (c); if (c == 0) @@ -1496,7 +1494,7 @@ String String::toUpperCase() const ++(builder.source); } - return builder.result; + return builder.get(); } String String::toLowerCase() const @@ -1505,7 +1503,7 @@ String String::toLowerCase() const for (;;) { - const juce_wchar c = builder.source.toLowerCase(); + auto c = builder.source.toLowerCase(); builder.write (c); if (c == 0) @@ -1514,7 +1512,7 @@ String String::toLowerCase() const ++(builder.source); } - return builder.result; + return builder.get(); } //============================================================================== @@ -1532,7 +1530,7 @@ String String::substring (int start, const int end) const return {}; int i = 0; - CharPointerType t1 (text); + auto t1 = text; while (i < start) { @@ -1543,7 +1541,8 @@ String String::substring (int start, const int end) const ++t1; } - CharPointerType t2 (t1); + auto t2 = t1; + while (i < end) { if (t2.isEmpty()) @@ -1566,7 +1565,7 @@ String String::substring (int start) const if (start <= 0) return *this; - CharPointerType t (text); + auto t = text; while (--start >= 0) { @@ -1589,48 +1588,40 @@ String String::getLastCharacters (const int numCharacters) const return String (text + jmax (0, length() - jmax (0, numCharacters))); } -String String::fromFirstOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::fromFirstOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? indexOfIgnoreCase (sub) - : indexOf (sub); + auto i = ignoreCase ? indexOfIgnoreCase (sub) + : indexOf (sub); if (i < 0) return {}; return substring (includeSubString ? i : i + sub.length()); } -String String::fromLastOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::fromLastOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? lastIndexOfIgnoreCase (sub) - : lastIndexOf (sub); + auto i = ignoreCase ? lastIndexOfIgnoreCase (sub) + : lastIndexOf (sub); if (i < 0) return *this; return substring (includeSubString ? i : i + sub.length()); } -String String::upToFirstOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::upToFirstOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? indexOfIgnoreCase (sub) - : indexOf (sub); + auto i = ignoreCase ? indexOfIgnoreCase (sub) + : indexOf (sub); if (i < 0) return *this; return substring (0, includeSubString ? i + sub.length() : i); } -String String::upToLastOccurrenceOf (StringRef sub, - const bool includeSubString, - const bool ignoreCase) const +String String::upToLastOccurrenceOf (StringRef sub, bool includeSubString, bool ignoreCase) const { - const int i = ignoreCase ? lastIndexOfIgnoreCase (sub) - : lastIndexOf (sub); + auto i = ignoreCase ? lastIndexOfIgnoreCase (sub) + : lastIndexOf (sub); if (i < 0) return *this; @@ -1656,7 +1647,7 @@ String String::unquoted() const return substring (1, len - (isQuoteCharacter (text[len - 1]) ? 1 : 0)); } -String String::quoted (const juce_wchar quoteCharacter) const +String String::quoted (juce_wchar quoteCharacter) const { if (isEmpty()) return charToString (quoteCharacter) + quoteCharacter; @@ -1692,10 +1683,9 @@ String String::trim() const { if (isNotEmpty()) { - CharPointerType start (text.findEndOfWhitespace()); - - const CharPointerType end (start.findTerminatingNull()); - CharPointerType trimmedEnd (findTrimmedEnd (start, end)); + auto start = text.findEndOfWhitespace(); + auto end = start.findTerminatingNull(); + auto trimmedEnd = findTrimmedEnd (start, end); if (trimmedEnd <= start) return {}; @@ -1711,7 +1701,7 @@ String String::trimStart() const { if (isNotEmpty()) { - const CharPointerType t (text.findEndOfWhitespace()); + auto t = text.findEndOfWhitespace(); if (t != text) return String (t); @@ -1724,8 +1714,8 @@ String String::trimEnd() const { if (isNotEmpty()) { - const CharPointerType end (text.findTerminatingNull()); - CharPointerType trimmedEnd (findTrimmedEnd (text, end)); + auto end = text.findTerminatingNull(); + auto trimmedEnd = findTrimmedEnd (text, end); if (trimmedEnd < end) return String (text, trimmedEnd); @@ -1736,7 +1726,7 @@ String String::trimEnd() const String String::trimCharactersAtStart (StringRef charactersToTrim) const { - CharPointerType t (text); + auto t = text; while (charactersToTrim.text.indexOf (*t) >= 0) ++t; @@ -1748,8 +1738,8 @@ String String::trimCharactersAtEnd (StringRef charactersToTrim) const { if (isNotEmpty()) { - const CharPointerType end (text.findTerminatingNull()); - CharPointerType trimmedEnd (end); + auto end = text.findTerminatingNull(); + auto trimmedEnd = end; while (trimmedEnd > text) { @@ -1777,7 +1767,7 @@ String String::retainCharacters (StringRef charactersToRetain) const for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (charactersToRetain.text.indexOf (c) >= 0) builder.write (c); @@ -1787,7 +1777,7 @@ String String::retainCharacters (StringRef charactersToRetain) const } builder.write (0); - return builder.result; + return builder.get(); } String String::removeCharacters (StringRef charactersToRemove) const @@ -1799,7 +1789,7 @@ String String::removeCharacters (StringRef charactersToRemove) const for (;;) { - juce_wchar c = builder.source.getAndAdvance(); + auto c = builder.source.getAndAdvance(); if (charactersToRemove.text.indexOf (c) < 0) builder.write (c); @@ -1808,12 +1798,12 @@ String String::removeCharacters (StringRef charactersToRemove) const break; } - return builder.result; + return builder.get(); } String String::initialSectionContainingOnly (StringRef permittedCharacters) const { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (permittedCharacters.text.indexOf (*t) < 0) return String (text, t); @@ -1822,7 +1812,7 @@ String String::initialSectionContainingOnly (StringRef permittedCharacters) cons String String::initialSectionNotContaining (StringRef charactersToStopAt) const { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (charactersToStopAt.text.indexOf (*t) >= 0) return String (text, t); @@ -1831,7 +1821,7 @@ String String::initialSectionNotContaining (StringRef charactersToStopAt) const bool String::containsOnly (StringRef chars) const noexcept { - for (CharPointerType t (text); ! t.isEmpty();) + for (auto t = text; ! t.isEmpty();) if (chars.text.indexOf (t.getAndAdvance()) < 0) return false; @@ -1840,7 +1830,7 @@ bool String::containsOnly (StringRef chars) const noexcept bool String::containsAnyOf (StringRef chars) const noexcept { - for (CharPointerType t (text); ! t.isEmpty();) + for (auto t = text; ! t.isEmpty();) if (chars.text.indexOf (t.getAndAdvance()) >= 0) return true; @@ -1849,7 +1839,7 @@ bool String::containsAnyOf (StringRef chars) const noexcept bool String::containsNonWhitespaceChars() const noexcept { - for (CharPointerType t (text); ! t.isEmpty(); ++t) + for (auto t = text; ! t.isEmpty(); ++t) if (! t.isWhitespace()) return true; @@ -1867,7 +1857,7 @@ String String::formattedRaw (const char* pf, ...) #if JUCE_ANDROID HeapBlock temp (bufferSize); - int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf, args); + int num = (int) vsnprintf (temp.get(), bufferSize - 1, pf, args); if (num >= static_cast (bufferSize)) num = -1; #else @@ -1879,7 +1869,7 @@ String String::formattedRaw (const char* pf, ...) #else vswprintf #endif - (temp.getData(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args); + (temp.get(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args); #endif va_end (args); @@ -1905,7 +1895,7 @@ int String::getTrailingIntValue() const noexcept { int n = 0; int mult = 1; - CharPointerType t (text.findTerminatingNull()); + auto t = text.findTerminatingNull(); while (--t >= text) { @@ -1962,7 +1952,7 @@ String String::toHexString (const void* const d, const int size, const int group String s (PreallocationBytes (sizeof (CharPointerType::CharType) * (size_t) numChars)); auto* data = static_cast (d); - CharPointerType dest (s.text); + auto dest = s.text; for (int i = 0; i < size; ++i) { @@ -2010,7 +2000,7 @@ String String::createStringFromData (const void* const unknownData, int size) StringCreationHelper builder ((size_t) numChars); - const uint16* const src = (const uint16*) (data + 2); + auto src = (const uint16*) (data + 2); if (CharPointer_UTF16::isByteOrderMarkBigEndian (data)) { @@ -2024,7 +2014,7 @@ String String::createStringFromData (const void* const unknownData, int size) } builder.write (0); - return builder.result; + return builder.get(); } auto* start = (const char*) data; @@ -2058,9 +2048,9 @@ struct StringEncodingConverter return CharPointerType_Dest (reinterpret_cast (&emptyChar)); CharPointerType_Src text (source.getCharPointer()); - const size_t extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text) + sizeof (typename CharPointerType_Dest::CharType); - const size_t endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows - // functions will fail to read it correctly! + auto extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text) + sizeof (typename CharPointerType_Dest::CharType); + auto endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows + // functions will fail to read it correctly! source.preallocateBytes (endOffset + extraBytesNeeded); text = source.getCharPointer(); @@ -2068,7 +2058,7 @@ struct StringEncodingConverter const CharPointerType_Dest extraSpace (static_cast (newSpace)); #if JUCE_DEBUG // (This just avoids spurious warnings from valgrind about the uninitialised bytes at the end of the buffer..) - const size_t bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); + auto bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); zeromem (addBytesToPointer (newSpace, extraBytesNeeded - bytesToClear), bytesToClear); #endif @@ -2708,3 +2698,5 @@ public: static StringTests stringUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index 885256b322..4ba4156d42 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -1327,6 +1327,8 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string /** Appends a string to the end of the first one. */ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, StringRef string2); +/** Appends a decimal number to the end of a string. */ +JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, uint8 number); /** Appends a decimal number to the end of a string. */ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, short number); /** Appends a decimal number to the end of a string. */ @@ -1346,7 +1348,7 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, double number); // Automatically creating a String from a bool opens up lots of nasty type conversion edge cases. // If you want a String representation of a bool you can cast the bool to an int first. -JUCE_API String& JUCE_CALLTYPE operator<< (String&, bool) = delete; +String& JUCE_CALLTYPE operator<< (String&, bool) = delete; //============================================================================== /** Case-sensitive comparison of two strings. */ @@ -1356,11 +1358,11 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF16 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF32 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) noexcept; @@ -1369,11 +1371,11 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* strin /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF8 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF16 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF16 string2) noexcept; /** Case-sensitive comparison of two strings. */ -JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF32 string2) noexcept; +JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, CharPointer_UTF32 string2) noexcept; /** Case-sensitive comparison of two strings. */ JUCE_API bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) noexcept; @@ -1408,3 +1410,15 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Str /** Writes a string to an OutputStream as UTF8. */ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef stringToWrite); + +} // namespace juce + +#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS // just used to avoid compiling this under compilers that lack libc++ +namespace std +{ + template <> struct hash + { + size_t operator() (const juce::String& s) const noexcept { return s.hash(); } + }; +} +#endif diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index 2ce830f71d..a22b31c7b0 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + StringArray::StringArray() noexcept { } @@ -492,3 +495,5 @@ void StringArray::minimiseStorageOverheads() { strings.minimiseStorageOverheads(); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringArray.h b/modules/juce_core/text/juce_StringArray.h index a49c65f6b8..49d8662753 100644 --- a/modules/juce_core/text/juce_StringArray.h +++ b/modules/juce_core/text/juce_StringArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -423,3 +423,5 @@ public: private: JUCE_LEAK_DETECTOR (StringArray) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPairArray.cpp b/modules/juce_core/text/juce_StringPairArray.cpp index 5ae706fbc2..202fd44f8c 100644 --- a/modules/juce_core/text/juce_StringPairArray.cpp +++ b/modules/juce_core/text/juce_StringPairArray.cpp @@ -20,8 +20,10 @@ ============================================================================== */ -StringPairArray::StringPairArray (const bool ignoreCase_) - : ignoreCase (ignoreCase_) +namespace juce +{ + +StringPairArray::StringPairArray (bool shouldIgnoreCase) : ignoreCase (shouldIgnoreCase) { } @@ -139,3 +141,5 @@ void StringPairArray::minimiseStorageOverheads() keys.minimiseStorageOverheads(); values.minimiseStorageOverheads(); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPairArray.h b/modules/juce_core/text/juce_StringPairArray.h index 7d9f3afef5..8bf8b61543 100644 --- a/modules/juce_core/text/juce_StringPairArray.h +++ b/modules/juce_core/text/juce_StringPairArray.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -145,3 +145,5 @@ private: JUCE_LEAK_DETECTOR (StringPairArray) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPool.cpp b/modules/juce_core/text/juce_StringPool.cpp index 65bde3535f..a9a1121032 100644 --- a/modules/juce_core/text/juce_StringPool.cpp +++ b/modules/juce_core/text/juce_StringPool.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static const int minNumberOfStringsForGarbageCollection = 300; static const uint32 garbageCollectionInterval = 30000; @@ -158,3 +161,5 @@ StringPool& StringPool::getGlobalPool() noexcept static StringPool pool; return pool; } + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringPool.h b/modules/juce_core/text/juce_StringPool.h index 26240ca036..0f81bbbca3 100644 --- a/modules/juce_core/text/juce_StringPool.h +++ b/modules/juce_core/text/juce_StringPool.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -84,3 +84,5 @@ private: JUCE_DECLARE_NON_COPYABLE (StringPool) }; + +} // namespace juce diff --git a/modules/juce_core/text/juce_StringRef.h b/modules/juce_core/text/juce_StringRef.h index 77919b63bc..308474d10c 100644 --- a/modules/juce_core/text/juce_StringRef.h +++ b/modules/juce_core/text/juce_StringRef.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -128,3 +129,5 @@ inline String operator+ (String s1, StringRef s2) { return s1 += Strin inline String operator+ (StringRef s1, const String& s2) { return String (s1.text) + s2; } inline String operator+ (const char* s1, StringRef s2) { return String (s1) + String (s2.text); } inline String operator+ (StringRef s1, const char* s2) { return String (s1.text) + String (s2); } + +} // namespace juce diff --git a/modules/juce_core/text/juce_TextDiff.cpp b/modules/juce_core/text/juce_TextDiff.cpp index 35b13f7a48..f3e6b21daf 100644 --- a/modules/juce_core/text/juce_TextDiff.cpp +++ b/modules/juce_core/text/juce_TextDiff.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct TextDiffHelpers { enum { minLengthToMatch = 3, @@ -276,3 +279,5 @@ public: static DiffTests diffTests; #endif + +} // namespace juce diff --git a/modules/juce_core/text/juce_TextDiff.h b/modules/juce_core/text/juce_TextDiff.h index a0b9c29bad..05910ff0cd 100644 --- a/modules/juce_core/text/juce_TextDiff.h +++ b/modules/juce_core/text/juce_TextDiff.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Calculates and applies a sequence of changes to convert one text string into @@ -68,3 +68,5 @@ public: */ Array changes; }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index 262882bb9a..1afd058ef7 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChildProcess::ChildProcess() {} ChildProcess::~ChildProcess() {} @@ -45,7 +48,7 @@ uint32 ChildProcess::getExitCode() const bool ChildProcess::waitForProcessToFinish (const int timeoutMs) const { - const uint32 timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs; + auto timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs; do { @@ -110,3 +113,5 @@ public: static ChildProcessTests childProcessUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ChildProcess.h b/modules/juce_core/threads/juce_ChildProcess.h index cbc380dfec..ac4d94e446 100644 --- a/modules/juce_core/threads/juce_ChildProcess.h +++ b/modules/juce_core/threads/juce_ChildProcess.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcess) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_CriticalSection.h b/modules/juce_core/threads/juce_CriticalSection.h index 60a2409232..b382acdc75 100644 --- a/modules/juce_core/threads/juce_CriticalSection.h +++ b/modules/juce_core/threads/juce_CriticalSection.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -254,3 +254,5 @@ typedef CriticalSection::ScopedUnlockType ScopedUnlock; @see CriticalSection::tryEnter, ScopedLock, ScopedUnlock, ScopedReadLock */ typedef CriticalSection::ScopedTryLockType ScopedTryLock; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_DynamicLibrary.h b/modules/juce_core/threads/juce_DynamicLibrary.h index 0d07839997..a4a273769b 100644 --- a/modules/juce_core/threads/juce_DynamicLibrary.h +++ b/modules/juce_core/threads/juce_DynamicLibrary.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** Handles the opening and closing of DLLs. @@ -35,14 +36,14 @@ public: /** Creates an unopened DynamicLibrary object. Call open() to actually open one. */ - DynamicLibrary() noexcept : handle (nullptr) {} + DynamicLibrary() noexcept {} /** */ - DynamicLibrary (const String& name) : handle (nullptr) { open (name); } + DynamicLibrary (const String& name) { open (name); } /** Move constructor */ - DynamicLibrary (DynamicLibrary&& other) noexcept : handle (nullptr) + DynamicLibrary (DynamicLibrary&& other) noexcept { std::swap (handle, other.handle); } @@ -75,7 +76,9 @@ public: void* getNativeHandle() const noexcept { return handle; } private: - void* handle; + void* handle = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DynamicLibrary) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/modules/juce_core/threads/juce_HighResolutionTimer.cpp index 9e7550d7f9..91f9eac784 100644 --- a/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/modules/juce_core/threads/juce_HighResolutionTimer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + HighResolutionTimer::HighResolutionTimer() { pimpl = new Pimpl (*this); } HighResolutionTimer::~HighResolutionTimer() { stopTimer(); } @@ -28,3 +31,5 @@ void HighResolutionTimer::stopTimer() { pimpl->stop(); } bool HighResolutionTimer::isTimerRunning() const noexcept { return pimpl->periodMs != 0; } int HighResolutionTimer::getTimerInterval() const noexcept { return pimpl->periodMs; } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_HighResolutionTimer.h b/modules/juce_core/threads/juce_HighResolutionTimer.h index d90f59737e..4c846093cb 100644 --- a/modules/juce_core/threads/juce_HighResolutionTimer.h +++ b/modules/juce_core/threads/juce_HighResolutionTimer.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** A high-resolution periodic timer. @@ -97,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HighResolutionTimer) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_InterProcessLock.h b/modules/juce_core/threads/juce_InterProcessLock.h index effcf26e9b..3bec0275d7 100644 --- a/modules/juce_core/threads/juce_InterProcessLock.h +++ b/modules/juce_core/threads/juce_InterProcessLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ private: JUCE_DECLARE_NON_COPYABLE (InterProcessLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Process.h b/modules/juce_core/threads/juce_Process.h index 656f88acb3..1804b89452 100644 --- a/modules/juce_core/threads/juce_Process.h +++ b/modules/juce_core/threads/juce_Process.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Represents the current executable's process. @@ -150,3 +150,5 @@ private: Process(); JUCE_DECLARE_NON_COPYABLE (Process) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ReadWriteLock.cpp b/modules/juce_core/threads/juce_ReadWriteLock.cpp index 7a7efe4391..27347d5f40 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.cpp +++ b/modules/juce_core/threads/juce_ReadWriteLock.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ReadWriteLock::ReadWriteLock() noexcept : numWaitingWriters (0), numWriters (0), @@ -142,3 +145,5 @@ void ReadWriteLock::exitWrite() const noexcept waitEvent.signal(); } } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ReadWriteLock.h b/modules/juce_core/threads/juce_ReadWriteLock.h index cb5e4cdddf..4d3f6e5172 100644 --- a/modules/juce_core/threads/juce_ReadWriteLock.h +++ b/modules/juce_core/threads/juce_ReadWriteLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -140,3 +140,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ReadWriteLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedLock.h b/modules/juce_core/threads/juce_ScopedLock.h index c1b5795be1..886f555e9e 100644 --- a/modules/juce_core/threads/juce_ScopedLock.h +++ b/modules/juce_core/threads/juce_ScopedLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -225,3 +225,5 @@ private: JUCE_DECLARE_NON_COPYABLE (GenericScopedTryLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedReadLock.h b/modules/juce_core/threads/juce_ScopedReadLock.h index c459c29d02..fa5fe1ab04 100644 --- a/modules/juce_core/threads/juce_ScopedReadLock.h +++ b/modules/juce_core/threads/juce_ScopedReadLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -78,3 +78,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedReadLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ScopedWriteLock.h b/modules/juce_core/threads/juce_ScopedWriteLock.h index 52539fb7bb..7a9e8e53ef 100644 --- a/modules/juce_core/threads/juce_ScopedWriteLock.h +++ b/modules/juce_core/threads/juce_ScopedWriteLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -78,3 +78,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ScopedWriteLock) }; + +} diff --git a/modules/juce_core/threads/juce_SpinLock.h b/modules/juce_core/threads/juce_SpinLock.h index 5454006adb..f79a6e5afd 100644 --- a/modules/juce_core/threads/juce_SpinLock.h +++ b/modules/juce_core/threads/juce_SpinLock.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -79,3 +79,5 @@ private: JUCE_DECLARE_NON_COPYABLE (SpinLock) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Thread.cpp b/modules/juce_core/threads/juce_Thread.cpp index fa2b26a12d..8195ce7f49 100644 --- a/modules/juce_core/threads/juce_Thread.cpp +++ b/modules/juce_core/threads/juce_Thread.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Thread::Thread (const String& name, size_t stackSize) : threadName (name), threadStackSize (stackSize) { @@ -503,3 +506,5 @@ private: ThreadLocalValueUnitTest threadLocalValueUnitTest; #endif + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Thread.h b/modules/juce_core/threads/juce_Thread.h index e5d1a49230..e4baa969d6 100644 --- a/modules/juce_core/threads/juce_Thread.h +++ b/modules/juce_core/threads/juce_Thread.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -330,3 +330,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Thread) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadLocalValue.h b/modules/juce_core/threads/juce_ThreadLocalValue.h index 2b6d4fe028..ca2630976d 100644 --- a/modules/juce_core/threads/juce_ThreadLocalValue.h +++ b/modules/juce_core/threads/juce_ThreadLocalValue.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -143,3 +144,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ThreadLocalValue) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index f12300155f..4cee61dabf 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ThreadPool::ThreadPoolThread : public Thread { public: @@ -419,3 +422,5 @@ void ThreadPool::addToDeleteList (OwnedArray& deletionList, Threa if (job->shouldBeDeleted) deletionList.add (job); } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_ThreadPool.h b/modules/juce_core/threads/juce_ThreadPool.h index 6dda3ed939..9ead49c864 100644 --- a/modules/juce_core/threads/juce_ThreadPool.h +++ b/modules/juce_core/threads/juce_ThreadPool.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ThreadPool; class ThreadPoolThread; @@ -328,3 +329,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPool) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_TimeSliceThread.cpp b/modules/juce_core/threads/juce_TimeSliceThread.cpp index 94ecca528f..d5c4c227e5 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/modules/juce_core/threads/juce_TimeSliceThread.cpp @@ -20,9 +20,10 @@ ============================================================================== */ -TimeSliceThread::TimeSliceThread (const String& name) - : Thread (name), - clientBeingCalled (nullptr) +namespace juce +{ + +TimeSliceThread::TimeSliceThread (const String& name) : Thread (name) { } @@ -179,3 +180,5 @@ void TimeSliceThread::run() wait (timeToWait); } } + +} // namespace juce diff --git a/modules/juce_core/threads/juce_TimeSliceThread.h b/modules/juce_core/threads/juce_TimeSliceThread.h index 7a3ad7791e..53648b69c5 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.h +++ b/modules/juce_core/threads/juce_TimeSliceThread.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TimeSliceThread; @@ -135,9 +136,11 @@ public: private: CriticalSection callbackLock, listLock; Array clients; - TimeSliceClient* clientBeingCalled; + TimeSliceClient* clientBeingCalled = nullptr; TimeSliceClient* getNextClient (int index) const; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimeSliceThread) }; + +} // namespace juce diff --git a/modules/juce_core/threads/juce_WaitableEvent.h b/modules/juce_core/threads/juce_WaitableEvent.h index 55900a268d..e13ec398d9 100644 --- a/modules/juce_core/threads/juce_WaitableEvent.h +++ b/modules/juce_core/threads/juce_WaitableEvent.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaitableEvent) }; + +} // namespace juce diff --git a/modules/juce_core/time/juce_PerformanceCounter.cpp b/modules/juce_core/time/juce_PerformanceCounter.cpp index 6c3c3bbdd6..4650e16f17 100644 --- a/modules/juce_core/time/juce_PerformanceCounter.cpp +++ b/modules/juce_core/time/juce_PerformanceCounter.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static void appendToFile (const File& f, const String& s) { if (f.getFullPathName().isNotEmpty()) @@ -124,3 +127,5 @@ PerformanceCounter::Statistics PerformanceCounter::getStatisticsAndReset() return s; } + +} // namespace juce diff --git a/modules/juce_core/time/juce_PerformanceCounter.h b/modules/juce_core/time/juce_PerformanceCounter.h index 7108b0f874..506a490442 100644 --- a/modules/juce_core/time/juce_PerformanceCounter.h +++ b/modules/juce_core/time/juce_PerformanceCounter.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A timer for measuring performance of code and dumping the results to a file. @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ScopedTimeMeasurement) }; + +} // namespace juce diff --git a/modules/juce_core/time/juce_RelativeTime.cpp b/modules/juce_core/time/juce_RelativeTime.cpp index 013a1fc26f..3dc2fd4da9 100644 --- a/modules/juce_core/time/juce_RelativeTime.cpp +++ b/modules/juce_core/time/juce_RelativeTime.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + RelativeTime::RelativeTime (const double secs) noexcept : numSeconds (secs) {} RelativeTime::RelativeTime (const RelativeTime& other) noexcept : numSeconds (other.numSeconds) {} RelativeTime::~RelativeTime() noexcept {} @@ -131,3 +134,5 @@ String RelativeTime::getDescription (const String& returnValueForZeroTime) const return result.trimEnd(); } + +} // namespace juce diff --git a/modules/juce_core/time/juce_RelativeTime.h b/modules/juce_core/time/juce_RelativeTime.h index 9700d9aa29..7ccbce2cd1 100644 --- a/modules/juce_core/time/juce_RelativeTime.h +++ b/modules/juce_core/time/juce_RelativeTime.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A relative measure of time. @@ -171,3 +171,5 @@ JUCE_API bool JUCE_CALLTYPE operator<= (RelativeTime t1, RelativeTime t2) noexce JUCE_API RelativeTime JUCE_CALLTYPE operator+ (RelativeTime t1, RelativeTime t2) noexcept; /** Subtracts two RelativeTimes. */ JUCE_API RelativeTime JUCE_CALLTYPE operator- (RelativeTime t1, RelativeTime t2) noexcept; + +} // namespace juce diff --git a/modules/juce_core/time/juce_Time.cpp b/modules/juce_core/time/juce_Time.cpp index 2e78b58edb..dfa54dfa77 100644 --- a/modules/juce_core/time/juce_Time.cpp +++ b/modules/juce_core/time/juce_Time.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + namespace TimeHelpers { static std::tm millisToLocal (int64 millis) noexcept @@ -679,3 +682,5 @@ public: static TimeTests timeTests; #endif + +} // namespace juce diff --git a/modules/juce_core/time/juce_Time.h b/modules/juce_core/time/juce_Time.h index c38321b5a0..2ff37375b5 100644 --- a/modules/juce_core/time/juce_Time.h +++ b/modules/juce_core/time/juce_Time.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -403,3 +403,5 @@ JUCE_API bool operator<= (Time time1, Time time2) noexcept; JUCE_API bool operator> (Time time1, Time time2) noexcept; /** Compares two Time objects. */ JUCE_API bool operator>= (Time time1, Time time2) noexcept; + +} // namespace juce diff --git a/modules/juce_core/unit_tests/juce_UnitTest.cpp b/modules/juce_core/unit_tests/juce_UnitTest.cpp index 2ed41b9813..9e9150ee63 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + UnitTest::UnitTest (const String& nm, const String& ctg) : name (nm), category (ctg), runner (nullptr) { @@ -286,3 +289,5 @@ void UnitTestRunner::addFail (const String& failureMessage) if (assertOnFailure) { jassertfalse; } } + +} // namespace juce diff --git a/modules/juce_core/unit_tests/juce_UnitTest.h b/modules/juce_core/unit_tests/juce_UnitTest.h index 68c4459818..9a9580b836 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.h +++ b/modules/juce_core/unit_tests/juce_UnitTest.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class UnitTestRunner; @@ -431,3 +432,5 @@ private: JUCE_DECLARE_NON_COPYABLE (UnitTestRunner) }; + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlDocument.cpp b/modules/juce_core/xml/juce_XmlDocument.cpp index e522a45a83..b3268dfc7c 100644 --- a/modules/juce_core/xml/juce_XmlDocument.cpp +++ b/modules/juce_core/xml/juce_XmlDocument.cpp @@ -20,23 +20,16 @@ ============================================================================== */ +namespace juce +{ + XmlDocument::XmlDocument (const String& documentText) - : originalText (documentText), - input (nullptr), - outOfData (false), - errorOccurred (false), - needToLoadDTD (false), - ignoreEmptyTextElements (true) + : originalText (documentText) { } XmlDocument::XmlDocument (const File& file) - : input (nullptr), - outOfData (false), - errorOccurred (false), - needToLoadDTD (false), - ignoreEmptyTextElements (true), - inputSource (new FileInputSource (file)) + : inputSource (new FileInputSource (file)) { } @@ -883,3 +876,5 @@ String XmlDocument::getParameterEntity (const String& entity) return entity; } + +} diff --git a/modules/juce_core/xml/juce_XmlDocument.h b/modules/juce_core/xml/juce_XmlDocument.h index 6d0bd62174..e09bd63584 100644 --- a/modules/juce_core/xml/juce_XmlDocument.h +++ b/modules/juce_core/xml/juce_XmlDocument.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -143,12 +143,11 @@ public: //============================================================================== private: String originalText; - String::CharPointerType input; - bool outOfData, errorOccurred; - + String::CharPointerType input { nullptr }; + bool outOfData = false, errorOccurred = false; String lastError, dtdText; StringArray tokenisedDTD; - bool needToLoadDTD, ignoreEmptyTextElements; + bool needToLoadDTD = false, ignoreEmptyTextElements = true; ScopedPointer inputSource; XmlElement* parseDocumentElement (String::CharPointerType, bool outer); @@ -169,3 +168,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlDocument) }; + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlElement.cpp b/modules/juce_core/xml/juce_XmlElement.cpp index 04e81b6da2..b04e307282 100644 --- a/modules/juce_core/xml/juce_XmlElement.cpp +++ b/modules/juce_core/xml/juce_XmlElement.cpp @@ -20,38 +20,38 @@ ============================================================================== */ -namespace +namespace juce { - inline bool isValidXmlNameStartCharacter (const juce_wchar character) noexcept - { - return character == ':' - || character == '_' - || (character >= 'a' && character <= 'z') - || (character >= 'A' && character <= 'Z') - || (character >= 0xc0 && character <= 0xd6) - || (character >= 0xd8 && character <= 0xf6) - || (character >= 0xf8 && character <= 0x2ff) - || (character >= 0x370 && character <= 0x37d) - || (character >= 0x37f && character <= 0x1fff) - || (character >= 0x200c && character <= 0x200d) - || (character >= 0x2070 && character <= 0x218f) - || (character >= 0x2c00 && character <= 0x2fef) - || (character >= 0x3001 && character <= 0xd7ff) - || (character >= 0xf900 && character <= 0xfdcf) - || (character >= 0xfdf0 && character <= 0xfffd) - || (character >= 0x10000 && character <= 0xeffff); - } - inline bool isValidXmlNameBodyCharacter (const juce_wchar character) noexcept - { - return isValidXmlNameStartCharacter (character) - || character == '-' - || character == '.' - || character == 0xb7 - || (character >= '0' && character <= '9') - || (character >= 0x300 && character <= 0x036f) - || (character >= 0x203f && character <= 0x2040); - } +inline static bool isValidXmlNameStartCharacter (juce_wchar character) noexcept +{ + return character == ':' + || character == '_' + || (character >= 'a' && character <= 'z') + || (character >= 'A' && character <= 'Z') + || (character >= 0xc0 && character <= 0xd6) + || (character >= 0xd8 && character <= 0xf6) + || (character >= 0xf8 && character <= 0x2ff) + || (character >= 0x370 && character <= 0x37d) + || (character >= 0x37f && character <= 0x1fff) + || (character >= 0x200c && character <= 0x200d) + || (character >= 0x2070 && character <= 0x218f) + || (character >= 0x2c00 && character <= 0x2fef) + || (character >= 0x3001 && character <= 0xd7ff) + || (character >= 0xf900 && character <= 0xfdcf) + || (character >= 0xfdf0 && character <= 0xfffd) + || (character >= 0x10000 && character <= 0xeffff); +} + +inline static bool isValidXmlNameBodyCharacter (juce_wchar character) noexcept +{ + return isValidXmlNameStartCharacter (character) + || character == '-' + || character == '.' + || character == 0xb7 + || (character >= '0' && character <= '9') + || (character >= 0x300 && character <= 0x036f) + || (character >= 0x203f && character <= 0x2040); } XmlElement::XmlAttributeNode::XmlAttributeNode (const XmlAttributeNode& other) noexcept @@ -928,3 +928,5 @@ void XmlElement::deleteAllTextElements() noexcept child = next; } } + +} // namespace juce diff --git a/modules/juce_core/xml/juce_XmlElement.h b/modules/juce_core/xml/juce_XmlElement.h index 5c1b90fe34..33f86744ec 100644 --- a/modules/juce_core/xml/juce_XmlElement.h +++ b/modules/juce_core/xml/juce_XmlElement.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A handy macro to make it easy to iterate all the child elements in an XmlElement. @@ -762,3 +762,5 @@ private: JUCE_LEAK_DETECTOR (XmlElement) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index d8c46bc009..df64f23d2c 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -20,14 +20,14 @@ ============================================================================== */ +namespace juce +{ + class GZIPCompressorOutputStream::GZIPCompressorHelper { public: GZIPCompressorHelper (const int compressionLevel, const int windowBits) - : compLevel ((compressionLevel < 0 || compressionLevel > 9) ? -1 : compressionLevel), - isFirstDeflate (true), - streamIsValid (false), - finished (false) + : compLevel ((compressionLevel < 0 || compressionLevel > 9) ? -1 : compressionLevel) { using namespace zlibNamespace; zerostruct (stream); @@ -70,7 +70,7 @@ private: zlibNamespace::z_stream stream; const int compLevel; - bool isFirstDeflate, streamIsValid, finished; + bool isFirstDeflate = true, streamIsValid = false, finished = false; zlibNamespace::Bytef buffer[32768]; bool doNextBlock (const uint8*& data, size_t& dataSize, OutputStream& out, const int flushMode) @@ -155,9 +155,8 @@ bool GZIPCompressorOutputStream::setPosition (int64 /*newPosition*/) //============================================================================== #if JUCE_UNIT_TESTS -class GZIPTests : public UnitTest +struct GZIPTests : public UnitTest { -public: GZIPTests() : UnitTest ("GZIP", "Compression") {} void runTest() override @@ -205,3 +204,5 @@ public: static GZIPTests gzipTests; #endif + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h index ff14f9fcc2..25a28101a6 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -90,3 +90,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPCompressorOutputStream) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 35e7a15042..0bae4d39d6 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4309 4305 4365) @@ -97,12 +100,6 @@ class GZIPDecompressorInputStream::GZIPDecompressHelper { public: GZIPDecompressHelper (Format f) - : finished (true), - needsDictionary (false), - error (true), - streamIsValid (false), - data (nullptr), - dataSize (0) { using namespace zlibNamespace; zerostruct (stream); @@ -112,9 +109,8 @@ public: ~GZIPDecompressHelper() { - using namespace zlibNamespace; if (streamIsValid) - inflateEnd (&stream); + zlibNamespace::inflateEnd (&stream); } bool needsInput() const noexcept { return dataSize <= 0; } @@ -128,6 +124,7 @@ public: int doNextBlock (uint8* const dest, const unsigned int destSize) { using namespace zlibNamespace; + if (streamIsValid && data != nullptr && ! finished) { stream.next_in = data; @@ -176,14 +173,14 @@ public: return MAX_WBITS; } - bool finished, needsDictionary, error, streamIsValid; + bool finished = true, needsDictionary = false, error = true, streamIsValid = false; enum { gzipDecompBufferSize = 32768 }; private: zlibNamespace::z_stream stream; - uint8* data; - size_t dataSize; + uint8* data = nullptr; + size_t dataSize = 0; JUCE_DECLARE_NON_COPYABLE (GZIPDecompressHelper) }; @@ -303,3 +300,5 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos) skipNextBytes (newPos - currentPos); return true; } + +} // namespace juce diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h index be0e287310..a7edadc04d 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -98,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPDecompressorInputStream) }; + +} // namespace juce diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index 87e461f14f..78badf8165 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ZipFile::ZipEntryHolder { public: @@ -603,3 +606,5 @@ bool ZipFile::Builder::writeToStream (OutputStream& target, double* const progre return true; } + +} // namespace juce diff --git a/modules/juce_core/zip/juce_ZipFile.h b/modules/juce_core/zip/juce_ZipFile.h index ca83230577..4e1c75bf11 100644 --- a/modules/juce_core/zip/juce_ZipFile.h +++ b/modules/juce_core/zip/juce_ZipFile.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -254,3 +254,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ZipFile) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_BlowFish.cpp b/modules/juce_cryptography/encryption/juce_BlowFish.cpp index 7d2f7358f4..ca1b3f3741 100644 --- a/modules/juce_cryptography/encryption/juce_BlowFish.cpp +++ b/modules/juce_cryptography/encryption/juce_BlowFish.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BlowFish::BlowFish (const void* const keyData, const int keyBytes) { jassert (keyData != nullptr); @@ -466,3 +469,5 @@ public: static BlowFishTests blowFishUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_BlowFish.h b/modules/juce_cryptography/encryption/juce_BlowFish.h index dfa50dd88d..cdabc1ac68 100644 --- a/modules/juce_cryptography/encryption/juce_BlowFish.h +++ b/modules/juce_cryptography/encryption/juce_BlowFish.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_LEAK_DETECTOR (BlowFish) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_Primes.cpp b/modules/juce_cryptography/encryption/juce_Primes.cpp index 16c9ec2232..217f98156f 100644 --- a/modules/juce_cryptography/encryption/juce_Primes.cpp +++ b/modules/juce_cryptography/encryption/juce_Primes.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PrimesHelpers { static void createSmallSieve (const int numBits, BigInteger& result) @@ -238,3 +241,5 @@ bool Primes::isProbablyPrime (const BigInteger& number, const int certainty) return passesMillerRabin (number, certainty); } } + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_Primes.h b/modules/juce_cryptography/encryption/juce_Primes.h index 904c92d073..7adcddb0cb 100644 --- a/modules/juce_cryptography/encryption/juce_Primes.h +++ b/modules/juce_cryptography/encryption/juce_Primes.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -69,3 +69,5 @@ private: JUCE_DECLARE_NON_COPYABLE (Primes) }; + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_RSAKey.cpp b/modules/juce_cryptography/encryption/juce_RSAKey.cpp index 6536cd64fe..7e7735a7d1 100644 --- a/modules/juce_cryptography/encryption/juce_RSAKey.cpp +++ b/modules/juce_cryptography/encryption/juce_RSAKey.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RSAKey::RSAKey() { } @@ -135,3 +138,5 @@ void RSAKey::createKeyPair (RSAKey& publicKey, RSAKey& privateKey, privateKey.part1 = d; privateKey.part2 = n; } + +} // namespace juce diff --git a/modules/juce_cryptography/encryption/juce_RSAKey.h b/modules/juce_cryptography/encryption/juce_RSAKey.h index 6927175e93..334513ea0f 100644 --- a/modules/juce_cryptography/encryption/juce_RSAKey.h +++ b/modules/juce_cryptography/encryption/juce_RSAKey.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -170,3 +170,5 @@ private: JUCE_LEAK_DETECTOR (RSAKey) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_MD5.cpp b/modules/juce_cryptography/hashing/juce_MD5.cpp index c4f7f86393..d139393b00 100644 --- a/modules/juce_cryptography/hashing/juce_MD5.cpp +++ b/modules/juce_cryptography/hashing/juce_MD5.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MD5Generator { public: @@ -336,3 +339,5 @@ public: static MD5Tests MD5UnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_MD5.h b/modules/juce_cryptography/hashing/juce_MD5.h index 0eed61e8cb..ffd22f8f47 100644 --- a/modules/juce_cryptography/hashing/juce_MD5.h +++ b/modules/juce_cryptography/hashing/juce_MD5.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -115,3 +115,5 @@ private: JUCE_LEAK_DETECTOR (MD5) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_SHA256.cpp b/modules/juce_cryptography/hashing/juce_SHA256.cpp index 4173e4c644..8504eaa8fc 100644 --- a/modules/juce_cryptography/hashing/juce_SHA256.cpp +++ b/modules/juce_cryptography/hashing/juce_SHA256.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SHA256Processor { public: @@ -275,3 +278,5 @@ public: static SHA256Tests sha256UnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_SHA256.h b/modules/juce_cryptography/hashing/juce_SHA256.h index 5c30cae3c2..de56d5e9c1 100644 --- a/modules/juce_cryptography/hashing/juce_SHA256.h +++ b/modules/juce_cryptography/hashing/juce_SHA256.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ private: JUCE_LEAK_DETECTOR (SHA256) }; + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp index de4474fbbd..0078ceda4c 100644 --- a/modules/juce_cryptography/hashing/juce_Whirlpool.cpp +++ b/modules/juce_cryptography/hashing/juce_Whirlpool.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct WhirlpoolProcessor { WhirlpoolProcessor() noexcept : bufferBits (0), bufferPos (0) @@ -661,3 +664,5 @@ public: static WhirlpoolTests whirlpoolUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_cryptography/hashing/juce_Whirlpool.h b/modules/juce_cryptography/hashing/juce_Whirlpool.h index a6912d557c..b04622fbaa 100644 --- a/modules/juce_cryptography/hashing/juce_Whirlpool.h +++ b/modules/juce_cryptography/hashing/juce_Whirlpool.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_LEAK_DETECTOR (Whirlpool) }; + +} // namespace juce diff --git a/modules/juce_cryptography/juce_cryptography.cpp b/modules/juce_cryptography/juce_cryptography.cpp index 931013b442..e9cf86f33c 100644 --- a/modules/juce_cryptography/juce_cryptography.cpp +++ b/modules/juce_cryptography/juce_cryptography.cpp @@ -35,14 +35,9 @@ #include "juce_cryptography.h" -namespace juce -{ - #include "encryption/juce_BlowFish.cpp" #include "encryption/juce_Primes.cpp" #include "encryption/juce_RSAKey.cpp" #include "hashing/juce_MD5.cpp" #include "hashing/juce_SHA256.cpp" #include "hashing/juce_Whirlpool.cpp" - -} diff --git a/modules/juce_cryptography/juce_cryptography.h b/modules/juce_cryptography/juce_cryptography.h index 269777f772..3d9f6e5c45 100644 --- a/modules/juce_cryptography/juce_cryptography.h +++ b/modules/juce_cryptography/juce_cryptography.h @@ -35,7 +35,7 @@ ID: juce_cryptography vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE cryptography classes description: Classes for various basic cryptography functions, including RSA, Blowfish, MD5, SHA, etc. website: http://www.juce.com/juce @@ -54,14 +54,9 @@ //============================================================================== #include -namespace juce -{ - #include "encryption/juce_BlowFish.h" #include "encryption/juce_Primes.h" #include "encryption/juce_RSAKey.h" #include "hashing/juce_MD5.h" #include "hashing/juce_SHA256.h" #include "hashing/juce_Whirlpool.h" - -} diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp index e120a1469d..eca113fb41 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationProperties::ApplicationProperties() : commonSettingsAreReadOnly (0) { @@ -102,3 +105,5 @@ void ApplicationProperties::closeFiles() userProps = nullptr; commonProps = nullptr; } + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h index b65e5854d7..faa3817c43 100644 --- a/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h +++ b/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,3 +128,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationProperties) }; + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 666710f865..d964fb9cdd 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PropertyFileConstants { JUCE_CONSTEXPR static const int magicNumber = (int) ByteOrder::littleEndianInt ('P', 'R', 'O', 'P'); @@ -356,3 +359,5 @@ void PropertiesFile::propertyChanged() else if (options.millisecondsBeforeSaving == 0) saveIfNeeded(); } + +} // namespace juce diff --git a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index bc29a13659..2848c5bb2c 100644 --- a/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/modules/juce_data_structures/app_properties/juce_PropertiesFile.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Wrapper on a file that stores a list of key/value data pairs. @@ -248,3 +248,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertiesFile) }; + +} // namespace juce diff --git a/modules/juce_data_structures/juce_data_structures.cpp b/modules/juce_data_structures/juce_data_structures.cpp index 7b3a3c497c..5913ca47f5 100644 --- a/modules/juce_data_structures/juce_data_structures.cpp +++ b/modules/juce_data_structures/juce_data_structures.cpp @@ -35,9 +35,6 @@ #include "juce_data_structures.h" -namespace juce -{ - #include "values/juce_Value.cpp" #include "values/juce_ValueTree.cpp" #include "values/juce_ValueTreeSynchroniser.cpp" @@ -45,5 +42,3 @@ namespace juce #include "undomanager/juce_UndoManager.cpp" #include "app_properties/juce_ApplicationProperties.cpp" #include "app_properties/juce_PropertiesFile.cpp" - -} diff --git a/modules/juce_data_structures/juce_data_structures.h b/modules/juce_data_structures/juce_data_structures.h index 0692f4682a..7856e1917c 100644 --- a/modules/juce_data_structures/juce_data_structures.h +++ b/modules/juce_data_structures/juce_data_structures.h @@ -35,7 +35,7 @@ ID: juce_data_structures vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE data model helper classes description: Classes for undo/redo management, and smart data structures. website: http://www.juce.com/juce @@ -54,9 +54,6 @@ //============================================================================== #include -namespace juce -{ - #include "undomanager/juce_UndoableAction.h" #include "undomanager/juce_UndoManager.h" #include "values/juce_Value.h" @@ -65,5 +62,3 @@ namespace juce #include "values/juce_CachedValue.h" #include "app_properties/juce_PropertiesFile.h" #include "app_properties/juce_ApplicationProperties.h" - -} diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index 5c0fb525f8..a5a705a32e 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct UndoManager::ActionSet { ActionSet (const String& transactionName) @@ -345,3 +348,5 @@ int UndoManager::getNumActionsInCurrentTransaction() const return 0; } + +} // namespace juce diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.h b/modules/juce_data_structures/undomanager/juce_UndoManager.h index 1cca8518a1..75f3d0f30d 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.h +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -242,3 +242,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UndoManager) }; + +} // namespace juce diff --git a/modules/juce_data_structures/undomanager/juce_UndoableAction.h b/modules/juce_data_structures/undomanager/juce_UndoableAction.h index b5447210e5..9b418cd4ff 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoableAction.h +++ b/modules/juce_data_structures/undomanager/juce_UndoableAction.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -95,3 +95,5 @@ public: */ virtual UndoableAction* createCoalescedAction (UndoableAction* nextAction) { ignoreUnused (nextAction); return nullptr; } }; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_CachedValue.cpp b/modules/juce_data_structures/values/juce_CachedValue.cpp index b8ecbcc34d..ace2c41de7 100644 --- a/modules/juce_data_structures/values/juce_CachedValue.cpp +++ b/modules/juce_data_structures/values/juce_CachedValue.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_UNIT_TESTS class CachedValueTests : public UnitTest @@ -152,3 +155,5 @@ public: static CachedValueTests cachedValueTests; #endif + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_CachedValue.h b/modules/juce_data_structures/values/juce_CachedValue.h index f2725b6a8e..7a807df300 100644 --- a/modules/juce_data_structures/values/juce_CachedValue.h +++ b/modules/juce_data_structures/values/juce_CachedValue.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -308,3 +308,5 @@ inline void CachedValue::valueTreePropertyChanged (ValueTree& changedTree, if (changedProperty == targetProperty && targetTree == changedTree) forceUpdateOfCachedValue(); } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_Value.cpp b/modules/juce_data_structures/values/juce_Value.cpp index 19e678871c..b09530fed6 100644 --- a/modules/juce_data_structures/values/juce_Value.cpp +++ b/modules/juce_data_structures/values/juce_Value.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Value::ValueSource::ValueSource() { } @@ -235,3 +238,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const Value& value { return stream << value.toString(); } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_Value.h b/modules/juce_data_structures/values/juce_Value.h index d470a9da73..e1216da45c 100644 --- a/modules/juce_data_structures/values/juce_Value.h +++ b/modules/juce_data_structures/values/juce_Value.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -239,3 +239,5 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream&, const Value&); /** This typedef is just for compatibility with old code - newer code should use the Value::Listener class directly. */ typedef Value::Listener ValueListener; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index afe068d16d..b1e596e354 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ValueTree::SharedObject : public ReferenceCountedObject { public: @@ -1144,3 +1147,5 @@ public: static ValueTreeTests valueTreeTests; #endif + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 7c3e3eccfc..d0a66f0cff 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -574,3 +574,5 @@ private: explicit ValueTree (SharedObject*) noexcept; }; + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp index d29b692b4c..7e49e712fb 100644 --- a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp +++ b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace ValueTreeSynchroniserHelpers { enum ChangeType @@ -235,3 +238,5 @@ bool ValueTreeSynchroniser::applyChange (ValueTree& root, const void* data, size return false; } + +} // namespace juce diff --git a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h index 0867a56e95..42c3823602 100644 --- a/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h +++ b/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ValueTreeSynchroniser) }; + +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_AudioBlock.h b/modules/juce_dsp/containers/juce_AudioBlock.h index cd4ccd2daa..b8a40f23af 100644 --- a/modules/juce_dsp/containers/juce_AudioBlock.h +++ b/modules/juce_dsp/containers/juce_AudioBlock.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN namespace SampleTypeHelpers // Internal classes needed for handling sample type classes { @@ -539,3 +544,6 @@ private: ChannelCountType numChannels = 0; size_t startSample = 0, numSamples = 0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_SIMDRegister.h b/modules/juce_dsp/containers/juce_SIMDRegister.h index 059f5c5bef..ffcb086d9e 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister.h +++ b/modules/juce_dsp/containers/juce_SIMDRegister.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN // This class is needed internally. template @@ -56,21 +61,24 @@ template struct SIMDRegister { //============================================================================== + /** The type that represents the individual constituents of the SIMD Register */ + typedef Type ElementType; + + /** STL compatible value_type definition (same as ElementType). */ + typedef ElementType value_type; + /** The corresponding primitive integer type, for example, this will be int32_t if type is a float. */ - typedef typename SIMDInternal::MaskTypeFor::type MaskType; + typedef typename SIMDInternal::MaskTypeFor::type MaskType; //============================================================================== // Here are some types which are needed internally /** The native primitive type (used internally). */ - typedef typename SIMDInternal::PrimitiveType::type ElementType; - - /** STL compatible value_type definition. */ - typedef typename SIMDInternal::PrimitiveType::type value_type; + typedef typename SIMDInternal::PrimitiveType::type PrimitiveType; /** The native operations for this platform and type combination (used internally) */ - typedef SIMDNativeOps NativeOps; + typedef SIMDNativeOps NativeOps; /** The native type (used internally). */ typedef typename NativeOps::vSIMDType vSIMDType; @@ -83,14 +91,14 @@ struct SIMDRegister /** Wrapper for operations which need to be handled differently for complex and scalar types (used internally). */ - typedef CmplxSIMDOps CmplxOps; + typedef CmplxSIMDOps CmplxOps; //============================================================================== /** The size in bytes of this register. */ static constexpr size_t SIMDRegisterSize = sizeof (vSIMDType); /** The number of elements that this vector can hold. */ - static constexpr size_t SIMDNumElements = SIMDRegisterSize / sizeof (Type); + static constexpr size_t SIMDNumElements = SIMDRegisterSize / sizeof (ElementType); vSIMDType value; @@ -101,7 +109,7 @@ struct SIMDRegister //============================================================================== /** Creates a new SIMDRegister from the corresponding scalar primitive. The scalar is extended to all elements of the vector. */ - inline static SIMDRegister JUCE_VECTOR_CALLTYPE expand (Type s) noexcept { return {CmplxOps::expand (s)}; } + inline static SIMDRegister JUCE_VECTOR_CALLTYPE expand (ElementType s) noexcept { return {CmplxOps::expand (s)}; } /** Creates a new SIMDRegister from the internal SIMD type (for example __mm128 for single-precision floating point on SSE architectures). */ @@ -110,18 +118,18 @@ struct SIMDRegister //============================================================================== /** Returns the idx-th element of the receiver. Note that this does not check if idx is larger than the native register size. */ - inline Type JUCE_VECTOR_CALLTYPE operator[] (size_t idx) const noexcept + inline ElementType JUCE_VECTOR_CALLTYPE operator[] (size_t idx) const noexcept { jassert (idx < SIMDNumElements); - return reinterpret_cast (&value) [idx]; + return reinterpret_cast (&value) [idx]; } /** Returns the idx-th element of the receiver. Note that this does not check if idx is larger than the native register size. */ - inline Type& JUCE_VECTOR_CALLTYPE operator[] (size_t idx) noexcept + inline ElementType& JUCE_VECTOR_CALLTYPE operator[] (size_t idx) noexcept { jassert (idx < SIMDNumElements); - return reinterpret_cast (&value) [idx]; + return reinterpret_cast (&value) [idx]; } //============================================================================== @@ -136,16 +144,16 @@ struct SIMDRegister //============================================================================== /** Broadcasts the scalar to all elements of the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator= (Type s) noexcept { value = CmplxOps::expand (s); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator= (ElementType s) noexcept { value = CmplxOps::expand (s); return *this; } /** Adds a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator+= (Type s) noexcept { value = NativeOps::add (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator+= (ElementType s) noexcept { value = NativeOps::add (value, CmplxOps::expand (s)); return *this; } /** Subtracts a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator-= (Type s) noexcept { value = NativeOps::sub (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator-= (ElementType s) noexcept { value = NativeOps::sub (value, CmplxOps::expand (s)); return *this; } /** Multiplies a scalar to the receiver. */ - inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator*= (Type s) noexcept { value = CmplxOps::mul (value, CmplxOps::expand (s)); return *this; } + inline SIMDRegister& JUCE_VECTOR_CALLTYPE operator*= (ElementType s) noexcept { value = CmplxOps::mul (value, CmplxOps::expand (s)); return *this; } //============================================================================== /** Bit-and the reciver with SIMDRegister v and store the result in the receiver. */ @@ -179,13 +187,13 @@ struct SIMDRegister //============================================================================== /** Returns a vector where each element is the sum of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator+ (Type s) const noexcept { return { NativeOps::add (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator+ (ElementType s) const noexcept { return { NativeOps::add (value, CmplxOps::expand (s)) }; } /** Returns a vector where each element is the difference of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator- (Type s) const noexcept { return { NativeOps::sub (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator- (ElementType s) const noexcept { return { NativeOps::sub (value, CmplxOps::expand (s)) }; } /** Returns a vector where each element is the difference of the corresponding element in the receiver and the scalar s.*/ - inline SIMDRegister JUCE_VECTOR_CALLTYPE operator* (Type s) const noexcept { return { CmplxOps::mul (value, CmplxOps::expand (s)) }; } + inline SIMDRegister JUCE_VECTOR_CALLTYPE operator* (ElementType s) const noexcept { return { CmplxOps::mul (value, CmplxOps::expand (s)) }; } //============================================================================== /** Returns the bit-and of the receiver and v. */ @@ -257,11 +265,11 @@ struct SIMDRegister //============================================================================== /** Returns a scalar which is the sum of all elements of the receiver. */ - inline Type sum() const noexcept { return CmplxOps::sum (value); } + inline ElementType sum() const noexcept { return CmplxOps::sum (value); } //============================================================================== /** Checks if the given pointer is suffeciently aligned for using SIMD operations. */ - static inline bool isSIMDAligned (Type* ptr) noexcept + static inline bool isSIMDAligned (ElementType* ptr) noexcept { uintptr_t bitmask = SIMDRegisterSize - 1; return (reinterpret_cast (ptr) & bitmask) == 0; @@ -272,7 +280,7 @@ struct SIMDRegister If the current position in memory is already aligned then this method will simply return the pointer. */ - static inline Type* getNextSIMDAlignedPtr (Type* ptr) noexcept + static inline ElementType* getNextSIMDAlignedPtr (ElementType* ptr) noexcept { return snapPointerToAlignment (ptr, SIMDRegisterSize); } @@ -386,14 +394,21 @@ struct CmplxSIMDOps > } }; - //============================================================================== -// Extend some common used global functions to SIMDRegister types -} // close namespace dsp +#ifndef DOXYGEN + namespace util + { + template + inline void snapToZero (SIMDRegister&) noexcept {} + } +#endif + +} // namespace dsp +// Extend some common used global functions to SIMDRegister types template inline dsp::SIMDRegister JUCE_VECTOR_CALLTYPE jmin (dsp::SIMDRegister a, dsp::SIMDRegister b) { return dsp::SIMDRegister::min (a, b); } template inline dsp::SIMDRegister JUCE_VECTOR_CALLTYPE jmax (dsp::SIMDRegister a, dsp::SIMDRegister b) { return dsp::SIMDRegister::max (a, b); } -namespace dsp { +} // namespace juce diff --git a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp index 38e0df9724..49bd48eaee 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp +++ b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ namespace SIMDRegister_test_internal { @@ -667,3 +671,6 @@ public: }; static SIMDRegisterUnitTests SIMDRegisterUnitTests; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp index 38e296e51e..f961fcabaa 100644 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.cpp +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template typename FIR::Coefficients::Ptr @@ -616,3 +620,6 @@ typename FilterDesign::IIRPolyphaseAllpassStructure template struct FilterDesign; template struct FilterDesign; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/filter_design/juce_FilterDesign.h b/modules/juce_dsp/filter_design/juce_FilterDesign.h index abc19aff2c..5ab6aa9d36 100644 --- a/modules/juce_dsp/filter_design/juce_FilterDesign.h +++ b/modules/juce_dsp/filter_design/juce_FilterDesign.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class provides a set of functions which generates FIR::Coefficients @@ -257,3 +261,6 @@ private: FloatType stopbandAttenuationdB); FilterDesign() = delete; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Convolution.cpp b/modules/juce_dsp/frequency/juce_Convolution.cpp index ad07352a24..e09dc73df9 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class is the convolution engine itself, processing only one channel at a time of input signal. @@ -54,6 +58,7 @@ struct ConvolutionEngine double sampleRate = 0; bool wantsStereo; + bool wantsTrimming; size_t impulseResponseSize; size_t maximumBufferSize = 0; }; @@ -335,6 +340,7 @@ public: changeSource, changeImpulseResponseSize, changeStereo, + changeTrimming, numChangeRequestTypes }; @@ -588,6 +594,17 @@ public: } break; + case ChangeRequest::changeTrimming: + { + bool newWantsTrimming = requestParameters[n]; + + if (currentInfo.wantsTrimming != newWantsTrimming) + changeLevel = jmax(1, changeLevel); + + currentInfo.wantsTrimming = newWantsTrimming; + } + break; + default: jassertfalse; break; @@ -732,6 +749,7 @@ private: void processImpulseResponse() { + if (currentInfo.sourceType == SourceType::sourceBinaryData) { copyAudioStreamInAudioBuffer (new MemoryInputStream (currentInfo.sourceData, currentInfo.sourceDataSize, false)); @@ -743,7 +761,7 @@ private: else if (currentInfo.sourceType == SourceType::sourceAudioBuffer) { copyBufferFromTemporaryLocation(); - trimAndResampleImpulseResponse (temporaryBuffer.getNumChannels(), currentInfo.bufferSampleRate); + trimAndResampleImpulseResponse (temporaryBuffer.getNumChannels(), currentInfo.bufferSampleRate, currentInfo.wantsTrimming); } if (isThreadRunning() && threadShouldExit()) @@ -751,19 +769,19 @@ private: if (currentInfo.wantsStereo) { - normalizeImpulseResponse (currentInfo.buffer->getWritePointer(0), currentInfo.buffer->getNumSamples()); - normalizeImpulseResponse (currentInfo.buffer->getWritePointer(1), currentInfo.buffer->getNumSamples()); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer(0), currentInfo.buffer->getNumSamples(), 1.0); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer(1), currentInfo.buffer->getNumSamples(), 1.0); } else { - normalizeImpulseResponse (currentInfo.buffer->getWritePointer (0), currentInfo.buffer->getNumSamples()); + normalizeImpulseResponse (currentInfo.buffer->getWritePointer (0), currentInfo.buffer->getNumSamples(), 1.0); } } /** Converts the data from an audio file into a stereo audio buffer of floats, and performs resampling if necessary. */ - void copyAudioStreamInAudioBuffer (InputStream* stream) + double copyAudioStreamInAudioBuffer (InputStream* stream) { AudioFormatManager manager; manager.registerBasicFormats(); @@ -778,54 +796,65 @@ private: impulseResponseOriginal.clear(); formatReader->read (&(impulseResponseOriginal), 0, impulseResponseOriginal.getNumSamples(), 0, true, numChannels > 1); - trimAndResampleImpulseResponse (numChannels, formatReader->sampleRate); + return trimAndResampleImpulseResponse (numChannels, formatReader->sampleRate, currentInfo.wantsTrimming); } + else + return 0.0; } - void trimAndResampleImpulseResponse (int numChannels, double bufferSampleRate) + double trimAndResampleImpulseResponse (int numChannels, double bufferSampleRate, bool mustTrim) { auto thresholdTrim = Decibels::decibelsToGain (-80.0f); - auto indexStart = impulseResponseOriginal.getNumSamples() - 1; - auto indexEnd = 0; + auto indexStart = 0; + auto indexEnd = impulseResponseOriginal.getNumSamples() - 1; - for (auto channel = 0; channel < numChannels; ++channel) + if (mustTrim) { - auto localIndexStart = 0; - auto localIndexEnd = impulseResponseOriginal.getNumSamples() - 1; + indexStart = impulseResponseOriginal.getNumSamples() - 1; + indexEnd = 0; - auto* channelData = impulseResponseOriginal.getReadPointer (channel); + for (auto channel = 0; channel < numChannels; ++channel) + { + auto localIndexStart = 0; + auto localIndexEnd = impulseResponseOriginal.getNumSamples() - 1; - while (localIndexStart < impulseResponseOriginal.getNumSamples() - 1 - && channelData[localIndexStart] <= thresholdTrim - && channelData[localIndexStart] >= -thresholdTrim) - ++localIndexStart; + auto* channelData = impulseResponseOriginal.getReadPointer (channel); - while (localIndexEnd >= 0 - && channelData[localIndexEnd] <= thresholdTrim - && channelData[localIndexEnd] >= -thresholdTrim) - --localIndexEnd; + while (localIndexStart < impulseResponseOriginal.getNumSamples() - 1 + && channelData[localIndexStart] <= thresholdTrim + && channelData[localIndexStart] >= -thresholdTrim) + ++localIndexStart; - indexStart = jmin (indexStart, localIndexStart); - indexEnd = jmax (indexEnd, localIndexEnd); - } + while (localIndexEnd >= 0 + && channelData[localIndexEnd] <= thresholdTrim + && channelData[localIndexEnd] >= -thresholdTrim) + --localIndexEnd; - if (indexStart > 0) - { - for (auto channel = 0; channel < numChannels; ++channel) + indexStart = jmin (indexStart, localIndexStart); + indexEnd = jmax (indexEnd, localIndexEnd); + } + + if (indexStart > 0) { - auto* channelData = impulseResponseOriginal.getWritePointer (channel); + for (auto channel = 0; channel < numChannels; ++channel) + { + auto* channelData = impulseResponseOriginal.getWritePointer (channel); - for (auto i = 0; i < indexEnd - indexStart + 1; ++i) - channelData[i] = channelData[i + indexStart]; + for (auto i = 0; i < indexEnd - indexStart + 1; ++i) + channelData[i] = channelData[i + indexStart]; - for (auto i = indexEnd - indexStart + 1; i < impulseResponseOriginal.getNumSamples() - 1; ++i) - channelData[i] = 0.0f; + for (auto i = indexEnd - indexStart + 1; i < impulseResponseOriginal.getNumSamples() - 1; ++i) + channelData[i] = 0.0f; + } } } + double factorReading; + if (currentInfo.sampleRate == bufferSampleRate) { // No resampling + factorReading = 1.0; auto impulseSize = jmin (static_cast (currentInfo.impulseResponseSize), indexEnd - indexStart + 1); impulseResponse.setSize (2, impulseSize); @@ -837,7 +866,7 @@ private: else { // Resampling - auto factorReading = bufferSampleRate / currentInfo.sampleRate; + factorReading = bufferSampleRate / currentInfo.sampleRate; auto impulseSize = jmin (static_cast (currentInfo.impulseResponseSize), roundDoubleToInt ((indexEnd - indexStart + 1) / factorReading)); impulseResponse.setSize (2, impulseSize); @@ -860,16 +889,18 @@ private: // Filling the second channel with the first if necessary if (numChannels == 1) impulseResponse.copyFrom (1, 0, impulseResponse, 0, 0, impulseResponse.getNumSamples()); + + return factorReading; } - void normalizeImpulseResponse (float* samples, int numSamples) const + void normalizeImpulseResponse (float* samples, int numSamples, double factorResampling) const { auto magnitude = 0.0f; for (int i = 0; i < numSamples; ++i) magnitude += samples[i] * samples[i]; - auto magnitudeInv = 1.0f / (4.0f * std::sqrt (magnitude)); + auto magnitudeInv = 1.0f / (4.0f * std::sqrt (magnitude)) * 0.5f * static_cast (factorResampling); for (int i = 0; i < numSamples; ++i) samples[i] *= magnitudeInv; @@ -965,14 +996,15 @@ Convolution::~Convolution() { } -void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceDataSize, bool wantsStereo, size_t size) +void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceDataSize, bool wantsStereo, bool wantsTrimming, size_t size) { if (sourceData == nullptr) return; Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; @@ -981,19 +1013,21 @@ void Convolution::loadImpulseResponse (const void* sourceData, size_t sourceData juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } -void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wantsStereo, size_t size) +void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wantsStereo, bool wantsTrimming, size_t size) { if (! fileImpulseResponse.existsAsFile()) return; Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; @@ -1002,13 +1036,14 @@ void Convolution::loadImpulseResponse (const File& fileImpulseResponse, bool wan juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer& buffer, - double bufferSampleRate, bool wantsStereo, size_t size) + double bufferSampleRate, bool wantsStereo, bool wantsTrimming, size_t size) { jassert (bufferSampleRate > 0); @@ -1019,7 +1054,8 @@ void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer Pimpl::ChangeRequest types[] = { Pimpl::ChangeRequest::changeSource, Pimpl::ChangeRequest::changeImpulseResponseSize, - Pimpl::ChangeRequest::changeStereo }; + Pimpl::ChangeRequest::changeStereo, + Pimpl::ChangeRequest::changeTrimming }; Array sourceParameter; sourceParameter.add (juce::var ((int) ConvolutionEngine::ProcessingInformation::SourceType::sourceAudioBuffer)); @@ -1027,7 +1063,8 @@ void Convolution::copyAndLoadImpulseResponseFromBuffer (const AudioBuffer juce::var parameters[] = { juce::var (sourceParameter), juce::var (static_cast (size)), - juce::var (wantsStereo) }; + juce::var (wantsStereo), + juce::var (wantsTrimming) }; pimpl->addToFifo (types, parameters, 3); } @@ -1108,3 +1145,6 @@ void Convolution::processSamples (const AudioBlock& input, AudioBlock& buffer, double bufferSampleRate, - bool wantsStereo, size_t size); + bool wantsStereo, bool wantsTrimming, size_t size); private: //============================================================================== @@ -133,3 +140,6 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Convolution) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_FFT.cpp b/modules/juce_dsp/frequency/juce_FFT.cpp index f252a9dd65..a89afb2634 100644 --- a/modules/juce_dsp/frequency/juce_FFT.cpp +++ b/modules/juce_dsp/frequency/juce_FFT.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ struct FFT::Instance { @@ -836,3 +840,6 @@ void FFT::performFrequencyOnlyForwardTransform (float* inputOutputData) const no zeromem (&inputOutputData[size], sizeof (float) * static_cast (size)); } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_FFT.h b/modules/juce_dsp/frequency/juce_FFT.h index 6b0ece8955..7879684d7c 100644 --- a/modules/juce_dsp/frequency/juce_FFT.h +++ b/modules/juce_dsp/frequency/juce_FFT.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Performs a fast fourier transform. @@ -111,3 +115,6 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FFT) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_FFT_test.cpp b/modules/juce_dsp/frequency/juce_FFT_test.cpp index 056560dc97..0bf3b1c156 100644 --- a/modules/juce_dsp/frequency/juce_FFT_test.cpp +++ b/modules/juce_dsp/frequency/juce_FFT_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ struct FFTUnitTest : public UnitTest { @@ -204,3 +208,6 @@ struct FFTUnitTest : public UnitTest }; static FFTUnitTest fftUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Windowing.cpp b/modules/juce_dsp/frequency/juce_Windowing.cpp index bf3fa0531f..0c563d54a4 100644 --- a/modules/juce_dsp/frequency/juce_Windowing.cpp +++ b/modules/juce_dsp/frequency/juce_Windowing.cpp @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template static inline FloatType ncos (size_t order, size_t i, size_t size) noexcept { @@ -184,3 +189,6 @@ const char* WindowingFunction::getWindowingMethodName (WindowingMetho template struct WindowingFunction; template struct WindowingFunction; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/frequency/juce_Windowing.h b/modules/juce_dsp/frequency/juce_Windowing.h index 09aa720867..81c9ea247c 100644 --- a/modules/juce_dsp/frequency/juce_Windowing.h +++ b/modules/juce_dsp/frequency/juce_Windowing.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A class which provides multiple windowing functions useful for filter design @@ -71,3 +75,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowingFunction) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/juce_dsp.cpp b/modules/juce_dsp/juce_dsp.cpp index fd9dea4cc1..1545ee54c5 100644 --- a/modules/juce_dsp/juce_dsp.cpp +++ b/modules/juce_dsp/juce_dsp.cpp @@ -49,42 +49,36 @@ #include #endif -namespace juce -{ - namespace dsp - { - #include "processors/juce_FIRFilter.cpp" - #include "processors/juce_IIRFilter.cpp" - #include "processors/juce_Oversampling.cpp" - #include "maths/juce_SpecialFunctions.cpp" - #include "maths/juce_Matrix.cpp" - #include "maths/juce_LookupTable.cpp" - #include "frequency/juce_FFT.cpp" - #include "frequency/juce_Convolution.cpp" - #include "frequency/juce_Windowing.cpp" - #include "filter_design/juce_FilterDesign.cpp" +#include "processors/juce_FIRFilter.cpp" +#include "processors/juce_IIRFilter.cpp" +#include "processors/juce_Oversampling.cpp" +#include "maths/juce_SpecialFunctions.cpp" +#include "maths/juce_Matrix.cpp" +#include "maths/juce_LookupTable.cpp" +#include "frequency/juce_FFT.cpp" +#include "frequency/juce_Convolution.cpp" +#include "frequency/juce_Windowing.cpp" +#include "filter_design/juce_FilterDesign.cpp" - #if JUCE_USE_SIMD - #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) - #ifdef __AVX2__ - #include "native/juce_avx_SIMDNativeOps.cpp" - #else - #include "native/juce_sse_SIMDNativeOps.cpp" - #endif - #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) - #include "native/juce_neon_SIMDNativeOps.cpp" - #else - #error "SIMD register support not implemented for this platform" - #endif - #endif +#if JUCE_USE_SIMD +#if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) + #ifdef __AVX2__ + #include "native/juce_avx_SIMDNativeOps.cpp" + #else + #include "native/juce_sse_SIMDNativeOps.cpp" + #endif +#elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) + #include "native/juce_neon_SIMDNativeOps.cpp" +#else + #error "SIMD register support not implemented for this platform" +#endif +#endif - #if JUCE_UNIT_TESTS - #include "maths/juce_Matrix_test.cpp" - #if JUCE_USE_SIMD - #include "containers/juce_SIMDRegister_test.cpp" - #endif - #include "frequency/juce_FFT_test.cpp" - #include "processors/juce_FIRFilter_test.cpp" - #endif - } -} +#if JUCE_UNIT_TESTS +#include "maths/juce_Matrix_test.cpp" +#if JUCE_USE_SIMD +#include "containers/juce_SIMDRegister_test.cpp" +#endif +#include "frequency/juce_FFT_test.cpp" +#include "processors/juce_FIRFilter_test.cpp" +#endif diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index 5a2cc076a5..c85da40d8b 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -36,7 +36,7 @@ ID: juce_dsp vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE DSP classes description: Classes for audio buffer manipulation, digital audio processing, filtering, oversampling, fast math functions etc. website: http://www.juce.com/juce @@ -166,57 +166,98 @@ #define JUCE_DSP_USE_STATIC_FFTW 0 #endif +/** Config: JUCE_DSP_ENABLE_SNAP_TO_ZERO + + Enables code in the dsp module to avoid floating point denormals during the + processing of some of the dsp module's filters. + + Enabling this will add a slight performance overhead to the DSP module's + filters and algorithms. If your audio app already disables denormals altogether + (for exmaple, by using the ScopedNoDenormals class or the + FloatVectorOperations::disableDenormalisedNumberSupport method), then you + can safely disable this flag to shave off a few cpu cycles from the DSP module's + filters and algorithms. +*/ +#ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO + #define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 +#endif + + //============================================================================== +#undef Complex // apparently some C libraries actually define these symbols (!) +#undef Factor + namespace juce { namespace dsp { - #undef Complex // apparently some C libraries actually define these symbols (!) - #undef Factor template using Complex = ::std::complex; - #if JUCE_USE_SIMD - #include "native/juce_fallback_SIMDNativeOps.h" - - // include the correct native file for this build target CPU - #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) - #ifdef __AVX2__ - #include "native/juce_avx_SIMDNativeOps.h" + //============================================================================== + namespace util + { + /** Use this function to prevent denormals on intel CPUs. + + This function will work with both primitives and simple containers. + */ + #if JUCE_DSP_ENABLE_SNAP_TO_ZERO + inline void snapToZero (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #ifndef DOXYGEN + inline void snapToZero (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + inline void snapToZero (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } + #endif #else - #include "native/juce_sse_SIMDNativeOps.h" + inline void snapToZero (float& x) noexcept { ignoreUnused (x); } + #ifndef DOXYGEN + inline void snapToZero (double& x) noexcept { ignoreUnused (x); } + inline void snapToZero (long double& x) noexcept { ignoreUnused (x); } + #endif #endif - #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) - #include "native/juce_neon_SIMDNativeOps.h" - #else - #error "SIMD register support not implemented for this platform" - #endif - - #include "containers/juce_SIMDRegister.h" - #endif - - #include "maths/juce_SpecialFunctions.h" - #include "maths/juce_Matrix.h" - #include "maths/juce_Polynomial.h" - #include "maths/juce_FastMathApproximations.h" - #include "maths/juce_LookupTable.h" - #include "containers/juce_AudioBlock.h" - #include "processors/juce_ProcessContext.h" - #include "processors/juce_ProcessorWrapper.h" - #include "processors/juce_ProcessorChain.h" - #include "processors/juce_ProcessorDuplicator.h" - #include "processors/juce_Bias.h" - #include "processors/juce_Gain.h" - #include "processors/juce_WaveShaper.h" - #include "processors/juce_IIRFilter.h" - #include "processors/juce_FIRFilter.h" - #include "processors/juce_Oscillator.h" - #include "processors/juce_StateVariableFilter.h" - #include "processors/juce_Oversampling.h" - #include "frequency/juce_FFT.h" - #include "frequency/juce_Convolution.h" - #include "frequency/juce_Windowing.h" - #include "filter_design/juce_FilterDesign.h" + } } } + +//============================================================================== +#if JUCE_USE_SIMD + #include "native/juce_fallback_SIMDNativeOps.h" + + // include the correct native file for this build target CPU + #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) + #ifdef __AVX2__ + #include "native/juce_avx_SIMDNativeOps.h" + #else + #include "native/juce_sse_SIMDNativeOps.h" + #endif + #elif defined(__arm__) || defined(_M_ARM) || defined (__arm64__) || defined (__aarch64__) + #include "native/juce_neon_SIMDNativeOps.h" + #else + #error "SIMD register support not implemented for this platform" + #endif + + #include "containers/juce_SIMDRegister.h" +#endif + +#include "maths/juce_SpecialFunctions.h" +#include "maths/juce_Matrix.h" +#include "maths/juce_Polynomial.h" +#include "maths/juce_FastMathApproximations.h" +#include "maths/juce_LookupTable.h" +#include "containers/juce_AudioBlock.h" +#include "processors/juce_ProcessContext.h" +#include "processors/juce_ProcessorWrapper.h" +#include "processors/juce_ProcessorChain.h" +#include "processors/juce_ProcessorDuplicator.h" +#include "processors/juce_Bias.h" +#include "processors/juce_Gain.h" +#include "processors/juce_WaveShaper.h" +#include "processors/juce_IIRFilter.h" +#include "processors/juce_FIRFilter.h" +#include "processors/juce_Oscillator.h" +#include "processors/juce_StateVariableFilter.h" +#include "processors/juce_Oversampling.h" +#include "frequency/juce_FFT.h" +#include "frequency/juce_Convolution.h" +#include "frequency/juce_Windowing.h" +#include "filter_design/juce_FilterDesign.h" diff --git a/modules/juce_dsp/maths/juce_FastMathApproximations.h b/modules/juce_dsp/maths/juce_FastMathApproximations.h index 0b59afea8c..3be0473c23 100644 --- a/modules/juce_dsp/maths/juce_FastMathApproximations.h +++ b/modules/juce_dsp/maths/juce_FastMathApproximations.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This class contains various fast mathematical function approximations. @@ -254,3 +258,6 @@ struct FastMathApproximations values[i] = FastMathApproximations::logNPlusOne (values[i]); } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_LookupTable.cpp b/modules/juce_dsp/maths/juce_LookupTable.cpp index 8d0a6e0bf7..21fe2563bb 100644 --- a/modules/juce_dsp/maths/juce_LookupTable.cpp +++ b/modules/juce_dsp/maths/juce_LookupTable.cpp @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template LookupTable::LookupTable() { @@ -147,3 +152,6 @@ template class LookupTable; template class LookupTableTransform; template class LookupTableTransform; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_LookupTable.h b/modules/juce_dsp/maths/juce_LookupTable.h index f6dba351db..a4d4061f69 100644 --- a/modules/juce_dsp/maths/juce_LookupTable.h +++ b/modules/juce_dsp/maths/juce_LookupTable.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Class for efficiently approximating expensive arithmetic operations. @@ -319,3 +323,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookupTableTransform) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix.cpp b/modules/juce_dsp/maths/juce_Matrix.cpp index 19fa3a57a2..d91859ad09 100644 --- a/modules/juce_dsp/maths/juce_Matrix.cpp +++ b/modules/juce_dsp/maths/juce_Matrix.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template Matrix Matrix::identity (size_t size) @@ -309,3 +313,6 @@ String Matrix::toString() const template class Matrix; template class Matrix; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix.h b/modules/juce_dsp/maths/juce_Matrix.h index 756b573970..1d49594741 100644 --- a/modules/juce_dsp/maths/juce_Matrix.h +++ b/modules/juce_dsp/maths/juce_Matrix.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + /** General matrix and vectors class, meant for classic math manipulation such as additions, multiplications, and linear systems of equations solving. @@ -243,3 +248,6 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (Matrix) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Matrix_test.cpp b/modules/juce_dsp/maths/juce_Matrix_test.cpp index e81bfa4d7f..e9f3357f63 100644 --- a/modules/juce_dsp/maths/juce_Matrix_test.cpp +++ b/modules/juce_dsp/maths/juce_Matrix_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ struct LinearAlgebraUnitTest : public UnitTest { @@ -163,3 +167,6 @@ struct LinearAlgebraUnitTest : public UnitTest }; static LinearAlgebraUnitTest linearAlgebraUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_Polynomial.h b/modules/juce_dsp/maths/juce_Polynomial.h index 6a4d0e2c2a..4099436615 100644 --- a/modules/juce_dsp/maths/juce_Polynomial.h +++ b/modules/juce_dsp/maths/juce_Polynomial.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A class representing a polynomial @@ -160,3 +164,6 @@ private: JUCE_LEAK_DETECTOR (Polynomial) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_SpecialFunctions.cpp b/modules/juce_dsp/maths/juce_SpecialFunctions.cpp index 6874ef020a..55da31118b 100644 --- a/modules/juce_dsp/maths/juce_SpecialFunctions.cpp +++ b/modules/juce_dsp/maths/juce_SpecialFunctions.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ double SpecialFunctions::besselI0 (double x) noexcept { @@ -133,3 +137,6 @@ Complex SpecialFunctions::asne (Complex w, double k) noexcept return 2.0 / double_Pi * std::asin (last); } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/maths/juce_SpecialFunctions.h b/modules/juce_dsp/maths/juce_SpecialFunctions.h index 834416d969..275aac21e5 100644 --- a/modules/juce_dsp/maths/juce_SpecialFunctions.h +++ b/modules/juce_dsp/maths/juce_SpecialFunctions.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Contains miscellaneous filter design and windowing functions. @@ -57,3 +61,6 @@ struct SpecialFunctions */ static Complex asne (Complex w, double k) noexcept; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp index 3780fd5375..25d47499d0 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.cpp @@ -24,31 +24,36 @@ ============================================================================== */ +namespace juce +{ + namespace dsp + { + DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; -DEFINE_AVX_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_AVX_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; + DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; -DEFINE_AVX_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast (0x8000000000000000), 0, static_cast (0x8000000000000000), 0 }; -DEFINE_AVX_SIMD_CONST (double, double, kOne) = { 1.0, 1.0, 1.0, 1.0 }; + DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_AVX_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; -DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_AVX_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_AVX_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; -DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_AVX_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; -DEFINE_AVX_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1LL, -1LL, -1LL, -1LL }; - -DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; -DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL, 0xffffffffffffffffULL }; + DEFINE_AVX_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL, 0x8000000000000000ULL }; + } +} diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h index cdeda72596..c5894209f7 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ #ifndef DOXYGEN @@ -198,7 +202,7 @@ struct SIMDNativeOps const int8_t* lo_ptr = reinterpret_cast (&lo); const int8_t* hi_ptr = reinterpret_cast (&hi); - return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]; + return (int8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b) @@ -257,7 +261,7 @@ struct SIMDNativeOps const uint8_t* lo_ptr = reinterpret_cast (&lo); const uint8_t* hi_ptr = reinterpret_cast (&hi); - return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]; + return (uint8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b) @@ -308,7 +312,7 @@ struct SIMDNativeOps tmp = _mm256_hadd_epi16 (tmp, tmp); tmp = _mm256_hadd_epi16 (tmp, tmp); int16_t* ptr = reinterpret_cast (&tmp); - return ptr[0] + ptr[8]; + return (int16_t) (ptr[0] + ptr[8]); } }; @@ -351,7 +355,7 @@ struct SIMDNativeOps tmp = _mm256_hadd_epi16 (tmp, tmp); tmp = _mm256_hadd_epi16 (tmp, tmp); uint16_t* ptr = reinterpret_cast (&tmp); - return ptr[0] + ptr[8]; + return (uint16_t) (ptr[0] + ptr[8]); } }; @@ -558,3 +562,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h index 78c11ddf61..4701beb981 100644 --- a/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_fallback_SIMDNativeOps.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** A template specialisation to find corresponding mask type for primitives. */ namespace SIMDInternal @@ -211,3 +215,6 @@ struct SIMDFallbackOps return retval; } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp index d52f7505bd..8193545391 100644 --- a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.cpp @@ -24,16 +24,21 @@ ============================================================================== */ - -DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; - -DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; -DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; +namespace juce +{ + namespace dsp + { + DEFINE_NEON_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_NEON_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + + DEFINE_NEON_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_NEON_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_NEON_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_NEON_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; + DEFINE_NEON_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; + } +} diff --git a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h index de8bc9d602..55a23e107b 100644 --- a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN #ifdef _MSC_VER @@ -384,3 +389,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp index c3af98e6e0..e12923121e 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.cpp @@ -24,31 +24,36 @@ ============================================================================== */ +namespace juce +{ + namespace dsp + { + DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; + DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; -DEFINE_SSE_SIMD_CONST (int32_t, float, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int32_t, float, kEvenHighBit) = { static_cast(0x80000000), 0, static_cast(0x80000000), 0 }; -DEFINE_SSE_SIMD_CONST (float, float, kOne) = { 1.0f, 1.0f, 1.0f, 1.0f }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; + DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast(0x8000000000000000), 0 }; + DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; -DEFINE_SSE_SIMD_CONST (int64_t, double, kAllBitsSet) = { -1LL, -1LL }; -DEFINE_SSE_SIMD_CONST (int64_t, double, kEvenHighBit) = { static_cast(0x8000000000000000), 0 }; -DEFINE_SSE_SIMD_CONST (double, double, kOne) = { 1.0, 1.0 }; + DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int8_t, int8_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kAllBitsSet) = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -DEFINE_SSE_SIMD_CONST (uint8_t, uint8_t, kHighBit) = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int16_t, int16_t, kAllBitsSet) = { -1, -1, -1, -1, -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; + DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; -DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kAllBitsSet) = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -DEFINE_SSE_SIMD_CONST (uint16_t, uint16_t, kHighBit) = { 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000 }; + DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; -DEFINE_SSE_SIMD_CONST (int32_t, int32_t, kAllBitsSet) = { -1, -1, -1, -1 }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; -DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kAllBitsSet) = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; -DEFINE_SSE_SIMD_CONST (uint32_t, uint32_t, kHighBit) = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; -DEFINE_SSE_SIMD_CONST (int64_t, int64_t, kAllBitsSet) = { -1, -1 }; - -DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; -DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kAllBitsSet) = { 0xffffffffffffffff, 0xffffffffffffffff }; + DEFINE_SSE_SIMD_CONST (uint64_t, uint64_t, kHighBit) = { 0x8000000000000000, 0x8000000000000000 }; + } +} diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h index 847403334e..3b2c741fbd 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + #ifndef DOXYGEN #ifdef _MSC_VER @@ -738,3 +743,6 @@ struct SIMDNativeOps }; #endif + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Bias.h b/modules/juce_dsp/processors/juce_Bias.h index 7913965126..1937af9573 100644 --- a/modules/juce_dsp/processors/juce_Bias.h +++ b/modules/juce_dsp/processors/juce_Bias.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Adds a DC offset (voltage bias) to the audio samples. @@ -137,3 +141,6 @@ private: bias.reset (sampleRate, rampDurationSeconds); } }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter.cpp b/modules/juce_dsp/processors/juce_FIRFilter.cpp index c0008b2bbe..abcf5d27a9 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter.cpp +++ b/modules/juce_dsp/processors/juce_FIRFilter.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template double FIR::Coefficients::Coefficients::getMagnitudeForFrequency (double frequency, double theSampleRate) const noexcept @@ -153,3 +157,6 @@ void FIR::Coefficients::Coefficients::normalise() noexcept //============================================================================== template struct FIR::Coefficients; template struct FIR::Coefficients; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter.h b/modules/juce_dsp/processors/juce_FIRFilter.h index 902ff437df..08912dbfb1 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter.h +++ b/modules/juce_dsp/processors/juce_FIRFilter.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Classes for FIR filter processing. @@ -274,3 +278,6 @@ namespace FIR Array coefficients; }; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_FIRFilter_test.cpp b/modules/juce_dsp/processors/juce_FIRFilter_test.cpp index b1fc1ddfc9..437611ceac 100644 --- a/modules/juce_dsp/processors/juce_FIRFilter_test.cpp +++ b/modules/juce_dsp/processors/juce_FIRFilter_test.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ class FIRFilterTest : public UnitTest { @@ -201,3 +205,6 @@ public: }; static FIRFilterTest firFilterUnitTest; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Gain.h b/modules/juce_dsp/processors/juce_Gain.h index cfa2b1dcf8..e8e206f333 100644 --- a/modules/juce_dsp/processors/juce_Gain.h +++ b/modules/juce_dsp/processors/juce_Gain.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Applies a gain to audio samples as single samples or AudioBlocks. @@ -126,3 +130,6 @@ private: LinearSmoothedValue gain; double sampleRate = 0, rampDurationSeconds = 0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_IIRFilter.cpp b/modules/juce_dsp/processors/juce_IIRFilter.cpp index beb7664e68..1c9229cbbb 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.cpp +++ b/modules/juce_dsp/processors/juce_IIRFilter.cpp @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ template IIR::Coefficients::Coefficients() @@ -327,6 +331,7 @@ typename IIR::Coefficients::Ptr IIR::Coefficients::mak jassert (sampleRate > 0); jassert (frequency > 0 && frequency <= static_cast (sampleRate * 0.5)); jassert (Q > 0); + jassert (gainFactor > 0); auto A = jmax (static_cast (0.0), std::sqrt (gainFactor)); auto omega = (2 * MathConstants::pi * jmax (frequency, static_cast (2.0))) / static_cast (sampleRate); @@ -447,6 +452,8 @@ template void IIR::Coefficients::getPhaseForFrequencyArray (double* frequencies, double* phases, size_t numSamples, double sampleRate) const noexcept { + jassert (sampleRate > 0); + constexpr Complex j (0, 1); const auto order = getFilterOrder(); const auto* coefs = coefficients.begin(); @@ -482,3 +489,6 @@ void IIR::Coefficients::getPhaseForFrequencyArray (double* frequenc template struct IIR::Coefficients; template struct IIR::Coefficients; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_IIRFilter.h b/modules/juce_dsp/processors/juce_IIRFilter.h index 2c5e5980fd..056f8210cb 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter.h +++ b/modules/juce_dsp/processors/juce_IIRFilter.h @@ -24,10 +24,13 @@ ============================================================================== */ - /** Classes for IIR filter processing. */ +namespace juce +{ +namespace dsp +{ namespace IIR { template @@ -111,9 +114,14 @@ namespace IIR */ SampleType JUCE_VECTOR_CALLTYPE processSample (SampleType sample) noexcept; + /** Ensure that the state variables are rounded to zero if the state + variables are denormals. This is only needed if you are doing + sample by sample processing. + */ + void snapToZero() noexcept; + private: //============================================================================== - void snapToZero() noexcept; void check(); //============================================================================== @@ -276,5 +284,8 @@ namespace IIR static constexpr NumericType inverseRootTwo = static_cast (0.70710678118654752440L); }; - #include "juce_IIRFilter_Impl.h" -} +} // namespace IIR +} // namespace dsp +} // namespace juce + +#include "juce_IIRFilter_Impl.h" diff --git a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h index cb31cbdf13..5ef75be08c 100644 --- a/modules/juce_dsp/processors/juce_IIRFilter_Impl.h +++ b/modules/juce_dsp/processors/juce_IIRFilter_Impl.h @@ -24,26 +24,14 @@ ============================================================================== */ -#ifndef DOXYGEN - -template -struct SnapToZeroHelper +namespace juce +{ +namespace dsp +{ +namespace IIR { - static void snap (Type& x) noexcept - { - for (size_t i = 0; i < Type::size(); ++i) - JUCE_SNAP_TO_ZERO (x[i]); - } -}; - -template <> struct SnapToZeroHelper { static void snap (float& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; -template <> struct SnapToZeroHelper { static void snap (double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; -template <> struct SnapToZeroHelper { static void snap (long double& x) noexcept { JUCE_SNAP_TO_ZERO (x); } }; -#if JUCE_USE_SIMD -template -struct SnapToZeroHelper> { static void snap (SIMDRegister&) noexcept {} }; -#endif +#ifndef DOXYGEN //============================================================================== template @@ -120,7 +108,7 @@ void Filter::process (const ProcessContext& context) noexcept lv1 = (in * b1) - (out * a1); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; + util::snapToZero (lv1); state[0] = lv1; } break; @@ -145,8 +133,8 @@ void Filter::process (const ProcessContext& context) noexcept lv2 = (in * b2) - (out * a2); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; - SnapToZeroHelper::snap (lv2); state[1] = lv2; + util::snapToZero (lv1); state[0] = lv1; + util::snapToZero (lv2); state[1] = lv2; } break; @@ -175,9 +163,9 @@ void Filter::process (const ProcessContext& context) noexcept lv3 = (in * b3) - (out * a3); } - SnapToZeroHelper::snap (lv1); state[0] = lv1; - SnapToZeroHelper::snap (lv2); state[1] = lv2; - SnapToZeroHelper::snap (lv3); state[2] = lv3; + util::snapToZero (lv1); state[0] = lv1; + util::snapToZero (lv2); state[1] = lv2; + util::snapToZero (lv3); state[2] = lv3; } break; @@ -220,7 +208,7 @@ template void Filter::snapToZero() noexcept { for (size_t i = 0; i < order; ++i) - SnapToZeroHelper::snap (state[i]); + util::snapToZero (state[i]); } template @@ -233,3 +221,7 @@ void Filter::check() } #endif + +} // namespace IIR +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oscillator.h b/modules/juce_dsp/processors/juce_Oscillator.h index 9230658951..03f64f4ba8 100644 --- a/modules/juce_dsp/processors/juce_Oscillator.h +++ b/modules/juce_dsp/processors/juce_Oscillator.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Generates a signal based on a user-supplied function. @@ -153,3 +157,6 @@ private: LinearSmoothedValue frequency {static_cast (440.0)}; NumericType sampleRate = 48000.0, pos = 0.0; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oversampling.cpp b/modules/juce_dsp/processors/juce_Oversampling.cpp index 5748ec272d..2ce6ea6cb9 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.cpp +++ b/modules/juce_dsp/processors/juce_Oversampling.cpp @@ -24,8 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ -//=============================================================================== /** Abstract class for the provided oversampling engines used internally in the Oversampling class. */ @@ -34,7 +37,12 @@ class OversamplingEngine { public: //=============================================================================== - OversamplingEngine (size_t newFactor) { factor = newFactor; } + OversamplingEngine (size_t newNumChannels, size_t newFactor) + { + numChannels = newNumChannels; + factor = newFactor; + } + virtual ~OversamplingEngine() {} //=============================================================================== @@ -43,7 +51,7 @@ public: virtual void initProcessing (size_t maximumNumberOfSamplesBeforeOversampling) { - buffer.setSize (1, static_cast (maximumNumberOfSamplesBeforeOversampling * factor)); + buffer.setSize (static_cast (numChannels), static_cast (maximumNumberOfSamplesBeforeOversampling * factor), false, false, true); } virtual void reset() @@ -51,16 +59,19 @@ public: buffer.clear(); } - SampleType* getProcessedSamples() { return buffer.getWritePointer (0); } - size_t getNumProcessedSamples() { return static_cast (buffer.getNumSamples()); } + dsp::AudioBlock getProcessedSamples (size_t numSamples) + { + return dsp::AudioBlock (buffer).getSubBlock (0, numSamples); + } - virtual void processSamplesUp (SampleType *samples, size_t numSamples) = 0; - virtual void processSamplesDown (SampleType *samples, size_t numSamples) = 0; + virtual void processSamplesUp (dsp::AudioBlock &inputBlock) = 0; + virtual void processSamplesDown (dsp::AudioBlock &outputBlock) = 0; protected: //=============================================================================== AudioBuffer buffer; size_t factor; + size_t numChannels; }; @@ -73,7 +84,7 @@ class OversamplingDummy : public OversamplingEngine { public: //=============================================================================== - OversamplingDummy() : OversamplingEngine(1) {} + OversamplingDummy (size_t numChannels) : OversamplingEngine (numChannels, 1) {} ~OversamplingDummy() {} //=============================================================================== @@ -82,20 +93,22 @@ public: return 0.f; } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { - auto bufferSamples = this->buffer.getWritePointer (0); + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); - for (size_t i = 0; i < numSamples; i++) - bufferSamples[i] = samples[i]; + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) + OversamplingEngine::buffer.copyFrom (static_cast (channel), 0, + inputBlock.getChannelPointer (channel), static_cast (inputBlock.getNumSamples())); } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); - for (size_t i = 0; i < numSamples; i++) - samples[i] = bufferSamples[i]; + outputBlock.copy (OversamplingEngine::getProcessedSamples (outputBlock.getNumSamples())); } private: @@ -104,8 +117,7 @@ private: }; //=============================================================================== -/** - Oversampling engine class performing 2 times oversampling using the Filter +/** Oversampling engine class performing 2 times oversampling using the Filter Design FIR Equiripple method. The resulting filter is linear phase, symmetric, and has every two samples but the middle one equal to zero, leading to specific processing optimizations. @@ -115,21 +127,26 @@ class Oversampling2TimesEquirippleFIR : public OversamplingEngine { public: //=============================================================================== - Oversampling2TimesEquirippleFIR (SampleType normalizedTransitionWidthUp, + Oversampling2TimesEquirippleFIR (size_t numChannels, + SampleType normalizedTransitionWidthUp, SampleType stopbandAttenuationdBUp, SampleType normalizedTransitionWidthDown, - SampleType stopbandAttenuationdBDown) : OversamplingEngine (2) + SampleType stopbandAttenuationdBDown) : OversamplingEngine (numChannels, 2) { coefficientsUp = *dsp::FilterDesign::designFIRLowpassHalfBandEquirippleMethod (normalizedTransitionWidthUp, stopbandAttenuationdBUp); coefficientsDown = *dsp::FilterDesign::designFIRLowpassHalfBandEquirippleMethod (normalizedTransitionWidthDown, stopbandAttenuationdBDown); - auto N = coefficientsDown.getFilterOrder() + 1; + auto N = coefficientsUp.getFilterOrder() + 1; + stateUp.setSize (static_cast (numChannels), static_cast (N)); + + N = coefficientsDown.getFilterOrder() + 1; auto Ndiv2 = N / 2; auto Ndiv4 = Ndiv2 / 2; - stateUp.setSize (1, static_cast (coefficientsUp.getFilterOrder() + 1)); - stateDown.setSize (1, static_cast (N)); - stateDown2.setSize (1, static_cast (Ndiv4)); + stateDown.setSize (static_cast (numChannels), static_cast (N)); + stateDown2.setSize (static_cast (numChannels), static_cast (Ndiv4 + 1)); + + position.resize (static_cast (numChannels)); } ~Oversampling2TimesEquirippleFIR() {} @@ -137,7 +154,7 @@ public: //=============================================================================== SampleType getLatencyInSamples() override { - return static_cast (coefficientsUp.getFilterOrder() + coefficientsDown.getFilterOrder()); + return static_cast (coefficientsUp.getFilterOrder() + coefficientsDown.getFilterOrder()) * 0.5f; } void reset() override @@ -148,83 +165,103 @@ public: stateDown.clear(); stateDown2.clear(); - position = 0; + position.fill (0); } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto fir = coefficientsUp.getRawCoefficients(); - auto buf = stateUp.getWritePointer (0); - auto N = coefficientsUp.getFilterOrder() + 1; auto Ndiv2 = N / 2; + auto numSamples = inputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) { - // Input - buf[N - 1] = 2 * samples[i]; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto buf = stateUp.getWritePointer (static_cast (channel)); + auto samples = inputBlock.getChannelPointer (channel); + + for (size_t i = 0; i < numSamples; i++) + { + // Input + buf[N - 1] = 2 * samples[i]; - // Convolution - auto out = static_cast (0.0); - for (size_t k = 0; k < Ndiv2; k += 2) - out += (buf[k] + buf[N - k - 1]) * fir[k]; + // Convolution + auto out = static_cast (0.0); + for (size_t k = 0; k < Ndiv2; k += 2) + out += (buf[k] + buf[N - k - 1]) * fir[k]; - // Outputs - bufferSamples[i << 1] = out; - bufferSamples[(i << 1) + 1] = buf[Ndiv2 + 1] * fir[Ndiv2]; + // Outputs + bufferSamples[i << 1] = out; + bufferSamples[(i << 1) + 1] = buf[Ndiv2 + 1] * fir[Ndiv2]; - // Shift data - for (size_t k = 0; k < N - 2; k+=2) - buf[k] = buf[k + 2]; + // Shift data + for (size_t k = 0; k < N - 2; k += 2) + buf[k] = buf[k + 2]; + } } } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto fir = coefficientsDown.getRawCoefficients(); - auto buf = stateDown.getWritePointer (0); - auto buf2 = stateDown2.getWritePointer (0); - auto N = coefficientsDown.getFilterOrder() + 1; auto Ndiv2 = N / 2; auto Ndiv4 = Ndiv2 / 2; + auto numSamples = outputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < outputBlock.getNumChannels(); channel++) { - // Input - buf[N - 1] = bufferSamples[2 * i]; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto buf = stateDown.getWritePointer (static_cast (channel)); + auto buf2 = stateDown2.getWritePointer (static_cast (channel)); + auto samples = outputBlock.getChannelPointer (channel); + auto pos = position.getUnchecked (static_cast (channel)); + + for (size_t i = 0; i < numSamples; i++) + { + // Input + buf[N - 1] = bufferSamples[i << 1]; - // Convolution - auto out = static_cast (0.0); - for (size_t k = 0; k < Ndiv2; k += 2) - out += (buf[k] + buf[N - k - 1]) * fir[k]; + // Convolution + auto out = static_cast (0.0); + for (size_t k = 0; k < Ndiv2; k += 2) + out += (buf[k] + buf[N - k - 1]) * fir[k]; - // Output - out += buf2[position] * fir[Ndiv2]; - buf2[position] = bufferSamples[2 * i + 1]; + // Output + out += buf2[pos] * fir[Ndiv2]; + buf2[pos] = bufferSamples[(i << 1) + 1]; - samples[i] = out; + samples[i] = out; - // Shift data - for (size_t k = 0; k < N - 2; k++) - buf[k] = buf[k + 2]; + // Shift data + for (size_t k = 0; k < N - 2; k++) + buf[k] = buf[k + 2]; - // Circular buffer - position = (position == 0 ? Ndiv4 - 1 : position - 1); + // Circular buffer + pos = (pos == 0 ? Ndiv4 : pos - 1); + } + + position.setUnchecked (static_cast (channel), pos); } + } private: //=============================================================================== dsp::FIR::Coefficients coefficientsUp, coefficientsDown; AudioBuffer stateUp, stateDown, stateDown2; - size_t position; + Array position; //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling2TimesEquirippleFIR) @@ -241,10 +278,11 @@ class Oversampling2TimesPolyphaseIIR : public OversamplingEngine { public: //=============================================================================== - Oversampling2TimesPolyphaseIIR (SampleType normalizedTransitionWidthUp, + Oversampling2TimesPolyphaseIIR (size_t numChannels, + SampleType normalizedTransitionWidthUp, SampleType stopbandAttenuationdBUp, SampleType normalizedTransitionWidthDown, - SampleType stopbandAttenuationdBDown) : OversamplingEngine (2) + SampleType stopbandAttenuationdBDown) : OversamplingEngine (2, numChannels) { auto structureUp = dsp::FilterDesign::designIIRLowpassHalfBandPolyphaseAllpassMethod (normalizedTransitionWidthUp, stopbandAttenuationdBUp); dsp::IIR::Coefficients coeffsUp = getCoefficients (structureUp); @@ -266,8 +304,9 @@ public: for (auto i = 1; i < structureDown.delayedPath.size(); i++) coefficientsDown.add (structureDown.delayedPath[i].coefficients[0]); - v1Up.resize (coefficientsUp.size()); - v1Down.resize (coefficientsDown.size()); + v1Up.setSize (static_cast (numChannels), coefficientsUp.size()); + v1Down.setSize (static_cast (numChannels), coefficientsDown.size()); + delayDown.resize (static_cast (numChannels)); } ~Oversampling2TimesPolyphaseIIR() {} @@ -282,95 +321,113 @@ public: { OversamplingEngine::reset(); - v1Up.fill (0); - v1Down.fill (0); - delayDown = 0; + v1Up.clear(); + v1Down.clear(); + delayDown.fill (0); } - void processSamplesUp (SampleType *samples, size_t numSamples) override + void processSamplesUp (dsp::AudioBlock &inputBlock) override { + jassert (inputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (inputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto coeffs = coefficientsUp.getRawDataPointer(); - auto lv1 = v1Up.getRawDataPointer(); - auto numStages = coefficientsUp.size(); auto delayedStages = numStages / 2; auto directStages = numStages - delayedStages; + auto numSamples = inputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < inputBlock.getNumChannels(); channel++) { - // Direct path cascaded allpass filters - auto input = samples[i]; - for (auto n = 0; n < directStages; n++) - { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; - } - - // Output - bufferSamples[i << 1] = input; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto lv1 = v1Up.getWritePointer (static_cast (channel)); + auto samples = inputBlock.getChannelPointer (channel); - // Delayed path cascaded allpass filters - input = samples[i]; - for (auto n = directStages; n < numStages; n++) + for (size_t i = 0; i < numSamples; i++) { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; + // Direct path cascaded allpass filters + auto input = samples[i]; + for (auto n = 0; n < directStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + bufferSamples[i << 1] = input; + + // Delayed path cascaded allpass filters + input = samples[i]; + for (auto n = directStages; n < numStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + bufferSamples[(i << 1) + 1] = input; } - - // Output - bufferSamples[(i << 1) + 1] = input; } // Snap To Zero snapToZero (true); - } - void processSamplesDown (SampleType *samples, size_t numSamples) override + void processSamplesDown (dsp::AudioBlock &outputBlock) override { + jassert (outputBlock.getNumChannels() <= static_cast (OversamplingEngine::buffer.getNumChannels())); + jassert (outputBlock.getNumSamples() * OversamplingEngine::factor <= static_cast (OversamplingEngine::buffer.getNumSamples())); + // Initialization - auto bufferSamples = OversamplingEngine::buffer.getWritePointer (0); auto coeffs = coefficientsDown.getRawDataPointer(); - auto lv1 = v1Down.getRawDataPointer(); - auto numStages = coefficientsDown.size(); auto delayedStages = numStages / 2; auto directStages = numStages - delayedStages; + auto numSamples = outputBlock.getNumSamples(); // Processing - for (size_t i = 0; i < numSamples; i++) + for (size_t channel = 0; channel < outputBlock.getNumChannels(); channel++) { - // Direct path cascaded allpass filters - auto input = bufferSamples[i << 1]; - for (auto n = 0; n < directStages; n++) - { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; - } - auto directOut = input; + auto bufferSamples = OversamplingEngine::buffer.getWritePointer (static_cast (channel)); + auto lv1 = v1Down.getWritePointer (static_cast (channel)); + auto samples = outputBlock.getChannelPointer (channel); + auto delay = delayDown.getUnchecked (static_cast (channel)); - // Delayed path cascaded allpass filters - input = bufferSamples[(i << 1) + 1]; - for (auto n = directStages; n < numStages; n++) + for (size_t i = 0; i < numSamples; i++) { - auto alpha = coeffs[n]; - auto output = alpha * input + lv1[n]; - lv1[n] = input - alpha * output; - input = output; + // Direct path cascaded allpass filters + auto input = bufferSamples[i << 1]; + for (auto n = 0; n < directStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + auto directOut = input; + + // Delayed path cascaded allpass filters + input = bufferSamples[(i << 1) + 1]; + for (auto n = directStages; n < numStages; n++) + { + auto alpha = coeffs[n]; + auto output = alpha * input + lv1[n]; + lv1[n] = input - alpha * output; + input = output; + } + + // Output + samples[i] = (delay + directOut) * static_cast (0.5); + delay = input; } - // Output - samples[i] = (delayDown + directOut) * static_cast (0.5); - delayDown = input; + delayDown.setUnchecked (static_cast (channel), delay); } // Snap To Zero @@ -381,19 +438,25 @@ public: { if (snapUpProcessing) { - auto lv1 = v1Up.getRawDataPointer(); - auto numStages = coefficientsUp.size(); + for (auto channel = 0; channel < OversamplingEngine::buffer.getNumChannels(); channel++) + { + auto lv1 = v1Up.getWritePointer (channel); + auto numStages = coefficientsUp.size(); - for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + for (auto n = 0; n < numStages; n++) + util::snapToZero (lv1[n]); + } } else { - auto lv1 = v1Down.getRawDataPointer(); - auto numStages = coefficientsDown.size(); + for (auto channel = 0; channel < OversamplingEngine::buffer.getNumChannels(); channel++) + { + auto lv1 = v1Down.getWritePointer (channel); + auto numStages = coefficientsDown.size(); - for (auto n = 0; n < numStages; n++) - JUCE_SNAP_TO_ZERO (lv1[n]); + for (auto n = 0; n < numStages; n++) + util::snapToZero (lv1[n]); + } } } @@ -478,8 +541,8 @@ private: Array coefficientsUp, coefficientsDown; SampleType latency; - Array v1Up, v1Down; - SampleType delayDown; + AudioBuffer v1Up, v1Down; + Array delayDown; //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling2TimesPolyphaseIIR) @@ -492,43 +555,53 @@ Oversampling::Oversampling (size_t newNumChannels, size_t newFactor, { jassert (newFactor >= 0 && newFactor <= 4 && newNumChannels > 0); - factorOversampling = (size_t) 1 << newFactor; + factorOversampling = static_cast (1) << newFactor; isMaximumQuality = newMaxQuality; type = newType; numChannels = newNumChannels; if (newFactor == 0) { - for (size_t channel = 0; channel < numChannels; channel++) - engines.add (new OversamplingDummy()); - numStages = 1; + engines.add (new OversamplingDummy (numChannels)); } else if (type == FilterType::filterHalfBandPolyphaseIIR) { numStages = newFactor; - for (size_t channel = 0; channel < numChannels; channel++) - for (size_t n = 0; n < numStages; n++) - { - auto tw1 = (isMaximumQuality ? 0.10f : 0.12f); - auto tw2 = (isMaximumQuality ? 0.12f : 0.15f); + for (size_t n = 0; n < numStages; n++) + { + auto twUp = (isMaximumQuality ? 0.10f : 0.12f) * (n == 0 ? 0.5f : 1.f); + auto twDown = (isMaximumQuality ? 0.12f : 0.15f) * (n == 0 ? 0.5f : 1.f); - engines.add (new Oversampling2TimesPolyphaseIIR (tw1, -75.f + 10.f * n, tw2, -70.f + 10.f * n)); - } + auto gaindBStartUp = (isMaximumQuality ? -75.f : -65.f); + auto gaindBStartDown = (isMaximumQuality ? -70.f : -60.f); + auto gaindBFactorUp = (isMaximumQuality ? 10.f : 8.f); + auto gaindBFactorDown = (isMaximumQuality ? 10.f : 8.f); + + engines.add (new Oversampling2TimesPolyphaseIIR (numChannels, + twUp, gaindBStartUp + gaindBFactorUp * n, + twDown, gaindBStartDown + gaindBFactorDown * n)); + } } else if (type == FilterType::filterHalfBandFIREquiripple) { numStages = newFactor; - for (size_t channel = 0; channel < numChannels; channel++) - for (size_t n = 0; n < numStages; n++) - { - auto tw1 = (isMaximumQuality ? 0.10f : 0.12f); - auto tw2 = (isMaximumQuality ? 0.12f : 0.15f); + for (size_t n = 0; n < numStages; n++) + { + auto twUp = (isMaximumQuality ? 0.10f : 0.12f) * (n == 0 ? 0.5f : 1.f); + auto twDown = (isMaximumQuality ? 0.12f : 0.15f) * (n == 0 ? 0.5f : 1.f); - engines.add (new Oversampling2TimesEquirippleFIR (tw1, -90.f + 10.f * n, tw2, -70.f + 10.f * n)); - } + auto gaindBStartUp = (isMaximumQuality ? -90.f : -70.f); + auto gaindBStartDown = (isMaximumQuality ? -70.f : -60.f); + auto gaindBFactorUp = (isMaximumQuality ? 10.f : 8.f); + auto gaindBFactorDown = (isMaximumQuality ? 10.f : 8.f); + + engines.add (new Oversampling2TimesEquirippleFIR (numChannels, + twUp, gaindBStartUp + gaindBFactorUp * n, + twDown, gaindBStartDown + gaindBFactorDown * n)); + } } } @@ -550,7 +623,7 @@ SampleType Oversampling::getLatencyInSamples() noexcept auto& engine = *engines[static_cast (n)]; order *= engine.getFactor(); - latency += engine.getLatencyInSamples() / std::pow (static_cast (2), static_cast (order)); + latency += engine.getLatencyInSamples() / static_cast (order); } return latency; @@ -568,18 +641,14 @@ void Oversampling::initProcessing (size_t maximumNumberOfSamplesBefo { jassert (engines.size() > 0); - for (size_t channel = 0; channel < numChannels; channel++) - { - auto currentNumSamples = maximumNumberOfSamplesBeforeOversampling; - auto offset = numStages * channel; + auto currentNumSamples = maximumNumberOfSamplesBeforeOversampling; - for (size_t n = 0; n < numStages; n++) - { - auto& engine = *engines[static_cast (n + offset)]; + for (size_t n = 0; n < numStages; n++) + { + auto& engine = *engines[static_cast (n)]; - engine.initProcessing (currentNumSamples); - currentNumSamples *= engine.getFactor(); - } + engine.initProcessing (currentNumSamples); + currentNumSamples *= engine.getFactor(); } isReady = true; @@ -597,76 +666,53 @@ void Oversampling::reset() noexcept } template -typename dsp::AudioBlock Oversampling::getProcessedSamples() +typename dsp::AudioBlock Oversampling::processSamplesUp (const dsp::AudioBlock &inputBlock) noexcept { jassert (engines.size() > 0); - Array arrayChannels; - - for (size_t channel = 0; channel < numChannels; channel++) - arrayChannels.add (engines[static_cast (((channel + 1) * numStages) - 1)]->getProcessedSamples()); - - auto numSamples = engines[static_cast (numStages - 1)]->getNumProcessedSamples(); - auto block = dsp::AudioBlock (arrayChannels.getRawDataPointer(), numChannels, numSamples); - - return block; -} - -template -void Oversampling::processSamplesUp (dsp::AudioBlock &block) noexcept -{ - jassert (engines.size() > 0 && block.getNumChannels() <= numChannels); - if (! isReady) - return; + return dsp::AudioBlock(); - for (size_t channel = 0; channel < jmin (numChannels, block.getNumChannels()); channel++) - { - SampleType* dataSamples = block.getChannelPointer (channel); - auto currentNumSamples = block.getNumSamples(); - auto offset = numStages * channel; + dsp::AudioBlock audioBlock = inputBlock; - for (size_t n = 0; n < numStages; n++) - { - auto& engine = *engines[static_cast (n + offset)]; - engine.processSamplesUp (dataSamples, currentNumSamples); - - currentNumSamples *= engine.getFactor(); - dataSamples = engine.getProcessedSamples(); - } + for (size_t n = 0; n < numStages; n++) + { + auto& engine = *engines[static_cast (n)]; + engine.processSamplesUp (audioBlock); + audioBlock = engine.getProcessedSamples (audioBlock.getNumSamples() * engine.getFactor()); } + + return audioBlock; } template -void Oversampling::processSamplesDown (dsp::AudioBlock &block) noexcept +void Oversampling::processSamplesDown (dsp::AudioBlock &outputBlock) noexcept { - jassert (engines.size() > 0 && block.getNumChannels() <= numChannels); + jassert (engines.size() > 0); if (! isReady) return; - for (size_t channel = 0; channel < jmin (numChannels, block.getNumChannels()); channel++) - { - auto currentNumSamples = block.getNumSamples(); - auto offset = numStages * channel; - - for (size_t n = 0; n < numStages - 1; n++) - currentNumSamples *= engines[static_cast (n + offset)]->getFactor(); + auto currentNumSamples = outputBlock.getNumSamples(); - for (size_t n = numStages - 1; n > 0; n--) - { - auto& engine = *engines[static_cast (n + offset)]; + for (size_t n = 0; n < numStages - 1; n++) + currentNumSamples *= engines[static_cast (n)]->getFactor(); - auto dataSamples = engines[static_cast (n + offset - 1)]->getProcessedSamples(); - engine.processSamplesDown (dataSamples, currentNumSamples); + for (size_t n = numStages - 1; n > 0; n--) + { + auto& engine = *engines[static_cast (n)]; - currentNumSamples /= engine.getFactor(); - } + auto audioBlock = engines[static_cast (n - 1)]->getProcessedSamples (currentNumSamples); + engine.processSamplesDown (audioBlock); - engines[static_cast (offset)]->processSamplesDown (block.getChannelPointer (channel), currentNumSamples); + currentNumSamples /= engine.getFactor(); } + engines[static_cast (0)]->processSamplesDown (outputBlock); } template class Oversampling; template class Oversampling; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_Oversampling.h b/modules/juce_dsp/processors/juce_Oversampling.h index 0bcc7357a8..159f0a5dce 100644 --- a/modules/juce_dsp/processors/juce_Oversampling.h +++ b/modules/juce_dsp/processors/juce_Oversampling.h @@ -24,6 +24,11 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ + template class OversamplingEngine; @@ -87,6 +92,9 @@ public: in your main processor to compensate the additional latency involved with the oversampling, for example with a dry / wet functionality, and to report the latency to the DAW. + + Note : the latency might not be integer, so you might need to round its value + or to compensate it properly in your processing code. */ SampleType getLatencyInSamples() noexcept; @@ -102,21 +110,21 @@ public: /** Resets the processing pipeline, ready to oversample a new stream of data. */ void reset() noexcept; - /** Must be called to perform the upsampling, prior to any oversampled processing. */ - void processSamplesUp (dsp::AudioBlock &block) noexcept; + /** Must be called to perform the upsampling, prior to any oversampled processing. - /** Can be called to access to the oversampled input signal, to perform any non- - linear processing which needs the higher sample rate. Don't forget to set - the sample rate of that processing to N times the original sample rate. + Returns an AudioBlock referencing the oversampled input signal, which must be + used to perform the non-linear processing which needs the higher sample rate. + Don't forget to set the sample rate of that processing to N times the original + sample rate. */ - dsp::AudioBlock getProcessedSamples(); + dsp::AudioBlock processSamplesUp (const dsp::AudioBlock &inputBlock) noexcept; /** Must be called to perform the downsampling, after the upsampling and the non-linear processing. The output signal is probably delayed by the internal latency of the whole oversampling behaviour, so don't forget to take this into account. */ - void processSamplesDown (dsp::AudioBlock &block) noexcept; + void processSamplesDown (dsp::AudioBlock &outputBlock) noexcept; private: //=============================================================================== @@ -133,3 +141,6 @@ private: //=============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling) }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessContext.h b/modules/juce_dsp/processors/juce_ProcessContext.h index 8c41f7c686..3016ccdccb 100644 --- a/modules/juce_dsp/processors/juce_ProcessContext.h +++ b/modules/juce_dsp/processors/juce_ProcessContext.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** This structure is passed into a DSP algorithm's prepare() method, and contains @@ -153,3 +157,6 @@ private: const AudioBlockType& inputBlock; AudioBlockType& outputBlock; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorChain.h b/modules/juce_dsp/processors/juce_ProcessorChain.h index fa16f60d35..004380176d 100644 --- a/modules/juce_dsp/processors/juce_ProcessorChain.h +++ b/modules/juce_dsp/processors/juce_ProcessorChain.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ #ifndef DOXYGEN namespace ProcessorHelpers // Internal helper classes used in building the ProcessorChain @@ -112,3 +116,6 @@ namespace ProcessorHelpers // Internal helper classes used in building the Proc */ template using ProcessorChain = ProcessorHelpers::Chain; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h index f66f6a082f..cd561bb388 100644 --- a/modules/juce_dsp/processors/juce_ProcessorDuplicator.h +++ b/modules/juce_dsp/processors/juce_ProcessorDuplicator.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Converts a mono processor class into a multi-channel version by duplicating it @@ -88,3 +92,6 @@ private: juce::OwnedArray processors; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_ProcessorWrapper.h b/modules/juce_dsp/processors/juce_ProcessorWrapper.h index 2e9fe98dd5..9df2b2090d 100644 --- a/modules/juce_dsp/processors/juce_ProcessorWrapper.h +++ b/modules/juce_dsp/processors/juce_ProcessorWrapper.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Acts as a polymorphic base class for processors. @@ -69,3 +73,6 @@ struct ProcessorWrapper : public ProcessorBase ProcessorType processor; }; + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_StateVariableFilter.h b/modules/juce_dsp/processors/juce_StateVariableFilter.h index 98d3d4750b..35d24acb11 100644 --- a/modules/juce_dsp/processors/juce_StateVariableFilter.h +++ b/modules/juce_dsp/processors/juce_StateVariableFilter.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** An IIR filter that can perform low, band and high-pass filtering on an audio @@ -70,6 +74,12 @@ namespace StateVariableFilter /** Resets the filter's processing pipeline. */ void reset() noexcept { s1 = s2 = SampleType {0}; } + /** Ensure that the state variables are rounded to zero if the state + variables are denormals. This is only needed if you are doing + sample by sample processing. + */ + void snapToZero() noexcept { util::snapToZero (s1); util::snapToZero (s2); } + //============================================================================== /** The parameters of the state variable filter. It's up to the called to ensure that these parameters are modified in a thread-safe way. */ @@ -141,6 +151,7 @@ namespace StateVariableFilter for (size_t i = 0 ; i < n; ++i) output[i] = processLoop (input[i], state); + snapToZero(); *parameters = state; } @@ -198,3 +209,6 @@ namespace StateVariableFilter NumericType h = static_cast (1.0 / (1.0 + R2 * g + g * g)); }; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_dsp/processors/juce_WaveShaper.h b/modules/juce_dsp/processors/juce_WaveShaper.h index 7dd5aeb387..1681901165 100644 --- a/modules/juce_dsp/processors/juce_WaveShaper.h +++ b/modules/juce_dsp/processors/juce_WaveShaper.h @@ -24,6 +24,10 @@ ============================================================================== */ +namespace juce +{ +namespace dsp +{ /** Applies waveshaping to audio samples as single samples or AudioBlocks. @@ -63,3 +67,6 @@ struct WaveShaper //============================================================================== template static WaveShaper, Functor> CreateWaveShaper (Functor functionToUse) { return {functionToUse}; } + +} // namespace dsp +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index 76253f347c..2b4613e82c 100644 --- a/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class ActionBroadcaster::ActionMessage : public MessageManager::MessageBase { public: @@ -87,3 +90,5 @@ void ActionBroadcaster::sendActionMessage (const String& message) const for (int i = actionListeners.size(); --i >= 0;) (new ActionMessage (this, message, actionListeners.getUnchecked(i)))->post(); } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionBroadcaster.h b/modules/juce_events/broadcasters/juce_ActionBroadcaster.h index 8a2d559011..3267d86139 100644 --- a/modules/juce_events/broadcasters/juce_ActionBroadcaster.h +++ b/modules/juce_events/broadcasters/juce_ActionBroadcaster.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Manages a list of ActionListeners, and can send them messages. @@ -75,3 +75,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ActionBroadcaster) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ActionListener.h b/modules/juce_events/broadcasters/juce_ActionListener.h index 0571eaf05f..c16449f7df 100644 --- a/modules/juce_events/broadcasters/juce_ActionListener.h +++ b/modules/juce_events/broadcasters/juce_ActionListener.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -42,3 +42,5 @@ public: */ virtual void actionListenerCallback (const String& message) = 0; }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index 15659057f5..8d9a20e5a9 100644 --- a/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class AsyncUpdater::AsyncUpdaterMessage : public CallbackMessage { public: @@ -86,3 +89,5 @@ bool AsyncUpdater::isUpdatePending() const noexcept { return activeMessage->shouldDeliver.value != 0; } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_AsyncUpdater.h b/modules/juce_events/broadcasters/juce_AsyncUpdater.h index 3b61f21088..7a94a63d63 100644 --- a/modules/juce_events/broadcasters/juce_AsyncUpdater.h +++ b/modules/juce_events/broadcasters/juce_AsyncUpdater.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -104,3 +104,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncUpdater) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp index c7b4cbfae8..a816c3d8ff 100644 --- a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp +++ b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + ChangeBroadcaster::ChangeBroadcaster() noexcept { broadcastCallback.owner = this; @@ -92,3 +95,5 @@ void ChangeBroadcaster::ChangeBroadcasterCallback::handleAsyncUpdate() jassert (owner != nullptr); owner->callListeners(); } + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h index 7750e1278c..beef4e85a0 100644 --- a/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h +++ b/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ChangeBroadcaster) }; + +} // namespace juce diff --git a/modules/juce_events/broadcasters/juce_ChangeListener.h b/modules/juce_events/broadcasters/juce_ChangeListener.h index 37aabd0d60..aacaf223cd 100644 --- a/modules/juce_events/broadcasters/juce_ChangeListener.h +++ b/modules/juce_events/broadcasters/juce_ChangeListener.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ChangeBroadcaster; @@ -56,3 +57,5 @@ public: private: virtual int changeListenerCallback (void*) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp index a0e69161ba..9e7070e4d0 100644 --- a/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp +++ b/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + enum { magicMastSlaveConnectionHeader = 0x712baf04 }; static const char* startMessage = "__ipc_st"; @@ -260,3 +263,5 @@ bool ChildProcessSlave::initialiseFromCommandLine (const String& commandLine, return connection != nullptr; } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_ConnectedChildProcess.h b/modules/juce_events/interprocess/juce_ConnectedChildProcess.h index d1eaadc29d..8f6cc8cc1e 100644 --- a/modules/juce_events/interprocess/juce_ConnectedChildProcess.h +++ b/modules/juce_events/interprocess/juce_ConnectedChildProcess.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -184,3 +185,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcessMaster) }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 353beeaac2..6f98aed632 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct InterprocessConnection::ConnectionThread : public Thread { ConnectionThread (InterprocessConnection& c) : Thread ("JUCE IPC"), owner (c) {} @@ -361,3 +364,5 @@ void InterprocessConnection::runThread() break; } } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnection.h b/modules/juce_events/interprocess/juce_InterprocessConnection.h index 6f9048bc7c..83cd910f31 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnection.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnection.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class InterprocessConnectionServer; class MemoryBlock; @@ -203,3 +204,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnection) }; + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index d972d9794b..6c9022bd46 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + InterprocessConnectionServer::InterprocessConnectionServer() : Thread ("Juce IPC server") { @@ -58,6 +61,11 @@ void InterprocessConnectionServer::stop() socket = nullptr; } +int InterprocessConnectionServer::getBoundPort() const noexcept +{ + return (socket == nullptr) ? -1 : socket->getBoundPort(); +} + void InterprocessConnectionServer::run() { while ((! threadShouldExit()) && socket != nullptr) @@ -69,3 +77,5 @@ void InterprocessConnectionServer::run() newConnection->initialiseWithSocket (clientSocket.release()); } } + +} // namespace juce diff --git a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h index 8afd71ae34..552dd1c180 100644 --- a/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h +++ b/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -71,6 +71,15 @@ public: */ void stop(); + /** Returns the local port number to which this server is currently bound. + + This is useful if you need to know to which port the OS has actually bound your + socket when calling beginWaitingForSocket with a port number of zero. + + Returns -1 if the function fails. + */ + int getBoundPort() const noexcept; + protected: /** Creates a suitable connection object for a client process that wants to connect to this one. @@ -83,7 +92,6 @@ protected: */ virtual InterprocessConnection* createConnectionObject() = 0; - private: //============================================================================== ScopedPointer socket; @@ -92,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InterprocessConnectionServer) }; + +} // namespace juce diff --git a/modules/juce_events/juce_events.cpp b/modules/juce_events/juce_events.cpp index 50d8fdd69a..bee0e3dff2 100644 --- a/modules/juce_events/juce_events.cpp +++ b/modules/juce_events/juce_events.cpp @@ -54,9 +54,6 @@ #endif //============================================================================== -namespace juce -{ - #include "messages/juce_ApplicationBase.cpp" #include "messages/juce_DeletedAtShutdown.cpp" #include "messages/juce_MessageListener.cpp" @@ -103,5 +100,3 @@ namespace juce #include "native/juce_android_Messaging.cpp" #endif - -} diff --git a/modules/juce_events/juce_events.h b/modules/juce_events/juce_events.h index a09ece17d3..d0340e1fd4 100644 --- a/modules/juce_events/juce_events.h +++ b/modules/juce_events/juce_events.h @@ -31,7 +31,7 @@ ID: juce_events vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE message and event handling classes description: Classes for running an application's main event loop and sending/receiving messages, timers, etc. website: http://www.juce.com/juce @@ -62,9 +62,6 @@ #include #endif -namespace juce -{ - #include "messages/juce_MessageManager.h" #include "messages/juce_Message.h" #include "messages/juce_MessageListener.h" @@ -89,7 +86,6 @@ namespace juce #include "native/juce_linux_EventLoop.h" #endif - #if JUCE_WINDOWS #if JUCE_EVENTS_INCLUDE_WIN32_MESSAGE_WINDOW #include "native/juce_win32_HiddenMessageWindow.h" @@ -98,5 +94,3 @@ namespace juce #include "native/juce_win32_WinRTWrapper.h" #endif #endif - -} diff --git a/modules/juce_events/messages/juce_ApplicationBase.cpp b/modules/juce_events/messages/juce_ApplicationBase.cpp index be929bee3e..cbd549f8b0 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + JUCEApplicationBase::CreateInstanceFunction JUCEApplicationBase::createInstance = 0; JUCEApplicationBase* JUCEApplicationBase::appInstance = nullptr; @@ -326,3 +329,5 @@ int JUCEApplicationBase::shutdownApp() multipleInstanceHandler = nullptr; return getApplicationReturnValue(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_ApplicationBase.h b/modules/juce_events/messages/juce_ApplicationBase.h index c9ffc5f0b9..88950fd7c0 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.h +++ b/modules/juce_events/messages/juce_ApplicationBase.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -308,3 +308,5 @@ private: #define JUCE_TRY #define JUCE_CATCH_EXCEPTION #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_CallbackMessage.h b/modules/juce_events/messages/juce_CallbackMessage.h index 249b204c01..303c1b438a 100644 --- a/modules/juce_events/messages/juce_CallbackMessage.h +++ b/modules/juce_events/messages/juce_CallbackMessage.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -68,3 +68,5 @@ private: // messages still in the system event queue. These aren't harmful, but can cause annoying assertions. JUCE_DECLARE_NON_COPYABLE (CallbackMessage) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 897632a28b..feede821f1 100644 --- a/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/modules/juce_events/messages/juce_DeletedAtShutdown.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + static SpinLock deletedAtShutdownLock; // use a spin lock because it can be statically initialised static Array& getDeletedAtShutdownObjects() @@ -87,3 +90,5 @@ void DeletedAtShutdown::deleteAll() #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_DeletedAtShutdown.h b/modules/juce_events/messages/juce_DeletedAtShutdown.h index a0284f80dd..9b28a49eda 100644 --- a/modules/juce_events/messages/juce_DeletedAtShutdown.h +++ b/modules/juce_events/messages/juce_DeletedAtShutdown.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -59,3 +59,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE (DeletedAtShutdown) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_Initialisation.h b/modules/juce_events/messages/juce_Initialisation.h index e911807bd1..db2988a709 100644 --- a/modules/juce_events/messages/juce_Initialisation.h +++ b/modules/juce_events/messages/juce_Initialisation.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Initialises Juce's GUI classes. @@ -196,3 +196,5 @@ public: #endif #endif #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_Message.h b/modules/juce_events/messages/juce_Message.h index 52033be77a..c0abb238ce 100644 --- a/modules/juce_events/messages/juce_Message.h +++ b/modules/juce_events/messages/juce_Message.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MessageListener; @@ -57,3 +58,5 @@ private: // messages still in the system event queue. These aren't harmful, but can cause annoying assertions. JUCE_DECLARE_NON_COPYABLE (Message) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageListener.cpp b/modules/juce_events/messages/juce_MessageListener.cpp index 671cbe27d0..e1e8dcf637 100644 --- a/modules/juce_events/messages/juce_MessageListener.cpp +++ b/modules/juce_events/messages/juce_MessageListener.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + Message::Message() noexcept {} Message::~Message() {} @@ -45,3 +48,5 @@ void MessageListener::postMessage (Message* const message) const message->recipient = const_cast (this); message->post(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageListener.h b/modules/juce_events/messages/juce_MessageListener.h index 9e787864eb..8c8fe9bd50 100644 --- a/modules/juce_events/messages/juce_MessageListener.h +++ b/modules/juce_events/messages/juce_MessageListener.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -64,3 +64,5 @@ private: WeakReference::Master masterReference; friend class WeakReference; }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageManager.cpp b/modules/juce_events/messages/juce_MessageManager.cpp index 2d9fb60d7b..563852e54a 100644 --- a/modules/juce_events/messages/juce_MessageManager.cpp +++ b/modules/juce_events/messages/juce_MessageManager.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + MessageManager::MessageManager() noexcept : messageThreadId (Thread::getCurrentThreadId()) { @@ -380,3 +383,5 @@ static int numScopedInitInstances = 0; ScopedJuceInitialiser_GUI::ScopedJuceInitialiser_GUI() { if (numScopedInitInstances++ == 0) initialiseJuce_GUI(); } ScopedJuceInitialiser_GUI::~ScopedJuceInitialiser_GUI() { if (--numScopedInitInstances == 0) shutdownJuce_GUI(); } + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MessageManager.h b/modules/juce_events/messages/juce_MessageManager.h index cc8d44db51..688d53039a 100644 --- a/modules/juce_events/messages/juce_MessageManager.h +++ b/modules/juce_events/messages/juce_MessageManager.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MessageManagerLock; class ThreadPoolJob; @@ -376,3 +377,5 @@ private: JUCE_DECLARE_NON_COPYABLE (MessageManagerLock) }; + +} // namespace juce diff --git a/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h b/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h index 37d181e01c..ccc00b11b9 100644 --- a/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h +++ b/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || JUCE_WINDOWS || defined (DOXYGEN) @@ -52,3 +53,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_events/messages/juce_NotificationType.h b/modules/juce_events/messages/juce_NotificationType.h index 1ad3f35dbe..168ac5c681 100644 --- a/modules/juce_events/messages/juce_NotificationType.h +++ b/modules/juce_events/messages/juce_NotificationType.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -34,3 +35,5 @@ enum NotificationType sendNotificationSync, /**< Requests a synchronous notification. */ sendNotificationAsync, /**< Requests an asynchronous notification. */ }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_android_Messaging.cpp b/modules/juce_events/native/juce_android_Messaging.cpp index 922704ddd7..9cb4dfbfce 100644 --- a/modules/juce_events/native/juce_android_Messaging.cpp +++ b/modules/juce_events/native/juce_android_Messaging.cpp @@ -20,7 +20,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (constructor, "", "()V") \ METHOD (post, "post", "(Ljava/lang/Runnable;)Z") \ @@ -141,3 +143,5 @@ void MessageManager::stopDispatchLoop() (new QuitCallback())->post(); quitMessagePosted = true; } + +} // namespace juce diff --git a/modules/juce_events/native/juce_ios_MessageManager.mm b/modules/juce_events/native/juce_ios_MessageManager.mm index cf5ce1b5ae..47aed5f498 100644 --- a/modules/juce_events/native/juce_ios_MessageManager.mm +++ b/modules/juce_events/native/juce_ios_MessageManager.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + void MessageManager::runDispatchLoop() { jassert (isThisTheMessageThread()); // must only be called by the message thread @@ -96,3 +99,5 @@ void MessageManager::broadcastMessage (const String&) { // N/A on current iOS } + +} // namespace juce diff --git a/modules/juce_events/native/juce_linux_EventLoop.h b/modules/juce_events/native/juce_linux_EventLoop.h index 46df2bdfd4..ce99bd7ff0 100644 --- a/modules/juce_events/native/juce_linux_EventLoop.h +++ b/modules/juce_events/native/juce_linux_EventLoop.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ namespace LinuxEventLoop { @@ -50,3 +51,5 @@ namespace LinuxEventLoop void setWindowSystemFdInternal (int fd, CallbackFunctionBase* readCallback) noexcept; } + +} // namespace juce diff --git a/modules/juce_events/native/juce_linux_Messaging.cpp b/modules/juce_events/native/juce_linux_Messaging.cpp index 0a88349755..35cf97aef2 100644 --- a/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/modules/juce_events/native/juce_linux_Messaging.cpp @@ -22,22 +22,23 @@ #include -enum FdType { +enum FdType +{ INTERNAL_QUEUE_FD, WINDOW_SYSTEM_FD, FD_COUNT, }; +namespace juce +{ + //============================================================================== class InternalMessageQueue { public: InternalMessageQueue() - : fdCount (1), - loopCount (0), - bytesInSocket (0) { - int ret = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, fd); + auto ret = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, fd); ignoreUnused (ret); jassert (ret == 0); auto internalQueueCb = [this] (int _fd) @@ -115,11 +116,10 @@ public: { const int i = loopCount++; loopCount %= fdCount; + if (readCallback[i] != nullptr && readCallback[i]->active) - { if ((*readCallback[i]) (pfds[i].fd)) return true; - } } return false; @@ -140,9 +140,9 @@ private: int fd[2]; pollfd pfds[FD_COUNT]; ScopedPointer readCallback[FD_COUNT]; - int fdCount; - int loopCount; - int bytesInSocket; + int fdCount = 1; + int loopCount = 0; + int bytesInSocket = 0; int getWriteHandle() const noexcept { return fd[0]; } int getReadHandle() const noexcept { return fd[1]; } @@ -196,12 +196,10 @@ namespace LinuxErrorHandling void MessageManager::doPlatformSpecificInitialisation() { if (JUCEApplicationBase::isStandaloneApp()) - { LinuxErrorHandling::installKeyboardBreakHandler(); - } // Create the internal message queue - InternalMessageQueue* queue = InternalMessageQueue::getInstance(); + auto* queue = InternalMessageQueue::getInstance(); ignoreUnused (queue); } @@ -212,7 +210,7 @@ void MessageManager::doPlatformSpecificShutdown() bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message) { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) { queue->postMessage (message); return true; @@ -221,9 +219,9 @@ bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* cons return false; } -void MessageManager::broadcastMessage (const String& /* value */) +void MessageManager::broadcastMessage (const String&) { - /* TODO */ + // TODO } // this function expects that it will NEVER be called simultaneously for two concurrent threads @@ -234,12 +232,12 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMes if (LinuxErrorHandling::keyboardBreakOccurred) JUCEApplicationBase::getInstance()->quit(); - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) { if (queue->dispatchNextEvent()) break; - else if (returnIfNoPendingMessages) + if (returnIfNoPendingMessages) return false; // wait for 2000ms for next events if necessary @@ -251,16 +249,17 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMes } //============================================================================== - - void LinuxEventLoop::setWindowSystemFdInternal (int fd, LinuxEventLoop::CallbackFunctionBase* readCallback) noexcept { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) queue->setWindowSystemFd (fd, readCallback); } void LinuxEventLoop::removeWindowSystemFd() noexcept { - if (InternalMessageQueue* queue = InternalMessageQueue::getInstanceWithoutCreating()) + if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) queue->removeWindowSystemFd(); } + + +} // namespace juce diff --git a/modules/juce_events/native/juce_mac_MessageManager.mm b/modules/juce_events/native/juce_mac_MessageManager.mm index 95e9a59dcc..27456e63a9 100644 --- a/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/modules/juce_events/native/juce_mac_MessageManager.mm @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + typedef void (*AppFocusChangeCallback)(); AppFocusChangeCallback appFocusChangeCallback = nullptr; @@ -423,3 +426,5 @@ private: MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); } MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} #endif + +} // namespace juce diff --git a/modules/juce_events/native/juce_osx_MessageQueue.h b/modules/juce_events/native/juce_osx_MessageQueue.h index 9a23c15c42..32f24fde79 100644 --- a/modules/juce_events/native/juce_osx_MessageQueue.h +++ b/modules/juce_events/native/juce_osx_MessageQueue.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /* An internal message pump class used in OSX and iOS. */ @@ -100,3 +101,5 @@ private: static_cast (info)->runLoopCallback(); } }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h index 80328fb202..9135d99bd6 100644 --- a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h +++ b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== class HiddenMessageWindow @@ -80,7 +81,7 @@ public: private: static LONG_PTR getImprobableWindowNumber() noexcept { - static LONG_PTR number = (LONG_PTR) Random::getSystemRandom().nextInt64(); + static auto number = (LONG_PTR) Random().nextInt64(); return number; } }; @@ -130,3 +131,5 @@ private: systemDeviceChanged(); } }; + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index 12858ba64c..38b636aae1 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + extern HWND juce_messageWindowHandle; typedef bool (*CheckEventBlockedByModalComps) (const MSG&); @@ -225,3 +228,5 @@ struct MountedVolumeListChangeDetector::Pimpl : private DeviceChangeDetector MountedVolumeListChangeDetector::MountedVolumeListChangeDetector() { pimpl = new Pimpl (*this); } MountedVolumeListChangeDetector::~MountedVolumeListChangeDetector() {} + +} // namespace juce diff --git a/modules/juce_events/native/juce_win32_WinRTWrapper.cpp b/modules/juce_events/native/juce_win32_WinRTWrapper.cpp index 39cb99cae7..e8d848da42 100644 --- a/modules/juce_events/native/juce_win32_WinRTWrapper.cpp +++ b/modules/juce_events/native/juce_win32_WinRTWrapper.cpp @@ -20,4 +20,7 @@ ============================================================================== */ -juce_ImplementSingleton (WinRTWrapper) +namespace juce +{ + juce_ImplementSingleton (WinRTWrapper) +} diff --git a/modules/juce_events/native/juce_win32_WinRTWrapper.h b/modules/juce_events/native/juce_win32_WinRTWrapper.h index 8f2503daaf..4a48e04285 100644 --- a/modules/juce_events/native/juce_win32_WinRTWrapper.h +++ b/modules/juce_events/native/juce_win32_WinRTWrapper.h @@ -20,7 +20,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class WinRTWrapper : public DeletedAtShutdown { @@ -63,13 +64,9 @@ public: String hStringToString (HSTRING hstr) { - const wchar_t* str = nullptr; if (isInitialised()) - { - str = getHStringRawBuffer (hstr, nullptr); - if (str != nullptr) + if (const wchar_t* str = getHStringRawBuffer (hstr, nullptr)) return String (str); - } return {}; } @@ -130,3 +127,5 @@ private: WindowsGetStringRawBufferFuncPtr getHStringRawBuffer = nullptr; RoGetActivationFactoryFuncPtr roGetActivationFactory = nullptr; }; + +} // namespace juce diff --git a/modules/juce_events/timers/juce_MultiTimer.cpp b/modules/juce_events/timers/juce_MultiTimer.cpp index e9ace0a9d5..3f73eb3d7b 100644 --- a/modules/juce_events/timers/juce_MultiTimer.cpp +++ b/modules/juce_events/timers/juce_MultiTimer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + struct MultiTimerCallback : public Timer { MultiTimerCallback (const int tid, MultiTimer& mt) noexcept @@ -101,3 +104,5 @@ int MultiTimer::getTimerInterval (const int timerID) const noexcept return 0; } + +} // namespace juce diff --git a/modules/juce_events/timers/juce_MultiTimer.h b/modules/juce_events/timers/juce_MultiTimer.h index 87848458d5..8921b68443 100644 --- a/modules/juce_events/timers/juce_MultiTimer.h +++ b/modules/juce_events/timers/juce_MultiTimer.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -119,3 +119,5 @@ private: Timer* getCallback (int) const noexcept; MultiTimer& operator= (const MultiTimer&); }; + +} // namespace juce diff --git a/modules/juce_events/timers/juce_Timer.cpp b/modules/juce_events/timers/juce_Timer.cpp index da2ea738ee..ae6e48fb5e 100644 --- a/modules/juce_events/timers/juce_Timer.cpp +++ b/modules/juce_events/timers/juce_Timer.cpp @@ -20,6 +20,9 @@ ============================================================================== */ +namespace juce +{ + class Timer::TimerThread : private Thread, private DeletedAtShutdown, private AsyncUpdater @@ -364,3 +367,5 @@ void JUCE_CALLTYPE Timer::callAfterDelay (int milliseconds, std::function @@ -692,3 +695,5 @@ Graphics::ScopedSaveState::~ScopedSaveState() { context.restoreState(); } + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index 1e2e40053b..8351003c0d 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -742,3 +742,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Graphics) }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h index 92ca194393..a9828e3051 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ public: virtual void drawGlyph (int glyphNumber, const AffineTransform&) = 0; virtual bool drawTextLayout (const AttributedString&, const Rectangle&) { return false; } }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index a9900f03a0..868ccf7355 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // this will throw an assertion if you try to draw something that's not // possible in postscript #define WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS 0 @@ -533,3 +536,5 @@ void LowLevelGraphicsPostScriptRenderer::drawGlyph (int glyphNumber, const Affin font.getTypeface()->getOutlineForGlyph (glyphNumber, p); fillPath (p, AffineTransform::scale (font.getHeight() * font.getHorizontalScale(), font.getHeight()).followedBy (transform)); } + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 463df4dba7..889702bca3 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -116,3 +116,5 @@ protected: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer) }; + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index c884113714..a32e907710 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image) : RenderingHelpers::StackBasedLowLevelGraphicsContext (new RenderingHelpers::SoftwareRendererSavedState (image, image.getBounds())) @@ -38,3 +41,5 @@ LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& } LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer() {} + +} // namespace juce diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index 648970f91a..06ecca5e0a 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -52,3 +52,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsSoftwareRenderer) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index 5e68ac0dfe..6557c9dd85 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static inline void blurDataTriplets (uint8* d, int num, const int delta) noexcept { uint32 last = d[0]; @@ -182,3 +185,5 @@ void DropShadowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor g.setOpacity (alpha); g.drawImageAt (image, 0, 0); } + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.h b/modules/juce_graphics/effects/juce_DropShadowEffect.h index 9fefe9a365..3de0f97a62 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.h +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_LEAK_DETECTOR (DropShadowEffect) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_GlowEffect.cpp b/modules/juce_graphics/effects/juce_GlowEffect.cpp index e3af9ed032..4e1ee32c59 100644 --- a/modules/juce_graphics/effects/juce_GlowEffect.cpp +++ b/modules/juce_graphics/effects/juce_GlowEffect.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + GlowEffect::GlowEffect() {} GlowEffect::~GlowEffect() {} @@ -51,3 +54,5 @@ void GlowEffect::applyEffect (Image& image, Graphics& g, float scaleFactor, floa g.setOpacity (alpha); g.drawImageAt (image, offset.x, offset.y, false); } + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_GlowEffect.h b/modules/juce_graphics/effects/juce_GlowEffect.h index 2489516825..428ebad709 100644 --- a/modules/juce_graphics/effects/juce_GlowEffect.h +++ b/modules/juce_graphics/effects/juce_GlowEffect.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -71,3 +71,5 @@ private: JUCE_LEAK_DETECTOR (GlowEffect) }; + +} // namespace juce diff --git a/modules/juce_graphics/effects/juce_ImageEffectFilter.h b/modules/juce_graphics/effects/juce_ImageEffectFilter.h index 3d5d11afdd..e06222d92c 100644 --- a/modules/juce_graphics/effects/juce_ImageEffectFilter.h +++ b/modules/juce_graphics/effects/juce_ImageEffectFilter.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ public: virtual ~ImageEffectFilter() {} }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_AttributedString.cpp b/modules/juce_graphics/fonts/juce_AttributedString.cpp index 944a9be920..000223d966 100644 --- a/modules/juce_graphics/fonts/juce_AttributedString.cpp +++ b/modules/juce_graphics/fonts/juce_AttributedString.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { int getLength (const Array& atts) noexcept @@ -349,3 +352,5 @@ void AttributedString::draw (Graphics& g, const Rectangle& area) const } } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_AttributedString.h b/modules/juce_graphics/fonts/juce_AttributedString.h index 98d15a99fb..f0cac6a062 100644 --- a/modules/juce_graphics/fonts/juce_AttributedString.h +++ b/modules/juce_graphics/fonts/juce_AttributedString.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -203,3 +203,5 @@ private: JUCE_LEAK_DETECTOR (AttributedString) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index 26d5d9506b..acc1456aa6 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CustomTypeface::GlyphInfo { public: @@ -406,3 +409,5 @@ EdgeTable* CustomTypeface::getEdgeTableForGlyph (int glyphNumber, const AffineTr return nullptr; } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.h b/modules/juce_graphics/fonts/juce_CustomTypeface.h index 0de1862f9f..36dda6d5cd 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -161,3 +161,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomTypeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 8d43600250..40e7f1bdea 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace FontValues { static float limitFontHeight (const float height) noexcept @@ -715,3 +718,5 @@ Font Font::fromString (const String& fontDescription) return Font (name, style, height); } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Font.h b/modules/juce_graphics/fonts/juce_Font.h index 27fb61a976..cacea2d219 100644 --- a/modules/juce_graphics/fonts/juce_Font.h +++ b/modules/juce_graphics/fonts/juce_Font.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -474,3 +474,5 @@ private: JUCE_LEAK_DETECTOR (Font) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index adf8d7e03d..f0d05460c5 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PositionedGlyph::PositionedGlyph() noexcept : character (0), glyph (0), x (0), y (0), w (0), whitespace (false) { @@ -813,3 +816,5 @@ int GlyphArrangement::findGlyphIndexAt (const float x, const float y) const return -1; } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 42bcde4ef2..711e6a06fd 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -323,3 +323,5 @@ private: JUCE_LEAK_DETECTOR (GlyphArrangement) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_TextLayout.cpp b/modules/juce_graphics/fonts/juce_TextLayout.cpp index 895316607a..5987bb19a6 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/modules/juce_graphics/fonts/juce_TextLayout.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TextLayout::Glyph::Glyph (const int glyph, Point anch, float w) noexcept : glyphCode (glyph), anchor (anch), width (w) { @@ -583,3 +586,5 @@ void TextLayout::recalculateSize() height = 0; } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_TextLayout.h b/modules/juce_graphics/fonts/juce_TextLayout.h index 5a1510e654..d5b2016276 100644 --- a/modules/juce_graphics/fonts/juce_TextLayout.h +++ b/modules/juce_graphics/fonts/juce_TextLayout.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -191,3 +191,5 @@ private: JUCE_LEAK_DETECTOR (TextLayout) }; + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Typeface.cpp b/modules/juce_graphics/fonts/juce_Typeface.cpp index 1ce9a78fdf..d712e2d810 100644 --- a/modules/juce_graphics/fonts/juce_Typeface.cpp +++ b/modules/juce_graphics/fonts/juce_Typeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FontStyleHelpers { static const char* getStyleName (const bool bold, @@ -260,3 +263,5 @@ void Typeface::applyVerticalHintingTransform (float fontSize, Path& path) return hintingParams->applyVerticalHintingTransform (fontSize, path); } } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_Typeface.h b/modules/juce_graphics/fonts/juce_Typeface.h index 3669fc16ac..82a2eb8f6d 100644 --- a/modules/juce_graphics/fonts/juce_Typeface.h +++ b/modules/juce_graphics/fonts/juce_Typeface.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Typeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index b111ed5b1c..59115696db 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AffineTransform::AffineTransform() noexcept : mat00 (1.0f), mat01 (0), mat02 (0), mat10 (0), mat11 (1.0f), mat12 (0) @@ -262,3 +265,5 @@ float AffineTransform::getScaleFactor() const noexcept { return (std::abs (mat00) + std::abs (mat11)) / 2.0f; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.h b/modules/juce_graphics/geometry/juce_AffineTransform.h index 24fcf51568..a11561bafd 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/modules/juce_graphics/geometry/juce_AffineTransform.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -275,3 +275,5 @@ public: float mat00, mat01, mat02; float mat10, mat11, mat12; }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_BorderSize.h b/modules/juce_graphics/geometry/juce_BorderSize.h index 7dbfb8ce57..8678c2eb44 100644 --- a/modules/juce_graphics/geometry/juce_BorderSize.h +++ b/modules/juce_graphics/geometry/juce_BorderSize.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -149,3 +149,5 @@ private: //============================================================================== ValueType top, left, bottom, right; }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/modules/juce_graphics/geometry/juce_EdgeTable.cpp index ea35e47521..141613c844 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const int juce_edgeTableDefaultEdgesPerLine = 32; //============================================================================== @@ -831,3 +834,5 @@ bool EdgeTable::isEmpty() noexcept return bounds.getHeight() == 0; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.h b/modules/juce_graphics/geometry/juce_EdgeTable.h index f32e61e127..76c318ed1d 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.h +++ b/modules/juce_graphics/geometry/juce_EdgeTable.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -216,3 +216,5 @@ private: JUCE_LEAK_DETECTOR (EdgeTable) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Line.h b/modules/juce_graphics/geometry/juce_Line.h index 7143fe3082..d8db97a4e6 100644 --- a/modules/juce_graphics/geometry/juce_Line.h +++ b/modules/juce_graphics/geometry/juce_Line.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -424,3 +424,5 @@ private: return isZeroToOne (along2); } }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Path.cpp b/modules/juce_graphics/geometry/juce_Path.cpp index 38b0d53cc0..849d4a0835 100644 --- a/modules/juce_graphics/geometry/juce_Path.cpp +++ b/modules/juce_graphics/geometry/juce_Path.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // tests that some coordinates aren't NaNs #define JUCE_CHECK_COORDS_ARE_VALID(x, y) \ jassert (x == x && y == y); @@ -1631,3 +1634,5 @@ bool Path::Iterator::next() noexcept } #undef JUCE_CHECK_COORDS_ARE_VALID + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Path.h b/modules/juce_graphics/geometry/juce_Path.h index 03dc768949..1a4962ac6d 100644 --- a/modules/juce_graphics/geometry/juce_Path.h +++ b/modules/juce_graphics/geometry/juce_Path.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -829,3 +829,5 @@ private: JUCE_LEAK_DETECTOR (Path) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathIterator.cpp b/modules/juce_graphics/geometry/juce_PathIterator.cpp index f3fbe128ab..ca239d4f95 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/modules/juce_graphics/geometry/juce_PathIterator.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC && JUCE_DEBUG #pragma optimize ("t", on) #endif @@ -51,7 +54,7 @@ PathFlatteningIterator::~PathFlatteningIterator() bool PathFlatteningIterator::isLastInSubpath() const noexcept { - return stackPos == stackBase.getData() + return stackPos == stackBase.get() && (index >= path.numElements || isMarker (points[index], Path::moveMarker)); } @@ -279,3 +282,5 @@ bool PathFlatteningIterator::next() #if JUCE_MSVC && JUCE_DEBUG #pragma optimize ("", on) // resets optimisations to the project defaults #endif + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathIterator.h b/modules/juce_graphics/geometry/juce_PathIterator.h index 96c70a8525..d37b5407d6 100644 --- a/modules/juce_graphics/geometry/juce_PathIterator.h +++ b/modules/juce_graphics/geometry/juce_PathIterator.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,3 +106,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PathFlatteningIterator) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp index dbab9c7bbe..8069a696d2 100644 --- a/modules/juce_graphics/geometry/juce_PathStrokeType.cpp +++ b/modules/juce_graphics/geometry/juce_PathStrokeType.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PathStrokeType::PathStrokeType (float strokeThickness) noexcept : thickness (strokeThickness), jointStyle (mitered), endStyle (butt) { @@ -738,3 +741,5 @@ void PathStrokeType::createStrokeWithArrowheads (Path& destPath, PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle, destPath, sourcePath, transform, extraAccuracy, &head); } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_PathStrokeType.h b/modules/juce_graphics/geometry/juce_PathStrokeType.h index de804b1436..c84412dd98 100644 --- a/modules/juce_graphics/geometry/juce_PathStrokeType.h +++ b/modules/juce_graphics/geometry/juce_PathStrokeType.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_LEAK_DETECTOR (PathStrokeType) }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Point.h b/modules/juce_graphics/geometry/juce_Point.h index 69915c31a5..2b66ae8475 100644 --- a/modules/juce_graphics/geometry/juce_Point.h +++ b/modules/juce_graphics/geometry/juce_Point.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -239,3 +239,5 @@ public: /** Multiplies the point's coordinates by a scalar value. */ template Point operator* (ValueType value, Point p) noexcept { return p * value; } + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index dca99f300f..eb5d937be3 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -977,3 +977,5 @@ private: static int ceilAsInt (float n) noexcept { return n < (float) std::numeric_limits::max() ? (int) std::ceil (n) : std::numeric_limits::max(); } static int ceilAsInt (double n) noexcept { return n < (double) std::numeric_limits::max() ? (int) std::ceil (n) : std::numeric_limits::max(); } }; + +} // namespace juce diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index e611fcb8fe..55512fda1d 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -649,3 +649,5 @@ private: //============================================================================== Array rects; }; + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp index 5d8c205e16..80a101e644 100644 --- a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if (JUCE_MAC || JUCE_IOS) && USE_COREGRAPHICS_RENDERING && JUCE_USE_COREIMAGE_LOADER Image juce_loadWithCoreImage (InputStream& input); #else @@ -444,3 +447,5 @@ bool GIFImageFormat::writeImageToStream (const Image& /*sourceImage*/, OutputStr jassertfalse; // writing isn't implemented for GIFs! return false; } + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index ff5c1629d6..793d10ba64 100644 --- a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4365) @@ -449,3 +452,5 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) return true; } + +} // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index dbf35059eb..ee06273171 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MSVC #pragma warning (push) #pragma warning (disable: 4390 4611 4365 4267) @@ -598,3 +601,5 @@ bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) return true; } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index 7028b65e91..1b206f5a22 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImagePixelData::ImagePixelData (const Image::PixelFormat format, const int w, const int h) : pixelFormat (format), width (w), height (h) { @@ -673,3 +676,5 @@ void Image::moveImageSection (int dx, int dy, } } } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index a2c436d251..eefaa98d1f 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ImageType; class ImagePixelData; @@ -542,3 +543,5 @@ public: ImagePixelData::Ptr create (Image::PixelFormat, int width, int height, bool clearImage) const override; int getTypeID() const override; }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageCache.cpp b/modules/juce_graphics/images/juce_ImageCache.cpp index 50c3203f4b..e565f5e5e6 100644 --- a/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/modules/juce_graphics/images/juce_ImageCache.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct ImageCache::Pimpl : private Timer, private DeletedAtShutdown { @@ -163,3 +166,5 @@ void ImageCache::releaseUnusedImages() { Pimpl::getInstance()->releaseUnusedImages(); } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageCache.h b/modules/juce_graphics/images/juce_ImageCache.h index fa5b5710c7..753ce750de 100644 --- a/modules/juce_graphics/images/juce_ImageCache.h +++ b/modules/juce_graphics/images/juce_ImageCache.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -122,3 +122,5 @@ private: JUCE_DECLARE_NON_COPYABLE (ImageCache) }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp b/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp index a56cab1ebe..e7408c2f0c 100644 --- a/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp +++ b/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageConvolutionKernel::ImageConvolutionKernel (const int size_) : values ((size_t) (size_ * size_)), size (size_) @@ -290,3 +293,5 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, } } } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageConvolutionKernel.h b/modules/juce_graphics/images/juce_ImageConvolutionKernel.h index cc399d9653..c3495a2684 100644 --- a/modules/juce_graphics/images/juce_ImageConvolutionKernel.h +++ b/modules/juce_graphics/images/juce_ImageConvolutionKernel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageConvolutionKernel) }; + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageFileFormat.cpp b/modules/juce_graphics/images/juce_ImageFileFormat.cpp index 669a39be47..12ad6afb2e 100644 --- a/modules/juce_graphics/images/juce_ImageFileFormat.cpp +++ b/modules/juce_graphics/images/juce_ImageFileFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct DefaultImageFormats { static ImageFileFormat** get() @@ -105,3 +108,5 @@ Image ImageFileFormat::loadFrom (const void* rawData, const size_t numBytes) return Image(); } + +} // namespace juce diff --git a/modules/juce_graphics/images/juce_ImageFileFormat.h b/modules/juce_graphics/images/juce_ImageFileFormat.h index e558906af7..ec7138836a 100644 --- a/modules/juce_graphics/images/juce_ImageFileFormat.h +++ b/modules/juce_graphics/images/juce_ImageFileFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -212,3 +212,5 @@ public: Image decodeImage (InputStream&) override; bool writeImageToStream (const Image&, OutputStream&) override; }; + +} // namespace juce diff --git a/modules/juce_graphics/juce_graphics.cpp b/modules/juce_graphics/juce_graphics.cpp index 6884981880..2dcbc5e8bb 100644 --- a/modules/juce_graphics/juce_graphics.cpp +++ b/modules/juce_graphics/juce_graphics.cpp @@ -68,6 +68,7 @@ #if JUCE_MINGW #include + #include #endif #ifdef JUCE_MSVC @@ -106,9 +107,6 @@ #endif //============================================================================== -namespace juce -{ - #include "colour/juce_Colour.cpp" #include "colour/juce_ColourGradient.cpp" #include "colour/juce_Colours.cpp" @@ -167,7 +165,6 @@ namespace juce #include "native/juce_android_IconHelpers.cpp" #endif -} //============================================================================== #if JUCE_USE_FREETYPE && JUCE_USE_FREETYPE_AMALGAMATED diff --git a/modules/juce_graphics/juce_graphics.h b/modules/juce_graphics/juce_graphics.h index c823b10f10..41693ec5fb 100644 --- a/modules/juce_graphics/juce_graphics.h +++ b/modules/juce_graphics/juce_graphics.h @@ -35,7 +35,7 @@ ID: juce_graphics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE graphics classes description: Classes for 2D vector graphics, image loading/saving, font handling, etc. website: http://www.juce.com/juce @@ -92,14 +92,14 @@ //============================================================================== namespace juce { - -class Image; -class AffineTransform; -class Path; -class Font; -class Graphics; -class FillType; -class LowLevelGraphicsContext; + class Image; + class AffineTransform; + class Path; + class Font; + class Graphics; + class FillType; + class LowLevelGraphicsContext; +} #include "geometry/juce_AffineTransform.h" #include "geometry/juce_Point.h" @@ -145,5 +145,3 @@ class LowLevelGraphicsContext; #if JUCE_DIRECT2D && JUCE_WINDOWS #include "native/juce_win32_Direct2DGraphicsContext.h" #endif - -} diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 5cbb679e38..e552758b2c 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MSVC #pragma warning (push) @@ -996,10 +997,10 @@ namespace EdgeTableFillers } y = y_; - generate (scratchBuffer.getData(), x, width); + generate (scratchBuffer.get(), x, width); et.clipLineToMask (x, y_, - reinterpret_cast (scratchBuffer.getData()) + SrcPixelType::indexA, + reinterpret_cast (scratchBuffer.get()) + SrcPixelType::indexA, sizeof (SrcPixelType), width); } @@ -2685,3 +2686,5 @@ protected: #if JUCE_MSVC #pragma warning (pop) #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_Fonts.cpp b/modules/juce_graphics/native/juce_android_Fonts.cpp index 5bfe92da6f..a5ffa6b7d8 100644 --- a/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/modules/juce_graphics/native/juce_android_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct DefaultFontNames { DefaultFontNames() @@ -402,3 +405,5 @@ bool TextLayout::createNativeLayout (const AttributedString&) } #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index 2f36d872e5..77dabe2e3f 100644 --- a/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_android_GraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace GraphicsHelpers { jobject createPaint (Graphics::ResamplingQuality quality) @@ -60,3 +63,5 @@ ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int widt { return SoftwareImageType().create (format, width, height, clearImage); } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_android_IconHelpers.cpp b/modules/juce_graphics/native/juce_android_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_android_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_android_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/native/juce_freetype_Fonts.cpp b/modules/juce_graphics/native/juce_freetype_Fonts.cpp index 1f01b77c96..a813ec61b1 100644 --- a/modules/juce_graphics/native/juce_freetype_Fonts.cpp +++ b/modules/juce_graphics/native/juce_freetype_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FTLibWrapper : public ReferenceCountedObject { FTLibWrapper() : library (0) @@ -455,3 +458,5 @@ private: JUCE_DECLARE_NON_COPYABLE (FreeTypeTypeface) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_linux_Fonts.cpp b/modules/juce_graphics/native/juce_linux_Fonts.cpp index 24b98669e6..06cd9401a6 100644 --- a/modules/juce_graphics/native/juce_linux_Fonts.cpp +++ b/modules/juce_graphics/native/juce_linux_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static XmlElement* findFontsConfFile() { static const char* pathsToSearch[] = { "/etc/fonts/fonts.conf", @@ -190,3 +193,5 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) f.setTypefaceName (defaultNames.getRealFontName (font.getTypefaceName())); return Typeface::createSystemTypefaceFor (f); } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_linux_IconHelpers.cpp b/modules/juce_graphics/native/juce_linux_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_linux_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_linux_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index 4b81cf1002..5db0407439 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== class CoreGraphicsContext : public LowLevelGraphicsContext @@ -110,3 +111,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsContext) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index fa97d97a58..63e7f89259 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -24,9 +24,9 @@ ============================================================================== */ -#include "juce_mac_CoreGraphicsContext.h" +namespace juce +{ -//============================================================================== class CoreGraphicsImage : public ImagePixelData { public: @@ -919,3 +919,5 @@ Image juce_createImageFromUIImage (UIImage* img) return retval; } #endif + +} diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h b/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h index f60b158a1f..6d04d73ea7 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== namespace @@ -59,5 +59,7 @@ extern CGImageRef juce_createCoreGraphicsImage (const Image&, CGColorSpaceRef, b extern CGContextRef juce_getImageContext (const Image&); #if JUCE_IOS -extern Image juce_createImageFromUIImage (UIImage*); + extern Image juce_createImageFromUIImage (UIImage*); #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 61c9cf8c2f..19b3b38f3f 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #ifndef JUCE_CORETEXT_AVAILABLE #define JUCE_CORETEXT_AVAILABLE 1 #endif @@ -1245,3 +1248,5 @@ bool TextLayout::createNativeLayout (const AttributedString& text) ignoreUnused (text); return false; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_mac_IconHelpers.cpp b/modules/juce_graphics/native/juce_mac_IconHelpers.cpp index 0f3b740b06..03aa559c5e 100644 --- a/modules/juce_graphics/native/juce_mac_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_mac_IconHelpers.cpp @@ -24,9 +24,13 @@ ============================================================================== */ +namespace juce +{ + Image getIconFromIcnsFile (const File& icnsFile, const int size) { FileInputStream stream (icnsFile); + if (! stream.openedOk()) return {}; @@ -44,6 +48,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) return {}; const auto dataSize = juce::ByteOrder::bigEndianInt (headerSection); + if (dataSize <= 0) return {}; @@ -66,6 +71,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) break; const auto sectionSize = ByteOrder::bigEndianInt (headerSection); + if (sectionSize <= 0) break; @@ -81,6 +87,7 @@ Image getIconFromIcnsFile (const File& icnsFile, const int size) const auto lastImageIndex = images.size() - 1; const auto lastWidth = images.getReference (lastImageIndex).getWidth(); + if (lastWidth > maxWidth) { maxWidthIndex = lastImageIndex; @@ -122,16 +129,22 @@ Image JUCE_API getIconFromApplication (const String& applicationPath, const int hostIcon = getIconFromIcnsFile (icnsFile, size); CFRelease (iconPath); } + CFRelease (iconURL); } } } + CFRelease (appBundle); } + CFRelease (url); } + CFRelease (pathCFString); } return hostIcon; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index 40f848e58d..b9f7d592ff 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + template D2D1_RECT_F rectangleToRectF (const Rectangle& r) { @@ -823,3 +826,5 @@ bool Direct2DLowLevelGraphicsContext::drawTextLayout (const AttributedString& te pimpl->renderingTarget->SetTransform (D2D1::IdentityMatrix()); return true; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h index 2c923a76ed..fb8714dbf1 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #ifndef _WINDEF_ class HWND__; // Forward or never @@ -101,3 +102,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Direct2DLowLevelGraphicsContext) }; + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index 739fc539ae..d007ebb6bc 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_DIRECTWRITE namespace DirectWriteTypeLayout { @@ -453,3 +456,5 @@ bool TextLayout::createNativeLayout (const AttributedString& text) return false; } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index fb30ddb42d..2643d1a169 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_USE_DIRECTWRITE namespace { @@ -320,3 +323,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_Fonts.cpp b/modules/juce_graphics/native/juce_win32_Fonts.cpp index d8198341cd..b6159c3f94 100644 --- a/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* This is some quick-and-dirty code to extract the typeface name from a lump of TTF file data. It's needed because although win32 will happily load a TTF file from in-memory data, it won't tell you the name of the damned font that it just loaded.. and in order to actually use the font, @@ -644,3 +647,5 @@ void Typeface::scanFolderForFonts (const File&) { jassertfalse; // not implemented on this platform } + +} // namespace juce diff --git a/modules/juce_graphics/native/juce_win32_IconHelpers.cpp b/modules/juce_graphics/native/juce_win32_IconHelpers.cpp index 287005422c..3a11f8e344 100644 --- a/modules/juce_graphics/native/juce_win32_IconHelpers.cpp +++ b/modules/juce_graphics/native/juce_win32_IconHelpers.cpp @@ -24,7 +24,7 @@ ============================================================================== */ -Image JUCE_API getIconFromApplication (const String&, const int) +namespace juce { - return Image(); + Image JUCE_API getIconFromApplication (const String&, int) { return {}; } } diff --git a/modules/juce_graphics/placement/juce_Justification.h b/modules/juce_graphics/placement/juce_Justification.h index a70ea25184..8c8fb8362b 100644 --- a/modules/juce_graphics/placement/juce_Justification.h +++ b/modules/juce_graphics/placement/juce_Justification.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -186,3 +186,5 @@ private: //============================================================================== int flags; }; + +} // namespace juce diff --git a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp index 1d1143636e..6f718c0948 100644 --- a/modules/juce_graphics/placement/juce_RectanglePlacement.cpp +++ b/modules/juce_graphics/placement/juce_RectanglePlacement.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RectanglePlacement::RectanglePlacement (const RectanglePlacement& other) noexcept : flags (other.flags) { @@ -127,3 +130,5 @@ AffineTransform RectanglePlacement::getTransformToFit (const Rectangle& s .scaled (scaleX, scaleY) .translated (newX, newY); } + +} // namespace juce diff --git a/modules/juce_graphics/placement/juce_RectanglePlacement.h b/modules/juce_graphics/placement/juce_RectanglePlacement.h index 1d6aefd748..84eec1db0f 100644 --- a/modules/juce_graphics/placement/juce_RectanglePlacement.h +++ b/modules/juce_graphics/placement/juce_RectanglePlacement.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -169,3 +169,5 @@ private: //============================================================================== int flags; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/application/juce_Application.cpp b/modules/juce_gui_basics/application/juce_Application.cpp index a365031d2e..efa5242bbd 100644 --- a/modules/juce_gui_basics/application/juce_Application.cpp +++ b/modules/juce_gui_basics/application/juce_Application.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + JUCEApplication::JUCEApplication() {} JUCEApplication::~JUCEApplication() {} @@ -98,3 +101,5 @@ bool JUCEApplication::initialiseApp() return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/application/juce_Application.h b/modules/juce_gui_basics/application/juce_Application.h index 9ade8bbe9d..423f8ce5c6 100644 --- a/modules/juce_gui_basics/application/juce_Application.h +++ b/modules/juce_gui_basics/application/juce_Application.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -188,3 +188,5 @@ private: JUCE_DECLARE_NON_COPYABLE (JUCEApplication) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp b/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp index 4076462db9..fa76bc1d3d 100644 --- a/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, Colour arrowColour) : Button (name), colour (arrowColour) { @@ -45,3 +48,5 @@ void ArrowButton::paintButton (Graphics& g, bool /*isMouseOverButton*/, bool isB g.setColour (colour); g.fillPath (p); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ArrowButton.h b/modules/juce_gui_basics/buttons/juce_ArrowButton.h index c05a0c5f65..8ff4d7f476 100644 --- a/modules/juce_gui_basics/buttons/juce_ArrowButton.h +++ b/modules/juce_gui_basics/buttons/juce_ArrowButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -60,3 +60,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ArrowButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 9ece5dd0c6..e82b83897d 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class Button::CallbackHelper : public Timer, public ApplicationCommandManagerListener, public Value::Listener, @@ -692,3 +695,5 @@ void Button::repeatTimerCallback() callbackHelper->stopTimer(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index 9ba29f157c..79de48cc27 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -518,3 +518,5 @@ private: /** This typedef is just for compatibility with old code and VC6 - newer code should use Button::Listener instead. */ typedef Button::Listener ButtonListener; #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index 3fa94c0c85..f4b01ef3ef 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableButton::DrawableButton (const String& name, const DrawableButton::ButtonStyle buttonStyle) : Button (name), style (buttonStyle) { @@ -219,3 +222,5 @@ Drawable* DrawableButton::getDownImage() const noexcept return getOverImage(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/modules/juce_gui_basics/buttons/juce_DrawableButton.h index 44124c2b58..8e261373c9 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DrawableButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp index 5d76c4310a..acafad1ac8 100644 --- a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + HyperlinkButton::HyperlinkButton (const String& linkText, const URL& linkURL) : Button (linkText), @@ -109,3 +112,5 @@ void HyperlinkButton::paintButton (Graphics& g, justification.getOnlyHorizontalFlags() | Justification::verticallyCentred, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h index 746dd4e284..1b67e17d08 100644 --- a/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h +++ b/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -111,3 +111,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HyperlinkButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ImageButton.cpp b/modules/juce_gui_basics/buttons/juce_ImageButton.cpp index 7bd3fb5f17..e89f5736d5 100644 --- a/modules/juce_gui_basics/buttons/juce_ImageButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ImageButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageButton::ImageButton (const String& text_) : Button (text_), scaleImageToFit (true), @@ -192,3 +195,5 @@ bool ImageButton::hitTest (int x, int y) && alphaThreshold < im.getPixelAt (((x - imageBounds.getX()) * im.getWidth()) / imageBounds.getWidth(), ((y - imageBounds.getY()) * im.getHeight()) / imageBounds.getHeight()).getAlpha()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ImageButton.h b/modules/juce_gui_basics/buttons/juce_ImageButton.h index d24de290ce..c867973d7c 100644 --- a/modules/juce_gui_basics/buttons/juce_ImageButton.h +++ b/modules/juce_gui_basics/buttons/juce_ImageButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -156,3 +156,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index 733b1a41e6..3e7f91a59d 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ShapeButton::ShapeButton (const String& t, Colour n, Colour o, Colour d) : Button (t), normalColour (n), overColour (o), downColour (d), @@ -129,3 +132,5 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto g.strokePath (shape, PathStrokeType (outlineWidth), trans); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.h b/modules/juce_gui_basics/buttons/juce_ShapeButton.h index 60372a3bf0..193d886fd4 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.h +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -121,3 +121,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_TextButton.cpp b/modules/juce_gui_basics/buttons/juce_TextButton.cpp index 59e80696de..d7d4fb46cd 100644 --- a/modules/juce_gui_basics/buttons/juce_TextButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_TextButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TextButton::TextButton() : Button (String()) { } @@ -71,3 +74,5 @@ int TextButton::getBestWidthForHeight (int buttonHeight) { return getLookAndFeel().getTextButtonWidthToFitText (*this, buttonHeight); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_TextButton.h b/modules/juce_gui_basics/buttons/juce_TextButton.h index b5f6d346ba..1631af52cb 100644 --- a/modules/juce_gui_basics/buttons/juce_TextButton.h +++ b/modules/juce_gui_basics/buttons/juce_TextButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp index a9a3c84f99..a43e45d1e7 100644 --- a/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToggleButton::ToggleButton() : Button (String()) { @@ -54,3 +57,5 @@ void ToggleButton::colourChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToggleButton.h b/modules/juce_gui_basics/buttons/juce_ToggleButton.h index 500946ec61..afe3dcf2aa 100644 --- a/modules/juce_gui_basics/buttons/juce_ToggleButton.h +++ b/modules/juce_gui_basics/buttons/juce_ToggleButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp index e09bd913ac..d4f60ac8c0 100644 --- a/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarButton::ToolbarButton (const int iid, const String& buttonText, Drawable* const normalIm, Drawable* const toggledOnIm) : ToolbarItemComponent (iid, buttonText, true), @@ -107,3 +110,5 @@ void ToolbarButton::buttonStateChanged() { setCurrentImage (getImageToUse()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/buttons/juce_ToolbarButton.h b/modules/juce_gui_basics/buttons/juce_ToolbarButton.h index 20a4322bc6..ce2190e038 100644 --- a/modules/juce_gui_basics/buttons/juce_ToolbarButton.h +++ b/modules/juce_gui_basics/buttons/juce_ToolbarButton.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -93,3 +93,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h index 65c3e4b705..cae26668d5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A type used to hold the unique ID for an application command. @@ -87,3 +87,5 @@ namespace StandardApplicationCommandIDs redo = 0x1009 }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp index 388113d6c6..6599fdd9f5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationCommandInfo::ApplicationCommandInfo (const CommandID cid) noexcept : commandID (cid), flags (0) { @@ -60,3 +63,5 @@ void ApplicationCommandInfo::addDefaultKeypress (const int keyCode, ModifierKeys { defaultKeypresses.add (KeyPress (keyCode, modifiers, 0)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h index c6cb9927ee..63358df6a5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -185,3 +185,5 @@ struct JUCE_API ApplicationCommandInfo */ int flags; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 7379a9b48b..acd785a369 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ApplicationCommandManager::ApplicationCommandManager() : firstTarget (nullptr) { @@ -312,3 +315,5 @@ void ApplicationCommandManager::globalFocusChanged (Component*) { commandStatusChanged(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 9baf3da991..396002134b 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -348,3 +348,5 @@ public: */ virtual void applicationCommandListChanged() = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp index fa25e12444..17cd9a0a56 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ApplicationCommandTarget::CommandMessage : public MessageManager::MessageBase { public: @@ -186,3 +189,5 @@ ApplicationCommandTarget::InvocationInfo::InvocationInfo (const CommandID comman millisecsSinceKeyPressed (0) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h index f37414180f..bec7308406 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -241,3 +241,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationCommandTarget) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp index 2293d58351..0a0232843b 100644 --- a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp +++ b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager& cm) : commandManager (cm) { @@ -412,3 +415,5 @@ void KeyPressMappingSet::globalFocusChanged (Component* focusedComponent) if (focusedComponent != nullptr) focusedComponent->keyStateChanged (false); } + +} // namespace juce diff --git a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index 75e3ca5f3f..d850739bfa 100644 --- a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -241,3 +241,5 @@ private: KeyPressMappingSet& operator= (const KeyPressMappingSet&); JUCE_LEAK_DETECTOR (KeyPressMappingSet) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_CachedComponentImage.h b/modules/juce_gui_basics/components/juce_CachedComponentImage.h index fda4f550ee..7e2b5485d7 100644 --- a/modules/juce_gui_basics/components/juce_CachedComponentImage.h +++ b/modules/juce_gui_basics/components/juce_CachedComponentImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -67,3 +67,5 @@ public: */ virtual void releaseResources() = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index cdd9d634fc..d69a2bbf73 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Component* Component::currentlyFocusedComponent = nullptr; @@ -3039,3 +3042,5 @@ bool Component::BailOutChecker::shouldBailOut() const noexcept { return safePointer == nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 961609dee2..9c9c55a566 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -2372,3 +2372,5 @@ protected: virtual ComponentPeer* createNewPeer (int styleFlags, void* nativeWindowToAttachTo); #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ComponentListener.cpp b/modules/juce_gui_basics/components/juce_ComponentListener.cpp index 0c45b3f300..4f27a5109b 100644 --- a/modules/juce_gui_basics/components/juce_ComponentListener.cpp +++ b/modules/juce_gui_basics/components/juce_ComponentListener.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void ComponentListener::componentMovedOrResized (Component&, bool, bool) {} void ComponentListener::componentBroughtToFront (Component&) {} void ComponentListener::componentVisibilityChanged (Component&) {} @@ -31,3 +34,5 @@ void ComponentListener::componentChildrenChanged (Component&) {} void ComponentListener::componentParentHierarchyChanged (Component&) {} void ComponentListener::componentNameChanged (Component&) {} void ComponentListener::componentBeingDeleted (Component&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ComponentListener.h b/modules/juce_gui_basics/components/juce_ComponentListener.h index 9c24fb1b59..cc657b83a3 100644 --- a/modules/juce_gui_basics/components/juce_ComponentListener.h +++ b/modules/juce_gui_basics/components/juce_ComponentListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ public: */ virtual void componentBeingDeleted (Component& component); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 9317213fe2..edaf72f98b 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Desktop::Desktop() : mouseSources (new MouseInputSource::SourceList()), mouseClickCounter (0), mouseWheelCounter (0), @@ -425,3 +428,5 @@ void Desktop::setGlobalScaleFactor (float newScaleFactor) noexcept displays->refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index 502ca0fd97..a7486bfc7b 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -470,3 +470,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Desktop) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index d0cbb13f5b..b08f24014b 100644 --- a/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ModalComponentManager::ModalItem : public ComponentMovementWatcher { public: @@ -311,3 +314,5 @@ ModalComponentManager::Callback* ModalCallbackFunction::create (std::function(), Point (100.0f, 0.0f), Point (0.0f, 100.0f)) { @@ -327,3 +330,5 @@ Path DrawableComposite::getOutlineAsPath() const p.applyTransform (getTransform()); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableComposite.h b/modules/juce_gui_basics/drawables/juce_DrawableComposite.h index 00217e4f9c..b98bb62375 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableComposite.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableComposite.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -159,3 +159,5 @@ private: DrawableComposite& operator= (const DrawableComposite&); JUCE_LEAK_DETECTOR (DrawableComposite) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp b/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp index c8f1770955..c7675afce2 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableImage::DrawableImage() : opacity (1.0f), overlayColour (0x00000000) @@ -295,3 +298,5 @@ Path DrawableImage::getOutlineAsPath() const { return {}; // not applicable for images } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableImage.h b/modules/juce_gui_basics/drawables/juce_DrawableImage.h index 818012e444..d1277174ab 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableImage.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -136,3 +136,5 @@ private: DrawableImage& operator= (const DrawableImage&); JUCE_LEAK_DETECTOR (DrawableImage) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 975a053851..a581e980f4 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawablePath::DrawablePath() { } @@ -570,3 +573,5 @@ ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* imageP return tree; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.h b/modules/juce_gui_basics/drawables/juce_DrawablePath.h index 1dd33f7aee..66254d44c0 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.h +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -141,3 +141,5 @@ private: DrawablePath& operator= (const DrawablePath&); JUCE_LEAK_DETECTOR (DrawablePath) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp index 4bd0c70ecf..52a24ecd92 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableRectangle::DrawableRectangle() { } @@ -183,3 +186,5 @@ ValueTree DrawableRectangle::createValueTree (ComponentBuilder::ImageProvider* i return tree; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h index f34e77b794..fbb3f77ccb 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -99,3 +99,5 @@ private: DrawableRectangle& operator= (const DrawableRectangle&); JUCE_LEAK_DETECTOR (DrawableRectangle) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp index 9c23c44a7c..e93130a71a 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableShape::DrawableShape() : strokeType (0.0f), mainFill (Colours::black), @@ -496,3 +499,5 @@ Path DrawableShape::getOutlineAsPath() const outline.applyTransform (getTransform()); return outline; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableShape.h b/modules/juce_gui_basics/drawables/juce_DrawableShape.h index 2cb7e3712a..10a89dd1d9 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableShape.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableShape.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: DrawableShape& operator= (const DrawableShape&); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableText.cpp b/modules/juce_gui_basics/drawables/juce_DrawableText.cpp index 3bfddce9d7..de6d7c2a2c 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableText.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawableText.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DrawableText::DrawableText() : colour (Colours::black), justification (Justification::centredLeft) @@ -372,3 +375,5 @@ Path DrawableText::getOutlineAsPath() const return pathOfAllGlyphs; } + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_DrawableText.h b/modules/juce_gui_basics/drawables/juce_DrawableText.h index 1033b0b665..637659ed8d 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawableText.h +++ b/modules/juce_gui_basics/drawables/juce_DrawableText.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -155,3 +155,5 @@ private: DrawableText& operator= (const DrawableText&); JUCE_LEAK_DETECTOR (DrawableText) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 3f71281009..a2aaef12da 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class SVGState { public: @@ -1728,3 +1731,5 @@ Path Drawable::parseSVGPath (const String& svgPath) state.parsePathString (p, svgPath); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp index 5e9268fe94..b83d356253 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& l) : directoryContentsList (l) { @@ -64,3 +67,5 @@ void DirectoryContentsDisplayComponent::sendDoubleClickMessage (const File& file listeners.callChecked (checker, &FileBrowserListener::fileDoubleClicked, file); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h index 77279ed5a2..d01427f682 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -110,3 +110,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsDisplayComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 27a32cfa37..7db6e282ce 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DirectoryContentsList::DirectoryContentsList (const FileFilter* f, TimeSliceThread& t) : fileFilter (f), thread (t), fileTypeFlags (File::ignoreHiddenFiles | File::findFiles), @@ -258,3 +261,5 @@ bool DirectoryContentsList::addFile (const File& file, const bool isDir, return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h index 33e062ff7a..50877c395b 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsList) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index c7030fb88f..eb367095ba 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileBrowserComponent::FileBrowserComponent (int flags_, const File& initialFileOrDirectory, const FileFilter* fileFilter_, @@ -606,3 +609,5 @@ void FileBrowserComponent::timerCallback() refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index eb26c52556..148adeaebc 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -285,3 +285,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBrowserComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h index fe7776bcaf..45506a19d4 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -53,3 +53,5 @@ public: /** Callback when the browser's root folder changes. */ virtual void browserRootChanged (const File& newRoot) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 0e3995c757..024bafead1 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileChooser::FileChooser (const String& chooserBoxTitle, const File& currentFileOrDirectory, const String& fileFilters, @@ -150,3 +153,5 @@ File FileChooser::getResult() const //============================================================================== FilePreviewComponent::FilePreviewComponent() {} FilePreviewComponent::~FilePreviewComponent() {} + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h index 82a31abb56..4584acc659 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooser.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooser) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 642860daf3..22de557db7 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class FileChooserDialogBox::ContentComponent : public Component { public: @@ -269,3 +272,5 @@ void FileChooserDialogBox::createNewFolderConfirmed (const String& nameFromDialo content->chooserComponent.refresh(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h index feb82bdeaa..0ccd01df29 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -153,3 +153,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooserDialogBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index 4e201007c4..65fc283103 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File& file); @@ -255,3 +258,5 @@ void FileListComponent::returnKeyPressed (int currentSelectedRow) { sendDoubleClickMessage (directoryContentsList.getFile (currentSelectedRow)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h index 3dbf93efc7..770e666c20 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -89,3 +89,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileListComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h b/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h index 74e99c6e2c..4781531371 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -61,3 +61,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilePreviewComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp index 0bee475fc3..e74e7f769c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileSearchPathListComponent::FileSearchPathListComponent() : addButton ("+"), removeButton ("-"), @@ -266,3 +269,5 @@ void FileSearchPathListComponent::buttonClicked (Button* button) changed(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h index 5119d96782..07c285378f 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -112,3 +112,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 15bc43a44a..febfba3685 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File&); //============================================================================== @@ -321,3 +324,5 @@ void FileTreeComponent::setItemHeight (int newHeight) root->treeHasChanged(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index 46d2b21097..1a9a6cf2f3 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -100,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index fee3d6c964..11b718fd31 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FilenameComponent::FilenameComponent (const String& name, const File& currentFile, const bool canEditFilename, @@ -268,3 +271,5 @@ void FilenameComponent::handleAsyncUpdate() Component::BailOutChecker checker (this); listeners.callChecked (checker, &FilenameComponentListener::filenameComponentChanged, this); } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h index d3768f738f..72706db6d3 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -229,3 +229,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilenameComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp index c1d3e699d9..0de138337c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImagePreviewComponent::ImagePreviewComponent() { } @@ -114,3 +117,5 @@ void ImagePreviewComponent::paint (Graphics& g) Justification::centredTop, numLines); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h index 0af35fefd0..df96266468 100644 --- a/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -62,3 +62,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImagePreviewComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index d9afd8d114..491db1199e 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -133,16 +133,16 @@ #include //============================================================================== -namespace juce -{ - #define ASSERT_MESSAGE_MANAGER_IS_LOCKED \ jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); #define ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager() || getPeer() == nullptr); -extern bool juce_areThereAnyAlwaysOnTopWindows(); +namespace juce +{ + extern bool juce_areThereAnyAlwaysOnTopWindows(); +} #include "components/juce_Component.cpp" #include "components/juce_ComponentListener.cpp" @@ -259,10 +259,12 @@ extern bool juce_areThereAnyAlwaysOnTopWindows(); // these classes are C++11-only #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS #include "layout/juce_FlexBox.cpp" - #include "layout/juce_GridItem.cpp" - #include "layout/juce_Grid.cpp" - #if JUCE_UNIT_TESTS - #include "layout/juce_GridUnitTests.cpp" + #if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.cpp" + #include "layout/juce_Grid.cpp" + #if JUCE_UNIT_TESTS + #include "layout/juce_GridUnitTests.cpp" + #endif #endif #endif @@ -309,5 +311,3 @@ extern bool juce_areThereAnyAlwaysOnTopWindows(); #include "native/juce_android_FileChooser.cpp" #endif - -} diff --git a/modules/juce_gui_basics/juce_gui_basics.h b/modules/juce_gui_basics/juce_gui_basics.h index e3782c293a..cc8dc1016d 100644 --- a/modules/juce_gui_basics/juce_gui_basics.h +++ b/modules/juce_gui_basics/juce_gui_basics.h @@ -35,7 +35,7 @@ ID: juce_gui_basics vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE GUI core classes description: Basic user-interface components and related classes. website: http://www.juce.com/juce @@ -112,52 +112,55 @@ //============================================================================== namespace juce { - -class Component; -class LookAndFeel; -class MouseInputSource; -class MouseInputSourceInternal; -class ComponentPeer; -class MarkerList; -class RelativeRectangle; -class MouseEvent; -struct MouseWheelDetails; -struct PenDetails; -class ToggleButton; -class TextButton; -class AlertWindow; -class TextLayout; -class ScrollBar; -class ComboBox; -class Button; -class FilenameComponent; -class DocumentWindow; -class ResizableWindow; -class GroupComponent; -class MenuBarComponent; -class DropShadower; -class GlyphArrangement; -class PropertyComponent; -class TableHeaderComponent; -class Toolbar; -class ToolbarItemComponent; -class PopupMenu; -class ProgressBar; -class FileBrowserComponent; -class DirectoryContentsDisplayComponent; -class FilePreviewComponent; -class ImageButton; -class CallOutBox; -class Drawable; -class DrawablePath; -class DrawableComposite; -class CaretComponent; -class BubbleComponent; -class KeyPressMappingSet; -class ApplicationCommandManagerListener; -class DrawableButton; -class FlexBox; -class Grid; + class Component; + class LookAndFeel; + class MouseInputSource; + class MouseInputSourceInternal; + class ComponentPeer; + class MarkerList; + class RelativeRectangle; + class MouseEvent; + struct MouseWheelDetails; + struct PenDetails; + class ToggleButton; + class TextButton; + class AlertWindow; + class TextLayout; + class ScrollBar; + class ComboBox; + class Button; + class FilenameComponent; + class DocumentWindow; + class ResizableWindow; + class GroupComponent; + class MenuBarComponent; + class DropShadower; + class GlyphArrangement; + class PropertyComponent; + class TableHeaderComponent; + class Toolbar; + class ToolbarItemComponent; + class PopupMenu; + class ProgressBar; + class FileBrowserComponent; + class DirectoryContentsDisplayComponent; + class FilePreviewComponent; + class ImageButton; + class CallOutBox; + class Drawable; + class DrawablePath; + class DrawableComposite; + class CaretComponent; + class BubbleComponent; + class KeyPressMappingSet; + class ApplicationCommandManagerListener; + class DrawableButton; + + #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS + class FlexBox; + class Grid; + #endif +} #include "mouse/juce_MouseCursor.h" #include "mouse/juce_MouseListener.h" @@ -293,16 +296,11 @@ class Grid; // these classes are C++11-only #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS -#include "layout/juce_FlexItem.h" -#include "layout/juce_FlexBox.h" -#include "layout/juce_GridItem.h" -#include "layout/juce_Grid.h" - -constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; } -constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; } - -constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; } + #include "layout/juce_FlexItem.h" + #include "layout/juce_FlexBox.h" + #if JUCE_HAS_CONSTEXPR + #include "layout/juce_GridItem.h" + #include "layout/juce_Grid.h" + #endif #endif - -} diff --git a/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp b/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp index fce9c35bc3..c1e0d1e931 100644 --- a/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp +++ b/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + CaretComponent::CaretComponent (Component* const keyFocusOwner) : owner (keyFocusOwner) { @@ -58,3 +61,5 @@ bool CaretComponent::shouldBeShown() const return owner == nullptr || (owner->hasKeyboardFocus (false) && ! owner->isCurrentlyBlockedByAnotherModalComponent()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h index acee48a28e..b21cc7b5c3 100644 --- a/modules/juce_gui_basics/keyboard/juce_CaretComponent.h +++ b/modules/juce_gui_basics/keyboard/juce_CaretComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ private: JUCE_DECLARE_NON_COPYABLE (CaretComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp b/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp index 38e9de545e..43c5bdb7a9 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp @@ -24,7 +24,12 @@ ============================================================================== */ +namespace juce +{ + bool KeyListener::keyStateChanged (const bool, Component*) { return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyListener.h b/modules/juce_gui_basics/keyboard/juce_KeyListener.h index 1dc7b10cbd..f3cc762102 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyListener.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ public: */ virtual bool keyStateChanged (bool isKeyDown, Component* originatingComponent); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index 8f407972ba..eec2a85bc9 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + KeyPress::KeyPress() noexcept : keyCode (0), textCharacter (0) { @@ -269,7 +272,10 @@ String KeyPress::getTextDescription() const if (keyCode == KeyPressHelpers::translations[i].code) return desc + KeyPressHelpers::translations[i].name; - if (keyCode >= F1Key && keyCode <= F16Key) desc << 'F' << (1 + keyCode - F1Key); + // not all F keys have consecutive key codes on all platforms + if (keyCode >= F1Key && keyCode <= F16Key) desc << 'F' << (1 + keyCode - F1Key); + else if (keyCode >= F17Key && keyCode <= F24Key) desc << 'F' << (17 + keyCode - F17Key); + else if (keyCode >= F25Key && keyCode <= F35Key) desc << 'F' << (25 + keyCode - F25Key); else if (keyCode >= numberPad0 && keyCode <= numberPad9) desc << KeyPressHelpers::numberPadPrefix() << (keyCode - numberPad0); else if (keyCode >= 33 && keyCode < 176) desc += CharacterFunctions::toUpperCase ((juce_wchar) keyCode); else if (keyCode == numberPadAdd) desc << KeyPressHelpers::numberPadPrefix() << '+'; @@ -299,3 +305,5 @@ String KeyPress::getTextDescriptionWithIcons() const return getTextDescription(); #endif } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 420a869fb2..5f0300485d 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyPress.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -216,6 +216,25 @@ public: static const int F14Key; /**< key-code for the F14 key */ static const int F15Key; /**< key-code for the F15 key */ static const int F16Key; /**< key-code for the F16 key */ + static const int F17Key; /**< key-code for the F17 key */ + static const int F18Key; /**< key-code for the F18 key */ + static const int F19Key; /**< key-code for the F19 key */ + static const int F20Key; /**< key-code for the F20 key */ + static const int F21Key; /**< key-code for the F21 key */ + static const int F22Key; /**< key-code for the F22 key */ + static const int F23Key; /**< key-code for the F23 key */ + static const int F24Key; /**< key-code for the F24 key */ + static const int F25Key; /**< key-code for the F25 key */ + static const int F26Key; /**< key-code for the F26 key */ + static const int F27Key; /**< key-code for the F27 key */ + static const int F28Key; /**< key-code for the F28 key */ + static const int F29Key; /**< key-code for the F29 key */ + static const int F30Key; /**< key-code for the F30 key */ + static const int F31Key; /**< key-code for the F31 key */ + static const int F32Key; /**< key-code for the F32 key */ + static const int F33Key; /**< key-code for the F33 key */ + static const int F34Key; /**< key-code for the F34 key */ + static const int F35Key; /**< key-code for the F35 key */ static const int numberPad0; /**< key-code for the 0 on the numeric keypad. */ static const int numberPad1; /**< key-code for the 1 on the numeric keypad. */ @@ -250,3 +269,5 @@ private: JUCE_LEAK_DETECTOR (KeyPress) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index 13afbd4027..7ca108be03 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace KeyboardFocusHelpers { // This will sort a set of components, so that they are ordered in terms of @@ -127,3 +130,5 @@ Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentCompone return comps.getFirst(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h index 856677cc7e..c6d88f0c48 100644 --- a/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h +++ b/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,3 +85,5 @@ public: */ virtual Component* getDefaultComponent (Component* parentComponent); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp index 7fbb587429..5133ed23c6 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ModifierKeys::ModifierKeys() noexcept : flags (0) {} ModifierKeys::ModifierKeys (int rawFlags) noexcept : flags (rawFlags) {} ModifierKeys::ModifierKeys (const ModifierKeys& other) noexcept : flags (other.flags) {} @@ -51,3 +54,5 @@ int ModifierKeys::getNumMouseButtonsDown() const noexcept return num; } + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 3337b9adb4..61c02604b3 100644 --- a/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: static ModifierKeys currentModifiers; static void updateCurrentModifiers() noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h b/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h index dbe6bdabd2..b00135dbaf 100644 --- a/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h +++ b/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -44,3 +44,5 @@ public: */ static String getTextFromClipboard(); }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h index e8fd74f96f..05594ac45d 100644 --- a/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h +++ b/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** This class is used to invoke a range of text-editor navigation methods on @@ -118,3 +118,5 @@ struct TextEditorKeyMapper return false; } }; + +} // namespace juce diff --git a/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h b/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h index e63a84a613..9d198be134 100644 --- a/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h +++ b/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -91,3 +91,5 @@ public: */ virtual VirtualKeyboardType getKeyboardType() { return textKeyboard; } }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPosition.h b/modules/juce_gui_basics/layout/juce_AnimatedPosition.h index 7f75916fd1..7b4b320f4e 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPosition.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPosition.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -205,3 +205,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedPosition) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index e29bc73ccd..3be77da9be 100644 --- a/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Contains classes for different types of physics behaviours - these classes @@ -56,6 +56,13 @@ namespace AnimatedPositionBehaviours damping = 1.0 - newFriction; } + /** Sets the minimum velocity of the movement. Any velocity that's slower than + this will stop the animation. The default is 0.05. */ + void setMinimumVelocity (double newMinimumVelocityToUse) noexcept + { + minimumVelocity = newMinimumVelocityToUse; + } + /** Called by the AnimatedPosition class. This tells us the position and velocity at which the user is about to release the object. The velocity is measured in units/second. @@ -72,7 +79,7 @@ namespace AnimatedPositionBehaviours { velocity *= damping; - if (std::abs (velocity) < 0.05) + if (std::abs (velocity) < minimumVelocity) velocity = 0; return oldPos + velocity * elapsedSeconds; @@ -87,7 +94,7 @@ namespace AnimatedPositionBehaviours } private: - double velocity = 0, damping = 0.92; + double velocity = 0, damping = 0.92, minimumVelocity = 0.05; }; //============================================================================== @@ -146,3 +153,5 @@ namespace AnimatedPositionBehaviours double targetSnapPosition; }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index d322f4ae91..936660d221 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ComponentAnimator::AnimationTask { public: @@ -345,3 +348,5 @@ void ComponentAnimator::timerCallback() if (tasks.size() == 0) stopTimer(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index 5a9441b7c6..85fdb1e775 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -157,3 +157,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentAnimator) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp index b34240c575..158cbe61f2 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentBoundsConstrainer::ComponentBoundsConstrainer() noexcept {} ComponentBoundsConstrainer::~ComponentBoundsConstrainer() {} @@ -290,3 +293,5 @@ void ComponentBoundsConstrainer::checkBounds (Rectangle& bounds, jassert (! bounds.isEmpty()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h index e9d0a94937..16b8a44269 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h +++ b/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -192,3 +192,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentBoundsConstrainer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index bd5b6c52db..f735f35efa 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace ComponentBuilderHelpers { static String getStateId (const ValueTree& state) @@ -281,3 +284,5 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree componentsInOrder.getUnchecked(i)->toBehind (componentsInOrder.getUnchecked (i + 1)); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index fc389b68a7..8d8d7debfd 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -242,3 +242,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentBuilder) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp index c42f004b32..6e5cfe94e3 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentMovementWatcher::ComponentMovementWatcher (Component* const comp) : component (comp), lastPeerID (0), @@ -139,3 +142,5 @@ void ComponentMovementWatcher::unregister() registeredParentComps.clear(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h index 0a1c55bd9f..583ae4e32f 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h +++ b/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** An object that watches for any movement of a component or any of its parent components. @@ -91,3 +91,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentMovementWatcher) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index 175699812e..f5dad1d1b1 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct ConcertinaPanel::PanelSizes { struct Panel @@ -451,3 +454,5 @@ void ConcertinaPanel::panelHeaderDoubleClicked (Component* component) if (! expandPanelFully (component, true)) setPanelSize (component, 0, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h index 4670fd2ed6..aea9dbff62 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -141,3 +141,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ConcertinaPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index bdaaea8060..d647b15a3c 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct FlexBoxLayoutCalculation { using Coord = double; @@ -844,10 +847,12 @@ FlexItem FlexItem::withWidth (float newWidth) const noexcept { auto fi = FlexItem FlexItem::withMinWidth (float newMinWidth) const noexcept { auto fi = *this; fi.minWidth = newMinWidth; return fi; } FlexItem FlexItem::withMaxWidth (float newMaxWidth) const noexcept { auto fi = *this; fi.maxWidth = newMaxWidth; return fi; } -FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; }; -FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; }; +FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; } +FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; } FlexItem FlexItem::withHeight (float newHeight) const noexcept { auto fi = *this; fi.height = newHeight; return fi; } FlexItem FlexItem::withMargin (Margin m) const noexcept { auto fi = *this; fi.margin = m; return fi; } FlexItem FlexItem::withOrder (int newOrder) const noexcept { auto fi = *this; fi.order = newOrder; return fi; } FlexItem FlexItem::withAlignSelf (AlignSelf a) const noexcept { auto fi = *this; fi.alignSelf = a; return fi; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.h b/modules/juce_gui_basics/layout/juce_FlexBox.h index 35b26e9fdf..b2c3e0929d 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.h +++ b/modules/juce_gui_basics/layout/juce_FlexBox.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Represents a FlexBox container, which contains and manages the layout of a set @@ -102,3 +104,5 @@ public: private: JUCE_LEAK_DETECTOR (FlexBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_FlexItem.h b/modules/juce_gui_basics/layout/juce_FlexItem.h index 3565c98990..b52c3b6f48 100644 --- a/modules/juce_gui_basics/layout/juce_FlexItem.h +++ b/modules/juce_gui_basics/layout/juce_FlexItem.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Describes the properties of an item inside a FlexBox container. @@ -161,3 +163,5 @@ public: /** Returns a copy of this object with a new alignSelf value. */ FlexItem withAlignSelf (AlignSelf newAlignSelf) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Grid.cpp b/modules/juce_gui_basics/layout/juce_Grid.cpp index f3c97ec303..74338d1d3a 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.cpp +++ b/modules/juce_gui_basics/layout/juce_Grid.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ struct Grid::SizeCalculation { @@ -1023,3 +1025,5 @@ void Grid::performLayout (juce::Rectangle targetArea) c->setBounds (item->currentBounds.toNearestInt()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Grid.h b/modules/juce_gui_basics/layout/juce_Grid.h index 21d8cdbd42..bf8d8fd7d4 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.h +++ b/modules/juce_gui_basics/layout/juce_Grid.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Container that handles geometry for grid layouts (fixed columns and rows) using a set of declarative rules. @@ -172,3 +174,9 @@ private: struct AutoPlacement; struct BoxAlignment; }; + +constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; } +constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; } +constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridItem.cpp b/modules/juce_gui_basics/layout/juce_GridItem.cpp index 63101d9aa2..72088fb70b 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.cpp +++ b/modules/juce_gui_basics/layout/juce_GridItem.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ GridItem::Property::Property() noexcept : isAuto (true) { @@ -180,3 +182,5 @@ GridItem GridItem::withOrder (int newOrder) const noexcept gi.order = newOrder; return gi; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridItem.h b/modules/juce_gui_basics/layout/juce_GridItem.h index e529079465..f57ab79810 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.h +++ b/modules/juce_gui_basics/layout/juce_GridItem.h @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ /** Defines an item in a Grid @@ -221,3 +223,5 @@ public: /** Returns a copy of this object with a new order. */ GridItem withOrder (int newOrder) const noexcept; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp b/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp index 52ccda6bd9..99084d0993 100644 --- a/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp +++ b/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct GridTests : public juce::UnitTest { GridTests() : juce::UnitTest ("Grid class") {} @@ -255,3 +258,5 @@ struct GridTests : public juce::UnitTest }; static GridTests gridUnitTests; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GroupComponent.cpp b/modules/juce_gui_basics/layout/juce_GroupComponent.cpp index 172d3d7ef2..c632377069 100644 --- a/modules/juce_gui_basics/layout/juce_GroupComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_GroupComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + GroupComponent::GroupComponent (const String& name, const String& labelText) : Component (name), @@ -66,3 +69,5 @@ void GroupComponent::paint (Graphics& g) void GroupComponent::enablementChanged() { repaint(); } void GroupComponent::colourChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_GroupComponent.h b/modules/juce_gui_basics/layout/juce_GroupComponent.h index f8f3a2f05d..47ef9245db 100644 --- a/modules/juce_gui_basics/layout/juce_GroupComponent.h +++ b/modules/juce_gui_basics/layout/juce_GroupComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE (GroupComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index 65c7454200..94d0c88a91 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MultiDocumentPanelWindow::MultiDocumentPanelWindow (Colour backgroundColour) : DocumentWindow (String(), backgroundColour, DocumentWindow::maximiseButton | DocumentWindow::closeButton, false) @@ -507,3 +510,5 @@ void MultiDocumentPanel::updateOrder() if (components != oldList) activeDocumentChanged(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h index b55f3de30b..a19c37c14f 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class MultiDocumentPanel; @@ -300,3 +301,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiDocumentPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index ee4b1ee6bf..df67914306 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableBorderComponent::Zone::Zone() noexcept : zone (0) {} @@ -201,3 +204,5 @@ void ResizableBorderComponent::updateMouseZone (const MouseEvent& e) setMouseCursor (newZone.getMouseCursor()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 612fd26eb5..53ec37e166 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -191,3 +191,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableBorderComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp index 5e7ef095dc..7b3735cf06 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableCornerComponent::ResizableCornerComponent (Component* const componentToResize, ComponentBoundsConstrainer* const constrainer_) : component (componentToResize), @@ -99,3 +102,5 @@ bool ResizableCornerComponent::hitTest (int x, int y) return y >= yAtX - getHeight() / 4; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h index 14b36f22b6..ae1f8264c9 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A component that resizes a parent component when dragged. @@ -87,3 +87,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableCornerComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index 9c3a78d02b..a4c8441be2 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, ComponentBoundsConstrainer* const constrainer_, Edge edge_) @@ -107,3 +110,5 @@ void ResizableEdgeComponent::mouseUp (const MouseEvent&) if (constrainer != nullptr) constrainer->resizeEnd(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h index 4d8b45e266..2063375c8f 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -95,3 +95,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index e3aa126fdd..c84b71c126 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ScrollBar::ScrollbarButton : public Button { public: @@ -428,3 +431,5 @@ bool ScrollBar::keyPressed (const KeyPress& key) return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index f94e905c21..34996d6a8e 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -402,3 +402,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the ScrollBar::Listener class directly. */ typedef ScrollBar::Listener ScrollBarListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp index 64d2174714..75a52fa4f8 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableLayoutManager::StretchableLayoutManager() : totalSize (0) { @@ -342,3 +345,5 @@ int StretchableLayoutManager::sizeToRealSize (double size, int totalSpace) return roundToInt (size); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h index 2e86faaa96..e6b72ed40f 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -256,3 +256,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutManager) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp index c23baabe9b..dd009a7b81 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableLayoutResizerBar::StretchableLayoutResizerBar (StretchableLayoutManager* layout_, const int index, const bool vertical) @@ -73,3 +76,5 @@ void StretchableLayoutResizerBar::hasBeenMoved() if (Component* parent = getParentComponent()) parent->resized(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h index 87b18cfd2a..e1a20509f8 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h +++ b/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -100,3 +100,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp index 7fada6a5b3..bf56dea75a 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp +++ b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + StretchableObjectResizer::StretchableObjectResizer() {} StretchableObjectResizer::~StretchableObjectResizer() {} @@ -116,3 +119,5 @@ void StretchableObjectResizer::resizeToFit (const double targetSize) break; } } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h index c7e368fd06..32543b115f 100644 --- a/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h +++ b/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -97,3 +97,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableObjectResizer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 2e83ec0564..0031a1882d 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TabBarButton::TabBarButton (const String& name, TabbedButtonBar& owner_) : Button (name), owner (owner_), overlapPixels (0), extraCompPlacement (afterText) { @@ -585,3 +588,5 @@ void TabbedButtonBar::currentTabChanged (const int, const String&) void TabbedButtonBar::popupMenuClickOnTab (const int, const String&) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index cb46a0e332..a788408c93 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TabbedButtonBar; @@ -366,3 +367,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TabbedButtonBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 1e731df3df..d6349e32f1 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace TabbedComponentHelpers { const Identifier deleteComponentId ("deleteByTabComp_"); @@ -314,3 +317,5 @@ void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String void TabbedComponent::currentTabChanged (const int, const String&) {} void TabbedComponent::popupMenuClickOnTab (const int, const String&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.h b/modules/juce_gui_basics/layout/juce_TabbedComponent.h index 0dac8a02c1..f62846e656 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.h +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -221,3 +221,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TabbedComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index eae3b6bb52..a1f746aa12 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Viewport::Viewport (const String& name) : Component (name) { // content holder is used to clip the contents so they don't overlap the scrollbars @@ -191,6 +194,8 @@ struct Viewport::DragToScrollListener : private MouseListener, viewport.contentHolder.addMouseListener (this, true); offsetX.addListener (this); offsetY.addListener (this); + offsetX.behaviour.setMinimumVelocity (60); + offsetY.behaviour.setMinimumVelocity (60); } ~DragToScrollListener() @@ -209,6 +214,8 @@ struct Viewport::DragToScrollListener : private MouseListener, if (doesMouseEventComponentBlockViewportDrag (e.eventComponent)) isViewportDragBlocked = true; + offsetX.setPosition (offsetX.getPosition()); + offsetY.setPosition (offsetY.getPosition()); ++numTouches; } @@ -574,3 +581,5 @@ bool Viewport::respondsToKey (const KeyPress& key) { return isUpDownKeyPress (key) || isLeftRightKeyPress (key); } + +} // namespace juce diff --git a/modules/juce_gui_basics/layout/juce_Viewport.h b/modules/juce_gui_basics/layout/juce_Viewport.h index 7da6dfd272..32fe809b2e 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/modules/juce_gui_basics/layout/juce_Viewport.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -306,3 +306,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Viewport) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 4fd176651f..d2faffbaab 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + static Typeface::Ptr getTypefaceForFontFromLookAndFeel (const Font& font) { return LookAndFeel::getDefaultLookAndFeel().getTypefaceForFont (font); @@ -150,3 +152,5 @@ bool LookAndFeel::isUsingNativeAlertWindows() return useNativeAlertWindows; #endif } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 81267298a0..997180a517 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** This class is used to hold a few look and feel base classes which are associated @@ -229,3 +230,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp index d885965656..837bdfb11b 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LookAndFeel_V1::LookAndFeel_V1() { setColour (TextButton::buttonColourId, Colour (0xffbbbbff)); @@ -567,3 +570,5 @@ void LookAndFeel_V1::positionDocumentWindowButtons (DocumentWindow&, if (minimiseButton != nullptr) minimiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h index f9f7089403..45950042d1 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -97,3 +98,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V1) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 4622efd7b4..14510a9003 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace LookAndFeelHelpers { static Colour createBaseColour (Colour buttonColour, @@ -3018,3 +3021,5 @@ void LookAndFeel_V2::drawGlassLozenge (Graphics& g, g.setColour (colour.darker().withMultipliedAlpha (1.5f)); g.strokePath (outline, PathStrokeType (outlineThickness)); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h index 268f22a6d7..af0b365888 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -373,3 +373,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V2) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index b0090d8e31..25dffe0b29 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + LookAndFeel_V3::LookAndFeel_V3() { setColour (TreeView::selectedItemBackgroundColourId, Colour (0x301111ee)); @@ -637,3 +640,5 @@ Path LookAndFeel_V3::getCrossShape (const float height) p.scaleToFit (0, 0, height * 2.0f, height, true); return p; } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h index dc0be9ca5c..7a3bdcb4d8 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -92,3 +93,5 @@ private: Image backgroundTexture; Colour backgroundTextureBaseColour; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 29facbd2ba..6e23eb0fc2 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ Colour LookAndFeel_V4::ColourScheme::getUIColour (UIColour index) const noexcept { @@ -470,10 +472,12 @@ void LookAndFeel_V4::drawProgressBar (Graphics& g, ProgressBar& progressBar, if (width == height) drawCircularProgressBar (g, progressBar, textToShow); else - drawLinearProgressBar (g, progressBar, width, height, progress); + drawLinearProgressBar (g, progressBar, width, height, progress, textToShow); } -void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBar, int width, int height, double progress) +void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBar, + int width, int height, + double progress, const String& textToShow) { const auto background = progressBar.findColour (ProgressBar::backgroundColourId); const auto foreground = progressBar.findColour (ProgressBar::foregroundColourId); @@ -520,6 +524,14 @@ void LookAndFeel_V4::drawLinearProgressBar (Graphics& g, ProgressBar& progressBa g.setTiledImageFill (im, 0, 0, 0.85f); g.fillPath (p); } + + if (textToShow.isNotEmpty()) + { + g.setColour (Colour::contrasting (background, foreground)); + g.setFont (height * 0.6f); + + g.drawText (textToShow, 0, 0, width, height, Justification::centred, false); + } } void LookAndFeel_V4::drawCircularProgressBar (Graphics& g, ProgressBar& progressBar, const String& progressText) @@ -942,8 +954,8 @@ void LookAndFeel_V4::drawLinearSlider (Graphics& g, int x, int y, int width, int const auto trackWidth = jmin (6.0f, slider.isHorizontal() ? height * 0.25f : width * 0.25f); - const Point startPoint (slider.isHorizontal() ? x : width * 0.5f, - slider.isHorizontal() ? height * 0.5f : height + y); + const Point startPoint (slider.isHorizontal() ? x : x + width * 0.5f, + slider.isHorizontal() ? y + height * 0.5f : height + y); const Point endPoint (slider.isHorizontal() ? width + x : startPoint.x, slider.isHorizontal() ? startPoint.y : y); @@ -1293,7 +1305,7 @@ void LookAndFeel_V4::initialiseColours() TextEditor::backgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), TextEditor::textColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), - TextEditor::highlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + TextEditor::highlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), TextEditor::highlightedTextColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedText).getARGB(), TextEditor::outlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), TextEditor::focusedOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), @@ -1350,7 +1362,7 @@ void LookAndFeel_V4::initialiseColours() Slider::rotarySliderOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), Slider::textBoxTextColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), Slider::textBoxBackgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).withAlpha (0.0f).getARGB(), - Slider::textBoxHighlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + Slider::textBoxHighlightColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), Slider::textBoxOutlineColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::outline).getARGB(), ResizableWindow::backgroundColourId, currentColourScheme.getUIColour (ColourScheme::UIColour::windowBackground).getARGB(), @@ -1410,7 +1422,7 @@ void LookAndFeel_V4::initialiseColours() 0x1005008, /*MidiKeyboardComponent::shadowColourId*/ 0x4c000000, 0x1004500, /*CodeEditorComponent::backgroundColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::widgetBackground).getARGB(), - 0x1004502, /*CodeEditorComponent::highlightColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).getARGB(), + 0x1004502, /*CodeEditorComponent::highlightColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).withAlpha (0.4f).getARGB(), 0x1004503, /*CodeEditorComponent::defaultTextColourId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultText).getARGB(), 0x1004504, /*CodeEditorComponent::lineNumberBackgroundId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::highlightedFill).withAlpha (0.5f).getARGB(), 0x1004505, /*CodeEditorComponent::lineNumberTextId*/ currentColourScheme.getUIColour (ColourScheme::UIColour::defaultFill).getARGB(), @@ -1429,3 +1441,5 @@ void LookAndFeel_V4::initialiseColours() for (int i = 0; i < numElementsInArray (coloursToUse); i += 2) setColour ((int) coloursToUse [i], Colour ((uint32) coloursToUse [i + 1])); } + +} // namespace juce diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h index 76b1371f98..ad690d5e1e 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3 { @@ -226,7 +226,7 @@ public: private: //============================================================================== - void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress); + void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&); void drawCircularProgressBar (Graphics&, ProgressBar&, const String&); int getPropertyComponentIndent (PropertyComponent&); @@ -238,3 +238,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp b/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp index bc9515b5be..b24072acdf 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp +++ b/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MenuBarComponent::MenuBarComponent (MenuBarModel* m) : model (nullptr), itemUnderMouse (-1), @@ -352,3 +355,5 @@ void MenuBarComponent::timerCallback() stopTimer(); updateItemUnderMouse (getMouseXYRelative()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarComponent.h b/modules/juce_gui_basics/menus/juce_MenuBarComponent.h index 96a00c8f53..82f9a4e089 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarComponent.h +++ b/modules/juce_gui_basics/menus/juce_MenuBarComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -115,3 +115,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuBarComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp b/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp index e5be870ab8..fcc06afe98 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp +++ b/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MenuBarModel::MenuBarModel() noexcept : manager (nullptr) { @@ -93,3 +96,5 @@ void MenuBarModel::handleMenuBarActivate (bool isActive) void MenuBarModel::menuBarActivated (bool) {} void MenuBarModel::Listener::menuBarActivated (MenuBarModel*, bool) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_MenuBarModel.h b/modules/juce_gui_basics/menus/juce_MenuBarModel.h index 01e6023d60..a4b7d9c0ec 100644 --- a/modules/juce_gui_basics/menus/juce_MenuBarModel.h +++ b/modules/juce_gui_basics/menus/juce_MenuBarModel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -189,3 +189,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the MenuBarModel::Listener class directly. */ typedef MenuBarModel::Listener MenuBarModelListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 738aedb2f1..530a49f7ee 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace PopupMenuSettings { const int scrollZone = 24; @@ -71,9 +74,7 @@ struct HeaderItemComponent : public PopupMenu::CustomComponent struct ItemComponent : public Component { ItemComponent (const PopupMenu::Item& i, int standardItemHeight, MenuWindow& parent) - : item (i), - customComp (i.customComponent), - isHighlighted (false) + : item (i), customComp (i.customComponent) { if (item.isSectionHeader) customComp = new HeaderItemComponent (item.text); @@ -149,7 +150,7 @@ struct ItemComponent : public Component private: // NB: we use a copy of the one from the item info in case we're using our own section comp ReferenceCountedObjectPtr customComp; - bool isHighlighted; + bool isHighlighted = false; void updateShortcutKeyDescription() { @@ -197,7 +198,7 @@ public: parent (parentWindow), options (opts), managerOfChosenCommand (manager), - componentAttachedTo (options.targetComponent), + componentAttachedTo (options.getTargetComponent()), dismissOnMouseUp (shouldDismissOnMouseUp), windowCreationTime (Time::getMillisecondCounter()), lastFocusedTime (windowCreationTime), @@ -227,23 +228,22 @@ public: auto item = menu.items.getUnchecked (i); if (i < menu.items.size() - 1 || ! item->isSeparator) - items.add (new ItemComponent (*item, options.standardHeight, *this)); + items.add (new ItemComponent (*item, options.getStandardItemHeight(), *this)); } - Rectangle targetArea = options.targetArea / scaleFactor; + auto targetArea = options.getTargetScreenArea() / scaleFactor; calculateWindowPos (targetArea, alignToRectangle); setTopLeftPosition (windowPos.getPosition()); updateYPositions(); - if (options.visibleItemID != 0) + if (auto visibleID = options.getItemThatMustBeVisible()) { auto targetPosition = parentComponent != nullptr ? parentComponent->getLocalPoint (nullptr, targetArea.getTopLeft()) : targetArea.getTopLeft(); auto y = targetPosition.getY() - windowPos.getY(); - ensureItemIsVisible (options.visibleItemID, - isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1); + ensureItemIsVisible (visibleID, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1); } resizeToBestWindowPos(); @@ -489,7 +489,7 @@ public: if (! isVisible()) return false; - if (componentAttachedTo != options.targetComponent) + if (componentAttachedTo != options.getTargetComponent()) { dismissMenu (nullptr); return false; @@ -510,13 +510,21 @@ public: MouseSourceState& getMouseState (MouseInputSource source) { + MouseSourceState* mouseState = nullptr; + for (auto* ms : mouseSourceStates) - if (ms->source == source) - return *ms; + { + if (ms->source == source) mouseState = ms; + else if (ms->source.getType() != source.getType()) ms->stopTimer(); + } + + if (mouseState == nullptr) + { + mouseState = new MouseSourceState (*this, source); + mouseSourceStates.add (mouseState); + } - auto ms = new MouseSourceState (*this, source); - mouseSourceStates.add (ms); - return *ms; + return *mouseState; } //============================================================================== @@ -618,8 +626,8 @@ public: { x = target.getX(); - const int spaceUnder = parentArea.getHeight() - (target.getBottom() - parentArea.getY()); - const int spaceOver = target.getY() - parentArea.getY(); + auto spaceUnder = parentArea.getHeight() - (target.getBottom() - parentArea.getY()); + auto spaceOver = target.getY() - parentArea.getY(); if (heightToUse < spaceUnder - 30 || spaceUnder >= spaceOver) y = target.getBottom(); @@ -686,15 +694,14 @@ public: void layoutMenuItems (const int maxMenuW, const int maxMenuH, int& width, int& height) { - numColumns = 0; + numColumns = options.getMinimumNumColumns(); contentHeight = 0; int totalW; - const int maximumNumColumns = options.maxColumns > 0 ? options.maxColumns : 7; + auto maximumNumColumns = options.getMaximumNumColumns() > 0 ? options.getMaximumNumColumns() : 7; - do + for (;;) { - ++numColumns; totalW = workOutBestSize (maxMenuW); if (totalW > maxMenuW) @@ -704,12 +711,15 @@ public: break; } - if (totalW > maxMenuW / 2 || contentHeight < maxMenuH) + if (totalW > maxMenuW / 2 + || contentHeight < maxMenuH + || numColumns >= maximumNumColumns) break; - } while (numColumns < maximumNumColumns); + ++numColumns; + } - const int actualH = jmin (contentHeight, maxMenuH); + auto actualH = jmin (contentHeight, maxMenuH); needsToScroll = contentHeight > actualH; @@ -725,7 +735,7 @@ public: for (int col = 0; col < numColumns; ++col) { - int colW = options.standardHeight, colH = 0; + int colW = options.getStandardItemHeight(), colH = 0; const int numChildren = jmin (items.size() - childNum, (items.size() + numColumns - 1) / numColumns); @@ -746,7 +756,7 @@ public: } // width must never be larger than the screen - const int minWidth = jmin (maxMenuW, options.minWidth); + auto minWidth = jmin (maxMenuW, options.getMinimumWidth()); if (totalW < minWidth) { @@ -996,7 +1006,7 @@ public: }; //============================================================================== -class MouseSourceState : private Timer +class MouseSourceState : public Timer { public: MouseSourceState (MenuWindow& w, MouseInputSource s) @@ -1016,6 +1026,13 @@ public: void timerCallback() override { + #if JUCE_WINDOWS + // touch and pen devices on Windows send an offscreen mouse move after mouse up events + // but we don't want to forward these on as they will dismiss the menu + if ((source.isTouch() || source.isPen()) && ! isValidMousePosition()) + return; + #endif + if (window.windowIsStillValid()) handleMousePosition (source.getScreenPosition().roundToInt()); } @@ -1207,6 +1224,20 @@ private: return true; } + #if JUCE_WINDOWS + bool isValidMousePosition() + { + auto screenPos = source.getScreenPosition(); + auto localPos = (window.activeSubMenu == nullptr) ? window.getLocalPoint (nullptr, screenPos) + : window.activeSubMenu->getLocalPoint (nullptr, screenPos); + + if (localPos.x < 0 && localPos.y < 0) + return false; + + return true; + } + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseSourceState) }; @@ -1289,13 +1320,6 @@ void PopupMenu::clear() //============================================================================== PopupMenu::Item::Item() noexcept - : itemID (0), - commandManager (nullptr), - colour (0x00000000), - isEnabled (true), - isTicked (false), - isSeparator (false), - isSectionHeader (false) { } @@ -1494,12 +1518,6 @@ void PopupMenu::addSectionHeader (const String& title) //============================================================================== PopupMenu::Options::Options() - : targetComponent (nullptr), - parentComponent (nullptr), - visibleItemID (0), - minWidth (0), - maxColumns (0), - standardHeight (0) { targetArea.setPosition (Desktop::getMousePosition()); } @@ -1515,7 +1533,7 @@ PopupMenu::Options PopupMenu::Options::withTargetComponent (Component* comp) con return o; } -PopupMenu::Options PopupMenu::Options::withTargetScreenArea (const Rectangle& area) const noexcept +PopupMenu::Options PopupMenu::Options::withTargetScreenArea (Rectangle area) const noexcept { Options o (*this); o.targetArea = area; @@ -1529,6 +1547,13 @@ PopupMenu::Options PopupMenu::Options::withMinimumWidth (int w) const noexcept return o; } +PopupMenu::Options PopupMenu::Options::withMinimumNumColumns (int cols) const noexcept +{ + Options o (*this); + o.minColumns = cols; + return o; +} + PopupMenu::Options PopupMenu::Options::withMaximumNumColumns (int cols) const noexcept { Options o (*this); @@ -1560,13 +1585,11 @@ PopupMenu::Options PopupMenu::Options::withParentComponent (Component* parent) c Component* PopupMenu::createWindow (const Options& options, ApplicationCommandManager** managerOfChosenCommand) const { - if (items.size() > 0) - return new HelperClasses::MenuWindow (*this, nullptr, options, - ! options.targetArea.isEmpty(), - ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(), - managerOfChosenCommand); - - return nullptr; + return items.isEmpty() ? nullptr + : new HelperClasses::MenuWindow (*this, nullptr, options, + ! options.getTargetScreenArea().isEmpty(), + ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown(), + managerOfChosenCommand); } //============================================================================== @@ -1658,9 +1681,8 @@ void PopupMenu::showMenuAsync (const Options& options, ModalComponentManager::Ca //============================================================================== #if JUCE_MODAL_LOOPS_PERMITTED -int PopupMenu::show (const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, +int PopupMenu::show (int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { return showWithOptionalCallback (Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) @@ -1670,10 +1692,9 @@ int PopupMenu::show (const int itemIDThatMustBeVisible, callback, true); } -int PopupMenu::showAt (const Rectangle& screenAreaToAttachTo, - const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, +int PopupMenu::showAt (Rectangle screenAreaToAttachTo, + int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { return showWithOptionalCallback (Options().withTargetScreenArea (screenAreaToAttachTo) @@ -1685,15 +1706,14 @@ int PopupMenu::showAt (const Rectangle& screenAreaToAttachTo, } int PopupMenu::showAt (Component* componentToAttachTo, - const int itemIDThatMustBeVisible, - const int minimumWidth, const int maximumNumColumns, - const int standardItemHeight, + int itemIDThatMustBeVisible, int minimumWidth, + int maximumNumColumns, int standardItemHeight, ModalComponentManager::Callback* callback) { - Options options (Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) - .withMinimumWidth (minimumWidth) - .withMaximumNumColumns (maximumNumColumns) - .withStandardItemHeight (standardItemHeight)); + auto options = Options().withItemThatMustBeVisible (itemIDThatMustBeVisible) + .withMinimumWidth (minimumWidth) + .withMaximumNumColumns (maximumNumColumns) + .withStandardItemHeight (standardItemHeight); if (componentToAttachTo != nullptr) options = options.withTargetComponent (componentToAttachTo); @@ -1761,8 +1781,7 @@ void PopupMenu::setLookAndFeel (LookAndFeel* const newLookAndFeel) //============================================================================== PopupMenu::CustomComponent::CustomComponent (bool autoTrigger) - : isHighlighted (false), - triggeredAutomatically (autoTrigger) + : triggeredAutomatically (autoTrigger) { } @@ -1803,9 +1822,8 @@ PopupMenu::CustomCallback::CustomCallback() {} PopupMenu::CustomCallback::~CustomCallback() {} //============================================================================== -PopupMenu::MenuItemIterator::MenuItemIterator (const PopupMenu& m, bool searchR) : searchRecursively (searchR) +PopupMenu::MenuItemIterator::MenuItemIterator (const PopupMenu& m, bool recurse) : searchRecursively (recurse) { - currentItem = nullptr; index.add (0); menus.add (&m); } @@ -1844,3 +1862,5 @@ PopupMenu::Item& PopupMenu::MenuItemIterator::getItem() const noexcept jassert (currentItem != nullptr); return *(currentItem); } + +} // namespace juce diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.h b/modules/juce_gui_basics/menus/juce_PopupMenu.h index 276fb62a43..d3a91b94ce 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Creates and displays a popup-menu. @@ -89,19 +89,19 @@ public: PopupMenu(); /** Creates a copy of another menu. */ - PopupMenu (const PopupMenu& other); + PopupMenu (const PopupMenu&); /** Destructor. */ ~PopupMenu(); /** Copies this menu from another one. */ - PopupMenu& operator= (const PopupMenu& other); + PopupMenu& operator= (const PopupMenu&); /** Move constructor */ - PopupMenu (PopupMenu&& other) noexcept; + PopupMenu (PopupMenu&&) noexcept; /** Move assignment operator */ - PopupMenu& operator= (PopupMenu&& other) noexcept; + PopupMenu& operator= (PopupMenu&&) noexcept; //============================================================================== /** Resets the menu, removing all its items. */ @@ -125,8 +125,8 @@ public: /** The menu item's name. */ String text; - /** The menu item's ID. This can not be 0 if you want the item to be triggerable! */ - int itemID; + /** The menu item's ID. This must not be 0 if you want the item to be triggerable! */ + int itemID = 0; /** A sub-menu, or nullptr if there isn't one. */ ScopedPointer subMenu; @@ -141,7 +141,7 @@ public: ReferenceCountedObjectPtr customCallback; /** A command manager to use to automatically invoke the command, or nullptr if none is specified. */ - ApplicationCommandManager* commandManager; + ApplicationCommandManager* commandManager = nullptr; /** An optional string describing the shortcut key for this item. This is only used for displaying at the right-hand edge of a menu item - the @@ -157,16 +157,16 @@ public: Colour colour; /** True if this menu item is enabled. */ - bool isEnabled; + bool isEnabled = true; /** True if this menu item should have a tick mark next to it. */ - bool isTicked; + bool isTicked = false; /** True if this menu item is a separator line. */ - bool isSeparator; + bool isSeparator = false; /** True if this menu item is a section header. */ - bool isSectionHeader; + bool isSectionHeader = false; }; /** Adds an item to the menu. @@ -247,8 +247,6 @@ public: const String& displayName = String(), Drawable* iconToUse = nullptr); - - /** Appends a text item with a special colour. This is the same as addItem(), but specifies a colour to use for the @@ -389,11 +387,14 @@ public: { public: Options(); + Options (const Options&) = default; + Options& operator= (const Options&) = default; //============================================================================== Options withTargetComponent (Component* targetComponent) const noexcept; - Options withTargetScreenArea (const Rectangle& targetArea) const noexcept; + Options withTargetScreenArea (Rectangle targetArea) const noexcept; Options withMinimumWidth (int minWidth) const noexcept; + Options withMinimumNumColumns (int minNumColumns) const noexcept; Options withMaximumNumColumns (int maxNumColumns) const noexcept; Options withStandardItemHeight (int standardHeight) const noexcept; Options withItemThatMustBeVisible (int idOfItemToBeVisible) const noexcept; @@ -405,17 +406,16 @@ public: Rectangle getTargetScreenArea() const noexcept { return targetArea; } int getMinimumWidth() const noexcept { return minWidth; } int getMaximumNumColumns() const noexcept { return maxColumns; } + int getMinimumNumColumns() const noexcept { return minColumns; } int getStandardItemHeight() const noexcept { return standardHeight; } int getItemThatMustBeVisible() const noexcept { return visibleItemID; } private: //============================================================================== - friend class PopupMenu; - friend class PopupMenu::Window; Rectangle targetArea; - Component* targetComponent; - Component* parentComponent; - int visibleItemID, minWidth, maxColumns, standardHeight; + Component* targetComponent = nullptr; + Component* parentComponent = nullptr; + int visibleItemID = 0, minWidth = 0, minColumns = 1, maxColumns = 0, standardHeight = 0; }; //============================================================================== @@ -473,7 +473,7 @@ public: @see show() */ - int showAt (const Rectangle& screenAreaToAttachTo, + int showAt (Rectangle screenAreaToAttachTo, int itemIDThatMustBeVisible = 0, int minimumWidth = 0, int maximumNumColumns = 0, @@ -585,9 +585,9 @@ public: //============================================================================== bool searchRecursively; - Array index; - Array menus; - PopupMenu::Item *currentItem; + Array index; + Array menus; + PopupMenu::Item* currentItem = nullptr; MenuItemIterator& operator= (const MenuItemIterator&); JUCE_LEAK_DETECTOR (MenuItemIterator) @@ -638,7 +638,7 @@ public: private: //============================================================================== - bool isHighlighted, triggeredAutomatically; + bool isHighlighted = false, triggeredAutomatically; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomComponent) }; @@ -750,3 +750,5 @@ private: JUCE_LEAK_DETECTOR (PopupMenu) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index b2595731a7..13ce260eb6 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BubbleComponent::BubbleComponent() : allowablePlacements (above | below | left | right) { @@ -144,3 +147,5 @@ void BubbleComponent::setPosition (Rectangle rectangleToPointTo, setBounds (targetX - arrowTip.x, targetY - arrowTip.y, totalW, totalH); } + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.h b/modules/juce_gui_basics/misc/juce_BubbleComponent.h index 4b03495c2b..fe253274fc 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.h +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -181,3 +181,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BubbleComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 42cac3e67b..8f4fcb0724 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/modules/juce_gui_basics/misc/juce_DropShadower.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class DropShadower::ShadowWindow : public Component { public: @@ -216,3 +219,5 @@ void DropShadower::updateShadows() shadowWindows.clear(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_DropShadower.h b/modules/juce_gui_basics/misc/juce_DropShadower.h index d201430b7e..9137609869 100644 --- a/modules/juce_gui_basics/misc/juce_DropShadower.h +++ b/modules/juce_gui_basics/misc/juce_DropShadower.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DropShadower) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp new file mode 100644 index 0000000000..7ab23c3edd --- /dev/null +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.cpp @@ -0,0 +1,361 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/* + ============================================================================== + + In accordance with the terms of the JUCE 5 End-Use License Agreement, the + JUCE Code in SECTION A cannot be removed, changed or otherwise rendered + ineffective unless you have a JUCE Indie or Pro license, or are using JUCE + under the GPL v3 license. + + End User License Agreement: www.juce.com/juce-5-licence + ============================================================================== +*/ + +// BEGIN SECTION A + +#if ! defined (JUCE_REPORT_APP_USAGE) + #define JUCE_REPORT_APP_USAGE 1 +#endif + +#if ! defined (JUCE_DISPLAY_SPLASH_SCREEN) + #define JUCE_DISPLAY_SPLASH_SCREEN 1 +#endif + +#if ! defined (JUCE_USE_DARK_SPLASH_SCREEN) + #define JUCE_USE_DARK_SPLASH_SCREEN 1 +#endif + +static const int millisecondsToDisplaySplash = 2000, splashScreenFadeOutTime = 2000; +static const int splashScreenLogoWidth = 123, splashScreenLogoHeight = 63; +static uint32 splashDisplayTime = 0; +static bool appUsageReported = false; + + +Rectangle getLogoArea (Rectangle parentRect) +{ + return parentRect.reduced (6.0f) + .removeFromRight ((float) splashScreenLogoWidth) + .removeFromBottom ((float) splashScreenLogoHeight); +} + +//============================================================================== +struct ReportingThread; + +struct ReportingThreadContainer : public ChangeListener, + public DeletedAtShutdown +{ + void sendReport (String, String&, StringPairArray&); + void changeListenerCallback (ChangeBroadcaster*) override; + + ScopedPointer reportingThread; + + juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer) +}; + +juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer) + +//============================================================================== +struct ReportingThread : public Thread, + private ChangeBroadcaster +{ + ReportingThread (ReportingThreadContainer& container, + String& address, + String& userAgent, + StringPairArray& parameters) + : Thread ("JUCE app usage reporting"), + threadContainer (container), + headers ("User-Agent: " + userAgent) + { + StringArray postData; + + for (auto& key : parameters.getAllKeys()) + if (parameters[key].isNotEmpty()) + postData.add (key + "=" + URL::addEscapeChars (parameters[key], true)); + + url = URL (address).withPOSTData (postData.joinIntoString ("&")); + + addChangeListener (&threadContainer); + } + + ~ReportingThread() + { + removeChangeListener (&threadContainer); + + if (webStream != nullptr) + webStream->cancel(); + + stopThread (2000); + } + + void run() override + { + webStream = new WebInputStream (url, true); + webStream->withExtraHeaders (headers); + webStream->connect (nullptr); + + sendChangeMessage(); + } + +private: + ReportingThreadContainer& threadContainer; + URL url; + String headers; + ScopedPointer webStream; +}; + +//============================================================================== +void ReportingThreadContainer::sendReport (String address, String& userAgent, StringPairArray& parameters) +{ + reportingThread = new ReportingThread (*this, address, userAgent, parameters); + + reportingThread->startThread(); +} + +void ReportingThreadContainer::changeListenerCallback (ChangeBroadcaster*) +{ + reportingThread = nullptr; +} + +//============================================================================== +JUCESplashScreen::JUCESplashScreen (Component& parent) +{ + ignoreUnused (hasStartedFading); + ignoreUnused (parent); + + #if JUCE_REPORT_APP_USAGE + if (! appUsageReported) + { + const ScopedTryLock appUsageReportingLock (appUsageReporting); + + if (appUsageReportingLock.isLocked() && ! appUsageReported) + { + const auto deviceDescription = SystemStats::getDeviceDescription(); + const auto deviceString = SystemStats::getDeviceIdentifiers().joinIntoString (":"); + const auto deviceIdentifier = String::toHexString (deviceString.hashCode64()); + const auto osName = SystemStats::getOperatingSystemName(); + + StringPairArray data; + + data.set ("v", "1"); + data.set ("tid", "UA-19759318-3"); + data.set ("cid", deviceIdentifier); + data.set ("t", "event"); + data.set ("ec", "info"); + data.set ("ea", "appStarted"); + + data.set ("cd1", SystemStats::getJUCEVersion()); + data.set ("cd2", osName); + data.set ("cd3", deviceDescription); + data.set ("cd4", deviceIdentifier); + + String appType, appName, appVersion, appManufacturer; + + #if defined(JucePlugin_Name) + appType = "Plugin"; + appName = JucePlugin_Name; + appVersion = JucePlugin_VersionString; + appManufacturer = JucePlugin_Manufacturer; + #else + if (JUCEApplicationBase::isStandaloneApp()) + { + appType = "Application"; + + if (auto* app = JUCEApplicationBase::getInstance()) + { + appName = app->getApplicationName(); + appVersion = app->getApplicationVersion(); + } + } + else + { + appType = "Library"; + } + #endif + + data.set ("cd5", appType); + data.set ("cd6", appName); + data.set ("cd7", appVersion); + data.set ("cd8", appManufacturer); + + data.set ("an", appName); + data.set ("av", appVersion); + + auto agentCPUVendor = SystemStats::getCpuVendor(); + + if (agentCPUVendor.isEmpty()) + agentCPUVendor = "CPU"; + + auto agentOSName = osName.replaceCharacter ('.', '_') + .replace ("iOS", "iPhone OS"); + #if JUCE_IOS + agentOSName << " like Mac OS X"; + #endif + + String userAgent; + userAgent << "Mozilla/5.0 (" + << deviceDescription << ";" + << agentCPUVendor << " " << agentOSName << ";" + << SystemStats::getDisplayLanguage() << ")"; + + ReportingThreadContainer::getInstance()->sendReport ("https://www.google-analytics.com/collect", userAgent, data); + + appUsageReported = true; + } + } + #else + ignoreUnused (appUsageReported); + #endif + + #if JUCE_DISPLAY_SPLASH_SCREEN + if (splashDisplayTime == 0 + || Time::getMillisecondCounter() < splashDisplayTime + (uint32) millisecondsToDisplaySplash) + { + content = getSplashScreenLogo(); + + setAlwaysOnTop (true); + parent.addAndMakeVisible (this); + } + else + #endif + { + startTimer (1); + } +} + +JUCESplashScreen::~JUCESplashScreen() +{ +} + +Drawable* JUCESplashScreen::getSplashScreenLogo() +{ + const char* svgData = R"JUCESPLASHSCREEN( + + + + + + + + + + " + R"JUCESPLASHSCREEN( + + + + + + + + + + + + + + + + )JUCESPLASHSCREEN"; + + ScopedPointer svgXml (XmlDocument::parse (svgData)); + return Drawable::createFromSVG (*svgXml); +} + +void JUCESplashScreen::paint (Graphics& g) +{ + auto r = getLocalBounds().toFloat(); + Point bottomRight (0.9f * r.getWidth(), + 0.9f * r.getHeight()); + + ColourGradient cg (Colour (0x00000000), Line (0.0f, r.getHeight(), r.getWidth(), 0.0f) + .findNearestPointTo (bottomRight), + Colour (0xff000000), bottomRight, false); + cg.addColour (0.25f, Colour (0x10000000)); + cg.addColour (0.50f, Colour (0x30000000)); + cg.addColour (0.75f, Colour (0x70000000)); + g.setFillType (cg); + g.fillAll(); + + content->drawWithin (g, getLogoArea (r), RectanglePlacement::centred, 1.0f); + + if (splashDisplayTime == 0) + splashDisplayTime = Time::getMillisecondCounter(); + + if (! isTimerRunning()) + startTimer (millisecondsToDisplaySplash); +} + +void JUCESplashScreen::timerCallback() +{ + #if JUCE_DISPLAY_SPLASH_SCREEN + if (isVisible() && ! hasStartedFading) + { + hasStartedFading = true; + fader.animateComponent (this, getBounds(), 0.0f, splashScreenFadeOutTime, false, 0, 0); + } + + if (hasStartedFading && ! fader.isAnimating()) + #endif + delete this; +} + +void JUCESplashScreen::parentSizeChanged() +{ + if (auto* p = getParentComponent()) + setBounds (p->getLocalBounds().removeFromBottom (splashScreenLogoHeight * 3) + .removeFromRight (splashScreenLogoWidth * 3)); +} + +void JUCESplashScreen::parentHierarchyChanged() +{ + toFront (false); +} + +bool JUCESplashScreen::hitTest (int x, int y) +{ + return getLogoArea (getLocalBounds().toFloat()).contains ((float) x, (float) y); +} + +void JUCESplashScreen::mouseUp (const MouseEvent&) +{ + URL juceWebsite ("https://juce.com"); + juceWebsite.launchInDefaultBrowser(); +} + +// END SECTION A + +} // namespace juce diff --git a/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h new file mode 100644 index 0000000000..ab58d9db17 --- /dev/null +++ b/modules/juce_gui_basics/misc/juce_JUCESplashScreen.h @@ -0,0 +1,75 @@ +/* + ============================================================================== + + This file is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + JUCE is an open source library subject to commercial or open-source + licensing. + + By using JUCE, you agree to the terms of both the JUCE 5 End-User License + Agreement and JUCE 5 Privacy Policy (both updated and effective as of the + 27th April 2017). + + End User License Agreement: www.juce.com/juce-5-licence + Privacy Policy: www.juce.com/juce-5-privacy-policy + + Or: You may also use this code under the terms of the GPL v3 (see + www.gnu.org/licenses). + + JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE + DISCLAIMED. + + ============================================================================== +*/ + +/* + ============================================================================== + + In accordance with the terms of the JUCE 5 End-Use License Agreement, the + JUCE Code in SECTION A cannot be removed, changed or otherwise rendered + ineffective unless you have a JUCE Indie or Pro license, or are using JUCE + under the GPL v3 license. + + End User License Agreement: www.juce.com/juce-5-licence + ============================================================================== +*/ + +// BEGIN SECTION A + +namespace juce +{ + +/** + The standard JUCE splash screen component. +*/ +class JUCE_API JUCESplashScreen : public Component, + private Timer, + private DeletedAtShutdown +{ +public: + JUCESplashScreen (Component& parentToAddTo); + ~JUCESplashScreen(); + + static Drawable* getSplashScreenLogo(); + +private: + void paint (Graphics&) override; + void timerCallback() override; + void parentSizeChanged() override; + void parentHierarchyChanged() override; + bool hitTest (int, int) override; + void mouseUp (const MouseEvent&) override; + + ScopedPointer content; + CriticalSection appUsageReporting; + ComponentAnimator fader; + bool hasStartedFading = false; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JUCESplashScreen) +}; + +// END SECTION A + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp index d5c9f37092..5f01eb8c98 100644 --- a/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp +++ b/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComponentDragger::ComponentDragger() {} ComponentDragger::~ComponentDragger() {} @@ -61,3 +64,5 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo componentToDrag->setBounds (bounds); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_ComponentDragger.h b/modules/juce_gui_basics/mouse/juce_ComponentDragger.h index ab6141cdcd..dedf284f7e 100644 --- a/modules/juce_gui_basics/mouse/juce_ComponentDragger.h +++ b/modules/juce_gui_basics/mouse/juce_ComponentDragger.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -96,3 +96,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentDragger) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 14bf227fe8..4fc7e112d8 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + bool juce_performDragDropFiles (const StringArray&, const bool copyFiles, bool& shouldStop); bool juce_performDragDropText (const String&, bool& shouldStop); @@ -526,3 +529,5 @@ void FileDragAndDropTarget::fileDragExit (const StringArray&) {} void TextDragAndDropTarget::textDragEnter (const String&, int, int) {} void TextDragAndDropTarget::textDragMove (const String&, int, int) {} void TextDragAndDropTarget::textDragExit (const String&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h index 05793358ea..437037d38c 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -212,3 +212,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DragAndDropContainer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h index 886948e9ff..b7be4d4868 100644 --- a/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -149,3 +149,5 @@ private: virtual int itemDropped (const String&, Component*, int, int) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h index 465e234c91..e6491dcce5 100644 --- a/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** Components derived from this class can have files dropped onto them by an external application. @@ -100,3 +101,5 @@ public: */ virtual void filesDropped (const StringArray& files, int x, int y) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_LassoComponent.h b/modules/juce_gui_basics/mouse/juce_LassoComponent.h index 77663e5e09..f2c278b118 100644 --- a/modules/juce_gui_basics/mouse/juce_LassoComponent.h +++ b/modules/juce_gui_basics/mouse/juce_LassoComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -219,3 +219,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LassoComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 7716e519af..dad75c06d5 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct CustomMouseCursorInfo { CustomMouseCursorInfo (const Image& im, int hsX, int hsY) noexcept @@ -213,3 +216,5 @@ void MouseCursor::hideWaitCursor() { Desktop::getInstance().getMainMouseSource().revealCursor(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 0856fd6560..4ad39b1de6 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/modules/juce_gui_basics/mouse/juce_MouseCursor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -178,3 +178,5 @@ private: JUCE_LEAK_DETECTOR (MouseCursor) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp b/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp index 7990995645..126d0ada07 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MouseEvent::MouseEvent (MouseInputSource inputSource, Point pos, ModifierKeys modKeys, @@ -136,3 +139,5 @@ static int doubleClickTimeOutMs = 400; int MouseEvent::getDoubleClickTimeout() noexcept { return doubleClickTimeOutMs; } void MouseEvent::setDoubleClickTimeout (const int newTime) noexcept { doubleClickTimeOutMs = newTime; } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseEvent.h b/modules/juce_gui_basics/mouse/juce_MouseEvent.h index 44a7a49f1a..4643cc368a 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseEvent.h +++ b/modules/juce_gui_basics/mouse/juce_MouseEvent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -437,3 +438,5 @@ struct PenDetails */ float tiltY; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp index 6ac495c0ea..45b35219a0 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MouseInactivityDetector::MouseInactivityDetector (Component& c) : targetComp (c), delayMs (1500), toleranceDistance (15), isActive (true) { @@ -70,3 +73,5 @@ void MouseInactivityDetector::setActive (bool b) : &Listener::mouseBecameInactive); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h index 790c44b3a6..f8c6a5e555 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseInactivityDetector) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 3717e06678..541d542183 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class MouseInputSourceInternal : private AsyncUpdater { public: @@ -748,3 +751,5 @@ struct MouseInputSource::SourceList : public Timer OwnedArray sources; Array sourceArray; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index 3a8d51ad2b..b7e62e511c 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -252,3 +252,5 @@ private: JUCE_LEAK_DETECTOR (MouseInputSource) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp index abe9ff512c..984a436f29 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void MouseListener::mouseEnter (const MouseEvent&) {} void MouseListener::mouseExit (const MouseEvent&) {} void MouseListener::mouseDown (const MouseEvent&) {} @@ -32,3 +35,5 @@ void MouseListener::mouseDrag (const MouseEvent&) {} void MouseListener::mouseMove (const MouseEvent&) {} void MouseListener::mouseDoubleClick (const MouseEvent&) {} void MouseListener::mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) {} + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.h b/modules/juce_gui_basics/mouse/juce_MouseListener.h index fd467ba82b..859b91dec2 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.h +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -161,3 +161,5 @@ private: virtual int mouseWheelMove (const MouseEvent&, float, float) { return 0; } #endif }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index c78c970727..19211b0157 100644 --- a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Manages a list of selectable items. @@ -319,3 +319,5 @@ private: JUCE_LEAK_DETECTOR (SelectedItemSet) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h b/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h index 9cba6b2611..088065c249 100644 --- a/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h +++ b/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -101,3 +101,5 @@ public: */ virtual void textDropped (const String& text, int x, int y) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 1219822a68..9f8c0b9152 100644 --- a/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/modules/juce_gui_basics/mouse/juce_TooltipClient.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -81,3 +81,5 @@ protected: private: String tooltipString; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_MultiTouchMapper.h b/modules/juce_gui_basics/native/juce_MultiTouchMapper.h index 5cca8b5416..ed27ec1977 100644 --- a/modules/juce_gui_basics/native/juce_MultiTouchMapper.h +++ b/modules/juce_gui_basics/native/juce_MultiTouchMapper.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ template class MultiTouchMapper @@ -62,8 +63,8 @@ public: bool areAnyTouchesActive() const noexcept { - for (int i = currentTouches.size(); --i >= 0;) - if (currentTouches.getUnchecked(i) != 0) + for (auto& t : currentTouches) + if (t != 0) return true; return false; @@ -74,3 +75,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiTouchMapper) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp index aa8ed4f72c..27fb00d238 100644 --- a/modules/juce_gui_basics/native/juce_android_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_android_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void FileChooser::showPlatformDialog (Array& /*results*/, const String& /*title*/, const File& /*currentFileOrDirectory*/, @@ -45,3 +48,5 @@ bool FileChooser::isPlatformDialogAvailable() { return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index f6970feacb..54fa3ea608 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -24,15 +24,13 @@ ============================================================================== */ -} // (juce namespace) - extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_APPLICATION) namespace juce { //============================================================================== -#if JUCE_MODULE_AVAILABLE_juce_product_unlocking +#if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking extern void juce_inAppPurchaseCompleted (void*); #endif @@ -92,7 +90,7 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, appActivityResult, void, (JN { setEnv (env); - #if JUCE_MODULE_AVAILABLE_juce_product_unlocking + #if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking if (requestCode == 1001) juce_inAppPurchaseCompleted (intentData); #else @@ -528,6 +526,10 @@ public: sizeAllocated = sizeNeeded; buffer = GlobalRef (env->NewIntArray (sizeNeeded)); } + else if (sizeNeeded == 0) + { + return; + } if (jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), 0)) { @@ -1023,6 +1025,25 @@ const int KeyPress::F13Key = extendedKeyModifier + 23; const int KeyPress::F14Key = extendedKeyModifier + 24; const int KeyPress::F15Key = extendedKeyModifier + 25; const int KeyPress::F16Key = extendedKeyModifier + 26; +const int KeyPress::F17Key = extendedKeyModifier + 50; +const int KeyPress::F18Key = extendedKeyModifier + 51; +const int KeyPress::F19Key = extendedKeyModifier + 52; +const int KeyPress::F20Key = extendedKeyModifier + 53; +const int KeyPress::F21Key = extendedKeyModifier + 54; +const int KeyPress::F22Key = extendedKeyModifier + 55; +const int KeyPress::F23Key = extendedKeyModifier + 56; +const int KeyPress::F24Key = extendedKeyModifier + 57; +const int KeyPress::F25Key = extendedKeyModifier + 58; +const int KeyPress::F26Key = extendedKeyModifier + 59; +const int KeyPress::F27Key = extendedKeyModifier + 60; +const int KeyPress::F28Key = extendedKeyModifier + 61; +const int KeyPress::F29Key = extendedKeyModifier + 62; +const int KeyPress::F30Key = extendedKeyModifier + 63; +const int KeyPress::F31Key = extendedKeyModifier + 64; +const int KeyPress::F32Key = extendedKeyModifier + 65; +const int KeyPress::F33Key = extendedKeyModifier + 66; +const int KeyPress::F34Key = extendedKeyModifier + 67; +const int KeyPress::F35Key = extendedKeyModifier + 68; const int KeyPress::numberPad0 = extendedKeyModifier + 27; const int KeyPress::numberPad1 = extendedKeyModifier + 28; const int KeyPress::numberPad2 = extendedKeyModifier + 29; @@ -1045,3 +1066,5 @@ const int KeyPress::playKey = extendedKeyModifier + 45; const int KeyPress::stopKey = extendedKeyModifier + 46; const int KeyPress::fastForwardKey = extendedKeyModifier + 47; const int KeyPress::rewindKey = extendedKeyModifier + 48; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index e9cb4a22dd..d935d3ceee 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class UIViewComponentPeer; // The way rotation works changed in iOS8.. @@ -95,7 +98,7 @@ namespace Orientations } //============================================================================== -} // (juce namespace) +} // namespace juce using namespace juce; @@ -312,8 +315,9 @@ private: static void sendScreenBoundsUpdate (JuceUIViewController* c) { JuceUIView* juceView = (JuceUIView*) [c view]; - jassert (juceView != nil && juceView->owner != nullptr); - juceView->owner->updateTransformAndScreenBounds(); + + if (juceView != nil && juceView->owner != nullptr) + juceView->owner->updateTransformAndScreenBounds(); } static bool isKioskModeView (JuceUIViewController* c) @@ -326,8 +330,7 @@ static bool isKioskModeView (JuceUIViewController* c) MultiTouchMapper UIViewComponentPeer::currentTouches; - -} // (juce namespace) +} // namespace juce //============================================================================== //============================================================================== @@ -1127,6 +1130,25 @@ const int KeyPress::F13Key = 0x200d; const int KeyPress::F14Key = 0x200e; const int KeyPress::F15Key = 0x200f; const int KeyPress::F16Key = 0x2010; +const int KeyPress::F17Key = 0x2011; +const int KeyPress::F18Key = 0x2012; +const int KeyPress::F19Key = 0x2013; +const int KeyPress::F20Key = 0x2014; +const int KeyPress::F21Key = 0x2015; +const int KeyPress::F22Key = 0x2016; +const int KeyPress::F23Key = 0x2017; +const int KeyPress::F24Key = 0x2018; +const int KeyPress::F25Key = 0x2019; +const int KeyPress::F26Key = 0x201a; +const int KeyPress::F27Key = 0x201b; +const int KeyPress::F28Key = 0x201c; +const int KeyPress::F29Key = 0x201d; +const int KeyPress::F30Key = 0x201e; +const int KeyPress::F31Key = 0x201f; +const int KeyPress::F32Key = 0x2020; +const int KeyPress::F33Key = 0x2021; +const int KeyPress::F34Key = 0x2022; +const int KeyPress::F35Key = 0x2023; const int KeyPress::numberPad0 = 0x30020; const int KeyPress::numberPad1 = 0x30021; const int KeyPress::numberPad2 = 0x30022; @@ -1149,3 +1171,5 @@ const int KeyPress::playKey = 0x30000; const int KeyPress::stopKey = 0x30001; const int KeyPress::fastForwardKey = 0x30002; const int KeyPress::rewindKey = 0x30003; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/modules/juce_gui_basics/native/juce_ios_Windowing.mm index a82990358d..7007bcaefa 100644 --- a/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_ios_Windowing.mm @@ -24,18 +24,19 @@ ============================================================================== */ -extern bool isIOSAppActive; - -struct AppInactivityCallback // NB: careful, this declaration is duplicated in other modules +namespace juce { - virtual ~AppInactivityCallback() {} - virtual void appBecomingInactive() = 0; -}; + extern bool isIOSAppActive; -// This is an internal list of callbacks (but currently used between modules) -Array appBecomingInactiveCallbacks; + struct AppInactivityCallback // NB: careful, this declaration is duplicated in other modules + { + virtual ~AppInactivityCallback() {} + virtual void appBecomingInactive() = 0; + }; -} // (juce namespace) + // This is an internal list of callbacks (but currently used between modules) + Array appBecomingInactiveCallbacks; +} @interface JuceAppStartupDelegate : NSObject { @@ -478,3 +479,5 @@ void Desktop::Displays::findDisplays (float masterScale) displays.add (d); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 8a485abc22..ceab192946 100644 --- a/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static bool exeIsAvailable (const char* const executable) { ChildProcess child; @@ -206,3 +209,5 @@ void FileChooser::showPlatformDialog (Array& results, previousWorkingDirectory.setAsCurrentWorkingDirectory(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11.cpp b/modules/juce_gui_basics/native/juce_linux_X11.cpp index af009643d8..e9625b65df 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + typedef void (*WindowMessageReceiveCallback) (XEvent&); WindowMessageReceiveCallback dispatchWindowMessage = nullptr; @@ -333,3 +336,5 @@ GetXProperty::~GetXProperty() if (data != nullptr) XFree (data); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11.h b/modules/juce_gui_basics/native/juce_linux_X11.h index 00c55bf126..f4235a7b9e 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11.h +++ b/modules/juce_gui_basics/native/juce_linux_X11.h @@ -24,13 +24,6 @@ ============================================================================== */ -#pragma once - -// Hack to forward declare _XDisplay outside the -// juce namespace - -} - struct _XDisplay; namespace juce @@ -142,3 +135,5 @@ struct GetXProperty }; #undef ATOM_TYPE + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp index 9c8e92b5bd..8c3427b097 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern ::Window juce_messageWindowHandle; namespace ClipboardHelpers @@ -273,3 +276,5 @@ String SystemClipboard::getTextFromClipboard() return content; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 30367b17c9..5b82036d70 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_DEBUG && ! defined (JUCE_DEBUG_XERRORS) #define JUCE_DEBUG_XERRORS 1 #endif @@ -135,6 +138,26 @@ const int KeyPress::F13Key = (XK_F13 & 0xff) | Keys::extendedKe const int KeyPress::F14Key = (XK_F14 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::F15Key = (XK_F15 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::F16Key = (XK_F16 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F17Key = (XK_F17 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F18Key = (XK_F18 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F19Key = (XK_F19 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F20Key = (XK_F20 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F21Key = (XK_F21 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F22Key = (XK_F22 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F23Key = (XK_F23 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F24Key = (XK_F24 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F25Key = (XK_F25 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F26Key = (XK_F26 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F27Key = (XK_F27 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F28Key = (XK_F28 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F29Key = (XK_F29 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F30Key = (XK_F30 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F31Key = (XK_F31 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F32Key = (XK_F32 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F33Key = (XK_F33 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F34Key = (XK_F34 & 0xff) | Keys::extendedKeyModifier; +const int KeyPress::F35Key = (XK_F35 & 0xff) | Keys::extendedKeyModifier; + const int KeyPress::numberPad0 = (XK_KP_0 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::numberPad1 = (XK_KP_1 & 0xff) | Keys::extendedKeyModifier; const int KeyPress::numberPad2 = (XK_KP_2 & 0xff) | Keys::extendedKeyModifier; @@ -2125,7 +2148,7 @@ public: break; default: - if (sym >= XK_F1 && sym <= XK_F16) + if (sym >= XK_F1 && sym <= XK_F35) { keyPressed = true; keyCode = (sym & 0xff) | Keys::extendedKeyModifier; @@ -4339,3 +4362,5 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co jassertfalse; return false; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index f0f99d8d86..333850c5d7 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC struct FileChooserDelegateClass : public ObjCClass @@ -273,3 +276,5 @@ void FileChooser::showPlatformDialog (Array&, } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 8b5812cbee..2da59ea343 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class JuceMainMenuHandler : private MenuBarModel::Listener, private DeletedAtShutdown { @@ -724,3 +727,5 @@ NSMenu* createNSMenu (const PopupMenu& menu, const String& name, jassertfalse; // calling this before making sure the OSX main menu stuff was initialised? return nil; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 36e05219d8..5cd37e0fb4 100644 --- a/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm @@ -24,12 +24,15 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC //============================================================================== namespace MouseCursorHelpers { - NSImage* createNSImage (const Image&, float scaleFactor = 1.f); + NSImage* createNSImage (const Image&, float scaleFactor = 1.0f); NSImage* createNSImage (const Image& image, float scaleFactor) { JUCE_AUTORELEASEPOOL @@ -207,3 +210,5 @@ void MouseCursor::showInAllWindows() const void MouseCursor::showInWindow (ComponentPeer*) const {} #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 492bea9b1a..1102b0c6dc 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -24,14 +24,16 @@ ============================================================================== */ -typedef void (*AppFocusChangeCallback)(); -extern AppFocusChangeCallback appFocusChangeCallback; -typedef bool (*CheckEventBlockedByModalComps) (NSEvent*); -extern CheckEventBlockedByModalComps isEventBlockedByModalComps; +namespace juce +{ + typedef void (*AppFocusChangeCallback)(); + extern AppFocusChangeCallback appFocusChangeCallback; + typedef bool (*CheckEventBlockedByModalComps) (NSEvent*); + extern CheckEventBlockedByModalComps isEventBlockedByModalComps; +} //============================================================================== #if ! (defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) -} // (juce namespace) @interface NSEvent (JuceDeviceDelta) - (CGFloat) scrollingDeltaX; @@ -40,9 +42,11 @@ extern CheckEventBlockedByModalComps isEventBlockedByModalComps; - (BOOL) isDirectionInvertedFromDevice; @end -namespace juce { #endif +namespace juce +{ + //============================================================================== static CGFloat getMainScreenHeight() noexcept { @@ -2150,6 +2154,27 @@ const int KeyPress::F13Key = NSF13FunctionKey; const int KeyPress::F14Key = NSF14FunctionKey; const int KeyPress::F15Key = NSF15FunctionKey; const int KeyPress::F16Key = NSF16FunctionKey; +const int KeyPress::F17Key = NSF17FunctionKey; +const int KeyPress::F18Key = NSF18FunctionKey; +const int KeyPress::F19Key = NSF19FunctionKey; +const int KeyPress::F20Key = NSF20FunctionKey; +const int KeyPress::F21Key = NSF21FunctionKey; +const int KeyPress::F22Key = NSF22FunctionKey; +const int KeyPress::F23Key = NSF23FunctionKey; +const int KeyPress::F24Key = NSF24FunctionKey; +const int KeyPress::F25Key = NSF25FunctionKey; +const int KeyPress::F26Key = NSF26FunctionKey; +const int KeyPress::F27Key = NSF27FunctionKey; +const int KeyPress::F28Key = NSF28FunctionKey; +const int KeyPress::F29Key = NSF29FunctionKey; +const int KeyPress::F30Key = NSF30FunctionKey; +const int KeyPress::F31Key = NSF31FunctionKey; +const int KeyPress::F32Key = NSF32FunctionKey; +const int KeyPress::F33Key = NSF33FunctionKey; +const int KeyPress::F34Key = NSF34FunctionKey; +const int KeyPress::F35Key = NSF35FunctionKey; + + const int KeyPress::numberPad0 = 0x30020; const int KeyPress::numberPad1 = 0x30021; const int KeyPress::numberPad2 = 0x30022; @@ -2172,3 +2197,5 @@ const int KeyPress::playKey = 0x30000; const int KeyPress::stopKey = 0x30001; const int KeyPress::fastForwardKey = 0x30002; const int KeyPress::rewindKey = 0x30003; + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 3a6e57390d..47b9490544 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -24,13 +24,9 @@ ============================================================================== */ -} // namespace juce - -#include "../../juce_core/native/juce_osx_ObjCHelpers.h" - -namespace juce { +namespace juce +{ -//============================================================================== void LookAndFeel::playAlertSound() { NSBeep(); @@ -619,3 +615,5 @@ bool Desktop::isOSXDarkModeActive() return [[[NSUserDefaults standardUserDefaults] stringForKey: nsStringLiteral ("AppleInterfaceStyle")] isEqualToString: nsStringLiteral ("Dark")]; } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index 53de33836c..5db2b1266a 100644 --- a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace DragAndDropHelpers { //============================================================================== @@ -282,3 +285,5 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co return DragAndDropHelpers::performDragDrop (&format, &medium, DROPEFFECT_COPY | DROPEFFECT_MOVE); } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 728a4c6d36..bb352b23b0 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace FileChooserHelpers { struct FileChooserCallbackInfo @@ -202,7 +205,7 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ if (info.returnedString.isNotEmpty()) { - results.add (File (String (files)).getSiblingFile (info.returnedString)); + results.add (File (String (files.get())).getSiblingFile (info.returnedString)); return; } } @@ -287,12 +290,14 @@ void FileChooser::showPlatformDialog (Array& results, const String& title_ while (*filename != 0) { - results.add (File (String (files)).getChildFile (String (filename))); + results.add (File (String (files.get())).getChildFile (String (filename))); filename += wcslen (filename) + 1; } } else if (files[0] != 0) { - results.add (File (String (files))); + results.add (File (String (files.get()))); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 22e783b3d4..3db70379eb 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -24,6 +24,13 @@ ============================================================================== */ +#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client + #include +#endif + +namespace juce +{ + #undef GetSystemMetrics // multimon overrides this for some reason and causes a mess.. // these are in the windows SDK, but need to be repeated here for GCC.. @@ -41,10 +48,6 @@ #define WM_APPCOMMAND 0x0319 #endif -#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client - #include -#endif - extern void juce_repeatLastProcessPriority(); extern void juce_checkCurrentlyFocusedTopLevelWindow(); // in juce_TopLevelWindow.cpp extern bool juce_isRunningInWine(); @@ -434,6 +437,26 @@ const int KeyPress::F13Key = VK_F13 | extendedKeyMod const int KeyPress::F14Key = VK_F14 | extendedKeyModifier; const int KeyPress::F15Key = VK_F15 | extendedKeyModifier; const int KeyPress::F16Key = VK_F16 | extendedKeyModifier; +const int KeyPress::F17Key = VK_F17 | extendedKeyModifier; +const int KeyPress::F18Key = VK_F18 | extendedKeyModifier; +const int KeyPress::F19Key = VK_F19 | extendedKeyModifier; +const int KeyPress::F20Key = VK_F20 | extendedKeyModifier; +const int KeyPress::F21Key = VK_F21 | extendedKeyModifier; +const int KeyPress::F22Key = VK_F22 | extendedKeyModifier; +const int KeyPress::F23Key = VK_F23 | extendedKeyModifier; +const int KeyPress::F24Key = VK_F24 | extendedKeyModifier; +const int KeyPress::F25Key = 0x31000; // Windows doesn't support F-keys 25 or higher +const int KeyPress::F26Key = 0x31001; +const int KeyPress::F27Key = 0x31002; +const int KeyPress::F28Key = 0x31003; +const int KeyPress::F29Key = 0x31004; +const int KeyPress::F30Key = 0x31005; +const int KeyPress::F31Key = 0x31006; +const int KeyPress::F32Key = 0x31007; +const int KeyPress::F33Key = 0x31008; +const int KeyPress::F34Key = 0x31009; +const int KeyPress::F35Key = 0x3100a; + const int KeyPress::numberPad0 = VK_NUMPAD0 | extendedKeyModifier; const int KeyPress::numberPad1 = VK_NUMPAD1 | extendedKeyModifier; const int KeyPress::numberPad2 = VK_NUMPAD2 | extendedKeyModifier; @@ -2370,6 +2393,7 @@ private: else if (isUp) { modsToSend = modsToSend.withoutMouseButtons(); + currentModifiers = modsToSend; currentTouches.clearTouch (touchIndex); if (! currentTouches.areAnyTouchesActive()) @@ -2599,6 +2623,14 @@ private: case VK_F14: case VK_F15: case VK_F16: + case VK_F17: + case VK_F18: + case VK_F19: + case VK_F20: + case VK_F21: + case VK_F22: + case VK_F23: + case VK_F24: used = handleKeyUpOrDown (true); used = handleKeyPress (extendedKeyModifier | (int) key, 0) || used; break; @@ -3440,7 +3472,7 @@ private: HeapBlock buffer; buffer.calloc (stringSizeBytes / sizeof (TCHAR) + 1); ImmGetCompositionString (hImc, type, buffer, (DWORD) stringSizeBytes); - return String (buffer); + return String (buffer.get()); } return {}; @@ -4166,3 +4198,5 @@ void MouseCursor::showInAllWindows() const { showInWindow (nullptr); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index ee61180f07..7651dceedc 100644 --- a/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/modules/juce_gui_basics/positioning/juce_MarkerList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + MarkerList::MarkerList() { } @@ -278,3 +281,5 @@ void MarkerList::ValueTreeWrapper::readFrom (const MarkerList& markerList, UndoM for (int i = 0; i < markerList.getNumMarkers(); ++i) setMarker (*markerList.getMarker(i), undoManager); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_MarkerList.h b/modules/juce_gui_basics/positioning/juce_MarkerList.h index 8d6da7f7e0..c73f1f5ab9 100644 --- a/modules/juce_gui_basics/positioning/juce_MarkerList.h +++ b/modules/juce_gui_basics/positioning/juce_MarkerList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -180,3 +180,5 @@ private: JUCE_LEAK_DETECTOR (MarkerList) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index ce79716939..fcb803bafb 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const String RelativeCoordinate::Strings::parent ("parent"); const String RelativeCoordinate::Strings::left ("left"); const String RelativeCoordinate::Strings::right ("right"); @@ -147,3 +150,5 @@ String RelativeCoordinate::toString() const { return term.toString(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h index 507dfcd499..55d3edfded 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -175,3 +175,5 @@ private: //============================================================================== Expression term; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index 7260710de1..9afd38ee78 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct MarkerListScope : public Expression::Scope { MarkerListScope (Component& comp) : component (comp) {} @@ -317,3 +320,5 @@ void RelativeCoordinatePositionerBase::unregisterListeners() sourceComponents.clear(); sourceMarkerLists.clear(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h index 74abf43601..038f9dec65 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -88,3 +88,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp index 92ad11fc4a..3d9f6ed919 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RelativeParallelogram::RelativeParallelogram() { } @@ -134,3 +137,5 @@ Rectangle RelativeParallelogram::getBoundingBox (const Point* cons const Point points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) }; return Rectangle::findAreaContainingPoints (points, 4); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h index 38ab861eac..afd88c9f0c 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -61,3 +61,5 @@ public: //============================================================================== RelativePoint topLeft, topRight, bottomLeft; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp b/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp index 5f9228c202..51895b2983 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace RelativePointHelpers { inline void skipComma (String::CharPointerType& s) @@ -95,3 +98,5 @@ bool RelativePoint::isDynamic() const { return x.isDynamic() || y.isDynamic(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePoint.h b/modules/juce_gui_basics/positioning/juce_RelativePoint.h index cb874f6e2a..7bf446690b 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePoint.h +++ b/modules/juce_gui_basics/positioning/juce_RelativePoint.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -86,3 +86,5 @@ public: // The actual X and Y coords... RelativeCoordinate x, y; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 5f36d46ef8..ee57e48895 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RelativePointPath::RelativePointPath() : usesNonZeroWinding (true), containsDynamicPoints (false) @@ -292,3 +295,5 @@ RelativePointPath::ElementBase* RelativePointPath::CubicTo::clone() const { return new CubicTo (controlPoints[0], controlPoints[1], controlPoints[2]); } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativePointPath.h b/modules/juce_gui_basics/positioning/juce_RelativePointPath.h index ff628db343..6e648a5fe1 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativePointPath.h +++ b/modules/juce_gui_basics/positioning/juce_RelativePointPath.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -187,3 +187,5 @@ private: RelativePointPath& operator= (const RelativePointPath&); JUCE_LEAK_DETECTOR (RelativePointPath) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp index d2b73580e5..574be97676 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace RelativeRectangleHelpers { inline void skipComma (String::CharPointerType& s) @@ -262,3 +265,5 @@ void RelativeRectangle::applyToComponent (Component& component) const component.setBounds (resolve (nullptr).getSmallestIntegerContainer()); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h index b634adc659..4113769de7 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h +++ b/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -103,3 +103,5 @@ public: // The actual rectangle coords... RelativeCoordinate left, right, top, bottom; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp index bbf568a638..0e5dbdc08f 100644 --- a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BooleanPropertyComponent::BooleanPropertyComponent (const String& name, const String& buttonTextWhenTrue, const String& buttonTextWhenFalse) @@ -85,3 +88,5 @@ void BooleanPropertyComponent::buttonClicked (Button*) { setState (! getState()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h index 37e112c682..061541a70d 100644 --- a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -107,3 +107,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BooleanPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp index 00343f65a8..3d3a1b0ffa 100644 --- a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ButtonPropertyComponent::ButtonPropertyComponent (const String& name, const bool triggerOnMouseDown) : PropertyComponent (name) @@ -46,3 +49,5 @@ void ButtonPropertyComponent::buttonClicked (Button*) { buttonClicked(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h index 64390c805a..1415b8cd1c 100644 --- a/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -74,3 +74,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index 7c26d26362..c788ae3920 100644 --- a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ChoicePropertyComponent::RemapperValueSource : public Value::ValueSource, private Value::Listener { @@ -152,3 +155,5 @@ void ChoicePropertyComponent::comboBoxChanged (ComboBox*) setIndex (newIndex); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h index c9ffe6d092..600a23cc7f 100644 --- a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -119,3 +119,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChoicePropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 81ee114e9b..19136a5e76 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PropertyComponent::PropertyComponent (const String& name, const int preferredHeight_) : Component (name), preferredHeight (preferredHeight_) { @@ -50,3 +53,5 @@ void PropertyComponent::enablementChanged() { repaint(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyComponent.h b/modules/juce_gui_basics/properties/juce_PropertyComponent.h index c6e2ec6e29..263b3b5cf3 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_PropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -139,3 +139,5 @@ protected: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index a12c436a89..c2e5842d5a 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct PropertyPanel::SectionComponent : public Component { SectionComponent (const String& sectionTitle, @@ -374,3 +377,5 @@ const String& PropertyPanel::getMessageWhenEmpty() const noexcept { return messageWhenEmpty; } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_PropertyPanel.h b/modules/juce_gui_basics/properties/juce_PropertyPanel.h index 24150eb1f7..49ab8fde4e 100644 --- a/modules/juce_gui_basics/properties/juce_PropertyPanel.h +++ b/modules/juce_gui_basics/properties/juce_PropertyPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -173,3 +173,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp index 4db6859a7d..439ef36cf5 100644 --- a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SliderPropertyComponent::SliderPropertyComponent (const String& name, const double rangeMin, const double rangeMax, @@ -82,3 +85,5 @@ void SliderPropertyComponent::sliderValueChanged (Slider*) if (getValue() != slider.getValue()) setValue (slider.getValue()); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h index 9a30dbbc29..944d6c1b9c 100644 --- a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -105,3 +105,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SliderPropertyComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 3193f110bf..290b8fd478 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TextPropertyComponent::LabelComp : public Label, public FileDragAndDropTarget { @@ -181,3 +184,5 @@ void TextPropertyComponent::setInterestedInFileDrag (bool isInterested) if (textEditor != nullptr) textEditor->setInterestedInFileDrag (isInterested); } + +} // namespace juce diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index 5a10ca6f5e..8769ac1b9e 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -53,7 +53,7 @@ protected: public: /** Creates a text property component. - @param valueToControl The Value that is controlled by the TextPropertyCOmponent + @param valueToControl The Value that is controlled by the TextPropertyComponent @param propertyName The name of the property @param maxNumChars If not zero, then this specifies the maximum allowable length of the string. If zero, then the string will have no length limit. @@ -153,3 +153,5 @@ private: /** This typedef is just for compatibility with old code and VC6 - newer code should use TextPropertyComponent::Listener instead. */ typedef TextPropertyComponent::Listener TextPropertyComponentListener; #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 95702233a4..2100c123b8 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ComboBox::ComboBox (const String& name) : Component (name), lastCurrentId (0), @@ -384,7 +387,7 @@ void ComboBox::paint (Graphics& g) && ! label->isBeingEdited()) { g.setColour (findColour (textColourId).withMultipliedAlpha (0.5f)); - g.setFont (label->getFont()); + g.setFont (label->getLookAndFeel().getLabelFont (*label)); g.drawFittedText (textWhenNothingSelected, label->getBounds().reduced (2, 1), label->getJustificationType(), jmax (1, (int) (label->getHeight() / label->getFont().getHeight()))); @@ -505,7 +508,14 @@ void ComboBox::showPopupIfNotActive() if (! menuActive) { menuActive = true; - showPopup(); + + SafePointer safePointer (this); + + // as this method was triggered by a mouse event, the same mouse event may have + // exited the modal state of other popups currently on the screen. By calling + // showPopup asynchronously, we are giving the other popups a chance to properly + // close themselves + MessageManager::callAsync([safePointer] () mutable { if (safePointer != nullptr) safePointer->showPopup(); }); } } @@ -644,3 +654,5 @@ void ComboBox::clear (const bool dontSendChange) void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChange) { setSelectedItemIndex (index, dontSendChange ? dontSendNotification : sendNotification); } void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange) { setSelectedId (newItemId, dontSendChange ? dontSendNotification : sendNotification); } void ComboBox::setText (const String& newText, const bool dontSendChange) { setText (newText, dontSendChange ? dontSendNotification : sendNotification); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.h b/modules/juce_gui_basics/widgets/juce_ComboBox.h index 09d02984f9..2092287629 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -448,3 +448,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the ComboBox::Listener class directly. */ typedef ComboBox::Listener ComboBoxListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp b/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp index 77d2a98074..3dac30c5f6 100644 --- a/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ImageComponent::ImageComponent (const String& name) : Component (name), placement (RectanglePlacement::centred) @@ -77,3 +80,5 @@ void ImageComponent::paint (Graphics& g) g.setOpacity (1.0f); g.drawImage (image, getLocalBounds().toFloat(), placement); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ImageComponent.h b/modules/juce_gui_basics/widgets/juce_ImageComponent.h index 3957d58f64..3872634729 100644 --- a/modules/juce_gui_basics/widgets/juce_ImageComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ImageComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -74,3 +74,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 7304090f07..403c7d3a45 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Label::Label (const String& name, const String& labelText) : Component (name), textValue (labelText), @@ -472,3 +475,5 @@ void Label::textEditorFocusLost (TextEditor& ed) { textEditorTextChanged (ed); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index 7b0aa30d63..34104cdf0d 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -351,3 +351,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Label::Listener class directly. */ typedef Label::Listener LabelListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 9c303a9809..7f39a4eca8 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ListBox::RowComponent : public Component, public TooltipClient { @@ -950,3 +953,5 @@ void ListBoxModel::listWasScrolled() {} var ListBoxModel::getDragSourceDescription (const SparseSet&) { return {}; } String ListBoxModel::getTooltipForRow (int) { return {}; } MouseCursor ListBoxModel::getMouseCursorForRow (int) { return MouseCursor::NormalCursor; } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index 31275dc68f..191af7824f 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -598,3 +598,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index c0ed84250a..67f3e4885d 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ProgressBar::ProgressBar (double& progress_) : progress (progress_), displayPercentage (true), @@ -111,3 +114,5 @@ void ProgressBar::timerCallback() repaint(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/modules/juce_gui_basics/widgets/juce_ProgressBar.h index 5ce9410a34..d462be1d52 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -35,6 +35,10 @@ to keep an eye on a variable that you give it, and will automatically redraw itself when the variable changes. + If using LookAndFeel_V4 a circular spinning progress bar will be drawn if + the width and height of the ProgressBar are equal, otherwise the standard, + linear ProgressBar will be drawn. + For an easy way of running a background task with a dialog box showing its progress, see the ThreadWithProgressWindow class. @@ -51,9 +55,10 @@ public: @param progress pass in a reference to a double that you're going to update with your task's progress. The ProgressBar will monitor the value of this variable and will redraw itself - when the value changes. The range is from 0 to 1.0. Obviously - you'd better be careful not to delete this variable while the - ProgressBar still exists! + when the value changes. The range is from 0 to 1.0 and JUCE + LookAndFeel classes will draw a spinning animation for values + outside this range. Obviously you'd better be careful not to + delete this variable while the ProgressBar still exists! */ explicit ProgressBar (double& progress); @@ -133,3 +138,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProgressBar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 5981b4a0b1..bd6b0a268f 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -24,7 +24,11 @@ ============================================================================== */ -class Slider::Pimpl : private AsyncUpdater, +namespace juce +{ + +class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwise it will cause an + // error when JUCE_DLL_BUILD=1 private Button::Listener, private Label::Listener, private Value::Listener @@ -953,7 +957,7 @@ public: && style != TwoValueHorizontal && style != TwoValueVertical) { - if (owner.isMouseOver (true) && owner.getTopLevelComponent()->hasKeyboardFocus (true)) + if (owner.isMouseOver (true)) { if (popupDisplay == nullptr) showPopupDisplay(); @@ -1621,3 +1625,5 @@ void Slider::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel if (! (isEnabled() && pimpl->mouseWheelMove (e, wheel))) Component::mouseWheelMove (e, wheel); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 63e583ab6c..ae60454c96 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -940,3 +940,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the Slider::Listener class directly. */ typedef Slider::Listener SliderListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 444e7d50c6..b939a4ba75 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -24,11 +24,13 @@ ============================================================================== */ +namespace juce +{ + class TableHeaderComponent::DragOverlayComp : public Component { public: - DragOverlayComp (const Image& image_) - : image (image_) + DragOverlayComp (const Image& i) : image (i) { image.duplicateIfShared(); image.multiplyAllAlphas (0.8f); @@ -40,7 +42,6 @@ public: g.drawImageAt (image, 0, 0); } -private: Image image; JUCE_DECLARE_NON_COPYABLE (DragOverlayComp) @@ -49,15 +50,6 @@ private: //============================================================================== TableHeaderComponent::TableHeaderComponent() - : columnsChanged (false), - columnsResized (false), - sortChanged (false), - menuActive (true), - stretchToFit (false), - columnIdBeingResized (0), - columnIdBeingDragged (0), - columnIdUnderMouse (0), - lastDeliberateWidth (0) { } @@ -67,12 +59,12 @@ TableHeaderComponent::~TableHeaderComponent() } //============================================================================== -void TableHeaderComponent::setPopupMenuActive (const bool hasMenu) +void TableHeaderComponent::setPopupMenuActive (bool hasMenu) { menuActive = hasMenu; } -bool TableHeaderComponent::isPopupMenuActive() const { return menuActive; } +bool TableHeaderComponent::isPopupMenuActive() const { return menuActive; } //============================================================================== @@ -82,8 +74,8 @@ int TableHeaderComponent::getNumColumns (const bool onlyCountVisibleColumns) con { int num = 0; - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->isVisible()) + for (auto* c : columns) + if (c->isVisible()) ++num; return num; @@ -113,26 +105,24 @@ void TableHeaderComponent::setColumnName (const int columnId, const String& newN } void TableHeaderComponent::addColumn (const String& columnName, - const int columnId, - const int width, - const int minimumWidth, - const int maximumWidth, - const int propertyFlags, - const int insertIndex) -{ - // can't have a duplicate or null ID! + int columnId, + int width, + int minimumWidth, + int maximumWidth, + int propertyFlags, + int insertIndex) +{ + // can't have a duplicate or zero ID! jassert (columnId != 0 && getIndexOfColumnId (columnId, false) < 0); jassert (width > 0); - ColumnInfo* const ci = new ColumnInfo(); + auto ci = new ColumnInfo(); ci->name = columnName; ci->id = columnId; ci->width = width; ci->lastDeliberateWidth = width; ci->minimumWidth = minimumWidth; - ci->maximumWidth = maximumWidth; - if (ci->maximumWidth < 0) - ci->maximumWidth = std::numeric_limits::max(); + ci->maximumWidth = maximumWidth >= 0 ? maximumWidth : std::numeric_limits::max(); jassert (ci->maximumWidth >= ci->minimumWidth); ci->propertyFlags = propertyFlags; @@ -142,7 +132,7 @@ void TableHeaderComponent::addColumn (const String& columnName, void TableHeaderComponent::removeColumn (const int columnIdToRemove) { - const int index = getIndexOfColumnId (columnIdToRemove, false); + auto index = getIndexOfColumnId (columnIdToRemove, false); if (index >= 0) { @@ -163,7 +153,7 @@ void TableHeaderComponent::removeAllColumns() void TableHeaderComponent::moveColumn (const int columnId, int newIndex) { - const int currentIndex = getIndexOfColumnId (columnId, false); + auto currentIndex = getIndexOfColumnId (columnId, false); newIndex = visibleIndexToTotalIndex (newIndex); if (columns [currentIndex] != 0 && currentIndex != newIndex) @@ -175,7 +165,7 @@ void TableHeaderComponent::moveColumn (const int columnId, int newIndex) int TableHeaderComponent::getColumnWidth (const int columnId) const { - if (const ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) return ci->width; return 0; @@ -183,33 +173,34 @@ int TableHeaderComponent::getColumnWidth (const int columnId) const void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidth) { - ColumnInfo* const ci = getInfoForId (columnId); - - if (ci != nullptr && ci->width != newWidth) + if (auto* ci = getInfoForId (columnId)) { - const int numColumns = getNumColumns (true); - - ci->lastDeliberateWidth = ci->width - = jlimit (ci->minimumWidth, ci->maximumWidth, newWidth); - - if (stretchToFit) + if (ci->width != newWidth) { - const int index = getIndexOfColumnId (columnId, true) + 1; + auto numColumns = getNumColumns (true); - if (isPositiveAndBelow (index, numColumns)) + ci->lastDeliberateWidth = ci->width + = jlimit (ci->minimumWidth, ci->maximumWidth, newWidth); + + if (stretchToFit) { - const int x = getColumnPosition (index).getX(); + auto index = getIndexOfColumnId (columnId, true) + 1; + + if (isPositiveAndBelow (index, numColumns)) + { + auto x = getColumnPosition (index).getX(); - if (lastDeliberateWidth == 0) - lastDeliberateWidth = getTotalWidth(); + if (lastDeliberateWidth == 0) + lastDeliberateWidth = getTotalWidth(); - resizeColumnsToFit (visibleIndexToTotalIndex (index), lastDeliberateWidth - x); + resizeColumnsToFit (visibleIndexToTotalIndex (index), lastDeliberateWidth - x); + } } - } - repaint(); - columnsResized = true; - triggerAsyncUpdate(); + repaint(); + columnsResized = true; + triggerAsyncUpdate(); + } } } @@ -218,11 +209,11 @@ int TableHeaderComponent::getIndexOfColumnId (const int columnId, const bool onl { int n = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* c : columns) { - if ((! onlyCountVisibleColumns) || columns.getUnchecked(i)->isVisible()) + if ((! onlyCountVisibleColumns) || c->isVisible()) { - if (columns.getUnchecked(i)->id == columnId) + if (c->id == columnId) return n; ++n; @@ -237,7 +228,7 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis if (onlyCountVisibleColumns) index = visibleIndexToTotalIndex (index); - if (const ColumnInfo* const ci = columns [index]) + if (auto* ci = columns [index]) return ci->id; return 0; @@ -247,13 +238,13 @@ Rectangle TableHeaderComponent::getColumnPosition (const int index) const { int x = 0, width = 0, n = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* c : columns) { x += width; - if (columns.getUnchecked(i)->isVisible()) + if (c->isVisible()) { - width = columns.getUnchecked(i)->width; + width = c->width; if (n++ == index) break; @@ -264,7 +255,7 @@ Rectangle TableHeaderComponent::getColumnPosition (const int index) const } } - return Rectangle (x, 0, width, getHeight()); + return { x, 0, width, getHeight() }; } int TableHeaderComponent::getColumnIdAtX (const int xToFind) const @@ -273,10 +264,8 @@ int TableHeaderComponent::getColumnIdAtX (const int xToFind) const { int x = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked(i); - if (ci->isVisible()) { x += ci->width; @@ -294,9 +283,9 @@ int TableHeaderComponent::getTotalWidth() const { int w = 0; - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->isVisible()) - w += columns.getUnchecked(i)->width; + for (auto* c : columns) + if (c->isVisible()) + w += c->width; return w; } @@ -326,27 +315,27 @@ void TableHeaderComponent::resizeAllColumnsToFit (int targetTotalWidth) void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetTotalWidth) { targetTotalWidth = jmax (targetTotalWidth, 0); - StretchableObjectResizer sor; + for (int i = firstColumnIndex; i < columns.size(); ++i) { - ColumnInfo* const ci = columns.getUnchecked(i); + auto* ci = columns.getUnchecked(i); if (ci->isVisible()) sor.addItem (ci->lastDeliberateWidth, ci->minimumWidth, ci->maximumWidth); } sor.resizeToFit (targetTotalWidth); - int visIndex = 0; + for (int i = firstColumnIndex; i < columns.size(); ++i) { - ColumnInfo* const ci = columns.getUnchecked(i); + auto* ci = columns.getUnchecked(i); if (ci->isVisible()) { - const int newWidth = jlimit (ci->minimumWidth, ci->maximumWidth, - (int) std::floor (sor.getItemSize (visIndex++))); + auto newWidth = jlimit (ci->minimumWidth, ci->maximumWidth, + (int) std::floor (sor.getItemSize (visIndex++))); if (newWidth != ci->width) { @@ -361,7 +350,7 @@ void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetT void TableHeaderComponent::setColumnVisible (const int columnId, const bool shouldBeVisible) { - if (ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) { if (shouldBeVisible != ci->isVisible()) { @@ -378,8 +367,10 @@ void TableHeaderComponent::setColumnVisible (const int columnId, const bool shou bool TableHeaderComponent::isColumnVisible (const int columnId) const { - const ColumnInfo* const ci = getInfoForId (columnId); - return ci != nullptr && ci->isVisible(); + if (auto* ci = getInfoForId (columnId)) + return ci->isVisible(); + + return false; } //============================================================================== @@ -387,10 +378,10 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF { if (getSortColumnId() != columnId || isSortedForwards() != sortForwards) { - for (int i = columns.size(); --i >= 0;) - columns.getUnchecked(i)->propertyFlags &= ~(sortedForwards | sortedBackwards); + for (auto* c : columns) + c->propertyFlags &= ~(sortedForwards | sortedBackwards); - if (ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) ci->propertyFlags |= (sortForwards ? sortedForwards : sortedBackwards); reSortTable(); @@ -399,18 +390,18 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF int TableHeaderComponent::getSortColumnId() const { - for (int i = columns.size(); --i >= 0;) - if ((columns.getUnchecked(i)->propertyFlags & (sortedForwards | sortedBackwards)) != 0) - return columns.getUnchecked(i)->id; + for (auto* c : columns) + if ((c->propertyFlags & (sortedForwards | sortedBackwards)) != 0) + return c->id; return 0; } bool TableHeaderComponent::isSortedForwards() const { - for (int i = columns.size(); --i >= 0;) - if ((columns.getUnchecked(i)->propertyFlags & (sortedForwards | sortedBackwards)) != 0) - return (columns.getUnchecked(i)->propertyFlags & sortedForwards) != 0; + for (auto* c : columns) + if ((c->propertyFlags & (sortedForwards | sortedBackwards)) != 0) + return (c->propertyFlags & sortedForwards) != 0; return true; } @@ -432,17 +423,15 @@ String TableHeaderComponent::toString() const doc.setAttribute ("sortedCol", getSortColumnId()); doc.setAttribute ("sortForwards", isSortedForwards()); - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked (i); - - XmlElement* const e = doc.createNewChildElement ("COLUMN"); + auto* e = doc.createNewChildElement ("COLUMN"); e->setAttribute ("id", ci->id); e->setAttribute ("visible", ci->isVisible()); e->setAttribute ("width", ci->width); } - return doc.createDocument ("", true, false); + return doc.createDocument ({}, true, false); } void TableHeaderComponent::restoreFromString (const String& storedVersion) @@ -454,9 +443,9 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion) { forEachXmlChildElement (*storedXml, col) { - const int tabId = col->getIntAttribute ("id"); + auto tabId = col->getIntAttribute ("id"); - if (ColumnInfo* const ci = getInfoForId (tabId)) + if (auto* ci = getInfoForId (tabId)) { columns.move (columns.indexOf (ci), index); ci->width = col->getIntAttribute ("width"); @@ -488,22 +477,18 @@ void TableHeaderComponent::removeListener (Listener* const listenerToRemove) //============================================================================== void TableHeaderComponent::columnClicked (int columnId, const ModifierKeys& mods) { - if (const ColumnInfo* const ci = getInfoForId (columnId)) + if (auto* ci = getInfoForId (columnId)) if ((ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu()) setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0); } void TableHeaderComponent::addMenuItems (PopupMenu& menu, const int /*columnIdClicked*/) { - for (int i = 0; i < columns.size(); ++i) - { - const ColumnInfo* const ci = columns.getUnchecked(i); - + for (auto* ci : columns) if ((ci->propertyFlags & appearsOnColumnMenu) != 0) menu.addItem (ci->id, ci->name, (ci->propertyFlags & (sortedForwards | sortedBackwards)) == 0, isColumnVisible (ci->id)); - } } void TableHeaderComponent::reactToMenuItem (const int menuReturnId, const int /*columnIdClicked*/) @@ -521,10 +506,9 @@ void TableHeaderComponent::paint (Graphics& g) const Rectangle clip (g.getClipBounds()); int x = 0; - for (int i = 0; i < columns.size(); ++i) - { - const ColumnInfo* const ci = columns.getUnchecked(i); + for (auto* ci : columns) + { if (ci->isVisible()) { if (x + ci->width > clip.getX() @@ -551,24 +535,9 @@ void TableHeaderComponent::paint (Graphics& g) } } -void TableHeaderComponent::resized() -{ -} - -void TableHeaderComponent::mouseMove (const MouseEvent& e) -{ - updateColumnUnderMouse (e); -} - -void TableHeaderComponent::mouseEnter (const MouseEvent& e) -{ - updateColumnUnderMouse (e); -} - -void TableHeaderComponent::mouseExit (const MouseEvent&) -{ - setColumnUnderMouse (0); -} +void TableHeaderComponent::mouseMove (const MouseEvent& e) { updateColumnUnderMouse (e); } +void TableHeaderComponent::mouseEnter (const MouseEvent& e) { updateColumnUnderMouse (e); } +void TableHeaderComponent::mouseExit (const MouseEvent&) { setColumnUnderMouse (0); } void TableHeaderComponent::mouseDown (const MouseEvent& e) { @@ -601,9 +570,10 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) if (columnIdBeingResized != 0) { - const ColumnInfo* const ci = getInfoForId (columnIdBeingResized); - jassert (ci != nullptr); - initialColumnWidth = ci->width; + if (auto* ci = getInfoForId (columnIdBeingResized)) + initialColumnWidth = ci->width; + else + jassertfalse; } else { @@ -613,20 +583,21 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) if (columnIdBeingResized != 0) { - if (const ColumnInfo* const ci = getInfoForId (columnIdBeingResized)) + if (auto* ci = getInfoForId (columnIdBeingResized)) { - int w = jlimit (ci->minimumWidth, ci->maximumWidth, - initialColumnWidth + e.getDistanceFromDragStartX()); + auto w = jlimit (ci->minimumWidth, ci->maximumWidth, + initialColumnWidth + e.getDistanceFromDragStartX()); if (stretchToFit) { // prevent us dragging a column too far right if we're in stretch-to-fit mode int minWidthOnRight = 0; + for (int i = getIndexOfColumnId (columnIdBeingResized, false) + 1; i < columns.size(); ++i) if (columns.getUnchecked (i)->isVisible()) minWidthOnRight += columns.getUnchecked (i)->minimumWidth; - const Rectangle currentPos (getColumnPosition (getIndexOfColumnId (columnIdBeingResized, true))); + auto currentPos = getColumnPosition (getIndexOfColumnId (columnIdBeingResized, true)); w = jmax (ci->minimumWidth, jmin (w, lastDeliberateWidth - minWidthOnRight - currentPos.getX())); } @@ -656,15 +627,15 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) { // if the previous column isn't draggable, we can't move our column // past it, because that'd change the undraggable column's position.. - const ColumnInfo* const previous = columns.getUnchecked (newIndex - 1); + auto* previous = columns.getUnchecked (newIndex - 1); if ((previous->propertyFlags & draggable) != 0) { - const int leftOfPrevious = getColumnPosition (newIndex - 1).getX(); - const int rightOfCurrent = getColumnPosition (newIndex).getRight(); + auto leftOfPrevious = getColumnPosition (newIndex - 1).getX(); + auto rightOfCurrent = getColumnPosition (newIndex).getRight(); - if (abs (dragOverlayComp->getX() - leftOfPrevious) - < abs (dragOverlayComp->getRight() - rightOfCurrent)) + if (std::abs (dragOverlayComp->getX() - leftOfPrevious) + < std::abs (dragOverlayComp->getRight() - rightOfCurrent)) { --newIndex; } @@ -675,15 +646,15 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e) { // if the next column isn't draggable, we can't move our column // past it, because that'd change the undraggable column's position.. - const ColumnInfo* const nextCol = columns.getUnchecked (newIndex + 1); + auto* nextCol = columns.getUnchecked (newIndex + 1); if ((nextCol->propertyFlags & draggable) != 0) { - const int leftOfCurrent = getColumnPosition (newIndex).getX(); - const int rightOfNext = getColumnPosition (newIndex + 1).getRight(); + auto leftOfCurrent = getColumnPosition (newIndex).getX(); + auto rightOfNext = getColumnPosition (newIndex + 1).getRight(); - if (abs (dragOverlayComp->getX() - leftOfCurrent) - > abs (dragOverlayComp->getRight() - rightOfNext)) + if (std::abs (dragOverlayComp->getX() - leftOfCurrent) + > std::abs (dragOverlayComp->getRight() - rightOfNext)) { ++newIndex; } @@ -710,7 +681,7 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e) { columnIdBeingDragged = getColumnIdAtX (e.getMouseDownX()); - const ColumnInfo* const ci = getInfoForId (columnIdBeingDragged); + auto* ci = getInfoForId (columnIdBeingDragged); if (ci == nullptr || (ci->propertyFlags & draggable) == 0) { @@ -720,9 +691,8 @@ void TableHeaderComponent::beginDrag (const MouseEvent& e) { draggingColumnOriginalIndex = getIndexOfColumnId (columnIdBeingDragged, true); - const Rectangle columnRect (getColumnPosition (draggingColumnOriginalIndex)); - - const int temp = columnIdBeingDragged; + auto columnRect = getColumnPosition (draggingColumnOriginalIndex); + auto temp = columnIdBeingDragged; columnIdBeingDragged = 0; addAndMakeVisible (dragOverlayComp = new DragOverlayComp (createComponentSnapshot (columnRect, false))); @@ -760,9 +730,9 @@ void TableHeaderComponent::mouseUp (const MouseEvent& e) { mouseDrag (e); - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked (i)->isVisible()) - columns.getUnchecked (i)->lastDeliberateWidth = columns.getUnchecked (i)->width; + for (auto* c : columns) + if (c->isVisible()) + c->lastDeliberateWidth = c->width; columnIdBeingResized = 0; repaint(); @@ -791,11 +761,11 @@ bool TableHeaderComponent::ColumnInfo::isVisible() const return (propertyFlags & TableHeaderComponent::visible) != 0; } -TableHeaderComponent::ColumnInfo* TableHeaderComponent::getInfoForId (const int id) const +TableHeaderComponent::ColumnInfo* TableHeaderComponent::getInfoForId (int id) const { - for (int i = columns.size(); --i >= 0;) - if (columns.getUnchecked(i)->id == id) - return columns.getUnchecked(i); + for (auto* c : columns) + if (c->id == id) + return c; return nullptr; } @@ -872,13 +842,11 @@ int TableHeaderComponent::getResizeDraggerAt (const int mouseX) const const int draggableDistance = 3; int x = 0; - for (int i = 0; i < columns.size(); ++i) + for (auto* ci : columns) { - const ColumnInfo* const ci = columns.getUnchecked(i); - if (ci->isVisible()) { - if (abs (mouseX - (x + ci->width)) <= draggableDistance + if (std::abs (mouseX - (x + ci->width)) <= draggableDistance && (ci->propertyFlags & resizable) != 0) return ci->id; @@ -928,3 +896,5 @@ void TableHeaderComponent::showColumnChooserMenu (const int columnIdClicked) void TableHeaderComponent::Listener::tableColumnDraggingChanged (TableHeaderComponent*, int) { } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index 4efedbdf82..bccb5bbfe2 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -402,8 +402,6 @@ public: /** @internal */ void paint (Graphics&) override; /** @internal */ - void resized() override; - /** @internal */ void mouseMove (const MouseEvent&) override; /** @internal */ void mouseEnter (const MouseEvent&) override; @@ -436,9 +434,10 @@ private: ScopedPointer dragOverlayComp; class DragOverlayComp; - bool columnsChanged, columnsResized, sortChanged, menuActive, stretchToFit; - int columnIdBeingResized, columnIdBeingDragged, initialColumnWidth; - int columnIdUnderMouse, draggingColumnOffset, draggingColumnOriginalIndex, lastDeliberateWidth; + bool columnsChanged = false, columnsResized = false, sortChanged = false; + bool menuActive = true, stretchToFit = false; + int columnIdBeingResized = 0, columnIdBeingDragged = 0, initialColumnWidth = 0; + int columnIdUnderMouse = 0, draggingColumnOffset = 0, draggingColumnOriginalIndex = 0, lastDeliberateWidth = 0; ColumnInfo* getInfoForId (int columnId) const; int visibleIndexToTotalIndex (int visibleIndex) const; @@ -456,3 +455,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the TableHeaderComponent::Listener class directly. */ typedef TableHeaderComponent::Listener TableHeaderListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index b9b4b9f2a8..784bdbeba1 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -24,29 +24,30 @@ ============================================================================== */ +namespace juce +{ + class TableListBox::RowComp : public Component, public TooltipClient { public: - RowComp (TableListBox& tlb) noexcept : owner (tlb), row (-1), isSelected (false) - { - } + RowComp (TableListBox& tlb) noexcept : owner (tlb) {} void paint (Graphics& g) override { - if (TableListBoxModel* const tableModel = owner.getModel()) + if (auto* tableModel = owner.getModel()) { tableModel->paintRowBackground (g, row, getWidth(), getHeight(), isSelected); - const TableHeaderComponent& headerComp = owner.getHeader(); - const int numColumns = headerComp.getNumColumns (true); - const Rectangle clipBounds (g.getClipBounds()); + auto& headerComp = owner.getHeader(); + auto numColumns = headerComp.getNumColumns (true); + auto clipBounds = g.getClipBounds(); for (int i = 0; i < numColumns; ++i) { if (columnComponents[i] == nullptr) { - const Rectangle columnRect (headerComp.getColumnPosition(i).withHeight (getHeight())); + auto columnRect = headerComp.getColumnPosition(i).withHeight (getHeight()); if (columnRect.getX() >= clipBounds.getRight()) break; @@ -67,7 +68,7 @@ public: } } - void update (const int newRow, const bool isNowSelected) + void update (int newRow, bool isNowSelected) { jassert (newRow >= 0); @@ -78,19 +79,19 @@ public: repaint(); } - TableListBoxModel* const tableModel = owner.getModel(); + auto* tableModel = owner.getModel(); if (tableModel != nullptr && row < owner.getNumRows()) { const Identifier columnProperty ("_tableColumnId"); - const int numColumns = owner.getHeader().getNumColumns (true); + auto numColumns = owner.getHeader().getNumColumns (true); for (int i = 0; i < numColumns; ++i) { - const int columnId = owner.getHeader().getColumnIdOfIndex (i, true); - Component* comp = columnComponents[i]; + auto columnId = owner.getHeader().getColumnIdOfIndex (i, true); + auto* comp = columnComponents[i]; - if (comp != nullptr && columnId != (int) comp->getProperties() [columnProperty]) + if (comp != nullptr && columnId != static_cast (comp->getProperties() [columnProperty])) { columnComponents.set (i, nullptr); comp = nullptr; @@ -122,9 +123,9 @@ public: resizeCustomComp (i); } - void resizeCustomComp (const int index) + void resizeCustomComp (int index) { - if (Component* const c = columnComponents.getUnchecked (index)) + if (auto* c = columnComponents.getUnchecked (index)) c->setBounds (owner.getHeader().getColumnPosition (index) .withY (0).withHeight (getHeight())); } @@ -140,10 +141,10 @@ public: { owner.selectRowsBasedOnModifierKeys (row, e.mods, false); - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) - if (TableListBoxModel* m = owner.getModel()) + if (auto* m = owner.getModel()) m->cellClicked (row, columnId, e); } else @@ -169,7 +170,7 @@ public: if (rowsToDrag.size() > 0) { - const var dragDescription (owner.getModel()->getDragSourceDescription (rowsToDrag)); + auto dragDescription = owner.getModel()->getDragSourceDescription (rowsToDrag); if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty()))) { @@ -186,7 +187,7 @@ public: { owner.selectRowsBasedOnModifierKeys (row, e.mods, true); - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) if (TableListBoxModel* m = owner.getModel()) @@ -196,16 +197,16 @@ public: void mouseDoubleClick (const MouseEvent& e) override { - const int columnId = owner.getHeader().getColumnIdAtX (e.x); + auto columnId = owner.getHeader().getColumnIdAtX (e.x); if (columnId != 0) - if (TableListBoxModel* m = owner.getModel()) + if (auto* m = owner.getModel()) m->cellDoubleClicked (row, columnId, e); } String getTooltip() override { - const int columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); + auto columnId = owner.getHeader().getColumnIdAtX (getMouseXYRelative().getX()); if (columnId != 0) if (auto* m = owner.getModel()) @@ -214,7 +215,7 @@ public: return {}; } - Component* findChildComponentForColumn (const int columnId) const + Component* findChildComponentForColumn (int columnId) const { return columnComponents [owner.getHeader().getIndexOfColumnId (columnId, true)]; } @@ -222,8 +223,8 @@ public: private: TableListBox& owner; OwnedArray columnComponents; - int row; - bool isSelected, isDragging, selectRowOnMouseUp; + int row = -1; + bool isSelected = false, isDragging = false, selectRowOnMouseUp = false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RowComp) }; @@ -267,10 +268,7 @@ private: //============================================================================== TableListBox::TableListBox (const String& name, TableListBoxModel* const m) - : ListBox (name, nullptr), - header (nullptr), - model (m), - autoSizeOptionsShown (true) + : ListBox (name, nullptr), model (m) { ListBox::model = this; @@ -281,7 +279,7 @@ TableListBox::~TableListBox() { } -void TableListBox::setModel (TableListBoxModel* const newModel) +void TableListBox::setModel (TableListBoxModel* newModel) { if (model != newModel) { @@ -295,6 +293,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader) jassert (newHeader != nullptr); // you need to supply a real header for a table! Rectangle newBounds (100, 28); + if (header != nullptr) newBounds = header->getBounds(); @@ -311,15 +310,15 @@ int TableListBox::getHeaderHeight() const noexcept return header->getHeight(); } -void TableListBox::setHeaderHeight (const int newHeight) +void TableListBox::setHeaderHeight (int newHeight) { header->setSize (header->getWidth(), newHeight); resized(); } -void TableListBox::autoSizeColumn (const int columnId) +void TableListBox::autoSizeColumn (int columnId) { - const int width = model != nullptr ? model->getColumnAutoSizeWidth (columnId) : 0; + auto width = model != nullptr ? model->getColumnAutoSizeWidth (columnId) : 0; if (width > 0) header->setColumnWidth (columnId, width); @@ -331,15 +330,14 @@ void TableListBox::autoSizeAllColumns() autoSizeColumn (header->getColumnIdOfIndex (i, true)); } -void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown) noexcept +void TableListBox::setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept { autoSizeOptionsShown = shouldBeShown; } -Rectangle TableListBox::getCellPosition (const int columnId, const int rowNumber, - const bool relativeToComponentTopLeft) const +Rectangle TableListBox::getCellPosition (int columnId, int rowNumber, bool relativeToComponentTopLeft) const { - Rectangle headerCell (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); + auto headerCell = header->getColumnPosition (header->getIndexOfColumnId (columnId, true)); if (relativeToComponentTopLeft) headerCell.translate (header->getX(), 0); @@ -351,20 +349,20 @@ Rectangle TableListBox::getCellPosition (const int columnId, const int rowN Component* TableListBox::getCellComponent (int columnId, int rowNumber) const { - if (RowComp* const rowComp = dynamic_cast (getComponentForRowNumber (rowNumber))) + if (auto* rowComp = dynamic_cast (getComponentForRowNumber (rowNumber))) return rowComp->findChildComponentForColumn (columnId); return nullptr; } -void TableListBox::scrollToEnsureColumnIsOnscreen (const int columnId) +void TableListBox::scrollToEnsureColumnIsOnscreen (int columnId) { - if (ScrollBar* const scrollbar = getHorizontalScrollBar()) + if (auto* scrollbar = getHorizontalScrollBar()) { - const Rectangle pos (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); + auto pos = header->getColumnPosition (header->getIndexOfColumnId (columnId, true)); - double x = scrollbar->getCurrentRangeStart(); - const double w = scrollbar->getCurrentRangeSize(); + auto x = scrollbar->getCurrentRangeStart(); + auto w = scrollbar->getCurrentRangeSize(); if (pos.getX() < x) x = pos.getX(); @@ -461,10 +459,10 @@ void TableListBox::resized() void TableListBox::updateColumnComponents() const { - const int firstRow = getRowContainingPosition (0, 0); + auto firstRow = getRowContainingPosition (0, 0); for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;) - if (RowComp* const rowComp = dynamic_cast (getComponentForRowNumber (i))) + if (auto* rowComp = dynamic_cast (getComponentForRowNumber (i))) rowComp->resized(); } @@ -472,7 +470,7 @@ void TableListBox::updateColumnComponents() const void TableListBoxModel::cellClicked (int, int, const MouseEvent&) {} void TableListBoxModel::cellDoubleClicked (int, int, const MouseEvent&) {} void TableListBoxModel::backgroundClicked (const MouseEvent&) {} -void TableListBoxModel::sortOrderChanged (int, const bool) {} +void TableListBoxModel::sortOrderChanged (int, bool) {} int TableListBoxModel::getColumnAutoSizeWidth (int) { return 0; } void TableListBoxModel::selectedRowsChanged (int) {} void TableListBoxModel::deleteKeyPressed (int) {} @@ -488,3 +486,5 @@ Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component jassert (existingComponentToUpdate == nullptr); // indicates a failure in the code that recycles the components return nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.h b/modules/juce_gui_basics/widgets/juce_TableListBox.h index 8454e959c6..050d831012 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -336,12 +336,14 @@ private: class Header; class RowComp; - TableHeaderComponent* header; + TableHeaderComponent* header = nullptr; TableListBoxModel* model; - int columnIdNowBeingDragged; - bool autoSizeOptionsShown; + int columnIdNowBeingDragged = 0; + bool autoSizeOptionsShown = true; void updateColumnComponents() const; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TableListBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 133af341f7..c40956cfe8 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + // a word or space that can't be broken down any further struct TextAtom { @@ -887,14 +890,10 @@ namespace TextEditorDefs } //============================================================================== -TextEditor::TextEditor (const String& name, - const juce_wchar passwordChar) +TextEditor::TextEditor (const String& name, juce_wchar passwordChar) : Component (name), - passwordCharacter (passwordChar), - keyboardType (TextInputTarget::textKeyboard), - dragType (notDragging) + passwordCharacter (passwordChar) { - setOpaque (true); setMouseCursor (MouseCursor::IBeamCursor); addAndMakeVisible (viewport = new TextEditorViewport (*this)); @@ -1057,16 +1056,8 @@ void TextEditor::applyColourToAllText (const Colour& newColour, bool changeCurre repaint(); } -void TextEditor::colourChanged() -{ - setOpaque (findColour (backgroundColourId).isOpaque()); - repaint(); -} - void TextEditor::lookAndFeelChanged() { - colourChanged(); - caret = nullptr; recreateCaret(); repaint(); @@ -2519,3 +2510,5 @@ void TextEditor::coalesceSimilarSections() } } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 30a6465141..7077d57c04 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -651,8 +651,6 @@ public: /** @internal */ void enablementChanged() override; /** @internal */ - void colourChanged() override; - /** @internal */ void lookAndFeelChanged() override; /** @internal */ void parentHierarchyChanged() override; @@ -723,18 +721,20 @@ private: juce_wchar passwordCharacter; OptionalScopedPointer inputFilter; Value textValue; - VirtualKeyboardType keyboardType; + VirtualKeyboardType keyboardType = TextInputTarget::textKeyboard; float lineSpacing = 1.0f; - enum + enum DragType { notDragging, draggingSelectionStart, draggingSelectionEnd - } dragType; + }; + + DragType dragType = notDragging; ListenerList listeners; - Array > underlinedSections; + Array> underlinedSections; void moveCaret (int newCaretPos); void moveCaretTo (int newPosition, bool isSelecting); @@ -770,3 +770,5 @@ private: /** This typedef is just for compatibility with old code - newer code should use the TextEditor::Listener class directly. */ typedef TextEditor::Listener TextEditorListener; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 258d0e6961..aa5126ae11 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const char* const Toolbar::toolbarDragDescriptor = "_toolbarItem_"; //============================================================================== @@ -811,3 +814,5 @@ void Toolbar::showCustomisationDialog (ToolbarItemFactory& factory, const int op (new CustomisationDialog (factory, *this, optionFlags)) ->enterModalState (true, nullptr, true); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.h b/modules/juce_gui_basics/widgets/juce_Toolbar.h index 1065886358..4950dd5b3d 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.h +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class ToolbarItemComponent; class ToolbarItemFactory; @@ -326,3 +327,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Toolbar) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 707d63d2c5..154ef827e9 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarItemFactory::ToolbarItemFactory() {} ToolbarItemFactory::~ToolbarItemFactory() {} @@ -235,3 +238,5 @@ void ToolbarItemComponent::setEditingMode (const ToolbarEditingMode newMode) resized(); } } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index 76248b59f2..662ca6bc2c 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -201,3 +201,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h index f9d1520044..d6c4fdde8d 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -104,3 +104,5 @@ public: */ virtual ToolbarItemComponent* createItem (int itemId) = 0; }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp index c0b47edb96..474e4742a8 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ToolbarItemPalette::ToolbarItemPalette (ToolbarItemFactory& tbf, Toolbar& bar) : factory (tbf), toolbar (bar) { @@ -106,3 +109,5 @@ void ToolbarItemPalette::resized() itemHolder->setSize (maxX, y + height + 8); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h index 8321657d00..a281baa258 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemPalette) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index d4a24d59dd..c34e7ec5f0 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class TreeView::ContentComponent : public Component, public TooltipClient, public AsyncUpdater @@ -1082,7 +1085,7 @@ void TreeView::fileDragEnter (const StringArray& files, int x, int y) void TreeView::fileDragMove (const StringArray& files, int x, int y) { - handleDrag (files, SourceDetails ({}, this, { x, y })); + handleDrag (files, SourceDetails (var(), this, { x, y })); } void TreeView::fileDragExit (const StringArray&) @@ -1092,7 +1095,7 @@ void TreeView::fileDragExit (const StringArray&) void TreeView::filesDropped (const StringArray& files, int x, int y) { - handleDrop (files, SourceDetails ({}, this, { x, y })); + handleDrop (files, SourceDetails (var(), this, { x, y })); } bool TreeView::isInterestedInDragSource (const SourceDetails& /*dragSourceDetails*/) @@ -1905,3 +1908,5 @@ TreeViewItem::OpennessRestorer::~OpennessRestorer() if (oldOpenness != nullptr) treeViewItem.restoreOpennessState (*oldOpenness); } + +} // namespace juce diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index e2f407c9c5..1db4dacd37 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class TreeView; @@ -934,3 +935,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeView) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 87983568c5..b019f7d34f 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static juce_wchar getDefaultPasswordChar() noexcept { #if JUCE_LINUX @@ -721,3 +724,5 @@ bool AlertWindow::showNativeDialogBox (const String& title, return true; } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.h b/modules/juce_gui_basics/windows/juce_AlertWindow.h index cd8426cb76..e3f3ce5692 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A window that displays a message and has buttons for the user to react to it. @@ -486,3 +486,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlertWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 6ab46c14d3..d867b8748b 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + CallOutBox::CallOutBox (Component& c, const Rectangle& area, Component* const parent) : arrowSize (16.0f), content (c), dismissalMouseClicksAreAlwaysConsumed (false) { @@ -259,3 +262,5 @@ void CallOutBox::timerCallback() toFront (true); stopTimer(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_CallOutBox.h b/modules/juce_gui_basics/windows/juce_CallOutBox.h index 728b14af61..0a52efbf3f 100644 --- a/modules/juce_gui_basics/windows/juce_CallOutBox.h +++ b/modules/juce_gui_basics/windows/juce_CallOutBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -182,3 +182,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CallOutBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 19e3361990..feb9aacd04 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static uint32 lastUniquePeerID = 1; //============================================================================== @@ -574,3 +577,5 @@ void ComponentPeer::setRepresentedFile (const File&) //============================================================================== int ComponentPeer::getCurrentRenderingEngine() const { return 0; } void ComponentPeer::setCurrentRenderingEngine (int index) { jassert (index == 0); ignoreUnused (index); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 65e46e69cc..819cc8d93f 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -378,3 +378,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentPeer) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp index be3d9e58dc..030bce8ae8 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + DialogWindow::DialogWindow (const String& name, Colour colour, const bool escapeCloses, const bool onDesktop) : DocumentWindow (name, colour, DocumentWindow::closeButton, onDesktop), @@ -176,3 +179,5 @@ int DialogWindow::showModalDialog (const String& dialogTitle, return o.runModal(); } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DialogWindow.h b/modules/juce_gui_basics/windows/juce_DialogWindow.h index 44b662b266..fba819e217 100644 --- a/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/modules/juce_gui_basics/windows/juce_DialogWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -144,6 +144,8 @@ public: */ int runModal(); #endif + + JUCE_DECLARE_NON_COPYABLE (LaunchOptions) }; //============================================================================== @@ -260,3 +262,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DialogWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index ad5d6e7865..c81be075a2 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class DocumentWindow::ButtonListenerProxy : public Button::Listener { public: @@ -360,3 +363,5 @@ void DocumentWindow::userTriedToCloseWindow() { closeButtonPressed(); } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 9c48db1303..d6da6cd363 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -106,8 +106,8 @@ public: /** Sets an icon to show in the title bar, next to the title. A copy is made internally of the image, so the caller can delete the - image after calling this. If 0 is passed-in, any existing icon will be - removed. + image after calling this. If an empty Image is passed-in, any existing icon + will be removed. */ void setIcon (const Image& imageToUse); @@ -291,3 +291,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DocumentWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 2aa4d49e9f..52e6d51872 100644 --- a/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/modules/juce_gui_basics/windows/juce_NativeMessageBox.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -67,7 +68,10 @@ public: modalStateFinished() when the box is dismissed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted - before it gets called. + before it gets called. You can use the ModalCallbackFunction to easily + pass in a lambda for this parameter. + + @see ModalCallbackFunction */ static void JUCE_CALLTYPE showMessageBoxAsync (AlertWindow::AlertIconType iconType, const String& title, @@ -98,10 +102,13 @@ public: being 1 if the ok button was pressed, or 0 for cancel, The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references to objects that might be deleted - before it gets called. + before it gets called. You can use the ModalCallbackFunction to easily + pass in a lambda for this parameter. @returns true if button 1 was clicked, false if it was button 2. If the callback parameter is not null, the method always returns false, and the user's choice is delivered later by the callback. + + @see ModalCallbackFunction */ static bool JUCE_CALLTYPE showOkCancelBox (AlertWindow::AlertIconType iconType, const String& title, @@ -138,13 +145,16 @@ public: being 1 if the "yes" button was pressed, 2 for the "no" button, or 0 if it was cancelled, The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references - to objects that might be deleted before it gets called. + to objects that might be deleted before it gets called. You can use the + ModalCallbackFunction to easily pass in a lambda for this parameter. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values: - 0 if 'cancel' was pressed - 1 if 'yes' was pressed - 2 if 'no' was pressed + + @see ModalCallbackFunction */ static int JUCE_CALLTYPE showYesNoCancelBox (AlertWindow::AlertIconType iconType, const String& title, @@ -181,12 +191,15 @@ public: being 1 if the "yes" button was pressed or 0 for the "no" button was pressed. The callback object will be owned and deleted by the system, so make sure that it works safely and doesn't keep any references - to objects that might be deleted before it gets called. + to objects that might be deleted before it gets called. You can use the + ModalCallbackFunction to easily pass in a lambda for this parameter. @returns If the callback parameter has been set, this returns 0. Otherwise, it returns one of the following values: - 0 if 'no' was pressed - 1 if 'yes' was pressed + + @see ModalCallbackFunction */ static int JUCE_CALLTYPE showYesNoBox (AlertWindow::AlertIconType iconType, const String& title, @@ -203,3 +216,5 @@ private: NativeMessageBox() JUCE_DELETED_FUNCTION; JUCE_DECLARE_NON_COPYABLE (NativeMessageBox) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 278bdd8104..b12c93bb38 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ResizableWindow::ResizableWindow (const String& name, bool shouldAddToDesktop) : TopLevelWindow (name, shouldAddToDesktop) { @@ -623,3 +626,5 @@ void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder) Component::addAndMakeVisible (child, zOrder); } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 4e78c69ae1..a30af74787 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -406,3 +406,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp index 57b3ba79a7..eba08a01f1 100644 --- a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title, const bool hasProgressBar, const bool hasCancelButton, @@ -114,3 +117,5 @@ bool ThreadWithProgressWindow::runThread (const int priority) return ! wasCancelledByUser; } #endif + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h index 78e913a909..d996157bea 100644 --- a/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h +++ b/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -170,3 +170,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadWithProgressWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index abf71124af..65db7ff941 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -24,22 +24,21 @@ ============================================================================== */ -TooltipWindow::TooltipWindow (Component* const parentComp, const int delayMs) - : Component ("tooltip"), - lastComponentUnderMouse (nullptr), - millisecondsBeforeTipAppears (delayMs), - mouseClicks (0), mouseWheelMoves (0), - lastCompChangeTime (0), lastHideTime (0), - reentrant (false) +namespace juce { - if (Desktop::getInstance().getMainMouseSource().canHover()) - startTimer (123); +TooltipWindow::TooltipWindow (Component* parentComp, int delayMs) + : Component ("tooltip"), + millisecondsBeforeTipAppears (delayMs) +{ setAlwaysOnTop (true); setOpaque (true); if (parentComp != nullptr) parentComp->addChildComponent (this); + + if (Desktop::getInstance().getMainMouseSource().canHover()) + startTimer (123); } TooltipWindow::~TooltipWindow() @@ -102,14 +101,13 @@ void TooltipWindow::displayTip (Point screenPos, const String& tip) } } -String TooltipWindow::getTipFor (Component* const c) +String TooltipWindow::getTipFor (Component& c) { - if (c != nullptr - && Process::isForegroundProcess() + if (Process::isForegroundProcess() && ! ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown()) { - if (TooltipClient* const ttc = dynamic_cast (c)) - if (! c->isCurrentlyBlockedByAnotherModalComponent()) + if (auto* ttc = dynamic_cast (&c)) + if (! c.isCurrentlyBlockedByAnotherModalComponent()) return ttc->getTooltip(); } @@ -128,24 +126,24 @@ void TooltipWindow::hideTip() void TooltipWindow::timerCallback() { - Desktop& desktop = Desktop::getInstance(); - const MouseInputSource mouseSource (desktop.getMainMouseSource()); - const unsigned int now = Time::getApproximateMillisecondCounter(); + auto& desktop = Desktop::getInstance(); + auto mouseSource = desktop.getMainMouseSource(); + auto now = Time::getApproximateMillisecondCounter(); - Component* const newComp = ! mouseSource.isTouch() ? mouseSource.getComponentUnderMouse() : nullptr; - const String newTip (getTipFor (newComp)); - const bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); + auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse(); + auto newTip = newComp != nullptr ? getTipFor (*newComp) : String(); + bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); lastComponentUnderMouse = newComp; lastTipUnderMouse = newTip; - const int clickCount = desktop.getMouseButtonClickCounter(); - const int wheelCount = desktop.getMouseWheelMoveCounter(); - const bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves); + auto clickCount = desktop.getMouseButtonClickCounter(); + auto wheelCount = desktop.getMouseWheelMoveCounter(); + bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves); mouseClicks = clickCount; mouseWheelMoves = wheelCount; - const Point mousePos (mouseSource.getScreenPosition()); - const bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; + auto mousePos = mouseSource.getScreenPosition(); + bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; lastMousePos = mousePos; if (tipChanged || mouseWasClicked || mouseMovedQuickly) @@ -174,9 +172,11 @@ void TooltipWindow::timerCallback() // appear after a timeout.. if (newTip.isNotEmpty() && newTip != tipShowing - && now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears) + && now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears) { displayTip (mousePos.roundToInt(), newTip); } } } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.h b/modules/juce_gui_basics/windows/juce_TooltipWindow.h index 42d60a33f0..7ef54a5a31 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.h +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -85,6 +85,11 @@ public: /** Can be called to manually hide the tip if it's showing. */ void hideTip(); + /** Asks a component for its tooltip. + This can be overridden if you need custom lookup behaviour or to modify the strings. + */ + virtual String getTipFor (Component&); + //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the tooltip. @@ -121,19 +126,19 @@ public: private: //============================================================================== Point lastMousePos; - Component* lastComponentUnderMouse; + Component* lastComponentUnderMouse = nullptr; String tipShowing, lastTipUnderMouse; int millisecondsBeforeTipAppears; - int mouseClicks, mouseWheelMoves; - unsigned int lastCompChangeTime, lastHideTime; - bool reentrant; + int mouseClicks = 0, mouseWheelMoves = 0; + unsigned int lastCompChangeTime = 0, lastHideTime = 0; + bool reentrant = false; void paint (Graphics&) override; void mouseEnter (const MouseEvent&) override; void timerCallback() override; void updatePosition (const String&, Point, Rectangle); - static String getTipFor (Component*); - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TooltipWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index c32ea2a372..1f0e135243 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Keeps track of the active top level window. */ class TopLevelWindowManager : private Timer, private DeletedAtShutdown @@ -353,3 +356,5 @@ TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() noexcept return best; } + +} // namespace juce diff --git a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h index 9ee8d93765..51b146d721 100644 --- a/modules/juce_gui_basics/windows/juce_TopLevelWindow.h +++ b/modules/juce_gui_basics/windows/juce_TopLevelWindow.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -160,3 +160,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TopLevelWindow) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp index 11555a2f03..778dde8f44 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp @@ -24,8 +24,8 @@ ============================================================================== */ -#include "juce_CPlusPlusCodeTokeniserFunctions.h" - +namespace juce +{ //============================================================================== CPlusPlusCodeTokeniser::CPlusPlusCodeTokeniser() {} @@ -71,3 +71,5 @@ bool CPlusPlusCodeTokeniser::isReservedKeyword (const String& token) noexcept { return CppTokeniserFunctions::isReservedKeyword (token.getCharPointer(), token.length()); } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h index 88111a8e85..0eaa420460 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -67,3 +67,5 @@ private: //============================================================================== JUCE_LEAK_DETECTOR (CPlusPlusCodeTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h index f4ddfdf5e7..9eb2d8d0d4 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** Class containing some basic functions for simple tokenising of C++ code. @@ -661,3 +661,5 @@ struct CppTokeniserFunctions return mo.toString(); } }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index 57bc14a2e2..713b933cf2 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CodeDocumentLine { public: @@ -990,3 +993,5 @@ void CodeDocument::remove (const int startPos, const int endPos, const bool undo listeners.call (&CodeDocument::Listener::codeDocumentTextDeleted, startPos, endPos); } } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeDocument.h b/modules/juce_gui_extra/code_editor/juce_CodeDocument.h index f0fbd1a009..7c18a00f63 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeDocument.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeDocument.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class CodeDocumentLine; @@ -413,3 +414,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeDocument) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index c001c9b4e8..5d9feeb415 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class CodeEditorComponent::CodeEditorLine { public: @@ -1642,3 +1645,5 @@ String CodeEditorComponent::State::toString() const { return String (lastTopLine) + ":" + String (lastCaretPos) + ":" + String (lastSelectionEnd); } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index e0a1265c31..ffa33c4eab 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ class CodeTokeniser; @@ -430,3 +431,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeEditorComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h index 18834c725a..5e5e1ab3e0 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -54,3 +54,5 @@ public: private: JUCE_LEAK_DETECTOR (CodeTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp index d4d10478e4..f01bdff66f 100644 --- a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct LuaTokeniserFunctions { static bool isReservedKeyword (String::CharPointerType token, const int tokenLength) noexcept @@ -233,3 +236,5 @@ CodeEditorComponent::ColourScheme LuaTokeniser::getDefaultColourScheme() return cs; } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h index 35f63eef5f..5628cfa59f 100644 --- a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -60,3 +60,5 @@ private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LuaTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp index 974b7ce55a..192598db5a 100644 --- a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + XmlTokeniser::XmlTokeniser() {} XmlTokeniser::~XmlTokeniser() {} @@ -166,3 +169,5 @@ int XmlTokeniser::readNextToken (CodeDocument::Iterator& source) return tokenType_identifier; } + +} // namespace juce diff --git a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h index 20d06fba3d..9fb3f87918 100644 --- a/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h +++ b/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -58,3 +58,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlTokeniser) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp b/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp index 4c34585ca9..2edffd32c0 100644 --- a/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp +++ b/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + FileBasedDocument::FileBasedDocument (const String& fileExtension_, const String& fileWildcard_, const String& openFileDialogTitle_, @@ -259,3 +262,5 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool w return userCancelledSave; } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/documents/juce_FileBasedDocument.h b/modules/juce_gui_extra/documents/juce_FileBasedDocument.h index 1191f93c2a..42e39270d5 100644 --- a/modules/juce_gui_extra/documents/juce_FileBasedDocument.h +++ b/modules/juce_gui_extra/documents/juce_FileBasedDocument.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -290,3 +290,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBasedDocument) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h index ed1ce9734a..b4a8f9cba9 100644 --- a/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h +++ b/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || DOXYGEN @@ -123,3 +124,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_NSViewComponent.h b/modules/juce_gui_extra/embedding/juce_NSViewComponent.h index 896722bde8..2db7fe5c93 100644 --- a/modules/juce_gui_extra/embedding/juce_NSViewComponent.h +++ b/modules/juce_gui_extra/embedding/juce_NSViewComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_MAC || DOXYGEN @@ -85,3 +86,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h index 4558bbd9a7..d478aef286 100644 --- a/modules/juce_gui_extra/embedding/juce_UIViewComponent.h +++ b/modules/juce_gui_extra/embedding/juce_UIViewComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_IOS || DOXYGEN @@ -84,3 +85,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h b/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h index 8456e3d8d7..e3935e451c 100644 --- a/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h +++ b/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ /** @internal */ bool juce_handleXEmbedEvent (ComponentPeer*, void*); @@ -109,3 +110,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/juce_gui_extra.cpp b/modules/juce_gui_extra/juce_gui_extra.cpp index f89e0a86ec..457081d807 100644 --- a/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/modules/juce_gui_extra/juce_gui_extra.cpp @@ -83,9 +83,6 @@ #endif //============================================================================== -namespace juce -{ - #include "documents/juce_FileBasedDocument.cpp" #include "code_editor/juce_CodeDocument.cpp" #include "code_editor/juce_CodeEditorComponent.cpp" @@ -102,13 +99,6 @@ namespace juce #include "misc/juce_LiveConstantEditor.cpp" #include "misc/juce_AnimatedAppComponent.cpp" -} - -using namespace juce; - -namespace juce -{ - //============================================================================== #if JUCE_MAC || JUCE_IOS @@ -159,10 +149,12 @@ namespace juce #endif #if JUCE_WEB_BROWSER - bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; } - void WebBrowserComponent::pageFinishedLoading (const String&) {} - bool WebBrowserComponent::pageLoadHadNetworkError (const String&) { return true; } - void WebBrowserComponent::windowCloseRequest() {} - void WebBrowserComponent::newWindowAttemptingToLoad (const String&) {} -#endif +namespace juce +{ + bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; } + void WebBrowserComponent::pageFinishedLoading (const String&) {} + bool WebBrowserComponent::pageLoadHadNetworkError (const String&) { return true; } + void WebBrowserComponent::windowCloseRequest() {} + void WebBrowserComponent::newWindowAttemptingToLoad (const String&) {} } +#endif diff --git a/modules/juce_gui_extra/juce_gui_extra.h b/modules/juce_gui_extra/juce_gui_extra.h index c1162ba751..a5bcc30a7a 100644 --- a/modules/juce_gui_extra/juce_gui_extra.h +++ b/modules/juce_gui_extra/juce_gui_extra.h @@ -35,7 +35,7 @@ ID: juce_gui_extra vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE extended GUI classes description: Miscellaneous GUI classes for specialised tasks. website: http://www.juce.com/juce @@ -74,9 +74,6 @@ #endif //============================================================================== -namespace juce -{ - #include "documents/juce_FileBasedDocument.h" #include "code_editor/juce_CodeDocument.h" #include "code_editor/juce_CodeEditorComponent.h" @@ -100,5 +97,3 @@ namespace juce #include "misc/juce_WebBrowserComponent.h" #include "misc/juce_LiveConstantEditor.h" #include "misc/juce_AnimatedAppComponent.h" - -} diff --git a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp index 6f461d066f..424b973197 100644 --- a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AnimatedAppComponent::AnimatedAppComponent() : lastUpdateTime (Time::getCurrentTime()), totalUpdates (0) { @@ -48,3 +51,5 @@ void AnimatedAppComponent::timerCallback() repaint(); lastUpdateTime = Time::getCurrentTime(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h index eeb29e1525..9d84552772 100644 --- a/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h +++ b/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -72,3 +72,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedAppComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_AppleRemote.h b/modules/juce_gui_extra/misc/juce_AppleRemote.h index c784e7129d..1f27dc9d15 100644 --- a/modules/juce_gui_extra/misc/juce_AppleRemote.h +++ b/modules/juce_gui_extra/misc/juce_AppleRemote.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== #if JUCE_MAC || DOXYGEN @@ -112,3 +112,5 @@ private: }; #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index 556dae356d..a3aa074024 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + BubbleMessageComponent::BubbleMessageComponent (int fadeOutLengthMs) : fadeOutLength (fadeOutLengthMs), mouseClickCounter (0), expiryTime (0), deleteAfterUse (false) @@ -118,3 +121,5 @@ void BubbleMessageComponent::hide (const bool fadeOut) if (deleteAfterUse) delete this; } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h index d63e107206..785d542a96 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -126,3 +126,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BubbleMessageComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index 662fa0dc18..f41c64f849 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ColourSelector::ColourComponentSlider : public Slider { public: @@ -43,7 +46,6 @@ public: return (double) text.getHexValue32(); } -private: JUCE_DECLARE_NON_COPYABLE (ColourComponentSlider) }; @@ -64,7 +66,6 @@ public: g.drawEllipse (2.0f, 2.0f, getWidth() - 4.0f, getHeight() - 4.0f, 1.0f); } -private: JUCE_DECLARE_NON_COPYABLE (ColourSpaceMarker) }; @@ -570,3 +571,5 @@ void ColourSelector::setSwatchColour (int, const Colour&) { jassertfalse; // if you've overridden getNumSwatches(), you also need to implement this method } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.h b/modules/juce_gui_extra/misc/juce_ColourSelector.h index 6d9aa2ef90..83c2fe622d 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.h +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -167,3 +167,5 @@ private: ColourSelector (bool); #endif }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index 4b87b07595..c619b24120 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class KeyMappingEditorComponent::ChangeKeyButton : public Button { public: @@ -468,3 +471,5 @@ String KeyMappingEditorComponent::getDescriptionForKeyPress (const KeyPress& key { return key.getTextDescription(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h index e4207bc0be..e206c1e68b 100644 --- a/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h +++ b/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeyMappingEditorComponent) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp index e87c817d98..f98cb43918 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_ENABLE_LIVE_CONSTANT_EDITOR namespace LiveConstantEditor @@ -500,3 +503,5 @@ Component* createBoolSlider (LivePropertyEditorBase& editor) { return new Bo } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h index 4d44a740b2..9121a5828f 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_ENABLE_LIVE_CONSTANT_EDITOR && ! DOXYGEN @@ -309,3 +310,5 @@ namespace LiveConstantEditor #define JUCE_LIVE_CONSTANT(initialValue) \ (initialValue) #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index e6f612e37f..cb35ef5165 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + PreferencesPanel::PreferencesPanel() : buttonSize (70) { @@ -150,3 +153,5 @@ void PreferencesPanel::buttonClicked (Button*) } } } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.h b/modules/juce_gui_extra/misc/juce_PreferencesPanel.h index 6000ed3d13..99de995008 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.h +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -143,3 +143,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreferencesPanel) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp index d7470f6c92..580b79aa74 100644 --- a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp +++ b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + RecentlyOpenedFilesList::RecentlyOpenedFilesList() : maxNumberOfItems (10) { @@ -145,3 +148,5 @@ void RecentlyOpenedFilesList::registerRecentFileNatively (const File& file) ignoreUnused (file); #endif } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h index fadcaf71e1..02a24fe00b 100644 --- a/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h +++ b/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -160,3 +160,5 @@ private: JUCE_LEAK_DETECTOR (RecentlyOpenedFilesList) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SplashScreen.cpp b/modules/juce_gui_extra/misc/juce_SplashScreen.cpp index 654669091a..a33477d817 100644 --- a/modules/juce_gui_extra/misc/juce_SplashScreen.cpp +++ b/modules/juce_gui_extra/misc/juce_SplashScreen.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + SplashScreen::SplashScreen (const String& title, const Image& image, bool useDropShadow) : Component (title), backgroundImage (image), @@ -95,3 +98,5 @@ void SplashScreen::timerCallback() || Desktop::getInstance().getMouseButtonClickCounter() > clickCountToDelete) delete this; } + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SplashScreen.h b/modules/juce_gui_extra/misc/juce_SplashScreen.h index 62dfc5aace..bf16e5d0aa 100644 --- a/modules/juce_gui_extra/misc/juce_SplashScreen.h +++ b/modules/juce_gui_extra/misc/juce_SplashScreen.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** A component for showing a splash screen while your app starts up. @@ -151,3 +151,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SplashScreen) }; + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp index 33ae308285..72c6c983fc 100644 --- a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC SystemTrayIconComponent::SystemTrayIconComponent() @@ -36,3 +39,5 @@ SystemTrayIconComponent::~SystemTrayIconComponent() } #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h index c3f3930bf1..6dd877ddd2 100644 --- a/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h +++ b/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC || DOXYGEN @@ -100,3 +101,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h index f26a7309bd..67a055f82e 100644 --- a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h +++ b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_WEB_BROWSER || DOXYGEN @@ -149,3 +150,5 @@ private: #endif + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp index c236b4b3fa..7fc51d7cc7 100644 --- a/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + WebBrowserComponent::WebBrowserComponent (const bool unloadPageWhenBrowserIsHidden_) : browser (nullptr), blankPageShown (false), @@ -121,3 +124,5 @@ void WebBrowserComponent::focusGained (FocusChangeType) void WebBrowserComponent::clearCookies() { } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm b/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm index 933f25ccf1..6a954fd102 100644 --- a/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm @@ -24,14 +24,16 @@ ============================================================================== */ +namespace juce +{ + class UIViewComponent::Pimpl : public ComponentMovementWatcher { public: - Pimpl (UIView* const v, Component& comp) + Pimpl (UIView* v, Component& comp) : ComponentMovementWatcher (&comp), view (v), - owner (comp), - currentPeer (nullptr) + owner (comp) { [view retain]; @@ -47,11 +49,11 @@ public: void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) override { - Component* const topComp = owner.getTopLevelComponent(); + auto* topComp = owner.getTopLevelComponent(); if (topComp->getPeer() != nullptr) { - const Point pos (topComp->getLocalPoint (&owner, Point())); + auto pos = topComp->getLocalPoint (&owner, Point()); [view setFrame: CGRectMake ((float) pos.x, (float) pos.y, (float) owner.getWidth(), (float) owner.getHeight())]; @@ -60,7 +62,7 @@ public: void componentPeerChanged() override { - ComponentPeer* const peer = owner.getPeer(); + auto* peer = owner.getPeer(); if (currentPeer != peer) { @@ -95,7 +97,7 @@ public: private: Component& owner; - ComponentPeer* currentPeer; + ComponentPeer* currentPeer = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) }; @@ -127,3 +129,5 @@ void UIViewComponent::resizeToFitView() } void UIViewComponent::paint (Graphics&) {} + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp index 35eed37330..c60b9347d6 100644 --- a/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + class SystemTrayIconComponent::Pimpl { public: @@ -143,3 +145,5 @@ void* SystemTrayIconComponent::getNativeHandle() const { return getWindowHandle(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp index 07c64fbe23..6a8f0da89d 100644 --- a/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + extern int juce_gtkWebkitMain (int argc, const char* argv[]); class CommandReceiver @@ -821,3 +823,5 @@ int juce_gtkWebkitMain (int argc, const char* argv[]) String (argv[3]).getIntValue()); return child.entry(); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp b/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp index d50a7704d3..916b453333 100644 --- a/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp +++ b/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + bool juce_handleXEmbedEvent (ComponentPeer*, void*); Window juce_getCurrentFocusWindow (ComponentPeer*); @@ -672,10 +674,12 @@ unsigned long XEmbedComponent::getHostWindowID() { return pimp //============================================================================== bool juce_handleXEmbedEvent (ComponentPeer* p, void* e) { - return ::XEmbedComponent::Pimpl::dispatchX11Event (p, reinterpret_cast (e)); + return XEmbedComponent::Pimpl::dispatchX11Event (p, reinterpret_cast (e)); } unsigned long juce_getCurrentFocusWindow (ComponentPeer* peer) { - return (unsigned long) ::XEmbedComponent::Pimpl::getCurrentFocusWindow (peer); + return (unsigned long) XEmbedComponent::Pimpl::getCurrentFocusWindow (peer); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm b/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm index b1283c052d..bc07d33172 100644 --- a/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm +++ b/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + AppleRemoteDevice::AppleRemoteDevice() : device (nullptr), queue (nullptr), @@ -262,3 +265,5 @@ void AppleRemoteDevice::handleCallbackInternal() ++buttonNum; } } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index 9d38512439..c57277db6b 100644 --- a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -341,3 +341,5 @@ void* getCarbonWindow (Component* possibleCarbonComponent) return nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index d996650918..47dc7e87e3 100644 --- a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct NSViewResizeWatcher { NSViewResizeWatcher() : callback (nil) {} @@ -240,3 +243,5 @@ ReferenceCountedObject* NSViewComponent::attachViewToComponent (Component& comp, { return new NSViewAttachment ((NSView*) view, comp); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp index 49cde5eb2f..c7d893fa98 100644 --- a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace MouseCursorHelpers { extern NSImage* createNSImage (const Image&, float scaleFactor = 1.f); @@ -274,3 +277,5 @@ void SystemTrayIconComponent::showDropdownMenu (const PopupMenu& menu) if (pimpl != nullptr) pimpl->showMenu (menu); } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 186445ceeb..03078226ba 100644 --- a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm @@ -26,6 +26,9 @@ #if JUCE_MAC +namespace juce +{ + struct WebViewKeyEquivalentResponder : public ObjCClass { WebViewKeyEquivalentResponder() : ObjCClass ("WebViewKeyEquivalentResponder_") @@ -152,8 +155,6 @@ private: #else -} // (juce namespace) - //============================================================================== @interface WebViewTapDetector : NSObject { @@ -168,7 +169,7 @@ private: - (BOOL) gestureRecognizer: (UIGestureRecognizer*) gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer: (UIGestureRecognizer*) otherGestureRecognizer { - ignoreUnused (gestureRecognizer, otherGestureRecognizer); + juce::ignoreUnused (gestureRecognizer, otherGestureRecognizer); return YES; } @@ -198,17 +199,18 @@ private: - (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request navigationType: (UIWebViewNavigationType) navigationType { - ignoreUnused (webView, navigationType); - return ownerComponent->pageAboutToLoad (nsStringToJuce (request.URL.absoluteString)); + juce::ignoreUnused (webView, navigationType); + return ownerComponent->pageAboutToLoad (juce::nsStringToJuce (request.URL.absoluteString)); } - (void) webViewDidFinishLoad: (UIWebView*) webView { - ownerComponent->pageFinishedLoading (nsStringToJuce (webView.request.URL.absoluteString)); + ownerComponent->pageFinishedLoading (juce::nsStringToJuce (webView.request.URL.absoluteString)); } @end -namespace juce { +namespace juce +{ #endif @@ -485,3 +487,5 @@ void WebBrowserComponent::clearCookies() [[NSUserDefaults standardUserDefaults] synchronize]; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 188385b632..f0eec0ea44 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern int64 getMouseEventTime(); JUCE_DECLARE_UUID_GETTER (IOleObject, "00000112-0000-0000-C000-000000000046") @@ -451,3 +454,5 @@ LRESULT juce_offerEventToActiveXControl (::MSG& msg) return S_FALSE; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp index 7e3f9e2a64..b1667be77b 100644 --- a/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern void* getUser32Function (const char*); namespace IconConverters @@ -236,3 +239,5 @@ void* SystemTrayIconComponent::getNativeHandle() const { return pimpl != nullptr ? &(pimpl->iconData) : nullptr; } + +} // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 5831a9cc0d..7ca294913c 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -24,9 +24,18 @@ ============================================================================== */ +namespace juce +{ + JUCE_DECLARE_UUID_GETTER (DWebBrowserEvents2, "34A715A0-6587-11D0-924A-0020AFC7AC4D") JUCE_DECLARE_UUID_GETTER (IConnectionPointContainer, "B196B284-BAB4-101A-B69C-00AA00341D07") JUCE_DECLARE_UUID_GETTER (IWebBrowser2, "D30C1661-CDAF-11D0-8A3E-00C04FC9E26E") + +#if JUCE_MINGW + #define DISPID_NAVIGATEERROR 271 + class WebBrowser; +#endif + JUCE_DECLARE_UUID_GETTER (WebBrowser, "8856F961-340A-11D0-A96B-00C04FD705A2") class WebBrowserComponent::Pimpl : public ActiveXControlComponent @@ -389,12 +398,18 @@ void WebBrowserComponent::clearCookies() { HeapBlock<::INTERNET_CACHE_ENTRY_INFO> entry; ::DWORD entrySize = sizeof (::INTERNET_CACHE_ENTRY_INFO); - ::HANDLE urlCacheHandle = ::FindFirstUrlCacheEntry (TEXT ("cookie:"), entry.getData(), &entrySize); + + #if JUCE_MINGW + const auto searchPattern = "cookie:"; + #else + const auto searchPattern = TEXT ("cookie:"); + #endif + ::HANDLE urlCacheHandle = ::FindFirstUrlCacheEntry (searchPattern, entry.getData(), &entrySize); if (urlCacheHandle == nullptr && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { entry.realloc (1, entrySize); - urlCacheHandle = ::FindFirstUrlCacheEntry (TEXT ("cookie:"), entry.getData(), &entrySize); + urlCacheHandle = ::FindFirstUrlCacheEntry (searchPattern, entry.getData(), &entrySize); } if (urlCacheHandle != nullptr) @@ -420,3 +435,5 @@ void WebBrowserComponent::clearCookies() FindCloseUrlCache (urlCacheHandle); } } + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h index cbc9093def..8b11dff6f6 100644 --- a/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h +++ b/modules/juce_opengl/geometry/juce_Draggable3DOrientation.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -128,8 +128,8 @@ private: // calling any of the mouse input methods! jassert (scale > 0); - return Point ((mousePos.x - area.getCentreX()) / scale, - (area.getCentreY() - mousePos.y) / scale); + return Point ((mousePos.x - (float) area.getCentreX()) / (float) scale, + ((float) area.getCentreY() - mousePos.y) / (float) scale); } VectorType projectOnSphere (const Point pos) const noexcept @@ -154,3 +154,5 @@ private: return QuaternionType::fromAngle (2.0f * std::asin (d), rotationAxis); } }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Matrix3D.h b/modules/juce_opengl/geometry/juce_Matrix3D.h index a68e900b23..5bf7bdcf59 100644 --- a/modules/juce_opengl/geometry/juce_Matrix3D.h +++ b/modules/juce_opengl/geometry/juce_Matrix3D.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -150,3 +151,5 @@ public: /** The 4x4 matrix values. These are stored in the standard OpenGL order. */ Type mat[16]; }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Quaternion.h b/modules/juce_opengl/geometry/juce_Quaternion.h index fa80ed93dc..9fac1bd7f7 100644 --- a/modules/juce_opengl/geometry/juce_Quaternion.h +++ b/modules/juce_opengl/geometry/juce_Quaternion.h @@ -24,10 +24,8 @@ ============================================================================== */ -#pragma once - -#include "juce_Vector3D.h" -#include "juce_Matrix3D.h" +namespace juce +{ //============================================================================== /** @@ -95,3 +93,5 @@ public: /** The scalar part of the quaternion. */ Type scalar; }; + +} // namespace juce diff --git a/modules/juce_opengl/geometry/juce_Vector3D.h b/modules/juce_opengl/geometry/juce_Vector3D.h index 52d60063c4..ba292075f6 100644 --- a/modules/juce_opengl/geometry/juce_Vector3D.h +++ b/modules/juce_opengl/geometry/juce_Vector3D.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -77,3 +78,5 @@ public: Type x, y, z; }; + +} // namespace juce diff --git a/modules/juce_opengl/juce_opengl.cpp b/modules/juce_opengl/juce_opengl.cpp index 593931b3d8..60021bfbbd 100644 --- a/modules/juce_opengl/juce_opengl.cpp +++ b/modules/juce_opengl/juce_opengl.cpp @@ -84,12 +84,10 @@ #endif #endif +//============================================================================== namespace juce { -//============================================================================== -#include "native/juce_OpenGLExtensions.h" - void OpenGLExtensionFunctions::initialise() { #if JUCE_WINDOWS || JUCE_LINUX @@ -251,6 +249,8 @@ private: OpenGLTargetSaver& operator= (const OpenGLTargetSaver&); }; +} // namespace juce + //============================================================================== #include "opengl/juce_OpenGLFrameBuffer.cpp" #include "opengl/juce_OpenGLGraphicsContext.cpp" @@ -291,5 +291,3 @@ private: #include "opengl/juce_OpenGLContext.cpp" #include "utils/juce_OpenGLAppComponent.cpp" - -} diff --git a/modules/juce_opengl/juce_opengl.h b/modules/juce_opengl/juce_opengl.h index 7db74fbfa3..edad48042e 100644 --- a/modules/juce_opengl/juce_opengl.h +++ b/modules/juce_opengl/juce_opengl.h @@ -35,7 +35,7 @@ ID: juce_opengl vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE OpenGL classes description: Classes for rendering OpenGL in a JUCE window. website: http://www.juce.com/juce @@ -164,14 +164,14 @@ //============================================================================== namespace juce { + class OpenGLTexture; + class OpenGLFrameBuffer; + class OpenGLShaderProgram; +} -class OpenGLTexture; -class OpenGLFrameBuffer; -class OpenGLShaderProgram; - -#include "geometry/juce_Quaternion.h" -#include "geometry/juce_Matrix3D.h" #include "geometry/juce_Vector3D.h" +#include "geometry/juce_Matrix3D.h" +#include "geometry/juce_Quaternion.h" #include "geometry/juce_Draggable3DOrientation.h" #include "native/juce_MissingGLDefinitions.h" #include "opengl/juce_OpenGLHelpers.h" @@ -181,11 +181,7 @@ class OpenGLShaderProgram; #include "opengl/juce_OpenGLContext.h" #include "opengl/juce_OpenGLFrameBuffer.h" #include "opengl/juce_OpenGLGraphicsContext.h" -#include "opengl/juce_OpenGLHelpers.h" #include "opengl/juce_OpenGLImage.h" -#include "opengl/juce_OpenGLRenderer.h" #include "opengl/juce_OpenGLShaderProgram.h" #include "opengl/juce_OpenGLTexture.h" #include "utils/juce_OpenGLAppComponent.h" - -} diff --git a/modules/juce_opengl/native/juce_MissingGLDefinitions.h b/modules/juce_opengl/native/juce_MissingGLDefinitions.h index d628556221..dac8bff321 100644 --- a/modules/juce_opengl/native/juce_MissingGLDefinitions.h +++ b/modules/juce_opengl/native/juce_MissingGLDefinitions.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** These are important openGL values that aren't defined by default by the GL headers on various platforms. */ @@ -156,3 +159,5 @@ enum MissingOpenGLDefinitions typedef pointer_sized_int GLsizeiptr; typedef pointer_sized_int GLintptr; #endif + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGLExtensions.h b/modules/juce_opengl/native/juce_OpenGLExtensions.h index 30362501be..23b03af2f1 100644 --- a/modules/juce_opengl/native/juce_OpenGLExtensions.h +++ b/modules/juce_opengl/native/juce_OpenGLExtensions.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux. @see OpenGLExtensionFunctions @@ -154,3 +154,5 @@ struct OpenGLExtensionFunctions #undef JUCE_DECLARE_GL_FUNCTION }; + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_android.h b/modules/juce_opengl/native/juce_OpenGL_android.h index 776fe5647b..60f9fdc43d 100644 --- a/modules/juce_opengl/native/juce_OpenGL_android.h +++ b/modules/juce_opengl/native/juce_OpenGL_android.h @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (getParent, "getParent", "()Landroid/view/ViewParent;") \ METHOD (layout, "layout", "(IIII)V" ) \ @@ -306,3 +308,5 @@ bool OpenGLHelpers::isContextActive() { return eglGetCurrentContext() != EGL_NO_CONTEXT; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_ios.h b/modules/juce_opengl/native/juce_OpenGL_ios.h index ff810c34fb..a079a4d842 100644 --- a/modules/juce_opengl/native/juce_OpenGL_ios.h +++ b/modules/juce_opengl/native/juce_OpenGL_ios.h @@ -24,8 +24,6 @@ ============================================================================== */ -} // (juce namespace) - @interface JuceGLView : UIView { } @@ -309,3 +307,5 @@ bool OpenGLHelpers::isContextActive() { return [EAGLContext currentContext] != nil; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h index dc287b947d..c1b17d46ce 100644 --- a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h +++ b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern XContext windowHandleXContext; //============================================================================== @@ -249,3 +252,5 @@ bool OpenGLHelpers::isContextActive() return false; } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index 706486ebe5..4b61efd4bf 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLContext::NativeContext { public: @@ -255,3 +258,5 @@ void componentPeerAboutToChange (Component& comp, bool shouldSuspend) for (auto* child : comp.getChildren()) componentPeerAboutToChange (*child, shouldSuspend); } + +} // namespace juce diff --git a/modules/juce_opengl/native/juce_OpenGL_win32.h b/modules/juce_opengl/native/juce_OpenGL_win32.h index 40c9dedeb4..7cbd732b4b 100644 --- a/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component&, void* parent); //============================================================================== @@ -266,3 +269,5 @@ bool OpenGLHelpers::isContextActive() { return wglGetCurrentContext() != 0; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 495ea985d2..b57a50793a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_IOS struct AppInactivityCallback // NB: this is a duplicate of an internal declaration in juce_core { @@ -1244,3 +1247,5 @@ void OpenGLContext::NativeContext::surfaceDestroyed (jobject holder) cachedImage->pause(); } #endif + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.h b/modules/juce_opengl/opengl/juce_OpenGLContext.h index fe6627d35e..a1b9c05436 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -344,3 +344,5 @@ private: template void OpenGLContext::executeOnGLThread (T&& f, bool shouldBlock) { execute (new AsyncWorkerFunctor (f), shouldBlock); } #endif + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 38cd7c6fab..c7e4a2a4b6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLFrameBuffer::Pimpl { public: @@ -347,3 +350,5 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle JUCE_CHECK_OPENGL_ERROR return true; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h index 366fd68d95..8a466ad96a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -130,3 +130,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLFrameBuffer) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 56252ca487..4aaeb2ffb5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + extern void (*clearOpenGLGlyphCache)(); // declared in juce_graphics namespace OpenGLRendering @@ -1894,3 +1897,5 @@ Result OpenGLGraphicsContextCustomShader::checkCompilation (LowLevelGraphicsCont return Result::fail (errorMessage); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h index 755eeb4bba..10176ec423 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ /** Creates a graphics context object that will render into the given OpenGL target. The caller is responsible for deleting this object when no longer needed. @@ -92,3 +92,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLGraphicsContextCustomShader) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index aa7588ef28..23f3b7aeda 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + void OpenGLHelpers::resetErrorState() { while (glGetError() != GL_NO_ERROR) {} @@ -128,3 +131,5 @@ String OpenGLHelpers::translateFragmentShaderToV3 (const String& code) return code; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h index 091856ff28..0a64e48b5e 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -69,3 +69,5 @@ public: */ static String translateFragmentShaderToV3 (const String&); }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 027a90a6ad..4b748a2eb6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class OpenGLFrameBufferImage : public ImagePixelData { public: @@ -156,7 +159,7 @@ private: DataReleaser* r = new DataReleaser (frameBuffer, x, y, bitmapData.width, bitmapData.height); bitmapData.dataReleaser = r; - bitmapData.data = (uint8*) r->data.getData(); + bitmapData.data = (uint8*) r->data.get(); bitmapData.lineStride = (bitmapData.width * bitmapData.pixelStride + 3) & ~3; ReaderType::read (frameBuffer, bitmapData, x, y); @@ -200,3 +203,5 @@ OpenGLFrameBuffer* OpenGLImageType::getFrameBufferFrom (const Image& image) return nullptr; } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.h b/modules/juce_opengl/opengl/juce_OpenGLImage.h index 3bac505fe0..15b70e3059 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.h +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -49,3 +49,5 @@ public: static OpenGLFrameBuffer* getFrameBufferFrom (const Image&); }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp index 60661520ef..567460436c 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent, const int alphaBits_, const int depthBufferBits_, @@ -61,3 +64,5 @@ bool OpenGLPixelFormat::operator!= (const OpenGLPixelFormat& other) const noexce { return ! operator== (other); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h index ebc5d934d2..3b6c83b9fb 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h +++ b/modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -66,3 +66,5 @@ public: uint8 multisamplingLevel; /**< The number of samples to use for full-scene multisampled anti-aliasing (if available). */ }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLRenderer.h b/modules/juce_opengl/opengl/juce_OpenGLRenderer.h index 36bf176503..67ad2b808d 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLRenderer.h +++ b/modules/juce_opengl/opengl/juce_OpenGLRenderer.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -76,3 +76,5 @@ public: */ virtual void openGLContextClosing() = 0; }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index 0e41c05410..67611d5999 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLShaderProgram::OpenGLShaderProgram (const OpenGLContext& c) noexcept : context (c) { } @@ -186,3 +189,5 @@ void OpenGLShaderProgram::Uniform::set (const GLfloat* values, GLsizei numValues void OpenGLShaderProgram::Uniform::setMatrix2 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix2fv (uniformID, num, trns, v); } void OpenGLShaderProgram::Uniform::setMatrix3 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix3fv (uniformID, num, trns, v); } void OpenGLShaderProgram::Uniform::setMatrix4 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix4fv (uniformID, num, trns, v); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h index 72eb94b308..4efbf6fbfb 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -198,3 +199,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLShaderProgram) }; + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index b6254ac01d..d29adccc72 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + static int getAllowedTextureSize (int x) { #if JUCE_OPENGL_ALLOW_NON_POWER_OF_TWO_TEXTURES @@ -185,3 +188,5 @@ void OpenGLTexture::unbind() const { glBindTexture (GL_TEXTURE_2D, 0); } + +} // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.h b/modules/juce_opengl/opengl/juce_OpenGLTexture.h index 2794cba03a..8ced3f2faf 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.h +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -98,3 +99,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLTexture) }; + +} // namespace juce diff --git a/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp b/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp index a6bdb9c489..752c43e147 100644 --- a/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp +++ b/modules/juce_opengl/utils/juce_OpenGLAppComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OpenGLAppComponent::OpenGLAppComponent() { setOpaque (true); @@ -63,3 +66,5 @@ void OpenGLAppComponent::openGLContextClosing() { shutdown(); } + +} // namespace juce diff --git a/modules/juce_opengl/utils/juce_OpenGLAppComponent.h b/modules/juce_opengl/utils/juce_OpenGLAppComponent.h index 351bd6ea18..ba23d04da8 100644 --- a/modules/juce_opengl/utils/juce_OpenGLAppComponent.h +++ b/modules/juce_opengl/utils/juce_OpenGLAppComponent.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -92,3 +92,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLAppComponent) }; + +} // namespace juce diff --git a/modules/juce_osc/juce_osc.cpp b/modules/juce_osc/juce_osc.cpp index 738ef2ba83..6e026de4df 100644 --- a/modules/juce_osc/juce_osc.cpp +++ b/modules/juce_osc/juce_osc.cpp @@ -35,8 +35,6 @@ #include "juce_osc.h" -namespace juce -{ #include "osc/juce_OSCTypes.cpp" #include "osc/juce_OSCTimeTag.cpp" #include "osc/juce_OSCArgument.cpp" @@ -45,4 +43,3 @@ namespace juce #include "osc/juce_OSCBundle.cpp" #include "osc/juce_OSCReceiver.cpp" #include "osc/juce_OSCSender.cpp" -} diff --git a/modules/juce_osc/juce_osc.h b/modules/juce_osc/juce_osc.h index 6fb4e2879c..04961e9b41 100644 --- a/modules/juce_osc/juce_osc.h +++ b/modules/juce_osc/juce_osc.h @@ -35,7 +35,7 @@ ID: juce_osc vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE OSC classes description: Open Sound Control implementation. website: http://www.juce.com/juce @@ -56,9 +56,6 @@ //============================================================================== -namespace juce -{ - #include "osc/juce_OSCTypes.h" #include "osc/juce_OSCTimeTag.h" #include "osc/juce_OSCArgument.h" @@ -67,5 +64,3 @@ namespace juce #include "osc/juce_OSCBundle.h" #include "osc/juce_OSCReceiver.h" #include "osc/juce_OSCSender.h" - -} diff --git a/modules/juce_osc/osc/juce_OSCAddress.cpp b/modules/juce_osc/osc/juce_OSCAddress.cpp index 888a3f1010..3e70c9e068 100644 --- a/modules/juce_osc/osc/juce_OSCAddress.cpp +++ b/modules/juce_osc/osc/juce_OSCAddress.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -777,3 +780,5 @@ public: static OSCPatternMatcherTests OSCPatternMatcherUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCAddress.h b/modules/juce_osc/osc/juce_OSCAddress.h index b1b8555af3..2ef578f681 100644 --- a/modules/juce_osc/osc/juce_OSCAddress.h +++ b/modules/juce_osc/osc/juce_OSCAddress.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -146,3 +146,5 @@ private: String asString; bool wasInitialisedWithWildcards; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCArgument.cpp b/modules/juce_osc/osc/juce_OSCArgument.cpp index 1bde638129..6dabbf277d 100644 --- a/modules/juce_osc/osc/juce_OSCArgument.cpp +++ b/modules/juce_osc/osc/juce_OSCArgument.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OSCArgument::OSCArgument (int32 value) noexcept : type (OSCTypes::int32), intValue (value) { @@ -226,3 +229,5 @@ public: static OSCArgumentTests OSCArgumentUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCArgument.h b/modules/juce_osc/osc/juce_OSCArgument.h index 67e2a741ba..579227f047 100644 --- a/modules/juce_osc/osc/juce_OSCArgument.h +++ b/modules/juce_osc/osc/juce_OSCArgument.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -109,3 +109,5 @@ private: String stringValue; MemoryBlock blob; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCBundle.cpp b/modules/juce_osc/osc/juce_OSCBundle.cpp index d2dcaf1ecf..e2041834d6 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.cpp +++ b/modules/juce_osc/osc/juce_OSCBundle.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + OSCBundle::OSCBundle() { } @@ -237,3 +240,5 @@ public: static OSCBundleElementTests OSCBundleElementUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCBundle.h b/modules/juce_osc/osc/juce_OSCBundle.h index 1ab529860e..b3b0d4861e 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.h +++ b/modules/juce_osc/osc/juce_OSCBundle.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -129,3 +130,5 @@ private: Array elements; OSCTimeTag timeTag; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCMessage.cpp b/modules/juce_osc/osc/juce_OSCMessage.cpp index b62b61e8bc..6bb21cef21 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.cpp +++ b/modules/juce_osc/osc/juce_OSCMessage.cpp @@ -24,7 +24,9 @@ ============================================================================== */ -//============================================================================== +namespace juce +{ + OSCMessage::OSCMessage (const OSCAddressPattern& ap) noexcept : addressPattern (ap) { } @@ -197,3 +199,5 @@ public: static OSCMessageTests OSCMessageUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCMessage.h b/modules/juce_osc/osc/juce_OSCMessage.h index bcc4b7cb5b..1d2f7fcf7e 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.h +++ b/modules/juce_osc/osc/juce_OSCMessage.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -169,3 +169,5 @@ private: addArguments (std::forward (arg1), std::forward (args)...); } #endif + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCReceiver.cpp b/modules/juce_osc/osc/juce_OSCReceiver.cpp index 35da262ef0..3ee4110aef 100644 --- a/modules/juce_osc/osc/juce_OSCReceiver.cpp +++ b/modules/juce_osc/osc/juce_OSCReceiver.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -1156,3 +1159,5 @@ public: static OSCInputStreamTests OSCInputStreamUnitTests; #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCReceiver.h b/modules/juce_osc/osc/juce_OSCReceiver.h index 63871192bc..d9ad9ffb39 100644 --- a/modules/juce_osc/osc/juce_OSCReceiver.h +++ b/modules/juce_osc/osc/juce_OSCReceiver.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== /** @@ -209,3 +210,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSCReceiver) }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCSender.cpp b/modules/juce_osc/osc/juce_OSCSender.cpp index c0fe39854c..dc98d8b993 100644 --- a/modules/juce_osc/osc/juce_OSCSender.cpp +++ b/modules/juce_osc/osc/juce_OSCSender.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace { //============================================================================== @@ -844,3 +847,5 @@ static OSCRoundTripTests OSCRoundTripUnitTests; //============================================================================== #endif // JUCE_UNIT_TESTS + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCSender.h b/modules/juce_osc/osc/juce_OSCSender.h index 3da6df1691..7ec4bdc73b 100644 --- a/modules/juce_osc/osc/juce_OSCSender.h +++ b/modules/juce_osc/osc/juce_OSCSender.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -153,3 +153,5 @@ private: return sendToIPAddress (targetIPAddress, targetPortNumber, OSCMessage (address, std::forward (args)...)); } #endif // JUCE_COMPILER_SUPPORTS_VARIADIC_TEMPLATES + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTimeTag.cpp b/modules/juce_osc/osc/juce_OSCTimeTag.cpp index 35021a2ec8..431062fdc8 100644 --- a/modules/juce_osc/osc/juce_OSCTimeTag.cpp +++ b/modules/juce_osc/osc/juce_OSCTimeTag.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + const OSCTimeTag OSCTimeTag::immediately; static const uint64 millisecondsBetweenOscAndJuceEpochs = 2208988800000ULL; @@ -42,9 +45,6 @@ OSCTimeTag::OSCTimeTag (Time time) noexcept { const uint64 milliseconds = (uint64) time.toMilliseconds() + millisecondsBetweenOscAndJuceEpochs; - // something went seriously wrong if the line above didn't render the time nonnegative! - jassert (milliseconds >= 0); - uint64 seconds = milliseconds / 1000; uint32 fractionalPart = uint32 (4294967.296 * (milliseconds % 1000)); @@ -150,3 +150,5 @@ public: static OSCTimeTagTests OSCTimeTagUnitTests; #endif + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTimeTag.h b/modules/juce_osc/osc/juce_OSCTimeTag.h index 02f9973a4a..17a5feb72d 100644 --- a/modules/juce_osc/osc/juce_OSCTimeTag.h +++ b/modules/juce_osc/osc/juce_OSCTimeTag.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -81,3 +81,5 @@ private: //============================================================================== uint64 rawTimeTag; }; + +} // namespace juce diff --git a/modules/juce_osc/osc/juce_OSCTypes.cpp b/modules/juce_osc/osc/juce_OSCTypes.cpp index 18d7233de0..a78f21e28e 100644 --- a/modules/juce_osc/osc/juce_OSCTypes.cpp +++ b/modules/juce_osc/osc/juce_OSCTypes.cpp @@ -24,7 +24,10 @@ ============================================================================== */ -const OSCType OSCTypes::int32 = 'i'; -const OSCType OSCTypes::float32 = 'f'; -const OSCType OSCTypes::string = 's'; -const OSCType OSCTypes::blob = 'b'; +namespace juce +{ + const OSCType OSCTypes::int32 = 'i'; + const OSCType OSCTypes::float32 = 'f'; + const OSCType OSCTypes::string = 's'; + const OSCType OSCTypes::blob = 'b'; +} diff --git a/modules/juce_osc/osc/juce_OSCTypes.h b/modules/juce_osc/osc/juce_OSCTypes.h index 295b99056a..83dbee30af 100644 --- a/modules/juce_osc/osc/juce_OSCTypes.h +++ b/modules/juce_osc/osc/juce_OSCTypes.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== @@ -95,3 +96,5 @@ struct OSCInternalError : public OSCException { OSCInternalError (const String& desc) : OSCException (desc) {} }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp index 341ba1a0ad..ed5bb817ab 100644 --- a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.cpp @@ -24,12 +24,15 @@ ============================================================================== */ +namespace juce +{ InAppPurchases::InAppPurchases() #if JUCE_ANDROID || JUCE_IOS : pimpl (new Pimpl (*this)) #endif {} + InAppPurchases::~InAppPurchases() {} bool InAppPurchases::isInAppPurchasesSupported() const @@ -48,7 +51,7 @@ void InAppPurchases::getProductsInformation (const StringArray& productIdentifie #else Array products; for (auto productId : productIdentifiers) - products.add (Product {productId}); + products.add (Product { productId, {}, {}, {}, {} }); listeners.call (&Listener::productsInfoReturned, products); #endif @@ -63,7 +66,7 @@ void InAppPurchases::purchaseProduct (const String& productIdentifier, pimpl->purchaseProduct (productIdentifier, isSubscription, upgradeProductIdentifiers, creditForUnusedSubscription); #else - Listener::PurchaseInfo purchaseInfo { Purchase {"", productIdentifier}, {} }; + Listener::PurchaseInfo purchaseInfo { Purchase { "", productIdentifier, {}, {}, {} }, {} }; listeners.call (&Listener::productPurchaseFinished, purchaseInfo, false, "In-app purchases unavailable"); ignoreUnused (isSubscription, upgradeProductIdentifiers, creditForUnusedSubscription); @@ -128,3 +131,5 @@ void InAppPurchases::cancelDownloads (const Array& downloads) ignoreUnused (downloads); #endif } + +} // namespace juce diff --git a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h index 45695d86a3..157d44c853 100644 --- a/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h +++ b/modules/juce_product_unlocking/in_app_purchases/juce_InAppPurchases.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Provides in-app purchase functionality. @@ -269,3 +272,5 @@ private: ScopedPointer pimpl; #endif }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/juce_product_unlocking.cpp b/modules/juce_product_unlocking/juce_product_unlocking.cpp index aa15069954..7bab6c406d 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.cpp +++ b/modules/juce_product_unlocking/juce_product_unlocking.cpp @@ -48,22 +48,22 @@ #import #endif -namespace juce -{ - #if JUCE_ANDROID - #include "native/juce_android_InAppPurchases.cpp" - #elif JUCE_IOS - #include "native/juce_ios_InAppPurchases.cpp" - #endif - - #include "in_app_purchases/juce_InAppPurchases.cpp" - #include "marketplace/juce_OnlineUnlockStatus.cpp" - - #if JUCE_MODULE_AVAILABLE_juce_data_structures - #include "marketplace/juce_TracktionMarketplaceStatus.cpp" - #endif - - #if JUCE_MODULE_AVAILABLE_juce_gui_extra - #include "marketplace/juce_OnlineUnlockForm.cpp" - #endif -} +#if JUCE_IN_APP_PURCHASES + #if JUCE_ANDROID + #include "native/juce_android_InAppPurchases.cpp" + #elif JUCE_IOS + #include "native/juce_ios_InAppPurchases.cpp" + #endif + + #include "in_app_purchases/juce_InAppPurchases.cpp" +#endif + +#include "marketplace/juce_OnlineUnlockStatus.cpp" + +#if JUCE_MODULE_AVAILABLE_juce_data_structures + #include "marketplace/juce_TracktionMarketplaceStatus.cpp" +#endif + +#if JUCE_MODULE_AVAILABLE_juce_gui_extra + #include "marketplace/juce_OnlineUnlockForm.cpp" +#endif diff --git a/modules/juce_product_unlocking/juce_product_unlocking.h b/modules/juce_product_unlocking/juce_product_unlocking.h index e715afbf16..2f52f17354 100644 --- a/modules/juce_product_unlocking/juce_product_unlocking.h +++ b/modules/juce_product_unlocking/juce_product_unlocking.h @@ -35,7 +35,7 @@ ID: juce_product_unlocking vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE Online marketplace support description: Classes for online product authentication website: http://www.juce.com/juce @@ -77,17 +77,17 @@ #include #endif -namespace juce -{ - #include "in_app_purchases/juce_InAppPurchases.h" +#if JUCE_IN_APP_PURCHASES + #include "in_app_purchases/juce_InAppPurchases.h" +#endif + +#if JUCE_MODULE_AVAILABLE_juce_data_structures + #include "marketplace/juce_OnlineUnlockStatus.h" + #include "marketplace/juce_TracktionMarketplaceStatus.h" +#endif - #if JUCE_MODULE_AVAILABLE_juce_data_structures - #include "marketplace/juce_OnlineUnlockStatus.h" - #include "marketplace/juce_TracktionMarketplaceStatus.h" - #endif - #include "marketplace/juce_KeyFileGeneration.h" +#include "marketplace/juce_KeyFileGeneration.h" - #if JUCE_MODULE_AVAILABLE_juce_gui_extra - #include "marketplace/juce_OnlineUnlockForm.h" - #endif -} +#if JUCE_MODULE_AVAILABLE_juce_gui_extra + #include "marketplace/juce_OnlineUnlockForm.h" +#endif diff --git a/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h b/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h index fbf8b659c7..7e06c6e798 100644 --- a/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h +++ b/modules/juce_product_unlocking/marketplace/juce_KeyFileGeneration.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Contains static utilities for generating key-files that can be unlocked by the OnlineUnlockStatus class. @@ -107,3 +110,5 @@ public: return 0; } }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp index 4476997147..debb2384c3 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + struct Spinner : public Component, private Timer { Spinner() { startTimer (1000 / 50); } @@ -283,3 +286,5 @@ void OnlineUnlockForm::dismiss() { delete this; } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h index c4b20010a8..bc9dd492a5 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockForm.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** Acts as a GUI which asks the user for their details, and calls the approriate methods on your OnlineUnlockStatus object to attempt to register the app. @@ -88,3 +91,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OnlineUnlockForm) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp index d4001fd084..39affbf700 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /* Note: there's a bit of light obfuscation in this code, just to make things a bit more annoying for crackers who try to reverse-engineer your binaries, but nothing particularly foolproof. @@ -485,3 +488,5 @@ String KeyGeneration::generateExpiringKeyFile (const String& appName, return KeyFileUtils::createKeyFile (comment, xml, privateKey); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h index 7a72e079dd..0085d570ad 100644 --- a/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h +++ b/modules/juce_product_unlocking/marketplace/juce_OnlineUnlockStatus.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** A base class for online unlocking systems. @@ -258,3 +261,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OnlineUnlockStatus) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp index 2131c2d096..b30e263163 100644 --- a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp +++ b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + TracktionMarketplaceStatus::TracktionMarketplaceStatus() {} URL TracktionMarketplaceStatus::getServerAuthenticationURL() @@ -54,3 +57,5 @@ String TracktionMarketplaceStatus::readReplyFromWebserver (const String& email, return url.readEntireTextStream(); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h index 06566b83a2..c93cd5328c 100644 --- a/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h +++ b/modules/juce_product_unlocking/marketplace/juce_TracktionMarketplaceStatus.h @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + /** An implementation of the OnlineUnlockStatus class which talks to the Tracktion Marketplace server. @@ -51,3 +54,5 @@ public: private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TracktionMarketplaceStatus) }; + +} // namespace juce diff --git a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp index f9d4a25d20..da61ce003d 100644 --- a/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/native/juce_android_InAppPurchases.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (isBillingSupported, "isBillingSupported", "(ILjava/lang/String;Ljava/lang/String;)I") \ @@ -931,3 +933,5 @@ void juce_inAppPurchaseCompleted (void* intentData) { InAppPurchases::Pimpl::inAppPurchaseCompleted (static_cast (intentData)); } + +} // namespace juce diff --git a/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp b/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp index 8ff5b98628..aa7415b9f5 100644 --- a/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp +++ b/modules/juce_product_unlocking/native/juce_ios_InAppPurchases.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy { static void destroy (NSObject* o) { [o release]; } }; template <> struct ContainerDeletePolicy> { static void destroy (NSObject* o) { [o release]; } }; @@ -677,3 +680,5 @@ struct InAppPurchases::Pimpl : public SKDelegateAndPaymentObserver OwnedArray pendingDownloadsTransactions; Array restoredPurchases; }; + +} // namespace juce diff --git a/modules/juce_video/capture/juce_CameraDevice.cpp b/modules/juce_video/capture/juce_CameraDevice.cpp index 91955d59ee..97568e1b79 100644 --- a/modules/juce_video/capture/juce_CameraDevice.cpp +++ b/modules/juce_video/capture/juce_CameraDevice.cpp @@ -24,6 +24,8 @@ ============================================================================== */ +namespace juce +{ #if JUCE_MAC || JUCE_IOS #include "../native/juce_mac_CameraDevice.h" @@ -99,3 +101,5 @@ CameraDevice* CameraDevice::openDevice (int index, return nullptr; } + +} // namespace juce diff --git a/modules/juce_video/capture/juce_CameraDevice.h b/modules/juce_video/capture/juce_CameraDevice.h index 2e4f81a701..18a19b5f7a 100644 --- a/modules/juce_video/capture/juce_CameraDevice.h +++ b/modules/juce_video/capture/juce_CameraDevice.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ #if JUCE_USE_CAMERA || DOXYGEN @@ -164,3 +165,5 @@ private: #endif #endif + +} // namespace juce diff --git a/modules/juce_video/juce_video.cpp b/modules/juce_video/juce_video.cpp index 6edb8a60d6..bec17ed285 100644 --- a/modules/juce_video/juce_video.cpp +++ b/modules/juce_video/juce_video.cpp @@ -67,15 +67,8 @@ #endif //============================================================================== -using namespace juce; - -namespace juce -{ - #include "playback/juce_VideoComponent.cpp" #if JUCE_USE_CAMERA #include "capture/juce_CameraDevice.cpp" #endif - -} diff --git a/modules/juce_video/juce_video.h b/modules/juce_video/juce_video.h index 8d76427fea..b8ae9f3fdb 100644 --- a/modules/juce_video/juce_video.h +++ b/modules/juce_video/juce_video.h @@ -36,7 +36,7 @@ ID: juce_video vendor: juce - version: 5.1.1 + version: 5.1.2 name: JUCE video playback and capture classes description: Classes for playing video and capturing camera input. website: http://www.juce.com/juce @@ -57,9 +57,6 @@ //============================================================================== #include -//============================================================================= -#include "../juce_gui_extra/juce_gui_extra.h" - //============================================================================= /** Config: JUCE_USE_CAMERA Enables web-cam support using the CameraDevice class (Mac and Windows). @@ -73,10 +70,5 @@ #endif //============================================================================= -namespace juce -{ - #include "playback/juce_VideoComponent.h" #include "capture/juce_CameraDevice.h" - -} diff --git a/modules/juce_video/playback/juce_VideoComponent.cpp b/modules/juce_video/playback/juce_VideoComponent.cpp index 0d0552d1b4..135048b037 100644 --- a/modules/juce_video/playback/juce_VideoComponent.cpp +++ b/modules/juce_video/playback/juce_VideoComponent.cpp @@ -22,6 +22,9 @@ ============================================================================== */ +namespace juce +{ + #if JUCE_MAC || JUCE_IOS || JUCE_MSVC #if JUCE_MAC || JUCE_IOS @@ -116,3 +119,5 @@ void VideoComponent::timerCallback() } #endif + +} // namespace juce diff --git a/modules/juce_video/playback/juce_VideoComponent.h b/modules/juce_video/playback/juce_VideoComponent.h index 1980e1c897..ea08878039 100644 --- a/modules/juce_video/playback/juce_VideoComponent.h +++ b/modules/juce_video/playback/juce_VideoComponent.h @@ -25,6 +25,8 @@ #ifndef JUCE_VIDEOCOMPONENT_H_INCLUDED #define JUCE_VIDEOCOMPONENT_H_INCLUDED +namespace juce +{ //============================================================================== /** @@ -130,3 +132,5 @@ private: #endif + +} // namespace juce