diff --git a/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h b/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h index b8c3b0f52..16e729db2 100644 --- a/source/modules/juce_audio_basics/audio_play_head/juce_AudioPlayHead.h +++ b/source/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/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp b/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp index e75f90b4e..bffc3f4bf 100644 --- a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.cpp +++ b/source/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) { @@ -65,6 +68,8 @@ String AudioChannelSet::getChannelTypeName (AudioChannelSet::ChannelType type) case ambisonicX: return NEEDS_TRANS("Ambisonic X"); case ambisonicY: return NEEDS_TRANS("Ambisonic Y"); case ambisonicZ: return NEEDS_TRANS("Ambisonic Z"); + case topSideLeft: return NEEDS_TRANS("Top Side Left"); + case topSideRight: return NEEDS_TRANS("Top Side Right"); default: break; } @@ -105,6 +110,8 @@ String AudioChannelSet::getAbbreviatedChannelTypeName (AudioChannelSet::ChannelT case ambisonicX: return "X"; case ambisonicY: return "Y"; case ambisonicZ: return "Z"; + case topSideLeft: return "Tsl"; + case topSideRight: return "Tsr"; default: break; } @@ -144,6 +151,8 @@ AudioChannelSet::ChannelType AudioChannelSet::getChannelTypeFromAbbreviation (co if (abbr == "X") return ambisonicX; if (abbr == "Y") return ambisonicY; if (abbr == "Z") return ambisonicZ; + if (abbr == "Tsl") return topSideLeft; + if (abbr == "Tsr") return topSideRight; return unknown; } @@ -189,16 +198,18 @@ String AudioChannelSet::getDescription() const if (*this == createLRS()) return "LRS"; if (*this == createLCRS()) return "LCRS"; - if (*this == create5point0()) return "5.0 Surround"; - if (*this == create5point1()) return "5.1 Surround"; - if (*this == create6point0()) return "6.0 Surround"; - if (*this == create6point1()) return "6.1 Surround"; - if (*this == create6point0Music()) return "6.0 (Music) Surround"; - if (*this == create6point1Music()) return "6.1 (Music) Surround"; - if (*this == create7point0()) return "7.0 Surround"; - if (*this == create7point1()) return "7.1 Surround"; - if (*this == create7point0SDDS()) return "7.0 Surround SDDS"; - if (*this == create7point1SDDS()) return "7.1 Surround SDDS"; + if (*this == create5point0()) return "5.0 Surround"; + if (*this == create5point1()) return "5.1 Surround"; + if (*this == create6point0()) return "6.0 Surround"; + if (*this == create6point1()) return "6.1 Surround"; + if (*this == create6point0Music()) return "6.0 (Music) Surround"; + if (*this == create6point1Music()) return "6.1 (Music) Surround"; + if (*this == create7point0()) return "7.0 Surround"; + if (*this == create7point1()) return "7.1 Surround"; + if (*this == create7point0SDDS()) return "7.0 Surround SDDS"; + if (*this == create7point1SDDS()) return "7.1 Surround SDDS"; + if (*this == create7point0point2()) return "7.0.2 Surround"; + if (*this == create7point1point2()) return "7.1.2 Surround"; if (*this == quadraphonic()) return "Quadraphonic"; if (*this == pentagonal()) return "Pentagonal"; @@ -212,7 +223,7 @@ String AudioChannelSet::getDescription() const bool AudioChannelSet::isDiscreteLayout() const noexcept { for (auto& speaker : getChannelTypes()) - if (speaker <= ambisonicZ) + if (speaker <= topSideRight) return false; return true; @@ -272,27 +283,29 @@ void AudioChannelSet::removeChannel (ChannelType newChannel) channels.clearBit (bit); } -AudioChannelSet AudioChannelSet::disabled() { return {}; } -AudioChannelSet AudioChannelSet::mono() { return AudioChannelSet (1u << centre); } -AudioChannelSet AudioChannelSet::stereo() { return AudioChannelSet ((1u << left) | (1u << right)); } -AudioChannelSet AudioChannelSet::createLCR() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre)); } -AudioChannelSet AudioChannelSet::createLRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << surround)); } -AudioChannelSet AudioChannelSet::createLCRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << surround)); } -AudioChannelSet AudioChannelSet::create5point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround)); } -AudioChannelSet AudioChannelSet::create5point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround)); } -AudioChannelSet AudioChannelSet::create6point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); } -AudioChannelSet AudioChannelSet::create6point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); } -AudioChannelSet AudioChannelSet::create6point0Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); } -AudioChannelSet AudioChannelSet::create6point1Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); } -AudioChannelSet AudioChannelSet::create7point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } -AudioChannelSet AudioChannelSet::create7point0SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); } -AudioChannelSet AudioChannelSet::create7point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } -AudioChannelSet AudioChannelSet::create7point1SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); } -AudioChannelSet AudioChannelSet::ambisonic() { return AudioChannelSet ((1u << ambisonicW) | (1u << ambisonicX) | (1u << ambisonicY) | (1u << ambisonicZ)); } -AudioChannelSet AudioChannelSet::quadraphonic() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround)); } -AudioChannelSet AudioChannelSet::pentagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } -AudioChannelSet AudioChannelSet::hexagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << centreSurround) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } -AudioChannelSet AudioChannelSet::octagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround) | (1u << wideLeft) | (1u << wideRight)); } +AudioChannelSet AudioChannelSet::disabled() { return {}; } +AudioChannelSet AudioChannelSet::mono() { return AudioChannelSet (1u << centre); } +AudioChannelSet AudioChannelSet::stereo() { return AudioChannelSet ((1u << left) | (1u << right)); } +AudioChannelSet AudioChannelSet::createLCR() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre)); } +AudioChannelSet AudioChannelSet::createLRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << surround)); } +AudioChannelSet AudioChannelSet::createLCRS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << surround)); } +AudioChannelSet AudioChannelSet::create5point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround)); } +AudioChannelSet AudioChannelSet::create5point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround)); } +AudioChannelSet AudioChannelSet::create6point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); } +AudioChannelSet AudioChannelSet::create6point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround)); } +AudioChannelSet AudioChannelSet::create6point0Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); } +AudioChannelSet AudioChannelSet::create6point1Music() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftSurroundSide) | (1u << rightSurroundSide)); } +AudioChannelSet AudioChannelSet::create7point0() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } +AudioChannelSet AudioChannelSet::create7point0SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); } +AudioChannelSet AudioChannelSet::create7point1() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } +AudioChannelSet AudioChannelSet::create7point1SDDS() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurround) | (1u << rightSurround) | (1u << leftCentre) | (1u << rightCentre)); } +AudioChannelSet AudioChannelSet::ambisonic() { return AudioChannelSet ((1u << ambisonicW) | (1u << ambisonicX) | (1u << ambisonicY) | (1u << ambisonicZ)); } +AudioChannelSet AudioChannelSet::quadraphonic() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << leftSurround) | (1u << rightSurround)); } +AudioChannelSet AudioChannelSet::pentagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } +AudioChannelSet AudioChannelSet::hexagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << centreSurround) | (1u << leftSurroundRear) | (1u << rightSurroundRear)); } +AudioChannelSet AudioChannelSet::octagonal() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurround) | (1u << rightSurround) | (1u << centreSurround) | (1u << wideLeft) | (1u << wideRight)); } +AudioChannelSet AudioChannelSet::create7point0point2() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear) | (1u << topSideLeft) | (1u << topSideRight)); } +AudioChannelSet AudioChannelSet::create7point1point2() { return AudioChannelSet ((1u << left) | (1u << right) | (1u << centre) | (1u << LFE) | (1u << leftSurroundSide) | (1u << rightSurroundSide) | (1u << leftSurroundRear) | (1u << rightSurroundRear) | (1u << topSideLeft) | (1u << topSideRight)); } AudioChannelSet AudioChannelSet::discreteChannels (int numChannels) @@ -414,3 +427,5 @@ int32 AudioChannelSet::getWaveChannelMask() const noexcept return (channels.toInteger() >> 1); } + +} // namespace juce diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h b/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h index 14c0ff900..431ae389d 100644 --- a/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h +++ b/source/modules/juce_audio_basics/buffers/juce_AudioChannelSet.h @@ -20,8 +20,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -194,6 +194,18 @@ public: */ static AudioChannelSet JUCE_CALLTYPE create7point1SDDS(); + /** Creates a set for Dolby Atmos 7.0.2 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, topSideLeft, topSideRight). + + Is equivalent to: n/a (VST), AAX_eStemFormat_7_0_2 (AAX), n/a (CoreAudio) + */ + static AudioChannelSet JUCE_CALLTYPE create7point0point2(); + + /** Creates a set for Dolby Atmos 7.1.2 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide, leftSurroundRear, rightSurroundRear, LFE, topSideLeft, topSideRight). + + Is equivalent to: k71_2 (VST), AAX_eStemFormat_7_1_2 (AAX), n/a (CoreAudio) + */ + static AudioChannelSet JUCE_CALLTYPE create7point1point2(); + //============================================================================== /** Creates a set for ambisonic surround setups (ambisonicW, ambisonicX, ambisonicY, ambisonicZ). @@ -289,6 +301,10 @@ public: ambisonicY = 26, ambisonicZ = 27, + // Used by Dolby Atmos 7.0.2 and 7.1.2 + topSideLeft = 28, // Lts (AAX), Tsl (VST) + topSideRight = 29, // Rts (AAX), Tsr (VST) + discreteChannel0 = 64 /**< Non-typed individual channels are indexed upwards from this value. */ }; @@ -305,7 +321,7 @@ public: //============================================================================== enum { - maxChannelsOfNamedLayout = 8 + maxChannelsOfNamedLayout = 10 }; /** Adds a channel to the set. */ @@ -388,3 +404,5 @@ private: explicit AudioChannelSet (uint32); explicit AudioChannelSet (const Array&); }; + +} // namespace juce diff --git a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index de705a8d3..3f31379dd 100644 --- a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/source/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/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h b/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h index 91907c028..6af682200 100644 --- a/source/modules/juce_audio_basics/buffers/juce_AudioDataConverters.h +++ b/source/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/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 04dc75813..ac9addd56 100644 --- a/source/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/source/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/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp b/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp index cbf6fb255..5523a4a2f 100644 --- a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.cpp +++ b/source/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/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h b/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h index 9cb7895fc..c44bbd800 100644 --- a/source/modules/juce_audio_basics/buffers/juce_FloatVectorOperations.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp b/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp index 11f996b02..3d210938c 100644 --- a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.cpp +++ b/source/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/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h b/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h index 75eaeeca4..3876ae612 100644 --- a/source/modules/juce_audio_basics/effects/juce_CatmullRomInterpolator.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_Decibels.h b/source/modules/juce_audio_basics/effects/juce_Decibels.h index e144f11e0..4fc2d2fdb 100644 --- a/source/modules/juce_audio_basics/effects/juce_Decibels.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp b/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp index 39def04d3..01338c8d9 100644 --- a/source/modules/juce_audio_basics/effects/juce_IIRFilter.cpp +++ b/source/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/source/modules/juce_audio_basics/effects/juce_IIRFilter.h b/source/modules/juce_audio_basics/effects/juce_IIRFilter.h index b0ef1fa11..9db85b582 100644 --- a/source/modules/juce_audio_basics/effects/juce_IIRFilter.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp b/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp index 25ab4f14e..f8d5ee3bc 100644 --- a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.cpp +++ b/source/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/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h b/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h index 8c929c584..c6332171f 100644 --- a/source/modules/juce_audio_basics/effects/juce_IIRFilterOld.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index ecd892d72..eca8e98e6 100644 --- a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/source/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/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h b/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h index 7143842e3..d52757451 100644 --- a/source/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h b/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h index d39dc9173..3dc342c41 100644 --- a/source/modules/juce_audio_basics/effects/juce_LinearSmoothedValue.h +++ b/source/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/source/modules/juce_audio_basics/effects/juce_Reverb.h b/source/modules/juce_audio_basics/effects/juce_Reverb.h index 375fda090..02b95b3c3 100644 --- a/source/modules/juce_audio_basics/effects/juce_Reverb.h +++ b/source/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/source/modules/juce_audio_basics/juce_audio_basics.cpp b/source/modules/juce_audio_basics/juce_audio_basics.cpp index fae5bff83..9ee676fb3 100644 --- a/source/modules/juce_audio_basics/juce_audio_basics.cpp +++ b/source/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/source/modules/juce_audio_basics/juce_audio_basics.h b/source/modules/juce_audio_basics/juce_audio_basics.h index ce6c8f45c..bcce98b41 100644 --- a/source/modules/juce_audio_basics/juce_audio_basics.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp b/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp index cc71ff0bc..94d19898f 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h index b69d8796c..e856bfbd2 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp b/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp index 727f9f62d..6a67a0890 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiFile.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiFile.h b/source/modules/juce_audio_basics/midi/juce_MidiFile.h index 47a1fab98..b06589d29 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiFile.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp b/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp index 9f093628b..ad52ceb8f 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h b/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h index ef9a8f43c..b3fc4e61e 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiKeyboardState.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/source/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index e9e6c1be3..bf2eb56cd 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiMessage.h b/source/modules/juce_audio_basics/midi/juce_MidiMessage.h index aea8d4207..7fcefe2a2 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiMessage.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index 6a3f851cb..fe8b2c083 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h b/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h index 916431b98..8f5e3f699 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiRPN.cpp b/source/modules/juce_audio_basics/midi/juce_MidiRPN.cpp index a5189566c..9e2c2df32 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiRPN.cpp +++ b/source/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/source/modules/juce_audio_basics/midi/juce_MidiRPN.h b/source/modules/juce_audio_basics/midi/juce_MidiRPN.h index 53219c1f9..e8a74d107 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiRPN.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 70aee29fd..24bfd2e26 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.h b/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.h index 8fe26ae91..b6d05ea84 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEInstrument.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp b/source/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp index 09939a104..ebdc68993 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEMessages.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEMessages.h b/source/modules/juce_audio_basics/mpe/juce_MPEMessages.h index 87b12f09d..76b58b201 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEMessages.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPENote.cpp b/source/modules/juce_audio_basics/mpe/juce_MPENote.cpp index 1f47cec02..dad3ab602 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPENote.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPENote.h b/source/modules/juce_audio_basics/mpe/juce_MPENote.h index 874a03f3e..8d549ddd9 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPENote.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index 3e965f434..94763f1bc 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h index 73dcc9772..408970e6c 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiser.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp index 671249a30..7759eea5e 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h index 649abc884..b2b787a58 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserBase.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp index cdd35cfc0..6ac688eba 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h b/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h index 9f8205e63..142c96378 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPESynthesiserVoice.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEValue.cpp b/source/modules/juce_audio_basics/mpe/juce_MPEValue.cpp index 941305754..d9fbd7db3 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEValue.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEValue.h b/source/modules/juce_audio_basics/mpe/juce_MPEValue.h index 574341005..4bb5afc96 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEValue.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEZone.cpp b/source/modules/juce_audio_basics/mpe/juce_MPEZone.cpp index 912a86c3c..5b97f0677 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEZone.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEZone.h b/source/modules/juce_audio_basics/mpe/juce_MPEZone.h index 9fdfb5548..728439826 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEZone.h +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp b/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp index 450dc09f6..f0d525ad3 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp +++ b/source/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/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h b/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h index 0b08eb561..5b0337c11 100644 --- a/source/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h +++ b/source/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/source/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h b/source/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h index 1bf5cda27..0aaf6f666 100644 --- a/source/modules/juce_audio_basics/native/juce_mac_CoreAudioLayouts.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_AudioSource.h b/source/modules/juce_audio_basics/sources/juce_AudioSource.h index e58f93b29..6e5ddba5d 100644 --- a/source/modules/juce_audio_basics/sources/juce_AudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp index 1cf471839..ae33bea0d 100644 --- a/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 803695ea4..5624f5ceb 100644 --- a/source/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp index a70fe866e..3cec22131 100644 --- a/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h b/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h index 1ed44d824..b5a5cf058 100644 --- a/source/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp index be4479fbb..cbea3b8c2 100644 --- a/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h b/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h index 9f38d1ce8..38faf285b 100644 --- a/source/modules/juce_audio_basics/sources/juce_IIRFilterAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp index 220debfd1..6adec0444 100644 --- a/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h b/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h index 1a6fabf1b..50b11c7b9 100644 --- a/source/modules/juce_audio_basics/sources/juce_MemoryAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp index 70b265865..b3f1d148c 100644 --- a/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.h b/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.h index 5a3883f8e..0c2b6e22c 100644 --- a/source/modules/juce_audio_basics/sources/juce_MixerAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h b/source/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h index c9195dc90..5908bb82b 100644 --- a/source/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp index 386f894ca..67ff49ccd 100644 --- a/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h b/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h index 72134f983..9f8fcd239 100644 --- a/source/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp index 86e54eaf9..dd4e7ab03 100644 --- a/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h b/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h index fbdf48c94..1d2591b64 100644 --- a/source/modules/juce_audio_basics/sources/juce_ReverbAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp b/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp index b0f24d390..b33a92249 100644 --- a/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp +++ b/source/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/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h b/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h index a5fc03b4f..9c8e939d9 100644 --- a/source/modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.h +++ b/source/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/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 4df64603e..cb2eaf904 100644 --- a/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/source/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/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index cad5ac393..b8e50876f 100644 --- a/source/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 89eb7cf9f..cc8cd4e65 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index f4169644c..5d7ae8403 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp b/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp index 0fd48370f..935de58d0 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.cpp +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h b/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h index 6c3b8300f..a1599f4d2 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp b/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp index aef772d0a..838aaa654 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h b/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h index eaba0080e..c11f711a4 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h +++ b/source/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/source/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h b/source/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h index 592215c9d..bf5c44c6a 100644 --- a/source/modules/juce_audio_devices/audio_io/juce_SystemAudioVolume.h +++ b/source/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/source/modules/juce_audio_devices/juce_audio_devices.cpp b/source/modules/juce_audio_devices/juce_audio_devices.cpp index 33c6fe0c9..6bdd8fe06 100644 --- a/source/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/source/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/source/modules/juce_audio_devices/juce_audio_devices.h b/source/modules/juce_audio_devices/juce_audio_devices.h index 533bcd1af..9b26405da 100644 --- a/source/modules/juce_audio_devices/juce_audio_devices.h +++ b/source/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/source/modules/juce_audio_devices/midi_io/juce_MidiInput.h b/source/modules/juce_audio_devices/midi_io/juce_MidiInput.h index 54cd0e4e7..52edd9fe0 100644 --- a/source/modules/juce_audio_devices/midi_io/juce_MidiInput.h +++ b/source/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/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp b/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp index 66bab1f85..50ca20569 100644 --- a/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.cpp +++ b/source/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/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h b/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h index 97f2dd6bb..aa8bcdbeb 100644 --- a/source/modules/juce_audio_devices/midi_io/juce_MidiMessageCollector.h +++ b/source/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/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp b/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp index f364b31cd..36b7cf640 100644 --- a/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.cpp +++ b/source/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/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.h b/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.h index f71553dc7..f05dc32f1 100644 --- a/source/modules/juce_audio_devices/midi_io/juce_MidiOutput.h +++ b/source/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/source/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h b/source/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h index 0cf7e285d..1df491240 100644 --- a/source/modules/juce_audio_devices/native/juce_MidiDataConcatenator.h +++ b/source/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/source/modules/juce_audio_devices/native/juce_android_Audio.cpp b/source/modules/juce_audio_devices/native/juce_android_Audio.cpp index a22f0619f..42f6fdd98 100644 --- a/source/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/source/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") \ @@ -48,6 +50,13 @@ DECLARE_JNI_CLASS (AudioTrack, "android/media/AudioTrack"); DECLARE_JNI_CLASS (AudioRecord, "android/media/AudioRecord"); #undef JNI_CLASS_MEMBERS +//============================================================================== +#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ + STATICFIELD (SDK_INT, "SDK_INT", "I") \ + + DECLARE_JNI_CLASS (AndroidBuildVersion, "android/os/Build$VERSION"); +#undef JNI_CLASS_MEMBERS + //============================================================================== enum { @@ -193,6 +202,9 @@ public: STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, (jint) (minBufferSizeOut * numDeviceOutputChannels * static_cast (sizeof (int16))), MODE_STREAM)); + const bool supportsUnderrunCount = (getEnv()->GetStaticIntField (AndroidBuildVersion, AndroidBuildVersion.SDK_INT) >= 24); + getUnderrunCount = supportsUnderrunCount ? env->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : 0; + int outputDeviceState = env->CallIntMethod (outputDevice, AudioTrack.getState); if (outputDeviceState > 0) { @@ -279,6 +291,14 @@ public: String getLastError() override { return lastError; } bool isPlaying() override { return isRunning && callback != 0; } + int getXRunCount() const noexcept override + { + if (outputDevice != nullptr && getUnderrunCount != 0) + return getEnv()->CallIntMethod (outputDevice, getUnderrunCount); + + return -1; + } + void start (AudioIODeviceCallback* newCallback) override { if (isRunning && callback != newCallback) @@ -404,6 +424,7 @@ private: BigInteger activeOutputChans, activeInputChans; GlobalRef outputDevice, inputDevice; AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; + jmethodID getUnderrunCount = 0; void closeDevices() { @@ -472,3 +493,5 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() return new AndroidAudioIODeviceType(); } + +} // namespace juce diff --git a/source/modules/juce_audio_devices/native/juce_android_Midi.cpp b/source/modules/juce_audio_devices/native/juce_android_Midi.cpp index c968982cb..5afe6562c 100644 --- a/source/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index d1dd6be33..48cd2fe91 100644 --- a/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/source/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -20,12 +20,8 @@ ============================================================================== */ -//============================================================================== -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ -STATICFIELD (SDK_INT, "SDK_INT", "I") \ - -DECLARE_JNI_CLASS (AndroidBuildVersion, "android/os/Build$VERSION"); -#undef JNI_CLASS_MEMBERS +namespace juce +{ //============================================================================== #ifndef SL_ANDROID_DATAFORMAT_PCM_EX @@ -289,12 +285,39 @@ 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; + const bool supportsJavaProxy = (getEnv()->GetStaticIntField (AndroidBuildVersion, AndroidBuildVersion.SDK_INT) >= 24); + + if (supportsJavaProxy) + { + // 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 +331,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 +344,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 +368,8 @@ public: SlRef runner; SlRef queue; + SlRef config; + GlobalRef javaProxy; int numChannels; @@ -377,12 +402,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 +460,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 +473,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 +483,6 @@ public: } void setState (bool running) { (*Base::runner)->SetRecordState (Base::runner, running ? SL_RECORDSTATE_RECORDING : SL_RECORDSTATE_STOPPED); } - - SlRef config; }; //============================================================================== @@ -519,6 +539,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) { @@ -614,6 +635,9 @@ public: player = nullptr; return; } + + const bool supportsUnderrunCount = (getEnv()->GetStaticIntField (AndroidBuildVersion, AndroidBuildVersion.SDK_INT) >= 24); + getUnderrunCount = supportsUnderrunCount ? getEnv()->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : 0; } } } @@ -676,6 +700,14 @@ public: return true; } + int getXRunCount() const noexcept override + { + if (player != nullptr && player->javaProxy != nullptr && getUnderrunCount != 0) + return getEnv()->CallIntMethod (player->javaProxy, getUnderrunCount); + + return -1; + } + bool supportsFloatingPoint() const noexcept override { return (BufferHelpers::isFloatingPoint != 0); } void doSomeWorkOnAudioThread() @@ -726,6 +758,7 @@ public: ScopedPointer > player; ScopedPointer > recorder; Atomic guard; + jmethodID getUnderrunCount = 0; }; //============================================================================== @@ -890,6 +923,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 +1237,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 +1317,5 @@ pthread_t juce_createRealtimeAudioThread (void* (*entry) (void*), void* userPtr) return threadID; } + +} // namespace juce diff --git a/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp b/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp index ad69dad3c..432bb228b 100644 --- a/source/modules/juce_audio_devices/native/juce_ios_Audio.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_ios_Audio.h b/source/modules/juce_audio_devices/native/juce_ios_Audio.h index bab757384..b06be4d97 100644 --- a/source/modules/juce_audio_devices/native/juce_ios_Audio.h +++ b/source/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/source/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/source/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index 0912f4e46..7a521f468 100644 --- a/source/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp b/source/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp index 482437e89..35302a316 100644 --- a/source/modules/juce_audio_devices/native/juce_linux_JackAudio.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 74bbe4131..ef4dfade8 100644 --- a/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/source/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index 80758de9f..0bd8f3fbc 100644 --- a/source/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 4abff0f09..cd98d478e 100644 --- a/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp b/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp index e6d88aa13..2c11bdd23 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_ASIO.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/source/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 031be1892..10ea41aba 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp index b614f7138..c45ab2dc5 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/source/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/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 7fb96aaee..d0380d789 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/source/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/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp b/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp index 90525e01b..b03ca9a93 100644 --- a/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp +++ b/source/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/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h b/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h index 8ef176067..d624b0a57 100644 --- a/source/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h +++ b/source/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/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp b/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp index 31610633b..bbc3d8ae4 100644 --- a/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.cpp +++ b/source/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/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.h b/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.h index 36cb8f5a2..90103dad6 100644 --- a/source/modules/juce_audio_devices/sources/juce_AudioTransportSource.h +++ b/source/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/source/modules/juce_audio_formats/codecs/flac/compat.h b/source/modules/juce_audio_formats/codecs/flac/compat.h index 543f49e83..f97b1939e 100644 --- a/source/modules/juce_audio_formats/codecs/flac/compat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp index 40619c54c..f3c8c8053 100644 --- a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h index efafaa73a..cd4c5f43a 100644 --- a/source/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp index 4808fd85f..72d0aa974 100644 --- a/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h index dd5b54ab8..878d84e0f 100644 --- a/source/modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 0c6b26759..05c3c44ea 100644 --- a/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h index 8b3c43e4f..fe61e3c59 100644 --- a/source/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp index 78b61d904..01b39ea24 100644 --- a/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h index dc0290d94..45b578842 100644 --- a/source/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index bfc987db3..238eb4f3e 100644 --- a/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h index 5d952d42f..cde3298ec 100644 --- a/source/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 34a83caba..0a2737bca 100644 --- a/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h index 416ecad20..c8f4704e5 100644 --- a/source/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 9021d6814..565fecb6b 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h index e18e8e207..85580208f 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 6e75610d3..3167ff3d0 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h b/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h index 39566f9ef..97c746e29 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormat.cpp b/source/modules/juce_audio_formats/format/juce_AudioFormat.cpp index a1cacb4b4..5bad00afe 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormat.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormat.h b/source/modules/juce_audio_formats/format/juce_AudioFormat.h index 1db42e979..bd8113fa3 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormat.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp b/source/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp index 62406fea6..33f26d437 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatManager.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatManager.h b/source/modules/juce_audio_formats/format/juce_AudioFormatManager.h index 7c2f9d4f5..246908a41 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatManager.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/source/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index ccd002a0f..7f29c8377 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/source/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 8af863a8f..5486892ee 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp b/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp index 38c589304..9e6c56757 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h b/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h index a44709ced..3ad72c360 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index febf8a325..c7ba03103 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.h b/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.h index de8998931..c817e0bc0 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioFormatWriter.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp b/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp index 2ad71689d..0fc827297 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h b/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h index 63936138f..523fb59cb 100644 --- a/source/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp b/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp index da87e650d..0980c00b2 100644 --- a/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.cpp +++ b/source/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/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h b/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h index 5bdd31218..c8a4e1d8e 100644 --- a/source/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h +++ b/source/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/source/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h b/source/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h index 93deee386..4b9454c95 100644 --- a/source/modules/juce_audio_formats/format/juce_MemoryMappedAudioFormatReader.h +++ b/source/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/source/modules/juce_audio_formats/juce_audio_formats.cpp b/source/modules/juce_audio_formats/juce_audio_formats.cpp index ab3464dfc..7f930e7e0 100644 --- a/source/modules/juce_audio_formats/juce_audio_formats.cpp +++ b/source/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/source/modules/juce_audio_formats/juce_audio_formats.h b/source/modules/juce_audio_formats/juce_audio_formats.h index deabf519c..c1664704b 100644 --- a/source/modules/juce_audio_formats/juce_audio_formats.h +++ b/source/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/source/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/source/modules/juce_audio_formats/sampler/juce_Sampler.cpp index eab9b01c5..cb9aa5cf6 100644 --- a/source/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/source/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/source/modules/juce_audio_formats/sampler/juce_Sampler.h b/source/modules/juce_audio_formats/sampler/juce_Sampler.h index 77df8e891..68482d86b 100644 --- a/source/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/source/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/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp b/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp index 720260de4..8b33d4d04 100644 --- a/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp +++ b/source/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/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.h b/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.h index f82025789..6eb08eb32 100644 --- a/source/modules/juce_audio_processors/format/juce_AudioPluginFormat.h +++ b/source/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/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index d9e5551ce..ceedf1705 100644 --- a/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/source/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/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index 0be2c06b5..495c22291 100644 --- a/source/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/source/modules/juce_audio_processors/format_types/juce_AU_Shared.h index 71768e3b4..434326ff2 100644 --- a/source/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h b/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h index 9ade640df..a4d0e1b16 100644 --- a/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index ed05018b4..65b364950 100644 --- a/source/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 945f27263..85f307ca2 100644 --- a/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h b/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h index 27f91276d..7002c5181 100644 --- a/source/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VST3Common.h b/source/modules/juce_audio_processors/format_types/juce_VST3Common.h index 02a4b8a83..7ac3608ae 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/source/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -24,7 +24,8 @@ ============================================================================== */ -#pragma once +namespace juce +{ //============================================================================== #define JUCE_DECLARE_VST3_COM_REF_METHODS \ @@ -172,6 +173,8 @@ static inline Steinberg::Vst::Speaker getSpeakerType (const AudioChannelSet& set case AudioChannelSet::ambisonicX: return (1 << 21); /* kSpeakerX */ case AudioChannelSet::ambisonicY: return (1 << 22); /* kSpeakerY */ case AudioChannelSet::ambisonicZ: return (1 << 23); /* kSpeakerZ */ + case AudioChannelSet::topSideLeft: return (1 << 24); /* kSpeakerTsl */ + case AudioChannelSet::topSideRight: return (1 << 25); /* kSpeakerTsr */ case AudioChannelSet::discreteChannel0: return kSpeakerM; default: @@ -181,8 +184,6 @@ static inline Steinberg::Vst::Speaker getSpeakerType (const AudioChannelSet& set switch (static_cast (type)) { - case (int) AudioChannelSet::discreteChannel0 + 1: return (1 << 24); /* kSpeakerTsl */ - case (int) AudioChannelSet::discreteChannel0 + 2: return (1 << 25); /* kSpeakerTsr */ case (int) AudioChannelSet::discreteChannel0 + 3: return (1 << 28); /* kSpeakerBfl */ case (int) AudioChannelSet::discreteChannel0 + 4: return (1 << 29); /* kSpeakerBfc */ case (int) AudioChannelSet::discreteChannel0 + 5: return (1 << 30); /* kSpeakerBfr */ @@ -224,8 +225,8 @@ static inline AudioChannelSet::ChannelType getChannelType (Steinberg::Vst::Speak case (1 << 21): return AudioChannelSet::ambisonicX; /* kSpeakerX */ case (1 << 22): return AudioChannelSet::ambisonicY; /* kSpeakerY */ case (1 << 23): return AudioChannelSet::ambisonicZ; /* kSpeakerZ */ - case (1 << 24): return static_cast ((int)AudioChannelSet::discreteChannel0 + 1); /* kSpeakerTsl */ - case (1 << 25): return static_cast ((int)AudioChannelSet::discreteChannel0 + 2); /* kSpeakerTsr */ + case (1 << 24): return AudioChannelSet::topSideLeft; /* kSpeakerTsl */ + case (1 << 25): return AudioChannelSet::topSideRight; /* kSpeakerTsr */ case (1 << 26): return AudioChannelSet::leftSurroundSide; /* kSpeakerLcs */ case (1 << 27): return AudioChannelSet::rightSurroundSide; /* kSpeakerRcs */ case (1 << 28): return static_cast ((int)AudioChannelSet::discreteChannel0 + 3); /* kSpeakerBfl */ @@ -246,24 +247,28 @@ static inline AudioChannelSet::ChannelType getChannelType (Steinberg::Vst::Speak static inline Steinberg::Vst::SpeakerArrangement getVst3SpeakerArrangement (const AudioChannelSet& channels) noexcept { - if (channels == AudioChannelSet::disabled()) return Steinberg::Vst::SpeakerArr::kEmpty; - else if (channels == AudioChannelSet::mono()) return Steinberg::Vst::SpeakerArr::kMono; - else if (channels == AudioChannelSet::stereo()) return Steinberg::Vst::SpeakerArr::kStereo; - else if (channels == AudioChannelSet::createLCR()) return Steinberg::Vst::SpeakerArr::k30Cine; - else if (channels == AudioChannelSet::createLRS()) return Steinberg::Vst::SpeakerArr::k30Music; - else if (channels == AudioChannelSet::createLCRS()) return Steinberg::Vst::SpeakerArr::k40Cine; - else if (channels == AudioChannelSet::create5point0()) return Steinberg::Vst::SpeakerArr::k50; - else if (channels == AudioChannelSet::create5point1()) return Steinberg::Vst::SpeakerArr::k51; - else if (channels == AudioChannelSet::create6point0()) return Steinberg::Vst::SpeakerArr::k60Cine; - else if (channels == AudioChannelSet::create6point1()) return Steinberg::Vst::SpeakerArr::k61Cine; - else if (channels == AudioChannelSet::create6point0Music()) return Steinberg::Vst::SpeakerArr::k60Music; - else if (channels == AudioChannelSet::create6point1Music()) return Steinberg::Vst::SpeakerArr::k61Music; - else if (channels == AudioChannelSet::create7point0()) return Steinberg::Vst::SpeakerArr::k70Music; - else if (channels == AudioChannelSet::create7point0SDDS()) return Steinberg::Vst::SpeakerArr::k70Cine; - else if (channels == AudioChannelSet::create7point1()) return Steinberg::Vst::SpeakerArr::k71CineSideFill; - else if (channels == AudioChannelSet::create7point1SDDS()) return Steinberg::Vst::SpeakerArr::k71Cine; - else if (channels == AudioChannelSet::ambisonic()) return Steinberg::Vst::SpeakerArr::kBFormat; - else if (channels == AudioChannelSet::quadraphonic()) return Steinberg::Vst::SpeakerArr::k40Music; + using namespace Steinberg::Vst::SpeakerArr; + + if (channels == AudioChannelSet::disabled()) return kEmpty; + else if (channels == AudioChannelSet::mono()) return kMono; + else if (channels == AudioChannelSet::stereo()) return kStereo; + else if (channels == AudioChannelSet::createLCR()) return k30Cine; + else if (channels == AudioChannelSet::createLRS()) return k30Music; + else if (channels == AudioChannelSet::createLCRS()) return k40Cine; + else if (channels == AudioChannelSet::create5point0()) return k50; + else if (channels == AudioChannelSet::create5point1()) return k51; + else if (channels == AudioChannelSet::create6point0()) return k60Cine; + else if (channels == AudioChannelSet::create6point1()) return k61Cine; + else if (channels == AudioChannelSet::create6point0Music()) return k60Music; + else if (channels == AudioChannelSet::create6point1Music()) return k61Music; + else if (channels == AudioChannelSet::create7point0()) return k70Music; + else if (channels == AudioChannelSet::create7point0SDDS()) return k70Cine; + else if (channels == AudioChannelSet::create7point1()) return k71CineSideFill; + else if (channels == AudioChannelSet::create7point1SDDS()) return k71Cine; + else if (channels == AudioChannelSet::ambisonic()) return kBFormat; + else if (channels == AudioChannelSet::quadraphonic()) return k40Music; + else if (channels == AudioChannelSet::create7point0point2()) return k71_2 & ~(Steinberg::Vst::kSpeakerLfe); + else if (channels == AudioChannelSet::create7point1point2()) return k71_2; Steinberg::Vst::SpeakerArrangement result = 0; @@ -277,24 +282,28 @@ static inline Steinberg::Vst::SpeakerArrangement getVst3SpeakerArrangement (cons static inline AudioChannelSet getChannelSetForSpeakerArrangement (Steinberg::Vst::SpeakerArrangement arr) noexcept { - if (arr == Steinberg::Vst::SpeakerArr::kEmpty) return AudioChannelSet::disabled(); - else if (arr == Steinberg::Vst::SpeakerArr::kMono) return AudioChannelSet::mono(); - else if (arr == Steinberg::Vst::SpeakerArr::kStereo) return AudioChannelSet::stereo(); - else if (arr == Steinberg::Vst::SpeakerArr::k30Cine) return AudioChannelSet::createLCR(); - else if (arr == Steinberg::Vst::SpeakerArr::k30Music) return AudioChannelSet::createLRS(); - else if (arr == Steinberg::Vst::SpeakerArr::k40Cine) return AudioChannelSet::createLCRS(); - else if (arr == Steinberg::Vst::SpeakerArr::k50) return AudioChannelSet::create5point0(); - else if (arr == Steinberg::Vst::SpeakerArr::k51) return AudioChannelSet::create5point1(); - else if (arr == Steinberg::Vst::SpeakerArr::k60Cine) return AudioChannelSet::create6point0(); - else if (arr == Steinberg::Vst::SpeakerArr::k61Cine) return AudioChannelSet::create6point1(); - else if (arr == Steinberg::Vst::SpeakerArr::k60Music) return AudioChannelSet::create6point0Music(); - else if (arr == Steinberg::Vst::SpeakerArr::k61Music) return AudioChannelSet::create6point1Music(); - else if (arr == Steinberg::Vst::SpeakerArr::k70Music) return AudioChannelSet::create7point0(); - else if (arr == Steinberg::Vst::SpeakerArr::k70Cine) return AudioChannelSet::create7point0SDDS(); - else if (arr == Steinberg::Vst::SpeakerArr::k71CineSideFill) return AudioChannelSet::create7point1(); - else if (arr == Steinberg::Vst::SpeakerArr::k71Cine) return AudioChannelSet::create7point1SDDS(); - else if (arr == Steinberg::Vst::SpeakerArr::kBFormat) return AudioChannelSet::ambisonic(); - else if (arr == Steinberg::Vst::SpeakerArr::k40Music) return AudioChannelSet::quadraphonic(); + using namespace Steinberg::Vst::SpeakerArr; + + if (arr == kEmpty) return AudioChannelSet::disabled(); + else if (arr == kMono) return AudioChannelSet::mono(); + else if (arr == kStereo) return AudioChannelSet::stereo(); + else if (arr == k30Cine) return AudioChannelSet::createLCR(); + else if (arr == k30Music) return AudioChannelSet::createLRS(); + else if (arr == k40Cine) return AudioChannelSet::createLCRS(); + else if (arr == k50) return AudioChannelSet::create5point0(); + else if (arr == k51) return AudioChannelSet::create5point1(); + else if (arr == k60Cine) return AudioChannelSet::create6point0(); + else if (arr == k61Cine) return AudioChannelSet::create6point1(); + else if (arr == k60Music) return AudioChannelSet::create6point0Music(); + else if (arr == k61Music) return AudioChannelSet::create6point1Music(); + else if (arr == k70Music) return AudioChannelSet::create7point0(); + else if (arr == k70Cine) return AudioChannelSet::create7point0SDDS(); + else if (arr == k71CineSideFill) return AudioChannelSet::create7point1(); + else if (arr == k71Cine) return AudioChannelSet::create7point1SDDS(); + else if (arr == kBFormat) return AudioChannelSet::ambisonic(); + else if (arr == k40Music) return AudioChannelSet::quadraphonic(); + else if (arr == k71_2) return AudioChannelSet::create7point1point2(); + else if (arr == (k71_2 & ~(Steinberg::Vst::kSpeakerLfe))) return AudioChannelSet::create7point0point2(); AudioChannelSet result; @@ -620,3 +629,5 @@ template <> struct VST3FloatAndDoubleBusMapCompositeHelper { static inline VST3BufferExchange::BusMap& get (VST3FloatAndDoubleBusMapComposite& impl) { return impl.doubleVersion; } }; + +} // namespace juce diff --git a/source/modules/juce_audio_processors/format_types/juce_VST3Headers.h b/source/modules/juce_audio_processors/format_types/juce_VST3Headers.h index fc782e21f..6a68bc210 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3Headers.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index ae028b690..48ade86b5 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h index 4adbcefaf..4c3f140b5 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VSTCommon.h b/source/modules/juce_audio_processors/format_types/juce_VSTCommon.h index bda9ec84a..50494a748 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTCommon.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VSTInterface.h b/source/modules/juce_audio_processors/format_types/juce_VSTInterface.h index c8310a002..4d31c312a 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTInterface.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h b/source/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h index d78d7e0db..6665cb9ae 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 11e311d68..716b27401 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/source/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/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h b/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h index c6793a20b..1edeb83e1 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.h +++ b/source/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/source/modules/juce_audio_processors/juce_audio_processors.cpp b/source/modules/juce_audio_processors/juce_audio_processors.cpp index 5d1376f59..675784f1c 100644 --- a/source/modules/juce_audio_processors/juce_audio_processors.cpp +++ b/source/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/source/modules/juce_audio_processors/juce_audio_processors.h b/source/modules/juce_audio_processors/juce_audio_processors.h index fb8e13e0b..ff0b4f730 100644 --- a/source/modules/juce_audio_processors/juce_audio_processors.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h b/source/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h index 8acc55792..5e5c21c50 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioPluginInstance.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 9db4d0412..bf0c76b3e 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/source/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]) @@ -1342,20 +1353,22 @@ int32 AudioProcessor::getAAXPluginIDForMainBusConfig (const AudioChannelSet& mai const AudioChannelSet& set = (isInput ? mainInputLayout : mainOutputLayout); int aaxFormatIndex = 0; - if (set == AudioChannelSet::disabled()) aaxFormatIndex = 0; - else if (set == AudioChannelSet::mono()) aaxFormatIndex = 1; - else if (set == AudioChannelSet::stereo()) aaxFormatIndex = 2; - else if (set == AudioChannelSet::createLCR()) aaxFormatIndex = 3; - else if (set == AudioChannelSet::createLCRS()) aaxFormatIndex = 4; - else if (set == AudioChannelSet::quadraphonic()) aaxFormatIndex = 5; - else if (set == AudioChannelSet::create5point0()) aaxFormatIndex = 6; - else if (set == AudioChannelSet::create5point1()) aaxFormatIndex = 7; - else if (set == AudioChannelSet::create6point0()) aaxFormatIndex = 8; - else if (set == AudioChannelSet::create6point1()) aaxFormatIndex = 9; - else if (set == AudioChannelSet::create7point0()) aaxFormatIndex = 10; - else if (set == AudioChannelSet::create7point1()) aaxFormatIndex = 11; - else if (set == AudioChannelSet::create7point0SDDS()) aaxFormatIndex = 12; - else if (set == AudioChannelSet::create7point1SDDS()) aaxFormatIndex = 13; + if (set == AudioChannelSet::disabled()) aaxFormatIndex = 0; + else if (set == AudioChannelSet::mono()) aaxFormatIndex = 1; + else if (set == AudioChannelSet::stereo()) aaxFormatIndex = 2; + else if (set == AudioChannelSet::createLCR()) aaxFormatIndex = 3; + else if (set == AudioChannelSet::createLCRS()) aaxFormatIndex = 4; + else if (set == AudioChannelSet::quadraphonic()) aaxFormatIndex = 5; + else if (set == AudioChannelSet::create5point0()) aaxFormatIndex = 6; + else if (set == AudioChannelSet::create5point1()) aaxFormatIndex = 7; + else if (set == AudioChannelSet::create6point0()) aaxFormatIndex = 8; + else if (set == AudioChannelSet::create6point1()) aaxFormatIndex = 9; + else if (set == AudioChannelSet::create7point0()) aaxFormatIndex = 10; + else if (set == AudioChannelSet::create7point1()) aaxFormatIndex = 11; + else if (set == AudioChannelSet::create7point0SDDS()) aaxFormatIndex = 12; + else if (set == AudioChannelSet::create7point1SDDS()) aaxFormatIndex = 13; + else if (set == AudioChannelSet::create7point0point2()) aaxFormatIndex = 14; + else if (set == AudioChannelSet::create7point1point2()) aaxFormatIndex = 15; else { // AAX does not support this format and the wrapper should not have @@ -1405,11 +1418,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 +1460,5 @@ void AudioPlayHead::CurrentPositionInfo::resetToDefault() timeSigDenominator = 4; bpm = 120; } + +} // namespace juce diff --git a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 85054fbcb..f1838bf66 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 60f5fcd7d..e7a3ace6f 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index 672fea8fa..7017bd053 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 046ef6672..ef59bc470 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index 432a6fa25..bfd21d118 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h index 7b6ef71e5..7781af1fe 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorListener.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h b/source/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h index 3abccb795..8dc6e5eb0 100644 --- a/source/modules/juce_audio_processors/processors/juce_AudioProcessorParameter.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 32a2db854..08f160932 100644 --- a/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/source/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/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h b/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h index e5d54e5fa..611d62129 100644 --- a/source/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.h +++ b/source/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/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp b/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp index 445ca73f2..6d885d722 100644 --- a/source/modules/juce_audio_processors/processors/juce_PluginDescription.cpp +++ b/source/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/source/modules/juce_audio_processors/processors/juce_PluginDescription.h b/source/modules/juce_audio_processors/processors/juce_PluginDescription.h index 046626a50..7642545a1 100644 --- a/source/modules/juce_audio_processors/processors/juce_PluginDescription.h +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index 352b6c1c0..f7c0bf71e 100644 --- a/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 9095873bd..17ce28fb3 100644 --- a/source/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp b/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp index 680e17edd..1c68861b6 100644 --- a/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.cpp +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h b/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h index c22ccf300..200835a1e 100644 --- a/source/modules/juce_audio_processors/scanning/juce_PluginDirectoryScanner.h +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index dd18d45e8..733842ffb 100644 --- a/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/source/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/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.h b/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.h index da60cd0ea..df3ec367c 100644 --- a/source/modules/juce_audio_processors/scanning/juce_PluginListComponent.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h b/source/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h index ff65cff8b..c664ce801 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioParameterBool.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h b/source/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h index c12432db0..dc711d583 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioParameterChoice.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h b/source/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h index e4c27e2ba..c422749ed 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioParameterFloat.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h b/source/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h index 91f057976..4c2f02c33 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioParameterInt.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h b/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h index 2569c4d06..d5d005234 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameterWithID.h +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp b/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp index eecd0cc6d..88da76bc0 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioProcessorParameters.cpp +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index 4c7fb0054..055b1566c 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/source/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/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h b/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h index b3a129fef..13ace9595 100644 --- a/source/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h +++ b/source/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/source/modules/juce_core/containers/juce_AbstractFifo.cpp b/source/modules/juce_core/containers/juce_AbstractFifo.cpp index 03d61396b..d33f7f85b 100644 --- a/source/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/source/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/source/modules/juce_core/containers/juce_AbstractFifo.h b/source/modules/juce_core/containers/juce_AbstractFifo.h index 5412a2020..0d41d6d9b 100644 --- a/source/modules/juce_core/containers/juce_AbstractFifo.h +++ b/source/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/source/modules/juce_core/containers/juce_Array.h b/source/modules/juce_core/containers/juce_Array.h index 4e66a70ea..8f7380b1e 100644 --- a/source/modules/juce_core/containers/juce_Array.h +++ b/source/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/source/modules/juce_core/containers/juce_ArrayAllocationBase.h b/source/modules/juce_core/containers/juce_ArrayAllocationBase.h index a4c3d89f1..5ab3ce00f 100644 --- a/source/modules/juce_core/containers/juce_ArrayAllocationBase.h +++ b/source/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/source/modules/juce_core/containers/juce_DynamicObject.cpp b/source/modules/juce_core/containers/juce_DynamicObject.cpp index 697205bfa..4d299ac0c 100644 --- a/source/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/source/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/source/modules/juce_core/containers/juce_DynamicObject.h b/source/modules/juce_core/containers/juce_DynamicObject.h index 20c4e7608..83ee6ccf0 100644 --- a/source/modules/juce_core/containers/juce_DynamicObject.h +++ b/source/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/source/modules/juce_core/containers/juce_ElementComparator.h b/source/modules/juce_core/containers/juce_ElementComparator.h index 3f5881c1d..aa30b194a 100644 --- a/source/modules/juce_core/containers/juce_ElementComparator.h +++ b/source/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/source/modules/juce_core/containers/juce_HashMap.h b/source/modules/juce_core/containers/juce_HashMap.h index 019e5b41d..ab04728d7 100644 --- a/source/modules/juce_core/containers/juce_HashMap.h +++ b/source/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/source/modules/juce_core/containers/juce_HashMap_test.cpp b/source/modules/juce_core/containers/juce_HashMap_test.cpp index 428bdc807..76dcd87e0 100644 --- a/source/modules/juce_core/containers/juce_HashMap_test.cpp +++ b/source/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/source/modules/juce_core/containers/juce_LinkedListPointer.h b/source/modules/juce_core/containers/juce_LinkedListPointer.h index d8ddc7ed0..00994bc95 100644 --- a/source/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/source/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/source/modules/juce_core/containers/juce_ListenerList.cpp b/source/modules/juce_core/containers/juce_ListenerList.cpp index f0885171b..972122e0a 100644 --- a/source/modules/juce_core/containers/juce_ListenerList.cpp +++ b/source/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/source/modules/juce_core/containers/juce_ListenerList.h b/source/modules/juce_core/containers/juce_ListenerList.h index 36ca27e3c..7986b74ec 100644 --- a/source/modules/juce_core/containers/juce_ListenerList.h +++ b/source/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/source/modules/juce_core/containers/juce_NamedValueSet.cpp b/source/modules/juce_core/containers/juce_NamedValueSet.cpp index b33ea1da9..45bfff11d 100644 --- a/source/modules/juce_core/containers/juce_NamedValueSet.cpp +++ b/source/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/source/modules/juce_core/containers/juce_NamedValueSet.h b/source/modules/juce_core/containers/juce_NamedValueSet.h index 091605258..4e6ea7ab4 100644 --- a/source/modules/juce_core/containers/juce_NamedValueSet.h +++ b/source/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/source/modules/juce_core/containers/juce_OwnedArray.h b/source/modules/juce_core/containers/juce_OwnedArray.h index 4bb502814..ccfacb043 100644 --- a/source/modules/juce_core/containers/juce_OwnedArray.h +++ b/source/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/source/modules/juce_core/containers/juce_PropertySet.cpp b/source/modules/juce_core/containers/juce_PropertySet.cpp index ce28d140c..b1938de47 100644 --- a/source/modules/juce_core/containers/juce_PropertySet.cpp +++ b/source/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/source/modules/juce_core/containers/juce_PropertySet.h b/source/modules/juce_core/containers/juce_PropertySet.h index b8e934fce..26a2cad52 100644 --- a/source/modules/juce_core/containers/juce_PropertySet.h +++ b/source/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/source/modules/juce_core/containers/juce_ReferenceCountedArray.h b/source/modules/juce_core/containers/juce_ReferenceCountedArray.h index 64eb2d531..aaee95395 100644 --- a/source/modules/juce_core/containers/juce_ReferenceCountedArray.h +++ b/source/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/source/modules/juce_core/containers/juce_ScopedValueSetter.h b/source/modules/juce_core/containers/juce_ScopedValueSetter.h index eeb342650..f5e03345a 100644 --- a/source/modules/juce_core/containers/juce_ScopedValueSetter.h +++ b/source/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/source/modules/juce_core/containers/juce_SortedSet.h b/source/modules/juce_core/containers/juce_SortedSet.h index 632b659d2..04d096a02 100644 --- a/source/modules/juce_core/containers/juce_SortedSet.h +++ b/source/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/source/modules/juce_core/containers/juce_SparseSet.h b/source/modules/juce_core/containers/juce_SparseSet.h index 1b4e478e7..37efeb4f7 100644 --- a/source/modules/juce_core/containers/juce_SparseSet.h +++ b/source/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/source/modules/juce_core/containers/juce_Variant.cpp b/source/modules/juce_core/containers/juce_Variant.cpp index 2d79e22bd..7a2f3c3c0 100644 --- a/source/modules/juce_core/containers/juce_Variant.cpp +++ b/source/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/source/modules/juce_core/containers/juce_Variant.h b/source/modules/juce_core/containers/juce_Variant.h index d227a6a04..3a9cb7d24 100644 --- a/source/modules/juce_core/containers/juce_Variant.h +++ b/source/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/source/modules/juce_core/files/juce_DirectoryIterator.cpp b/source/modules/juce_core/files/juce_DirectoryIterator.cpp index c32ae7b51..a0f8aaa38 100644 --- a/source/modules/juce_core/files/juce_DirectoryIterator.cpp +++ b/source/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/source/modules/juce_core/files/juce_DirectoryIterator.h b/source/modules/juce_core/files/juce_DirectoryIterator.h index 83e579bcd..a9b576f24 100644 --- a/source/modules/juce_core/files/juce_DirectoryIterator.h +++ b/source/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/source/modules/juce_core/files/juce_File.cpp b/source/modules/juce_core/files/juce_File.cpp index c5bd5b8be..ef96be662 100644 --- a/source/modules/juce_core/files/juce_File.cpp +++ b/source/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/source/modules/juce_core/files/juce_File.h b/source/modules/juce_core/files/juce_File.h index de3a7d9e9..36b58f3f3 100644 --- a/source/modules/juce_core/files/juce_File.h +++ b/source/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/source/modules/juce_core/files/juce_FileFilter.cpp b/source/modules/juce_core/files/juce_FileFilter.cpp index 3fe61708a..2d0cb624a 100644 --- a/source/modules/juce_core/files/juce_FileFilter.cpp +++ b/source/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/source/modules/juce_core/files/juce_FileFilter.h b/source/modules/juce_core/files/juce_FileFilter.h index d40da458c..e1e241c7f 100644 --- a/source/modules/juce_core/files/juce_FileFilter.h +++ b/source/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/source/modules/juce_core/files/juce_FileInputStream.cpp b/source/modules/juce_core/files/juce_FileInputStream.cpp index f136cf090..638abf983 100644 --- a/source/modules/juce_core/files/juce_FileInputStream.cpp +++ b/source/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/source/modules/juce_core/files/juce_FileInputStream.h b/source/modules/juce_core/files/juce_FileInputStream.h index 8354b20d5..9fd84b025 100644 --- a/source/modules/juce_core/files/juce_FileInputStream.h +++ b/source/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/source/modules/juce_core/files/juce_FileOutputStream.cpp b/source/modules/juce_core/files/juce_FileOutputStream.cpp index 31d013b11..495104380 100644 --- a/source/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/source/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/source/modules/juce_core/files/juce_FileOutputStream.h b/source/modules/juce_core/files/juce_FileOutputStream.h index 75b14bc49..3e1100ce7 100644 --- a/source/modules/juce_core/files/juce_FileOutputStream.h +++ b/source/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/source/modules/juce_core/files/juce_FileSearchPath.cpp b/source/modules/juce_core/files/juce_FileSearchPath.cpp index 8219de13a..baa2539f6 100644 --- a/source/modules/juce_core/files/juce_FileSearchPath.cpp +++ b/source/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/source/modules/juce_core/files/juce_FileSearchPath.h b/source/modules/juce_core/files/juce_FileSearchPath.h index 94cde68c9..91011c093 100644 --- a/source/modules/juce_core/files/juce_FileSearchPath.h +++ b/source/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/source/modules/juce_core/files/juce_MemoryMappedFile.h b/source/modules/juce_core/files/juce_MemoryMappedFile.h index cd8a4b3ca..1afc08312 100644 --- a/source/modules/juce_core/files/juce_MemoryMappedFile.h +++ b/source/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/source/modules/juce_core/files/juce_TemporaryFile.cpp b/source/modules/juce_core/files/juce_TemporaryFile.cpp index a3c17ef63..701067792 100644 --- a/source/modules/juce_core/files/juce_TemporaryFile.cpp +++ b/source/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/source/modules/juce_core/files/juce_TemporaryFile.h b/source/modules/juce_core/files/juce_TemporaryFile.h index 8663f0cde..a781a101b 100644 --- a/source/modules/juce_core/files/juce_TemporaryFile.h +++ b/source/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/source/modules/juce_core/files/juce_WildcardFileFilter.cpp b/source/modules/juce_core/files/juce_WildcardFileFilter.cpp index 82ffe9645..8db43f34e 100644 --- a/source/modules/juce_core/files/juce_WildcardFileFilter.cpp +++ b/source/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/source/modules/juce_core/files/juce_WildcardFileFilter.h b/source/modules/juce_core/files/juce_WildcardFileFilter.h index 5492bdaaa..b49c49898 100644 --- a/source/modules/juce_core/files/juce_WildcardFileFilter.h +++ b/source/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/source/modules/juce_core/javascript/juce_JSON.cpp b/source/modules/juce_core/javascript/juce_JSON.cpp index 749d1067c..494da5a83 100644 --- a/source/modules/juce_core/javascript/juce_JSON.cpp +++ b/source/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/source/modules/juce_core/javascript/juce_JSON.h b/source/modules/juce_core/javascript/juce_JSON.h index 1cbe1a1d6..c185442be 100644 --- a/source/modules/juce_core/javascript/juce_JSON.h +++ b/source/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/source/modules/juce_core/javascript/juce_Javascript.cpp b/source/modules/juce_core/javascript/juce_Javascript.cpp index 72b059de2..9ef830516 100644 --- a/source/modules/juce_core/javascript/juce_Javascript.cpp +++ b/source/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/source/modules/juce_core/javascript/juce_Javascript.h b/source/modules/juce_core/javascript/juce_Javascript.h index 93a55a405..1a95998a5 100644 --- a/source/modules/juce_core/javascript/juce_Javascript.h +++ b/source/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/source/modules/juce_core/juce_core.cpp b/source/modules/juce_core/juce_core.cpp index a2d6a972a..136dd284e 100644 --- a/source/modules/juce_core/juce_core.cpp +++ b/source/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,7 +61,8 @@ #if JUCE_MINGW #include - _locale_t _create_locale(int, const char*) { _locale_t loc; juce::zeromem(&loc, sizeof(loc)); return loc; } + #include + #include #endif #else @@ -115,9 +117,6 @@ #endif //============================================================================== -namespace juce -{ - #include "containers/juce_AbstractFifo.cpp" #include "containers/juce_NamedValueSet.cpp" #include "containers/juce_ListenerList.cpp" @@ -180,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" @@ -239,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 @@ -254,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/source/modules/juce_core/juce_core.h b/source/modules/juce_core/juce_core.h index c6aead166..f34071080 100644 --- a/source/modules/juce_core/juce_core.h +++ b/source/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/source/modules/juce_core/logging/juce_FileLogger.cpp b/source/modules/juce_core/logging/juce_FileLogger.cpp index 9a92d383a..7ec9dba6d 100644 --- a/source/modules/juce_core/logging/juce_FileLogger.cpp +++ b/source/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/source/modules/juce_core/logging/juce_FileLogger.h b/source/modules/juce_core/logging/juce_FileLogger.h index c9846f81d..ac29683ca 100644 --- a/source/modules/juce_core/logging/juce_FileLogger.h +++ b/source/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/source/modules/juce_core/logging/juce_Logger.cpp b/source/modules/juce_core/logging/juce_Logger.cpp index b69d69dc6..3cb0d8963 100644 --- a/source/modules/juce_core/logging/juce_Logger.cpp +++ b/source/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/source/modules/juce_core/logging/juce_Logger.h b/source/modules/juce_core/logging/juce_Logger.h index 45b5949b8..bb38c565b 100644 --- a/source/modules/juce_core/logging/juce_Logger.h +++ b/source/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/source/modules/juce_core/maths/juce_BigInteger.cpp b/source/modules/juce_core/maths/juce_BigInteger.cpp index 14a935439..78634ed2f 100644 --- a/source/modules/juce_core/maths/juce_BigInteger.cpp +++ b/source/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/source/modules/juce_core/maths/juce_BigInteger.h b/source/modules/juce_core/maths/juce_BigInteger.h index 01a0965e3..54726e7fe 100644 --- a/source/modules/juce_core/maths/juce_BigInteger.h +++ b/source/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/source/modules/juce_core/maths/juce_Expression.cpp b/source/modules/juce_core/maths/juce_Expression.cpp index 639d85a1d..afab1ae9d 100644 --- a/source/modules/juce_core/maths/juce_Expression.cpp +++ b/source/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/source/modules/juce_core/maths/juce_Expression.h b/source/modules/juce_core/maths/juce_Expression.h index 189a4f03d..a3a4af7a4 100644 --- a/source/modules/juce_core/maths/juce_Expression.h +++ b/source/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/source/modules/juce_core/maths/juce_MathsFunctions.h b/source/modules/juce_core/maths/juce_MathsFunctions.h index 7361ea71f..7e6b348f8 100644 --- a/source/modules/juce_core/maths/juce_MathsFunctions.h +++ b/source/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/source/modules/juce_core/maths/juce_NormalisableRange.h b/source/modules/juce_core/maths/juce_NormalisableRange.h index 3f3794e15..cf5b3e7a1 100644 --- a/source/modules/juce_core/maths/juce_NormalisableRange.h +++ b/source/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/source/modules/juce_core/maths/juce_Random.cpp b/source/modules/juce_core/maths/juce_Random.cpp index 9fa81369e..219e1b40c 100644 --- a/source/modules/juce_core/maths/juce_Random.cpp +++ b/source/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/source/modules/juce_core/maths/juce_Random.h b/source/modules/juce_core/maths/juce_Random.h index fa97413f3..f3d7d490c 100644 --- a/source/modules/juce_core/maths/juce_Random.h +++ b/source/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/source/modules/juce_core/maths/juce_Range.h b/source/modules/juce_core/maths/juce_Range.h index bdb388530..bbdfa765f 100644 --- a/source/modules/juce_core/maths/juce_Range.h +++ b/source/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/source/modules/juce_core/maths/juce_StatisticsAccumulator.h b/source/modules/juce_core/maths/juce_StatisticsAccumulator.h index 31be08e4d..4d1b61f4b 100644 --- a/source/modules/juce_core/maths/juce_StatisticsAccumulator.h +++ b/source/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/source/modules/juce_core/memory/juce_Atomic.h b/source/modules/juce_core/memory/juce_Atomic.h index 65408b4c0..585b13550 100644 --- a/source/modules/juce_core/memory/juce_Atomic.h +++ b/source/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/source/modules/juce_core/memory/juce_ByteOrder.h b/source/modules/juce_core/memory/juce_ByteOrder.h index 49c79c181..f2e53d5cb 100644 --- a/source/modules/juce_core/memory/juce_ByteOrder.h +++ b/source/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/source/modules/juce_core/memory/juce_ContainerDeletePolicy.h b/source/modules/juce_core/memory/juce_ContainerDeletePolicy.h index 156feafa5..26d149738 100644 --- a/source/modules/juce_core/memory/juce_ContainerDeletePolicy.h +++ b/source/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/source/modules/juce_core/memory/juce_HeapBlock.h b/source/modules/juce_core/memory/juce_HeapBlock.h index 5bb5aa965..a469d5890 100644 --- a/source/modules/juce_core/memory/juce_HeapBlock.h +++ b/source/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/source/modules/juce_core/memory/juce_LeakedObjectDetector.h b/source/modules/juce_core/memory/juce_LeakedObjectDetector.h index 293ab18da..d48be309e 100644 --- a/source/modules/juce_core/memory/juce_LeakedObjectDetector.h +++ b/source/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/source/modules/juce_core/memory/juce_Memory.h b/source/modules/juce_core/memory/juce_Memory.h index ab9d83308..83b81117a 100644 --- a/source/modules/juce_core/memory/juce_Memory.h +++ b/source/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/source/modules/juce_core/memory/juce_MemoryBlock.cpp b/source/modules/juce_core/memory/juce_MemoryBlock.cpp index 85d3e20d9..8bf8b7667 100644 --- a/source/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/source/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/source/modules/juce_core/memory/juce_MemoryBlock.h b/source/modules/juce_core/memory/juce_MemoryBlock.h index ad70739a1..888449a4b 100644 --- a/source/modules/juce_core/memory/juce_MemoryBlock.h +++ b/source/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/source/modules/juce_core/memory/juce_OptionalScopedPointer.h b/source/modules/juce_core/memory/juce_OptionalScopedPointer.h index 6d6ad66c3..898c95ca5 100644 --- a/source/modules/juce_core/memory/juce_OptionalScopedPointer.h +++ b/source/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/source/modules/juce_core/memory/juce_ReferenceCountedObject.h b/source/modules/juce_core/memory/juce_ReferenceCountedObject.h index ba4b893c6..052e136dc 100644 --- a/source/modules/juce_core/memory/juce_ReferenceCountedObject.h +++ b/source/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/source/modules/juce_core/memory/juce_ScopedPointer.h b/source/modules/juce_core/memory/juce_ScopedPointer.h index d0c5cee70..8c7499ec8 100644 --- a/source/modules/juce_core/memory/juce_ScopedPointer.h +++ b/source/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/source/modules/juce_core/memory/juce_SharedResourcePointer.h b/source/modules/juce_core/memory/juce_SharedResourcePointer.h index 181f93fc6..89de47a64 100644 --- a/source/modules/juce_core/memory/juce_SharedResourcePointer.h +++ b/source/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/source/modules/juce_core/memory/juce_Singleton.h b/source/modules/juce_core/memory/juce_Singleton.h index 9bcaa34eb..e9567e461 100644 --- a/source/modules/juce_core/memory/juce_Singleton.h +++ b/source/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/source/modules/juce_core/memory/juce_WeakReference.h b/source/modules/juce_core/memory/juce_WeakReference.h index 1751cecc7..c743fc6c9 100644 --- a/source/modules/juce_core/memory/juce_WeakReference.h +++ b/source/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/source/modules/juce_core/misc/juce_Result.cpp b/source/modules/juce_core/misc/juce_Result.cpp index 678af8747..f94e0f268 100644 --- a/source/modules/juce_core/misc/juce_Result.cpp +++ b/source/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/source/modules/juce_core/misc/juce_Result.h b/source/modules/juce_core/misc/juce_Result.h index 0eda20c38..5f08bfc4d 100644 --- a/source/modules/juce_core/misc/juce_Result.h +++ b/source/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/source/modules/juce_core/misc/juce_RuntimePermissions.cpp b/source/modules/juce_core/misc/juce_RuntimePermissions.cpp index e15a07193..bf7306b55 100644 --- a/source/modules/juce_core/misc/juce_RuntimePermissions.cpp +++ b/source/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/source/modules/juce_core/misc/juce_RuntimePermissions.h b/source/modules/juce_core/misc/juce_RuntimePermissions.h index bb170eea3..4de84c678 100644 --- a/source/modules/juce_core/misc/juce_RuntimePermissions.h +++ b/source/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/source/modules/juce_core/misc/juce_StdFunctionCompat.cpp b/source/modules/juce_core/misc/juce_StdFunctionCompat.cpp index cf548ef60..93bcf5c60 100644 --- a/source/modules/juce_core/misc/juce_StdFunctionCompat.cpp +++ b/source/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/source/modules/juce_core/misc/juce_StdFunctionCompat.h b/source/modules/juce_core/misc/juce_StdFunctionCompat.h index f1b262b76..3d5381a46 100644 --- a/source/modules/juce_core/misc/juce_StdFunctionCompat.h +++ b/source/modules/juce_core/misc/juce_StdFunctionCompat.h @@ -28,8 +28,6 @@ ============================================================================== */ -#pragma once - namespace std { /** diff --git a/source/modules/juce_core/misc/juce_Uuid.cpp b/source/modules/juce_core/misc/juce_Uuid.cpp index 03f911cbf..807031d02 100644 --- a/source/modules/juce_core/misc/juce_Uuid.cpp +++ b/source/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/source/modules/juce_core/misc/juce_Uuid.h b/source/modules/juce_core/misc/juce_Uuid.h index cab55d8dc..5eee6d67c 100644 --- a/source/modules/juce_core/misc/juce_Uuid.h +++ b/source/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/source/modules/juce_core/misc/juce_WindowsRegistry.h b/source/modules/juce_core/misc/juce_WindowsRegistry.h index 239849cc7..1c49ac32a 100644 --- a/source/modules/juce_core/misc/juce_WindowsRegistry.h +++ b/source/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/source/modules/juce_core/native/java/JuceAppActivity.java b/source/modules/juce_core/native/java/JuceAppActivity.java index 53c3ff064..16b3eeabc 100644 --- a/source/modules/juce_core/native/java/JuceAppActivity.java +++ b/source/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/source/modules/juce_core/native/juce_android_Files.cpp b/source/modules/juce_core/native/juce_android_Files.cpp index 2b8f7ea99..5c0de2090 100644 --- a/source/modules/juce_core/native/juce_android_Files.cpp +++ b/source/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/source/modules/juce_core/native/juce_android_JNIHelpers.h b/source/modules/juce_core/native/juce_android_JNIHelpers.h index a0e17e347..ceb8dc394 100644 --- a/source/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/source/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/source/modules/juce_core/native/juce_android_Misc.cpp b/source/modules/juce_core/native/juce_android_Misc.cpp index 4a0f8189f..8ad39bed5 100644 --- a/source/modules/juce_core/native/juce_android_Misc.cpp +++ b/source/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/source/modules/juce_core/native/juce_android_Network.cpp b/source/modules/juce_core/native/juce_android_Network.cpp index 55e33f8b2..136ce47de 100644 --- a/source/modules/juce_core/native/juce_android_Network.cpp +++ b/source/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/source/modules/juce_core/native/juce_android_RuntimePermissions.cpp b/source/modules/juce_core/native/juce_android_RuntimePermissions.cpp index 155cffc74..6158271d6 100644 --- a/source/modules/juce_core/native/juce_android_RuntimePermissions.cpp +++ b/source/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/source/modules/juce_core/native/juce_android_SystemStats.cpp b/source/modules/juce_core/native/juce_android_SystemStats.cpp index 762ce02f4..00d0c44c6 100644 --- a/source/modules/juce_core/native/juce_android_SystemStats.cpp +++ b/source/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/source/modules/juce_core/native/juce_android_Threads.cpp b/source/modules/juce_core/native/juce_android_Threads.cpp index 7a526e450..be8780d23 100644 --- a/source/modules/juce_core/native/juce_android_Threads.cpp +++ b/source/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/source/modules/juce_core/native/juce_curl_Network.cpp b/source/modules/juce_core/native/juce_curl_Network.cpp index 9c14f6984..8781712c1 100644 --- a/source/modules/juce_core/native/juce_curl_Network.cpp +++ b/source/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/source/modules/juce_core/native/juce_linux_CommonFile.cpp b/source/modules/juce_core/native/juce_linux_CommonFile.cpp index 1166bd7b7..c22f64f77 100644 --- a/source/modules/juce_core/native/juce_linux_CommonFile.cpp +++ b/source/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/source/modules/juce_core/native/juce_linux_Files.cpp b/source/modules/juce_core/native/juce_linux_Files.cpp index 3b239df28..d022175a6 100644 --- a/source/modules/juce_core/native/juce_linux_Files.cpp +++ b/source/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/source/modules/juce_core/native/juce_linux_Network.cpp b/source/modules/juce_core/native/juce_linux_Network.cpp index c2965a323..2ca8d5120 100644 --- a/source/modules/juce_core/native/juce_linux_Network.cpp +++ b/source/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/source/modules/juce_core/native/juce_linux_SystemStats.cpp b/source/modules/juce_core/native/juce_linux_SystemStats.cpp index 4b8f4bdfb..40f19187f 100644 --- a/source/modules/juce_core/native/juce_linux_SystemStats.cpp +++ b/source/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/source/modules/juce_core/native/juce_linux_Threads.cpp b/source/modules/juce_core/native/juce_linux_Threads.cpp index d293a76e0..144fa05d9 100644 --- a/source/modules/juce_core/native/juce_linux_Threads.cpp +++ b/source/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/source/modules/juce_core/native/juce_mac_Files.mm b/source/modules/juce_core/native/juce_mac_Files.mm index 18bf390d9..958238aa5 100644 --- a/source/modules/juce_core/native/juce_mac_Files.mm +++ b/source/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/source/modules/juce_core/native/juce_mac_Network.mm b/source/modules/juce_core/native/juce_mac_Network.mm index 6410a8b22..f182a42b5 100644 --- a/source/modules/juce_core/native/juce_mac_Network.mm +++ b/source/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/source/modules/juce_core/native/juce_mac_Strings.mm b/source/modules/juce_core/native/juce_mac_Strings.mm index 62f9d8717..b8a479ead 100644 --- a/source/modules/juce_core/native/juce_mac_Strings.mm +++ b/source/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/source/modules/juce_core/native/juce_mac_SystemStats.mm b/source/modules/juce_core/native/juce_mac_SystemStats.mm index db81b1991..81f62192e 100644 --- a/source/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/source/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/source/modules/juce_core/native/juce_mac_Threads.mm b/source/modules/juce_core/native/juce_mac_Threads.mm index a02403e17..8ac6c0ed5 100644 --- a/source/modules/juce_core/native/juce_mac_Threads.mm +++ b/source/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/source/modules/juce_core/native/juce_osx_ObjCHelpers.h b/source/modules/juce_core/native/juce_osx_ObjCHelpers.h index 760803edf..b335287cb 100644 --- a/source/modules/juce_core/native/juce_osx_ObjCHelpers.h +++ b/source/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/source/modules/juce_core/native/juce_posix_NamedPipe.cpp b/source/modules/juce_core/native/juce_posix_NamedPipe.cpp index 80bfa2e70..be948ffd4 100644 --- a/source/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/source/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/source/modules/juce_core/native/juce_posix_SharedCode.h b/source/modules/juce_core/native/juce_posix_SharedCode.h index ed43cb392..67c884ab1 100644 --- a/source/modules/juce_core/native/juce_posix_SharedCode.h +++ b/source/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/source/modules/juce_core/native/juce_win32_ComSmartPtr.h b/source/modules/juce_core/native/juce_win32_ComSmartPtr.h index 09bfd5b7b..0a6511c4c 100644 --- a/source/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/source/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/source/modules/juce_core/native/juce_win32_Files.cpp b/source/modules/juce_core/native/juce_win32_Files.cpp index 17c2e34cf..6534ba6a6 100644 --- a/source/modules/juce_core/native/juce_win32_Files.cpp +++ b/source/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.getData()); + 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/source/modules/juce_core/native/juce_win32_Network.cpp b/source/modules/juce_core/native/juce_win32_Network.cpp index 42f17d9db..bdc7dc9c4 100644 --- a/source/modules/juce_core/native/juce_win32_Network.cpp +++ b/source/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/source/modules/juce_core/native/juce_win32_Registry.cpp b/source/modules/juce_core/native/juce_win32_Registry.cpp index 91b2c1257..e1b5f5b81 100644 --- a/source/modules/juce_core/native/juce_win32_Registry.cpp +++ b/source/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/source/modules/juce_core/native/juce_win32_SystemStats.cpp b/source/modules/juce_core/native/juce_win32_SystemStats.cpp index b2ff9e945..e2b440935 100644 --- a/source/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/source/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/source/modules/juce_core/native/juce_win32_Threads.cpp b/source/modules/juce_core/native/juce_win32_Threads.cpp index d38b733b8..172e7019e 100644 --- a/source/modules/juce_core/native/juce_win32_Threads.cpp +++ b/source/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/source/modules/juce_core/network/juce_IPAddress.cpp b/source/modules/juce_core/network/juce_IPAddress.cpp index 92c68bab6..2b38499fa 100644 --- a/source/modules/juce_core/network/juce_IPAddress.cpp +++ b/source/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/source/modules/juce_core/network/juce_IPAddress.h b/source/modules/juce_core/network/juce_IPAddress.h index a450ff7d1..ac29e0c41 100644 --- a/source/modules/juce_core/network/juce_IPAddress.h +++ b/source/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/source/modules/juce_core/network/juce_MACAddress.cpp b/source/modules/juce_core/network/juce_MACAddress.cpp index 62b0e24ea..a2c7e1fb5 100644 --- a/source/modules/juce_core/network/juce_MACAddress.cpp +++ b/source/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/source/modules/juce_core/network/juce_MACAddress.h b/source/modules/juce_core/network/juce_MACAddress.h index 7a709b01c..45a5a1a04 100644 --- a/source/modules/juce_core/network/juce_MACAddress.h +++ b/source/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/source/modules/juce_core/network/juce_NamedPipe.cpp b/source/modules/juce_core/network/juce_NamedPipe.cpp index 434fdb606..8d493488f 100644 --- a/source/modules/juce_core/network/juce_NamedPipe.cpp +++ b/source/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/source/modules/juce_core/network/juce_NamedPipe.h b/source/modules/juce_core/network/juce_NamedPipe.h index af09f4900..8ae048208 100644 --- a/source/modules/juce_core/network/juce_NamedPipe.h +++ b/source/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/source/modules/juce_core/network/juce_Socket.cpp b/source/modules/juce_core/network/juce_Socket.cpp index 19723b69b..f850bad50 100644 --- a/source/modules/juce_core/network/juce_Socket.cpp +++ b/source/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/source/modules/juce_core/network/juce_Socket.h b/source/modules/juce_core/network/juce_Socket.h index 66d259fdb..6a6b7b598 100644 --- a/source/modules/juce_core/network/juce_Socket.h +++ b/source/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/source/modules/juce_core/network/juce_URL.cpp b/source/modules/juce_core/network/juce_URL.cpp index 60c791a3a..402aa6298 100644 --- a/source/modules/juce_core/network/juce_URL.cpp +++ b/source/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/source/modules/juce_core/network/juce_URL.h b/source/modules/juce_core/network/juce_URL.h index b2a3f592c..fa2169ddf 100644 --- a/source/modules/juce_core/network/juce_URL.h +++ b/source/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/source/modules/juce_core/network/juce_WebInputStream.cpp b/source/modules/juce_core/network/juce_WebInputStream.cpp index 4a7aafc1f..c82b396a8 100644 --- a/source/modules/juce_core/network/juce_WebInputStream.cpp +++ b/source/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/source/modules/juce_core/network/juce_WebInputStream.h b/source/modules/juce_core/network/juce_WebInputStream.h index 5d013ea4a..fe6da1cfb 100644 --- a/source/modules/juce_core/network/juce_WebInputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_BufferedInputStream.cpp b/source/modules/juce_core/streams/juce_BufferedInputStream.cpp index b17c52691..8af122a69 100644 --- a/source/modules/juce_core/streams/juce_BufferedInputStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_BufferedInputStream.h b/source/modules/juce_core/streams/juce_BufferedInputStream.h index 5a5105385..8719b66c5 100644 --- a/source/modules/juce_core/streams/juce_BufferedInputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_FileInputSource.cpp b/source/modules/juce_core/streams/juce_FileInputSource.cpp index ab777793e..feb4081a8 100644 --- a/source/modules/juce_core/streams/juce_FileInputSource.cpp +++ b/source/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/source/modules/juce_core/streams/juce_FileInputSource.h b/source/modules/juce_core/streams/juce_FileInputSource.h index 00f8bee36..d5f594213 100644 --- a/source/modules/juce_core/streams/juce_FileInputSource.h +++ b/source/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/source/modules/juce_core/streams/juce_InputSource.h b/source/modules/juce_core/streams/juce_InputSource.h index 14f3d96b4..925cdf30f 100644 --- a/source/modules/juce_core/streams/juce_InputSource.h +++ b/source/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/source/modules/juce_core/streams/juce_InputStream.cpp b/source/modules/juce_core/streams/juce_InputStream.cpp index eb6bc57a7..a27f5cfc1 100644 --- a/source/modules/juce_core/streams/juce_InputStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_InputStream.h b/source/modules/juce_core/streams/juce_InputStream.h index 3db0e9d71..398615ad8 100644 --- a/source/modules/juce_core/streams/juce_InputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_MemoryInputStream.cpp b/source/modules/juce_core/streams/juce_MemoryInputStream.cpp index 3dfb1237c..041b24ec8 100644 --- a/source/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_MemoryInputStream.h b/source/modules/juce_core/streams/juce_MemoryInputStream.h index 3bfa985ac..86373ca65 100644 --- a/source/modules/juce_core/streams/juce_MemoryInputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 57226cb2a..1b27e05de 100644 --- a/source/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_MemoryOutputStream.h b/source/modules/juce_core/streams/juce_MemoryOutputStream.h index 794d78f86..6f89c940c 100644 --- a/source/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_OutputStream.cpp b/source/modules/juce_core/streams/juce_OutputStream.cpp index a87e5b2fc..499f532cf 100644 --- a/source/modules/juce_core/streams/juce_OutputStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_OutputStream.h b/source/modules/juce_core/streams/juce_OutputStream.h index 2b53107aa..1ab0a0ce7 100644 --- a/source/modules/juce_core/streams/juce_OutputStream.h +++ b/source/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/source/modules/juce_core/streams/juce_SubregionStream.cpp b/source/modules/juce_core/streams/juce_SubregionStream.cpp index 5e74c2894..c7b67900c 100644 --- a/source/modules/juce_core/streams/juce_SubregionStream.cpp +++ b/source/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/source/modules/juce_core/streams/juce_SubregionStream.h b/source/modules/juce_core/streams/juce_SubregionStream.h index 624d6b8a7..998a2ccdb 100644 --- a/source/modules/juce_core/streams/juce_SubregionStream.h +++ b/source/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/source/modules/juce_core/system/juce_CompilerSupport.h b/source/modules/juce_core/system/juce_CompilerSupport.h index e29eeff37..700c67f53 100644 --- a/source/modules/juce_core/system/juce_CompilerSupport.h +++ b/source/modules/juce_core/system/juce_CompilerSupport.h @@ -47,7 +47,7 @@ #define JUCE_COMPILER_SUPPORTS_THREAD_LOCAL 1 #endif - #if __cpp_constexpr >= 201304 + #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 #define JUCE_HAS_CONSTEXPR 1 #endif diff --git a/source/modules/juce_core/system/juce_PlatformDefs.h b/source/modules/juce_core/system/juce_PlatformDefs.h index d29b49237..32b932359 100644 --- a/source/modules/juce_core/system/juce_PlatformDefs.h +++ b/source/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/source/modules/juce_core/system/juce_StandardHeader.h b/source/modules/juce_core/system/juce_StandardHeader.h index c658514eb..896d5b4da 100644 --- a/source/modules/juce_core/system/juce_StandardHeader.h +++ b/source/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/source/modules/juce_core/system/juce_SystemStats.cpp b/source/modules/juce_core/system/juce_SystemStats.cpp index 7e0527742..c073331b9 100644 --- a/source/modules/juce_core/system/juce_SystemStats.cpp +++ b/source/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/source/modules/juce_core/system/juce_SystemStats.h b/source/modules/juce_core/system/juce_SystemStats.h index 4bf4e0e13..89d3854e3 100644 --- a/source/modules/juce_core/system/juce_SystemStats.h +++ b/source/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/source/modules/juce_core/text/juce_Base64.cpp b/source/modules/juce_core/text/juce_Base64.cpp index bda7c3b66..14bcdeb79 100644 --- a/source/modules/juce_core/text/juce_Base64.cpp +++ b/source/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/source/modules/juce_core/text/juce_Base64.h b/source/modules/juce_core/text/juce_Base64.h index 169c0e2eb..c7eafa221 100644 --- a/source/modules/juce_core/text/juce_Base64.h +++ b/source/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/source/modules/juce_core/text/juce_CharPointer_ASCII.h b/source/modules/juce_core/text/juce_CharPointer_ASCII.h index 0c9ed44ac..2e6b2b808 100644 --- a/source/modules/juce_core/text/juce_CharPointer_ASCII.h +++ b/source/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/source/modules/juce_core/text/juce_CharPointer_UTF16.h b/source/modules/juce_core/text/juce_CharPointer_UTF16.h index 7d45f9520..2176482de 100644 --- a/source/modules/juce_core/text/juce_CharPointer_UTF16.h +++ b/source/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/source/modules/juce_core/text/juce_CharPointer_UTF32.h b/source/modules/juce_core/text/juce_CharPointer_UTF32.h index 5367fbec8..41a9a7c25 100644 --- a/source/modules/juce_core/text/juce_CharPointer_UTF32.h +++ b/source/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/source/modules/juce_core/text/juce_CharPointer_UTF8.h b/source/modules/juce_core/text/juce_CharPointer_UTF8.h index 639b5c2d1..7b5a91df9 100644 --- a/source/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/source/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/source/modules/juce_core/text/juce_CharacterFunctions.cpp b/source/modules/juce_core/text/juce_CharacterFunctions.cpp index cd81957d9..9c10e8c38 100644 --- a/source/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/source/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/source/modules/juce_core/text/juce_CharacterFunctions.h b/source/modules/juce_core/text/juce_CharacterFunctions.h index 00d02d013..d9cec4bac 100644 --- a/source/modules/juce_core/text/juce_CharacterFunctions.h +++ b/source/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_WINDOWS - 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/source/modules/juce_core/text/juce_Identifier.cpp b/source/modules/juce_core/text/juce_Identifier.cpp index 513b921e5..3ca2b45ff 100644 --- a/source/modules/juce_core/text/juce_Identifier.cpp +++ b/source/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/source/modules/juce_core/text/juce_Identifier.h b/source/modules/juce_core/text/juce_Identifier.h index 1d960e586..4c6d9bcd2 100644 --- a/source/modules/juce_core/text/juce_Identifier.h +++ b/source/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/source/modules/juce_core/text/juce_LocalisedStrings.cpp b/source/modules/juce_core/text/juce_LocalisedStrings.cpp index 58533de91..c5d091f64 100644 --- a/source/modules/juce_core/text/juce_LocalisedStrings.cpp +++ b/source/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/source/modules/juce_core/text/juce_LocalisedStrings.h b/source/modules/juce_core/text/juce_LocalisedStrings.h index 71b6423fd..0cee6b3ad 100644 --- a/source/modules/juce_core/text/juce_LocalisedStrings.h +++ b/source/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/source/modules/juce_core/text/juce_NewLine.h b/source/modules/juce_core/text/juce_NewLine.h index 885618a7a..164f4b1c3 100644 --- a/source/modules/juce_core/text/juce_NewLine.h +++ b/source/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/source/modules/juce_core/text/juce_String.cpp b/source/modules/juce_core/text/juce_String.cpp index f1598f983..3fb472299 100644 --- a/source/modules/juce_core/text/juce_String.cpp +++ b/source/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/source/modules/juce_core/text/juce_String.h b/source/modules/juce_core/text/juce_String.h index 885256b32..4ba4156d4 100644 --- a/source/modules/juce_core/text/juce_String.h +++ b/source/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/source/modules/juce_core/text/juce_StringArray.cpp b/source/modules/juce_core/text/juce_StringArray.cpp index 2ce830f71..a22b31c7b 100644 --- a/source/modules/juce_core/text/juce_StringArray.cpp +++ b/source/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/source/modules/juce_core/text/juce_StringArray.h b/source/modules/juce_core/text/juce_StringArray.h index a49c65f6b..49d866275 100644 --- a/source/modules/juce_core/text/juce_StringArray.h +++ b/source/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/source/modules/juce_core/text/juce_StringPairArray.cpp b/source/modules/juce_core/text/juce_StringPairArray.cpp index 5ae706fbc..202fd44f8 100644 --- a/source/modules/juce_core/text/juce_StringPairArray.cpp +++ b/source/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/source/modules/juce_core/text/juce_StringPairArray.h b/source/modules/juce_core/text/juce_StringPairArray.h index 7d9f3afef..8bf8b6154 100644 --- a/source/modules/juce_core/text/juce_StringPairArray.h +++ b/source/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/source/modules/juce_core/text/juce_StringPool.cpp b/source/modules/juce_core/text/juce_StringPool.cpp index 65bde3535..a9a112103 100644 --- a/source/modules/juce_core/text/juce_StringPool.cpp +++ b/source/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/source/modules/juce_core/text/juce_StringPool.h b/source/modules/juce_core/text/juce_StringPool.h index 26240ca03..0f81bbbca 100644 --- a/source/modules/juce_core/text/juce_StringPool.h +++ b/source/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/source/modules/juce_core/text/juce_StringRef.h b/source/modules/juce_core/text/juce_StringRef.h index 77919b63b..308474d10 100644 --- a/source/modules/juce_core/text/juce_StringRef.h +++ b/source/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/source/modules/juce_core/text/juce_TextDiff.cpp b/source/modules/juce_core/text/juce_TextDiff.cpp index 35b13f7a4..f3e6b21da 100644 --- a/source/modules/juce_core/text/juce_TextDiff.cpp +++ b/source/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/source/modules/juce_core/text/juce_TextDiff.h b/source/modules/juce_core/text/juce_TextDiff.h index a0b9c29ba..05910ff0c 100644 --- a/source/modules/juce_core/text/juce_TextDiff.h +++ b/source/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/source/modules/juce_core/threads/juce_ChildProcess.cpp b/source/modules/juce_core/threads/juce_ChildProcess.cpp index 262882bb9..1afd058ef 100644 --- a/source/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/source/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/source/modules/juce_core/threads/juce_ChildProcess.h b/source/modules/juce_core/threads/juce_ChildProcess.h index cbc380dfe..ac4d94e44 100644 --- a/source/modules/juce_core/threads/juce_ChildProcess.h +++ b/source/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/source/modules/juce_core/threads/juce_CriticalSection.h b/source/modules/juce_core/threads/juce_CriticalSection.h index 60a240923..b382acdc7 100644 --- a/source/modules/juce_core/threads/juce_CriticalSection.h +++ b/source/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/source/modules/juce_core/threads/juce_DynamicLibrary.h b/source/modules/juce_core/threads/juce_DynamicLibrary.h index 0d0783999..a4a273769 100644 --- a/source/modules/juce_core/threads/juce_DynamicLibrary.h +++ b/source/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/source/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/source/modules/juce_core/threads/juce_HighResolutionTimer.cpp index 9e7550d7f..91f9eac78 100644 --- a/source/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/source/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/source/modules/juce_core/threads/juce_HighResolutionTimer.h b/source/modules/juce_core/threads/juce_HighResolutionTimer.h index d90f59737..4c846093c 100644 --- a/source/modules/juce_core/threads/juce_HighResolutionTimer.h +++ b/source/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/source/modules/juce_core/threads/juce_InterProcessLock.h b/source/modules/juce_core/threads/juce_InterProcessLock.h index effcf26e9..3bec0275d 100644 --- a/source/modules/juce_core/threads/juce_InterProcessLock.h +++ b/source/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/source/modules/juce_core/threads/juce_Process.h b/source/modules/juce_core/threads/juce_Process.h index 656f88acb..1804b8945 100644 --- a/source/modules/juce_core/threads/juce_Process.h +++ b/source/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/source/modules/juce_core/threads/juce_ReadWriteLock.cpp b/source/modules/juce_core/threads/juce_ReadWriteLock.cpp index 7a7efe439..27347d5f4 100644 --- a/source/modules/juce_core/threads/juce_ReadWriteLock.cpp +++ b/source/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/source/modules/juce_core/threads/juce_ReadWriteLock.h b/source/modules/juce_core/threads/juce_ReadWriteLock.h index cb5e4cddd..4d3f6e517 100644 --- a/source/modules/juce_core/threads/juce_ReadWriteLock.h +++ b/source/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/source/modules/juce_core/threads/juce_ScopedLock.h b/source/modules/juce_core/threads/juce_ScopedLock.h index c1b5795be..886f555e9 100644 --- a/source/modules/juce_core/threads/juce_ScopedLock.h +++ b/source/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/source/modules/juce_core/threads/juce_ScopedReadLock.h b/source/modules/juce_core/threads/juce_ScopedReadLock.h index c459c29d0..fa5fe1ab0 100644 --- a/source/modules/juce_core/threads/juce_ScopedReadLock.h +++ b/source/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/source/modules/juce_core/threads/juce_ScopedWriteLock.h b/source/modules/juce_core/threads/juce_ScopedWriteLock.h index 52539fb7b..7a9e8e53e 100644 --- a/source/modules/juce_core/threads/juce_ScopedWriteLock.h +++ b/source/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/source/modules/juce_core/threads/juce_SpinLock.h b/source/modules/juce_core/threads/juce_SpinLock.h index 5454006ad..f79a6e5af 100644 --- a/source/modules/juce_core/threads/juce_SpinLock.h +++ b/source/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/source/modules/juce_core/threads/juce_Thread.cpp b/source/modules/juce_core/threads/juce_Thread.cpp index fa2b26a12..8195ce7f4 100644 --- a/source/modules/juce_core/threads/juce_Thread.cpp +++ b/source/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/source/modules/juce_core/threads/juce_Thread.h b/source/modules/juce_core/threads/juce_Thread.h index e5d1a4923..e4baa969d 100644 --- a/source/modules/juce_core/threads/juce_Thread.h +++ b/source/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/source/modules/juce_core/threads/juce_ThreadLocalValue.h b/source/modules/juce_core/threads/juce_ThreadLocalValue.h index 2b6d4fe02..ca2630976 100644 --- a/source/modules/juce_core/threads/juce_ThreadLocalValue.h +++ b/source/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/source/modules/juce_core/threads/juce_ThreadPool.cpp b/source/modules/juce_core/threads/juce_ThreadPool.cpp index f12300155..4cee61dab 100644 --- a/source/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/source/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/source/modules/juce_core/threads/juce_ThreadPool.h b/source/modules/juce_core/threads/juce_ThreadPool.h index 6dda3ed93..9ead49c86 100644 --- a/source/modules/juce_core/threads/juce_ThreadPool.h +++ b/source/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/source/modules/juce_core/threads/juce_TimeSliceThread.cpp b/source/modules/juce_core/threads/juce_TimeSliceThread.cpp index 94ecca528..d5c4c227e 100644 --- a/source/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/source/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/source/modules/juce_core/threads/juce_TimeSliceThread.h b/source/modules/juce_core/threads/juce_TimeSliceThread.h index 7a3ad7791..53648b69c 100644 --- a/source/modules/juce_core/threads/juce_TimeSliceThread.h +++ b/source/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/source/modules/juce_core/threads/juce_WaitableEvent.h b/source/modules/juce_core/threads/juce_WaitableEvent.h index 55900a268..e13ec398d 100644 --- a/source/modules/juce_core/threads/juce_WaitableEvent.h +++ b/source/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/source/modules/juce_core/time/juce_PerformanceCounter.cpp b/source/modules/juce_core/time/juce_PerformanceCounter.cpp index 6c3c3bbdd..4650e16f1 100644 --- a/source/modules/juce_core/time/juce_PerformanceCounter.cpp +++ b/source/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/source/modules/juce_core/time/juce_PerformanceCounter.h b/source/modules/juce_core/time/juce_PerformanceCounter.h index 7108b0f87..506a49044 100644 --- a/source/modules/juce_core/time/juce_PerformanceCounter.h +++ b/source/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/source/modules/juce_core/time/juce_RelativeTime.cpp b/source/modules/juce_core/time/juce_RelativeTime.cpp index 013a1fc26..3dc2fd4da 100644 --- a/source/modules/juce_core/time/juce_RelativeTime.cpp +++ b/source/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/source/modules/juce_core/time/juce_RelativeTime.h b/source/modules/juce_core/time/juce_RelativeTime.h index 9700d9aa2..7ccbce2cd 100644 --- a/source/modules/juce_core/time/juce_RelativeTime.h +++ b/source/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/source/modules/juce_core/time/juce_Time.cpp b/source/modules/juce_core/time/juce_Time.cpp index 2e78b58ed..dfa54dfa7 100644 --- a/source/modules/juce_core/time/juce_Time.cpp +++ b/source/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/source/modules/juce_core/time/juce_Time.h b/source/modules/juce_core/time/juce_Time.h index c38321b5a..2ff37375b 100644 --- a/source/modules/juce_core/time/juce_Time.h +++ b/source/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/source/modules/juce_core/unit_tests/juce_UnitTest.cpp b/source/modules/juce_core/unit_tests/juce_UnitTest.cpp index 2ed41b981..9e9150ee6 100644 --- a/source/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/source/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/source/modules/juce_core/unit_tests/juce_UnitTest.h b/source/modules/juce_core/unit_tests/juce_UnitTest.h index 68c445981..9a9580b83 100644 --- a/source/modules/juce_core/unit_tests/juce_UnitTest.h +++ b/source/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/source/modules/juce_core/xml/juce_XmlDocument.cpp b/source/modules/juce_core/xml/juce_XmlDocument.cpp index e522a45a8..b3268dfc7 100644 --- a/source/modules/juce_core/xml/juce_XmlDocument.cpp +++ b/source/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/source/modules/juce_core/xml/juce_XmlDocument.h b/source/modules/juce_core/xml/juce_XmlDocument.h index 6d0bd6217..e09bd6358 100644 --- a/source/modules/juce_core/xml/juce_XmlDocument.h +++ b/source/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/source/modules/juce_core/xml/juce_XmlElement.cpp b/source/modules/juce_core/xml/juce_XmlElement.cpp index 04e81b6da..b04e30728 100644 --- a/source/modules/juce_core/xml/juce_XmlElement.cpp +++ b/source/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/source/modules/juce_core/xml/juce_XmlElement.h b/source/modules/juce_core/xml/juce_XmlElement.h index 5c1b90fe3..33f86744e 100644 --- a/source/modules/juce_core/xml/juce_XmlElement.h +++ b/source/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/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index d8c46bc00..df64f23d2 100644 --- a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/source/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/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h b/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h index ff14f9fcc..25a28101a 100644 --- a/source/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h +++ b/source/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/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 35e7a1504..0bae4d39d 100644 --- a/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/source/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/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h b/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h index be0e28731..a7edadc04 100644 --- a/source/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h +++ b/source/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/source/modules/juce_core/zip/juce_ZipFile.cpp b/source/modules/juce_core/zip/juce_ZipFile.cpp index 87e461f14..78badf816 100644 --- a/source/modules/juce_core/zip/juce_ZipFile.cpp +++ b/source/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/source/modules/juce_core/zip/juce_ZipFile.h b/source/modules/juce_core/zip/juce_ZipFile.h index ca8323057..4e1c75bf1 100644 --- a/source/modules/juce_core/zip/juce_ZipFile.h +++ b/source/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/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp b/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp index e120a1469..eca113fb4 100644 --- a/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.cpp +++ b/source/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/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h b/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h index b65e5854d..faa3817c4 100644 --- a/source/modules/juce_data_structures/app_properties/juce_ApplicationProperties.h +++ b/source/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/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp b/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp index 666710f86..d964fb9cd 100644 --- a/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp +++ b/source/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/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.h b/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.h index bc29a1365..2848c5bb2 100644 --- a/source/modules/juce_data_structures/app_properties/juce_PropertiesFile.h +++ b/source/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/source/modules/juce_data_structures/juce_data_structures.cpp b/source/modules/juce_data_structures/juce_data_structures.cpp index 7b3a3c497..5913ca47f 100644 --- a/source/modules/juce_data_structures/juce_data_structures.cpp +++ b/source/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/source/modules/juce_data_structures/juce_data_structures.h b/source/modules/juce_data_structures/juce_data_structures.h index 0692f4682..7856e1917 100644 --- a/source/modules/juce_data_structures/juce_data_structures.h +++ b/source/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/source/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/source/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index 5c0fb525f..a5a705a32 100644 --- a/source/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/source/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/source/modules/juce_data_structures/undomanager/juce_UndoManager.h b/source/modules/juce_data_structures/undomanager/juce_UndoManager.h index 1cca8518a..75f3d0f30 100644 --- a/source/modules/juce_data_structures/undomanager/juce_UndoManager.h +++ b/source/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/source/modules/juce_data_structures/undomanager/juce_UndoableAction.h b/source/modules/juce_data_structures/undomanager/juce_UndoableAction.h index b5447210e..9b418cd4f 100644 --- a/source/modules/juce_data_structures/undomanager/juce_UndoableAction.h +++ b/source/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/source/modules/juce_data_structures/values/juce_CachedValue.cpp b/source/modules/juce_data_structures/values/juce_CachedValue.cpp index b8ecbcc34..ace2c41de 100644 --- a/source/modules/juce_data_structures/values/juce_CachedValue.cpp +++ b/source/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/source/modules/juce_data_structures/values/juce_CachedValue.h b/source/modules/juce_data_structures/values/juce_CachedValue.h index f2725b6a8..7a807df30 100644 --- a/source/modules/juce_data_structures/values/juce_CachedValue.h +++ b/source/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/source/modules/juce_data_structures/values/juce_Value.cpp b/source/modules/juce_data_structures/values/juce_Value.cpp index 19e678871..b09530fed 100644 --- a/source/modules/juce_data_structures/values/juce_Value.cpp +++ b/source/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/source/modules/juce_data_structures/values/juce_Value.h b/source/modules/juce_data_structures/values/juce_Value.h index d470a9da7..e1216da45 100644 --- a/source/modules/juce_data_structures/values/juce_Value.h +++ b/source/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/source/modules/juce_data_structures/values/juce_ValueTree.cpp b/source/modules/juce_data_structures/values/juce_ValueTree.cpp index afe068d16..b1e596e35 100644 --- a/source/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/source/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/source/modules/juce_data_structures/values/juce_ValueTree.h b/source/modules/juce_data_structures/values/juce_ValueTree.h index 7c3e3eccf..d0a66f0cf 100644 --- a/source/modules/juce_data_structures/values/juce_ValueTree.h +++ b/source/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/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp b/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp index d29b692b4..7e49e712f 100644 --- a/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.cpp +++ b/source/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/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h b/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h index 0867a56e9..42c382360 100644 --- a/source/modules/juce_data_structures/values/juce_ValueTreeSynchroniser.h +++ b/source/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/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp b/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp index 76253f347..2b4613e82 100644 --- a/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.cpp +++ b/source/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/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.h b/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.h index 8a2d55901..3267d8613 100644 --- a/source/modules/juce_events/broadcasters/juce_ActionBroadcaster.h +++ b/source/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/source/modules/juce_events/broadcasters/juce_ActionListener.h b/source/modules/juce_events/broadcasters/juce_ActionListener.h index 0571eaf05..c16449f7d 100644 --- a/source/modules/juce_events/broadcasters/juce_ActionListener.h +++ b/source/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/source/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp b/source/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp index 15659057f..8d9a20e5a 100644 --- a/source/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp +++ b/source/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/source/modules/juce_events/broadcasters/juce_AsyncUpdater.h b/source/modules/juce_events/broadcasters/juce_AsyncUpdater.h index 3b61f2108..7a94a63d6 100644 --- a/source/modules/juce_events/broadcasters/juce_AsyncUpdater.h +++ b/source/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/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp b/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp index c7b4cbfae..a816c3d8f 100644 --- a/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.cpp +++ b/source/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/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h b/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h index 7750e1278..beef4e85a 100644 --- a/source/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h +++ b/source/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/source/modules/juce_events/broadcasters/juce_ChangeListener.h b/source/modules/juce_events/broadcasters/juce_ChangeListener.h index 37aabd0d6..aacaf223c 100644 --- a/source/modules/juce_events/broadcasters/juce_ChangeListener.h +++ b/source/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/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp b/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp index a0e69161b..9e7070e4d 100644 --- a/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.cpp +++ b/source/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/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.h b/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.h index d1eaadc29..8f6cc8cc1 100644 --- a/source/modules/juce_events/interprocess/juce_ConnectedChildProcess.h +++ b/source/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/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp b/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp index 353beeaac..6f98aed63 100644 --- a/source/modules/juce_events/interprocess/juce_InterprocessConnection.cpp +++ b/source/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/source/modules/juce_events/interprocess/juce_InterprocessConnection.h b/source/modules/juce_events/interprocess/juce_InterprocessConnection.h index 6f9048bc7..83cd910f3 100644 --- a/source/modules/juce_events/interprocess/juce_InterprocessConnection.h +++ b/source/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/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp b/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp index d972d9794..6c9022bd4 100644 --- a/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.cpp +++ b/source/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/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h b/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h index 8afd71ae3..552dd1c18 100644 --- a/source/modules/juce_events/interprocess/juce_InterprocessConnectionServer.h +++ b/source/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/source/modules/juce_events/juce_events.cpp b/source/modules/juce_events/juce_events.cpp index 50d8fdd69..bee0e3dff 100644 --- a/source/modules/juce_events/juce_events.cpp +++ b/source/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/source/modules/juce_events/juce_events.h b/source/modules/juce_events/juce_events.h index a09ece17d..d0340e1fd 100644 --- a/source/modules/juce_events/juce_events.h +++ b/source/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/source/modules/juce_events/messages/juce_ApplicationBase.cpp b/source/modules/juce_events/messages/juce_ApplicationBase.cpp index be929bee3..cbd549f8b 100644 --- a/source/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/source/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/source/modules/juce_events/messages/juce_ApplicationBase.h b/source/modules/juce_events/messages/juce_ApplicationBase.h index c9ffc5f0b..88950fd7c 100644 --- a/source/modules/juce_events/messages/juce_ApplicationBase.h +++ b/source/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/source/modules/juce_events/messages/juce_CallbackMessage.h b/source/modules/juce_events/messages/juce_CallbackMessage.h index 249b204c0..303c1b438 100644 --- a/source/modules/juce_events/messages/juce_CallbackMessage.h +++ b/source/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/source/modules/juce_events/messages/juce_DeletedAtShutdown.cpp b/source/modules/juce_events/messages/juce_DeletedAtShutdown.cpp index 897632a28..feede821f 100644 --- a/source/modules/juce_events/messages/juce_DeletedAtShutdown.cpp +++ b/source/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/source/modules/juce_events/messages/juce_DeletedAtShutdown.h b/source/modules/juce_events/messages/juce_DeletedAtShutdown.h index a0284f80d..9b28a49ed 100644 --- a/source/modules/juce_events/messages/juce_DeletedAtShutdown.h +++ b/source/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/source/modules/juce_events/messages/juce_Initialisation.h b/source/modules/juce_events/messages/juce_Initialisation.h index e911807bd..db2988a70 100644 --- a/source/modules/juce_events/messages/juce_Initialisation.h +++ b/source/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/source/modules/juce_events/messages/juce_Message.h b/source/modules/juce_events/messages/juce_Message.h index 52033be77..c0abb238c 100644 --- a/source/modules/juce_events/messages/juce_Message.h +++ b/source/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/source/modules/juce_events/messages/juce_MessageListener.cpp b/source/modules/juce_events/messages/juce_MessageListener.cpp index 671cbe27d..e1e8dcf63 100644 --- a/source/modules/juce_events/messages/juce_MessageListener.cpp +++ b/source/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/source/modules/juce_events/messages/juce_MessageListener.h b/source/modules/juce_events/messages/juce_MessageListener.h index 9e787864e..8c8fe9bd5 100644 --- a/source/modules/juce_events/messages/juce_MessageListener.h +++ b/source/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/source/modules/juce_events/messages/juce_MessageManager.cpp b/source/modules/juce_events/messages/juce_MessageManager.cpp index 2d9fb60d7..563852e54 100644 --- a/source/modules/juce_events/messages/juce_MessageManager.cpp +++ b/source/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/source/modules/juce_events/messages/juce_MessageManager.h b/source/modules/juce_events/messages/juce_MessageManager.h index cc8d44db5..688d53039 100644 --- a/source/modules/juce_events/messages/juce_MessageManager.h +++ b/source/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/source/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h b/source/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h index 37d181e01..ccc00b11b 100644 --- a/source/modules/juce_events/messages/juce_MountedVolumeListChangeDetector.h +++ b/source/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/source/modules/juce_events/messages/juce_NotificationType.h b/source/modules/juce_events/messages/juce_NotificationType.h index 1ad3f35db..168ac5c68 100644 --- a/source/modules/juce_events/messages/juce_NotificationType.h +++ b/source/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/source/modules/juce_events/native/juce_android_Messaging.cpp b/source/modules/juce_events/native/juce_android_Messaging.cpp index 922704ddd..9cb4dfbfc 100644 --- a/source/modules/juce_events/native/juce_android_Messaging.cpp +++ b/source/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/source/modules/juce_events/native/juce_ios_MessageManager.mm b/source/modules/juce_events/native/juce_ios_MessageManager.mm index cf5ce1b5a..47aed5f49 100644 --- a/source/modules/juce_events/native/juce_ios_MessageManager.mm +++ b/source/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/source/modules/juce_events/native/juce_linux_EventLoop.h b/source/modules/juce_events/native/juce_linux_EventLoop.h index 46df2bdfd..ce99bd7ff 100644 --- a/source/modules/juce_events/native/juce_linux_EventLoop.h +++ b/source/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/source/modules/juce_events/native/juce_linux_Messaging.cpp b/source/modules/juce_events/native/juce_linux_Messaging.cpp index 0a8834975..35cf97aef 100644 --- a/source/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/source/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/source/modules/juce_events/native/juce_mac_MessageManager.mm b/source/modules/juce_events/native/juce_mac_MessageManager.mm index 95e9a59dc..27456e63a 100644 --- a/source/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/source/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/source/modules/juce_events/native/juce_osx_MessageQueue.h b/source/modules/juce_events/native/juce_osx_MessageQueue.h index 9a23c15c4..32f24fde7 100644 --- a/source/modules/juce_events/native/juce_osx_MessageQueue.h +++ b/source/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/source/modules/juce_events/native/juce_win32_HiddenMessageWindow.h b/source/modules/juce_events/native/juce_win32_HiddenMessageWindow.h index 80328fb20..9135d99bd 100644 --- a/source/modules/juce_events/native/juce_win32_HiddenMessageWindow.h +++ b/source/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/source/modules/juce_events/native/juce_win32_Messaging.cpp b/source/modules/juce_events/native/juce_win32_Messaging.cpp index 12858ba64..38b636aae 100644 --- a/source/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/source/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/source/modules/juce_events/native/juce_win32_WinRTWrapper.cpp b/source/modules/juce_events/native/juce_win32_WinRTWrapper.cpp index 39cb99cae..e8d848da4 100644 --- a/source/modules/juce_events/native/juce_win32_WinRTWrapper.cpp +++ b/source/modules/juce_events/native/juce_win32_WinRTWrapper.cpp @@ -20,4 +20,7 @@ ============================================================================== */ -juce_ImplementSingleton (WinRTWrapper) +namespace juce +{ + juce_ImplementSingleton (WinRTWrapper) +} diff --git a/source/modules/juce_events/native/juce_win32_WinRTWrapper.h b/source/modules/juce_events/native/juce_win32_WinRTWrapper.h index 8f2503daa..4a48e0428 100644 --- a/source/modules/juce_events/native/juce_win32_WinRTWrapper.h +++ b/source/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/source/modules/juce_events/timers/juce_MultiTimer.cpp b/source/modules/juce_events/timers/juce_MultiTimer.cpp index e9ace0a9d..3f73eb3d7 100644 --- a/source/modules/juce_events/timers/juce_MultiTimer.cpp +++ b/source/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/source/modules/juce_events/timers/juce_MultiTimer.h b/source/modules/juce_events/timers/juce_MultiTimer.h index 87848458d..8921b6844 100644 --- a/source/modules/juce_events/timers/juce_MultiTimer.h +++ b/source/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/source/modules/juce_events/timers/juce_Timer.cpp b/source/modules/juce_events/timers/juce_Timer.cpp index da2ea738e..ae6e48fb5 100644 --- a/source/modules/juce_events/timers/juce_Timer.cpp +++ b/source/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/source/modules/juce_graphics/contexts/juce_GraphicsContext.h b/source/modules/juce_graphics/contexts/juce_GraphicsContext.h index 1e2e40053..8351003c0 100644 --- a/source/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/source/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/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h b/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h index 92ca19439..a9828e305 100644 --- a/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsContext.h +++ b/source/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/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index a9900f03a..868ccf735 100644 --- a/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/source/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/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h b/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h index 463df4dba..889702bca 100644 --- a/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h +++ b/source/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/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index c88411371..a32e90771 100644 --- a/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/source/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/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index 648970f91..06ecca5e0 100644 --- a/source/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/source/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/source/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/source/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index 5e68ac0df..6557c9dd8 100644 --- a/source/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/source/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/source/modules/juce_graphics/effects/juce_DropShadowEffect.h b/source/modules/juce_graphics/effects/juce_DropShadowEffect.h index 9fefe9a36..3de0f97a6 100644 --- a/source/modules/juce_graphics/effects/juce_DropShadowEffect.h +++ b/source/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/source/modules/juce_graphics/effects/juce_GlowEffect.cpp b/source/modules/juce_graphics/effects/juce_GlowEffect.cpp index e3af9ed03..4e1ee32c5 100644 --- a/source/modules/juce_graphics/effects/juce_GlowEffect.cpp +++ b/source/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/source/modules/juce_graphics/effects/juce_GlowEffect.h b/source/modules/juce_graphics/effects/juce_GlowEffect.h index 248951682..428ebad70 100644 --- a/source/modules/juce_graphics/effects/juce_GlowEffect.h +++ b/source/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/source/modules/juce_graphics/effects/juce_ImageEffectFilter.h b/source/modules/juce_graphics/effects/juce_ImageEffectFilter.h index 3d5d11afd..e06222d92 100644 --- a/source/modules/juce_graphics/effects/juce_ImageEffectFilter.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_AttributedString.cpp b/source/modules/juce_graphics/fonts/juce_AttributedString.cpp index 944a9be92..000223d96 100644 --- a/source/modules/juce_graphics/fonts/juce_AttributedString.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_AttributedString.h b/source/modules/juce_graphics/fonts/juce_AttributedString.h index 98d15a99f..f0cac6a06 100644 --- a/source/modules/juce_graphics/fonts/juce_AttributedString.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_CustomTypeface.cpp b/source/modules/juce_graphics/fonts/juce_CustomTypeface.cpp index 26d5d9506..acc1456aa 100644 --- a/source/modules/juce_graphics/fonts/juce_CustomTypeface.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_CustomTypeface.h b/source/modules/juce_graphics/fonts/juce_CustomTypeface.h index 0de1862f9..36dda6d5c 100644 --- a/source/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_Font.cpp b/source/modules/juce_graphics/fonts/juce_Font.cpp index 8d4360025..40e7f1bde 100644 --- a/source/modules/juce_graphics/fonts/juce_Font.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_Font.h b/source/modules/juce_graphics/fonts/juce_Font.h index 27fb61a97..cacea2d21 100644 --- a/source/modules/juce_graphics/fonts/juce_Font.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/source/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index adf8d7e03..f0d05460c 100644 --- a/source/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/source/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 42bcde4ef..711e6a06f 100644 --- a/source/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_TextLayout.cpp b/source/modules/juce_graphics/fonts/juce_TextLayout.cpp index 895316607..5987bb19a 100644 --- a/source/modules/juce_graphics/fonts/juce_TextLayout.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_TextLayout.h b/source/modules/juce_graphics/fonts/juce_TextLayout.h index 5a1510e65..d5b201627 100644 --- a/source/modules/juce_graphics/fonts/juce_TextLayout.h +++ b/source/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/source/modules/juce_graphics/fonts/juce_Typeface.cpp b/source/modules/juce_graphics/fonts/juce_Typeface.cpp index 1ce9a78fd..d712e2d81 100644 --- a/source/modules/juce_graphics/fonts/juce_Typeface.cpp +++ b/source/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/source/modules/juce_graphics/fonts/juce_Typeface.h b/source/modules/juce_graphics/fonts/juce_Typeface.h index 3669fc16a..82a2eb8f6 100644 --- a/source/modules/juce_graphics/fonts/juce_Typeface.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/source/modules/juce_graphics/geometry/juce_AffineTransform.cpp index b111ed5b1..59115696d 100644 --- a/source/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/source/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/source/modules/juce_graphics/geometry/juce_AffineTransform.h b/source/modules/juce_graphics/geometry/juce_AffineTransform.h index 24fcf5156..a11561baf 100644 --- a/source/modules/juce_graphics/geometry/juce_AffineTransform.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_BorderSize.h b/source/modules/juce_graphics/geometry/juce_BorderSize.h index 7dbfb8ce5..8678c2eb4 100644 --- a/source/modules/juce_graphics/geometry/juce_BorderSize.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/source/modules/juce_graphics/geometry/juce_EdgeTable.cpp index ea35e4752..141613c84 100644 --- a/source/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/source/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/source/modules/juce_graphics/geometry/juce_EdgeTable.h b/source/modules/juce_graphics/geometry/juce_EdgeTable.h index f32e61e12..76c318ed1 100644 --- a/source/modules/juce_graphics/geometry/juce_EdgeTable.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_Line.h b/source/modules/juce_graphics/geometry/juce_Line.h index 7143fe308..d8db97a4e 100644 --- a/source/modules/juce_graphics/geometry/juce_Line.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_Path.cpp b/source/modules/juce_graphics/geometry/juce_Path.cpp index 38b0d53cc..849d4a083 100644 --- a/source/modules/juce_graphics/geometry/juce_Path.cpp +++ b/source/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/source/modules/juce_graphics/geometry/juce_Path.h b/source/modules/juce_graphics/geometry/juce_Path.h index 03dc76894..1a4962ac6 100644 --- a/source/modules/juce_graphics/geometry/juce_Path.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_PathIterator.cpp b/source/modules/juce_graphics/geometry/juce_PathIterator.cpp index f3fbe128a..ca239d4f9 100644 --- a/source/modules/juce_graphics/geometry/juce_PathIterator.cpp +++ b/source/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/source/modules/juce_graphics/geometry/juce_PathIterator.h b/source/modules/juce_graphics/geometry/juce_PathIterator.h index 96c70a852..d37b5407d 100644 --- a/source/modules/juce_graphics/geometry/juce_PathIterator.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_PathStrokeType.cpp b/source/modules/juce_graphics/geometry/juce_PathStrokeType.cpp index dbab9c7bb..8069a696d 100644 --- a/source/modules/juce_graphics/geometry/juce_PathStrokeType.cpp +++ b/source/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/source/modules/juce_graphics/geometry/juce_PathStrokeType.h b/source/modules/juce_graphics/geometry/juce_PathStrokeType.h index de804b143..c84412dd9 100644 --- a/source/modules/juce_graphics/geometry/juce_PathStrokeType.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_Point.h b/source/modules/juce_graphics/geometry/juce_Point.h index 69915c31a..2b66ae847 100644 --- a/source/modules/juce_graphics/geometry/juce_Point.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_Rectangle.h b/source/modules/juce_graphics/geometry/juce_Rectangle.h index dca99f300..eb5d937be 100644 --- a/source/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/source/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/source/modules/juce_graphics/geometry/juce_RectangleList.h b/source/modules/juce_graphics/geometry/juce_RectangleList.h index e611fcb8f..55512fda1 100644 --- a/source/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/source/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/source/modules/juce_graphics/image_formats/juce_GIFLoader.cpp b/source/modules/juce_graphics/image_formats/juce_GIFLoader.cpp index 5d8c205e1..80a101e64 100644 --- a/source/modules/juce_graphics/image_formats/juce_GIFLoader.cpp +++ b/source/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/source/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/source/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index ff5c1629d..793d10ba6 100644 --- a/source/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/source/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/source/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/source/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index dbf35059e..ee0627317 100644 --- a/source/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/source/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/source/modules/juce_graphics/images/juce_Image.cpp b/source/modules/juce_graphics/images/juce_Image.cpp index 7028b65e9..1b206f5a2 100644 --- a/source/modules/juce_graphics/images/juce_Image.cpp +++ b/source/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/source/modules/juce_graphics/images/juce_Image.h b/source/modules/juce_graphics/images/juce_Image.h index a2c436d25..eefaa98d1 100644 --- a/source/modules/juce_graphics/images/juce_Image.h +++ b/source/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/source/modules/juce_graphics/images/juce_ImageCache.cpp b/source/modules/juce_graphics/images/juce_ImageCache.cpp index 50c3203f4..e565f5e5e 100644 --- a/source/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/source/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/source/modules/juce_graphics/images/juce_ImageCache.h b/source/modules/juce_graphics/images/juce_ImageCache.h index fa5b5710c..753ce750d 100644 --- a/source/modules/juce_graphics/images/juce_ImageCache.h +++ b/source/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/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp b/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp index a56cab1eb..e7408c2f0 100644 --- a/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.cpp +++ b/source/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/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.h b/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.h index cc399d965..c3495a268 100644 --- a/source/modules/juce_graphics/images/juce_ImageConvolutionKernel.h +++ b/source/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/source/modules/juce_graphics/images/juce_ImageFileFormat.cpp b/source/modules/juce_graphics/images/juce_ImageFileFormat.cpp index 669a39be4..12ad6afb2 100644 --- a/source/modules/juce_graphics/images/juce_ImageFileFormat.cpp +++ b/source/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/source/modules/juce_graphics/images/juce_ImageFileFormat.h b/source/modules/juce_graphics/images/juce_ImageFileFormat.h index e558906af..ec7138836 100644 --- a/source/modules/juce_graphics/images/juce_ImageFileFormat.h +++ b/source/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/source/modules/juce_graphics/juce_graphics.cpp b/source/modules/juce_graphics/juce_graphics.cpp index 688498188..2dcbc5e8b 100644 --- a/source/modules/juce_graphics/juce_graphics.cpp +++ b/source/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/source/modules/juce_graphics/juce_graphics.h b/source/modules/juce_graphics/juce_graphics.h index c823b10f1..41693ec5f 100644 --- a/source/modules/juce_graphics/juce_graphics.h +++ b/source/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/source/modules/juce_graphics/native/juce_RenderingHelpers.h b/source/modules/juce_graphics/native/juce_RenderingHelpers.h index 5cbb679e3..e552758b2 100644 --- a/source/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/source/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/source/modules/juce_graphics/native/juce_android_Fonts.cpp b/source/modules/juce_graphics/native/juce_android_Fonts.cpp index 5bfe92da6..a5ffa6b7d 100644 --- a/source/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_android_GraphicsContext.cpp b/source/modules/juce_graphics/native/juce_android_GraphicsContext.cpp index 2f36d872e..77dabe2e3 100644 --- a/source/modules/juce_graphics/native/juce_android_GraphicsContext.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_android_IconHelpers.cpp b/source/modules/juce_graphics/native/juce_android_IconHelpers.cpp index 287005422..3a11f8e34 100644 --- a/source/modules/juce_graphics/native/juce_android_IconHelpers.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_freetype_Fonts.cpp b/source/modules/juce_graphics/native/juce_freetype_Fonts.cpp index 1f01b77c9..a813ec61b 100644 --- a/source/modules/juce_graphics/native/juce_freetype_Fonts.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_linux_Fonts.cpp b/source/modules/juce_graphics/native/juce_linux_Fonts.cpp index 24b98669e..06cd9401a 100644 --- a/source/modules/juce_graphics/native/juce_linux_Fonts.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_linux_IconHelpers.cpp b/source/modules/juce_graphics/native/juce_linux_IconHelpers.cpp index 287005422..3a11f8e34 100644 --- a/source/modules/juce_graphics/native/juce_linux_IconHelpers.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h b/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h index 4b81cf100..5db040743 100644 --- a/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.h +++ b/source/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/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index fa97d97a5..63e7f8925 100644 --- a/source/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/source/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/source/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h b/source/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h index f60b158a1..6d04d73ea 100644 --- a/source/modules/juce_graphics/native/juce_mac_CoreGraphicsHelpers.h +++ b/source/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/source/modules/juce_graphics/native/juce_mac_Fonts.mm b/source/modules/juce_graphics/native/juce_mac_Fonts.mm index 61c9cf8c2..19b3b38f3 100644 --- a/source/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/source/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/source/modules/juce_graphics/native/juce_mac_IconHelpers.cpp b/source/modules/juce_graphics/native/juce_mac_IconHelpers.cpp index 0f3b740b0..03aa559c5 100644 --- a/source/modules/juce_graphics/native/juce_mac_IconHelpers.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index 40f848e58..b9f7d592f 100644 --- a/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h b/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h index 2c923a76e..fb8714dbf 100644 --- a/source/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.h +++ b/source/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/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp b/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp index 739fc539a..d007ebb6b 100644 --- a/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeLayout.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index fb30ddb42..2643d1a16 100644 --- a/source/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_win32_Fonts.cpp b/source/modules/juce_graphics/native/juce_win32_Fonts.cpp index d8198341c..b6159c3f9 100644 --- a/source/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/source/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/source/modules/juce_graphics/native/juce_win32_IconHelpers.cpp b/source/modules/juce_graphics/native/juce_win32_IconHelpers.cpp index 287005422..3a11f8e34 100644 --- a/source/modules/juce_graphics/native/juce_win32_IconHelpers.cpp +++ b/source/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/source/modules/juce_graphics/placement/juce_Justification.h b/source/modules/juce_graphics/placement/juce_Justification.h index a70ea2518..8c8fb8362 100644 --- a/source/modules/juce_graphics/placement/juce_Justification.h +++ b/source/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/source/modules/juce_graphics/placement/juce_RectanglePlacement.cpp b/source/modules/juce_graphics/placement/juce_RectanglePlacement.cpp index 1d1143636..6f718c094 100644 --- a/source/modules/juce_graphics/placement/juce_RectanglePlacement.cpp +++ b/source/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/source/modules/juce_graphics/placement/juce_RectanglePlacement.h b/source/modules/juce_graphics/placement/juce_RectanglePlacement.h index 1d6aefd74..84eec1db0 100644 --- a/source/modules/juce_graphics/placement/juce_RectanglePlacement.h +++ b/source/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/source/modules/juce_gui_basics/application/juce_Application.cpp b/source/modules/juce_gui_basics/application/juce_Application.cpp index a365031d2..efa5242bb 100644 --- a/source/modules/juce_gui_basics/application/juce_Application.cpp +++ b/source/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/source/modules/juce_gui_basics/application/juce_Application.h b/source/modules/juce_gui_basics/application/juce_Application.h index 9ade8bbe9..423f8ce5c 100644 --- a/source/modules/juce_gui_basics/application/juce_Application.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp b/source/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp index 4076462db..fa76bc1d3 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ArrowButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ArrowButton.h b/source/modules/juce_gui_basics/buttons/juce_ArrowButton.h index c05a0c5f6..8ff4d7f47 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ArrowButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_Button.cpp b/source/modules/juce_gui_basics/buttons/juce_Button.cpp index 9ece5dd0c..e82b83897 100644 --- a/source/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_Button.h b/source/modules/juce_gui_basics/buttons/juce_Button.h index 9ba29f157..79de48cc2 100644 --- a/source/modules/juce_gui_basics/buttons/juce_Button.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/source/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index 3fa94c0c8..f4b01ef3e 100644 --- a/source/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/source/modules/juce_gui_basics/buttons/juce_DrawableButton.h index 44124c2b5..8e261373c 100644 --- a/source/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp b/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp index 5d76c4310..acafad1ac 100644 --- a/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h b/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h index 746dd4e28..1b67e17d0 100644 --- a/source/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ImageButton.cpp b/source/modules/juce_gui_basics/buttons/juce_ImageButton.cpp index 7bd3fb5f1..e89f5736d 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ImageButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ImageButton.h b/source/modules/juce_gui_basics/buttons/juce_ImageButton.h index d24de290c..c867973d7 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ImageButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/source/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index 733b1a41e..3e7f91a59 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ShapeButton.h b/source/modules/juce_gui_basics/buttons/juce_ShapeButton.h index 60372a3bf..193d886fd 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ShapeButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_TextButton.cpp b/source/modules/juce_gui_basics/buttons/juce_TextButton.cpp index 59e80696d..d7d4fb46c 100644 --- a/source/modules/juce_gui_basics/buttons/juce_TextButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_TextButton.h b/source/modules/juce_gui_basics/buttons/juce_TextButton.h index b5f6d346b..1631af52c 100644 --- a/source/modules/juce_gui_basics/buttons/juce_TextButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp b/source/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp index a9a3c84f9..a43e45d1e 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ToggleButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ToggleButton.h b/source/modules/juce_gui_basics/buttons/juce_ToggleButton.h index 500946ec6..afe3dcf2a 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ToggleButton.h +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp b/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp index e09bd913a..d4f60ac8c 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.cpp +++ b/source/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/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.h b/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.h index 20a4322bc..ce2190e03 100644 --- a/source/modules/juce_gui_basics/buttons/juce_ToolbarButton.h +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h index 65c3e4b70..cae26668d 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp index 388113d6c..6599fdd9f 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h index c6cb9927e..63358df6a 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 7379a9b48..acd785a36 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h index 9baf3da99..396002134 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp index fa25e1244..17cd9a0a5 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.cpp +++ b/source/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/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h b/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h index f37414180..bec730840 100644 --- a/source/modules/juce_gui_basics/commands/juce_ApplicationCommandTarget.h +++ b/source/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/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp b/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp index 2293d5835..0a0232843 100644 --- a/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp +++ b/source/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/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index 75e3ca5f3..d850739bf 100644 --- a/source/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/source/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/source/modules/juce_gui_basics/components/juce_CachedComponentImage.h b/source/modules/juce_gui_basics/components/juce_CachedComponentImage.h index fda4f550e..7e2b5485d 100644 --- a/source/modules/juce_gui_basics/components/juce_CachedComponentImage.h +++ b/source/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/source/modules/juce_gui_basics/components/juce_Component.cpp b/source/modules/juce_gui_basics/components/juce_Component.cpp index cdd9d634f..d69a2bbf7 100644 --- a/source/modules/juce_gui_basics/components/juce_Component.cpp +++ b/source/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/source/modules/juce_gui_basics/components/juce_Component.h b/source/modules/juce_gui_basics/components/juce_Component.h index 961609dee..9c9c55a56 100644 --- a/source/modules/juce_gui_basics/components/juce_Component.h +++ b/source/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/source/modules/juce_gui_basics/components/juce_ComponentListener.cpp b/source/modules/juce_gui_basics/components/juce_ComponentListener.cpp index 0c45b3f30..4f27a5109 100644 --- a/source/modules/juce_gui_basics/components/juce_ComponentListener.cpp +++ b/source/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/source/modules/juce_gui_basics/components/juce_ComponentListener.h b/source/modules/juce_gui_basics/components/juce_ComponentListener.h index 9c24fb1b5..cc657b83a 100644 --- a/source/modules/juce_gui_basics/components/juce_ComponentListener.h +++ b/source/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/source/modules/juce_gui_basics/components/juce_Desktop.cpp b/source/modules/juce_gui_basics/components/juce_Desktop.cpp index 9317213fe..edaf72f98 100644 --- a/source/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/source/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/source/modules/juce_gui_basics/components/juce_Desktop.h b/source/modules/juce_gui_basics/components/juce_Desktop.h index 502ca0fd9..a7486bfc7 100644 --- a/source/modules/juce_gui_basics/components/juce_Desktop.h +++ b/source/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/source/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp b/source/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp index d0cbb13f5..b08f24014 100644 --- a/source/modules/juce_gui_basics/components/juce_ModalComponentManager.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableComposite.h b/source/modules/juce_gui_basics/drawables/juce_DrawableComposite.h index 00217e4f9..b98bb6237 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableComposite.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp b/source/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp index c8f177095..c7675afce 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableImage.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableImage.h b/source/modules/juce_gui_basics/drawables/juce_DrawableImage.h index 818012e44..d1277174a 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableImage.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/source/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 975a05385..a581e980f 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawablePath.h b/source/modules/juce_gui_basics/drawables/juce_DrawablePath.h index 1dd33f7ae..66254d44c 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawablePath.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp b/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp index 4bd0c70ec..52a24ecd9 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h b/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h index f34e77b79..fbb3f77cc 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableRectangle.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp b/source/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp index 9c23c44a7..e93130a71 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableShape.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableShape.h b/source/modules/juce_gui_basics/drawables/juce_DrawableShape.h index 2cb7e3712..10a89dd1d 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableShape.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableText.cpp b/source/modules/juce_gui_basics/drawables/juce_DrawableText.cpp index 3bfddce9d..de6d7c2a2 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableText.cpp +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_DrawableText.h b/source/modules/juce_gui_basics/drawables/juce_DrawableText.h index 1033b0b66..637659ed8 100644 --- a/source/modules/juce_gui_basics/drawables/juce_DrawableText.h +++ b/source/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/source/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/source/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 3f7128100..a2aaef12d 100644 --- a/source/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp index 5e9268fe9..b83d35625 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h index 77279ed5a..d01427f68 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsDisplayComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 27a32cfa3..7db6e282c 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h b/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h index 33e062ff7..50877c395 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index c7030fb88..eb367095b 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index eb26c5255..148adeaeb 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h b/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h index fe7776bca..45506a19d 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileBrowserListener.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp index 0e3995c75..024bafead 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.h b/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.h index 82a31abb5..4584acc65 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileChooser.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp index 642860daf..22de557db 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h b/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h index feb82bdea..0ccd01df2 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileChooserDialogBox.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp index 4e201007c..f1407a4a7 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp +++ b/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File& file); @@ -58,7 +61,7 @@ void FileListComponent::deselectAllFiles() void FileListComponent::scrollToTop() { - getVerticalScrollBar()->setCurrentRangeStart (0); + getVerticalScrollBar().setCurrentRangeStart (0); } void FileListComponent::setSelectedFile (const File& f) @@ -255,3 +258,5 @@ void FileListComponent::returnKeyPressed (int currentSelectedRow) { sendDoubleClickMessage (directoryContentsList.getFile (currentSelectedRow)); } + +} // namespace juce diff --git a/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h index 3dbf93efc..770e666c2 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileListComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h index 74e99c6e2..478153137 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FilePreviewComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp index 0bee475fc..e74e7f769 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h index 5119d9678..07c285378 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileSearchPathListComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 15bc43a44..e6ba4e0d0 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + Image juce_createIconForFile (const File&); //============================================================================== @@ -88,7 +91,7 @@ public: { jassert (parentContentsList != nullptr); - DirectoryContentsList* const l = new DirectoryContentsList (parentContentsList->getFilter(), thread); + auto l = new DirectoryContentsList (parentContentsList->getFilter(), thread); l->setDirectory (file, parentContentsList->isFindingDirectories(), @@ -296,7 +299,7 @@ void FileTreeComponent::deselectAllFiles() void FileTreeComponent::scrollToTop() { - getViewport()->getVerticalScrollBar()->setCurrentRangeStart (0); + getViewport()->getVerticalScrollBar().setCurrentRangeStart (0); } void FileTreeComponent::setDragAndDropDescription (const String& description) @@ -321,3 +324,5 @@ void FileTreeComponent::setItemHeight (int newHeight) root->treeHasChanged(); } } + +} // namespace juce diff --git a/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index 46d2b2109..1a9a6cf2f 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index fee3d6c96..11b718fd3 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h index d3768f738..72706db6d 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp b/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp index c1d3e699d..0de138337 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h b/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h index 0af35fefd..df9626646 100644 --- a/source/modules/juce_gui_basics/filebrowser/juce_ImagePreviewComponent.h +++ b/source/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/source/modules/juce_gui_basics/juce_gui_basics.cpp b/source/modules/juce_gui_basics/juce_gui_basics.cpp index d9afd8d11..491db1199 100644 --- a/source/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/source/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/source/modules/juce_gui_basics/juce_gui_basics.h b/source/modules/juce_gui_basics/juce_gui_basics.h index e3782c293..cc8dc1016 100644 --- a/source/modules/juce_gui_basics/juce_gui_basics.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp b/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp index fce9c35bc..c1e0d1e93 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.h b/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.h index acee48a28..b21cc7b5c 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_CaretComponent.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp b/source/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp index 38e9de545..43c5bdb7a 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyListener.cpp +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyListener.h b/source/modules/juce_gui_basics/keyboard/juce_KeyListener.h index 1dc7b10cb..f3cc76210 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyListener.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp b/source/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp index 8f407972b..eec2a85bc 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyPress.cpp +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyPress.h b/source/modules/juce_gui_basics/keyboard/juce_KeyPress.h index 420a869fb..5f0300485 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyPress.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp b/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp index 13afbd402..7ca108be0 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h b/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h index 856677cc7..c6d88f0c4 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp b/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp index 7fbb58742..5133ed23c 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h b/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h index 3337b9adb..61c02604b 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h b/source/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h index dbe6bdabd..b00135dba 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h b/source/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h index e8fd74f96..05594ac45 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_TextEditorKeyMapper.h +++ b/source/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/source/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h b/source/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h index e63a84a61..9d198be13 100644 --- a/source/modules/juce_gui_basics/keyboard/juce_TextInputTarget.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_AnimatedPosition.h b/source/modules/juce_gui_basics/layout/juce_AnimatedPosition.h index 7f75916fd..7b4b320f4 100644 --- a/source/modules/juce_gui_basics/layout/juce_AnimatedPosition.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h b/source/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h index e29bc73cc..3be77da9b 100644 --- a/source/modules/juce_gui_basics/layout/juce_AnimatedPositionBehaviours.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index d322f4ae9..936660d22 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index 5a9441b7c..85fdb1e77 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp index b34240c57..158cbe61f 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h b/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h index e9d0a9493..16b8a4426 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index bd5b6c52d..f735f35ef 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index fc389b68a..8d8d7debf 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp b/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp index c42f004b3..6e5cfe94e 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h b/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h index 0a1c55bd9..583ae4e32 100644 --- a/source/modules/juce_gui_basics/layout/juce_ComponentMovementWatcher.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index 175699812..f5dad1d1b 100644 --- a/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h b/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h index 4670fd2ed..aea9dbff6 100644 --- a/source/modules/juce_gui_basics/layout/juce_ConcertinaPanel.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/source/modules/juce_gui_basics/layout/juce_FlexBox.cpp index bdaaea806..d647b15a3 100644 --- a/source/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_FlexBox.h b/source/modules/juce_gui_basics/layout/juce_FlexBox.h index 35b26e9fd..b2c3e0929 100644 --- a/source/modules/juce_gui_basics/layout/juce_FlexBox.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_FlexItem.h b/source/modules/juce_gui_basics/layout/juce_FlexItem.h index 3565c9899..b52c3b6f4 100644 --- a/source/modules/juce_gui_basics/layout/juce_FlexItem.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_Grid.cpp b/source/modules/juce_gui_basics/layout/juce_Grid.cpp index f3c97ec30..74338d1d3 100644 --- a/source/modules/juce_gui_basics/layout/juce_Grid.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_Grid.h b/source/modules/juce_gui_basics/layout/juce_Grid.h index 21d8cdbd4..bf8d8fd7d 100644 --- a/source/modules/juce_gui_basics/layout/juce_Grid.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_GridItem.cpp b/source/modules/juce_gui_basics/layout/juce_GridItem.cpp index 63101d9aa..72088fb70 100644 --- a/source/modules/juce_gui_basics/layout/juce_GridItem.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_GridItem.h b/source/modules/juce_gui_basics/layout/juce_GridItem.h index e52907946..f57ab7981 100644 --- a/source/modules/juce_gui_basics/layout/juce_GridItem.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp b/source/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp index 52ccda6bd..99084d099 100644 --- a/source/modules/juce_gui_basics/layout/juce_GridUnitTests.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_GroupComponent.cpp b/source/modules/juce_gui_basics/layout/juce_GroupComponent.cpp index 172d3d7ef..c63237706 100644 --- a/source/modules/juce_gui_basics/layout/juce_GroupComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_GroupComponent.h b/source/modules/juce_gui_basics/layout/juce_GroupComponent.h index f8f3a2f05..47ef9245d 100644 --- a/source/modules/juce_gui_basics/layout/juce_GroupComponent.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index 65c745420..94d0c88a9 100644 --- a/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h b/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h index b55f3de30..a19c37c14 100644 --- a/source/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index ee4b1ee6b..df6791430 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 612fd26eb..53ec37e16 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp b/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp index 5e7ef095d..7b3735cf0 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h b/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h index 14b36f22b..ae1f8264c 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableCornerComponent.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp b/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp index 9c3a78d02..a4c8441be 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h b/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h index 4d8b45e26..2063375c8 100644 --- a/source/modules/juce_gui_basics/layout/juce_ResizableEdgeComponent.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/source/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index e3aa126fd..c84b71c12 100644 --- a/source/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_ScrollBar.h b/source/modules/juce_gui_basics/layout/juce_ScrollBar.h index f94e905c2..34996d6a8 100644 --- a/source/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp b/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp index 64d217471..75a52fa4f 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h b/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h index 2e86faaa9..e6b72ed40 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableLayoutManager.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp b/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp index c23baabe9..dd009a7b8 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h b/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h index 87b18cfd2..e1a20509f 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableLayoutResizerBar.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp b/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp index 7fada6a5b..bf56dea75 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h b/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h index c7e368fd0..32543b115 100644 --- a/source/modules/juce_gui_basics/layout/juce_StretchableObjectResizer.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 2e83ec056..0031a1882 100644 --- a/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index cb46a0e33..a788408c9 100644 --- a/source/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/source/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 1e731df3d..d6349e32f 100644 --- a/source/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/layout/juce_TabbedComponent.h b/source/modules/juce_gui_basics/layout/juce_TabbedComponent.h index 0dac8a02c..f62846e65 100644 --- a/source/modules/juce_gui_basics/layout/juce_TabbedComponent.h +++ b/source/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/source/modules/juce_gui_basics/layout/juce_Viewport.cpp b/source/modules/juce_gui_basics/layout/juce_Viewport.cpp index eae3b6bb5..d53453004 100644 --- a/source/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/source/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 @@ -32,11 +35,11 @@ Viewport::Viewport (const String& name) : Component (name) scrollBarThickness = getLookAndFeel().getDefaultScrollbarWidth(); - addChildComponent (verticalScrollBar); - addChildComponent (horizontalScrollBar); + addChildComponent (verticalScrollBar = createScrollBarComponent (true)); + addChildComponent (horizontalScrollBar = createScrollBarComponent (false)); - verticalScrollBar.addListener (this); - horizontalScrollBar.addListener (this); + getVerticalScrollBar().addListener (this); + getHorizontalScrollBar().addListener (this); setInterceptsMouseClicks (false, true); setWantsKeyboardFocus (true); @@ -137,7 +140,7 @@ bool Viewport::autoScroll (const int mouseX, const int mouseY, const int activeB { int dx = 0, dy = 0; - if (horizontalScrollBar.isVisible() || canScrollHorizontally()) + if (getHorizontalScrollBar().isVisible() || canScrollHorizontally()) { if (mouseX < activeBorderThickness) dx = activeBorderThickness - mouseX; @@ -150,7 +153,7 @@ bool Viewport::autoScroll (const int mouseX, const int mouseY, const int activeB dx = jmin (dx, maximumSpeed, -contentComp->getX()); } - if (verticalScrollBar.isVisible() || canScrollVertically()) + if (getVerticalScrollBar().isVisible() || canScrollVertically()) { if (mouseY < activeBorderThickness) dy = activeBorderThickness - mouseY; @@ -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; } @@ -216,7 +223,7 @@ struct Viewport::DragToScrollListener : private MouseListener, { if (numTouches == 1 && ! isViewportDragBlocked) { - Point totalOffset = e.getOffsetFromDragStart().toFloat(); + auto totalOffset = e.getOffsetFromDragStart().toFloat(); if (! isDragging && totalOffset.getDistanceFromOrigin() > 8.0f) { @@ -319,8 +326,8 @@ void Viewport::updateVisibleArea() for (int i = 3; --i >= 0;) { - hBarVisible = canShowHBar && ! horizontalScrollBar.autoHides(); - vBarVisible = canShowVBar && ! verticalScrollBar.autoHides(); + hBarVisible = canShowHBar && ! getHorizontalScrollBar().autoHides(); + vBarVisible = canShowVBar && ! getVerticalScrollBar().autoHides(); contentArea = getLocalBounds(); if (contentComp != nullptr && ! contentArea.contains (contentComp->getBounds())) @@ -364,27 +371,30 @@ void Viewport::updateVisibleArea() auto visibleOrigin = -contentBounds.getPosition(); - horizontalScrollBar.setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth); - horizontalScrollBar.setRangeLimits (0.0, contentBounds.getWidth()); - horizontalScrollBar.setCurrentRange (visibleOrigin.x, contentArea.getWidth()); - horizontalScrollBar.setSingleStepSize (singleStepX); - horizontalScrollBar.cancelPendingUpdate(); + auto& hbar = getHorizontalScrollBar(); + auto& vbar = getVerticalScrollBar(); + + hbar.setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth); + hbar.setRangeLimits (0.0, contentBounds.getWidth()); + hbar.setCurrentRange (visibleOrigin.x, contentArea.getWidth()); + hbar.setSingleStepSize (singleStepX); + hbar.cancelPendingUpdate(); if (canShowHBar && ! hBarVisible) visibleOrigin.setX (0); - verticalScrollBar.setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight()); - verticalScrollBar.setRangeLimits (0.0, contentBounds.getHeight()); - verticalScrollBar.setCurrentRange (visibleOrigin.y, contentArea.getHeight()); - verticalScrollBar.setSingleStepSize (singleStepY); - verticalScrollBar.cancelPendingUpdate(); + vbar.setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight()); + vbar.setRangeLimits (0.0, contentBounds.getHeight()); + vbar.setCurrentRange (visibleOrigin.y, contentArea.getHeight()); + vbar.setSingleStepSize (singleStepY); + vbar.cancelPendingUpdate(); if (canShowVBar && ! vBarVisible) visibleOrigin.setY (0); // Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers. - horizontalScrollBar.setVisible (hBarVisible); - verticalScrollBar.setVisible (vBarVisible); + hbar.setVisible (hBarVisible); + vbar.setVisible (vBarVisible); if (contentComp != nullptr) { @@ -407,8 +417,8 @@ void Viewport::updateVisibleArea() visibleAreaChanged (visibleArea); } - horizontalScrollBar.handleUpdateNowIfNeeded(); - verticalScrollBar.handleUpdateNowIfNeeded(); + hbar.handleUpdateNowIfNeeded(); + vbar.handleUpdateNowIfNeeded(); } //============================================================================== @@ -473,11 +483,11 @@ void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRange { const int newRangeStartInt = roundToInt (newRangeStart); - if (scrollBarThatHasMoved == &horizontalScrollBar) + if (scrollBarThatHasMoved == horizontalScrollBar) { setViewPosition (newRangeStartInt, getViewPositionY()); } - else if (scrollBarThatHasMoved == &verticalScrollBar) + else if (scrollBarThatHasMoved == verticalScrollBar) { setViewPosition (getViewPositionX(), newRangeStartInt); } @@ -504,8 +514,8 @@ bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelD { if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown())) { - const bool canScrollVert = (allowScrollingWithoutScrollbarV || verticalScrollBar.isVisible()); - const bool canScrollHorz = (allowScrollingWithoutScrollbarH || horizontalScrollBar.isVisible()); + const bool canScrollVert = (allowScrollingWithoutScrollbarV || getVerticalScrollBar().isVisible()); + const bool canScrollHorz = (allowScrollingWithoutScrollbarH || getHorizontalScrollBar().isVisible()); if (canScrollHorz || canScrollVert) { @@ -559,13 +569,13 @@ bool Viewport::keyPressed (const KeyPress& key) { const bool isUpDownKey = isUpDownKeyPress (key); - if (verticalScrollBar.isVisible() && isUpDownKey) - return verticalScrollBar.keyPressed (key); + if (getVerticalScrollBar().isVisible() && isUpDownKey) + return getVerticalScrollBar().keyPressed (key); const bool isLeftRightKey = isLeftRightKeyPress (key); - if (horizontalScrollBar.isVisible() && (isUpDownKey || isLeftRightKey)) - return horizontalScrollBar.keyPressed (key); + if (getHorizontalScrollBar().isVisible() && (isUpDownKey || isLeftRightKey)) + return getHorizontalScrollBar().keyPressed (key); return false; } @@ -574,3 +584,10 @@ bool Viewport::respondsToKey (const KeyPress& key) { return isUpDownKeyPress (key) || isLeftRightKeyPress (key); } + +ScrollBar* Viewport::createScrollBarComponent (bool isVertical) +{ + return new ScrollBar (isVertical); +} + +} // namespace juce diff --git a/source/modules/juce_gui_basics/layout/juce_Viewport.h b/source/modules/juce_gui_basics/layout/juce_Viewport.h index 7da6dfd27..b742186f0 100644 --- a/source/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/source/modules/juce_gui_basics/layout/juce_Viewport.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -231,12 +231,12 @@ public: /** Returns a pointer to the scrollbar component being used. Handy if you need to customise the bar somehow. */ - ScrollBar* getVerticalScrollBar() noexcept { return &verticalScrollBar; } + ScrollBar& getVerticalScrollBar() noexcept { return *verticalScrollBar; } /** Returns a pointer to the scrollbar component being used. Handy if you need to customise the bar somehow. */ - ScrollBar* getHorizontalScrollBar() noexcept { return &horizontalScrollBar; } + ScrollBar& getHorizontalScrollBar() noexcept { return *horizontalScrollBar; } /** True if there's any off-screen content that could be scrolled vertically, or false if everything is currently visible. @@ -277,9 +277,16 @@ public: /** @internal */ static bool respondsToKey (const KeyPress&); +protected: + //============================================================================== + /** Creates the Scrollbar components that will be added to the Viewport. + Subclasses can override this if they need to customise the scrollbars in some way. + */ + virtual ScrollBar* createScrollBarComponent (bool isVertical); + private: //============================================================================== - ScrollBar verticalScrollBar { true }, horizontalScrollBar { false }; + ScopedPointer verticalScrollBar, horizontalScrollBar; Component contentHolder; WeakReference contentComp; Rectangle lastVisibleArea; @@ -306,3 +313,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Viewport) }; + +} // namespace juce diff --git a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 4fd176651..d2faffbaa 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h index 81267298a..997180a51 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp index d88596565..837bdfb11 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.cpp +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h index f9f708940..45950042d 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V1.h +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 4622efd7b..15d02047a 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + namespace LookAndFeelHelpers { static Colour createBaseColour (Colour buttonColour, @@ -1491,7 +1494,7 @@ class LookAndFeel_V2::SliderLabelComp : public Label public: SliderLabelComp() : Label ({}, {}) {} - void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) {} + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override {} }; Label* LookAndFeel_V2::createSliderTextBox (Slider& slider) @@ -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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h index 268f22a6d..af0b36588 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index b0090d8e3..25dffe0b2 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h index dc0be9ca5..7a3bdcb4d 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 29facbd2b..6e23eb0fc 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/source/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/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h index 76b1371f9..ad690d5e1 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.h +++ b/source/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/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp b/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp index bc9515b5b..b24072acd 100644 --- a/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.h b/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.h index 96a00c8f5..82f9a4e08 100644 --- a/source/modules/juce_gui_basics/menus/juce_MenuBarComponent.h +++ b/source/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/source/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp b/source/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp index e5be870ab..fcc06afe9 100644 --- a/source/modules/juce_gui_basics/menus/juce_MenuBarModel.cpp +++ b/source/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/source/modules/juce_gui_basics/menus/juce_MenuBarModel.h b/source/modules/juce_gui_basics/menus/juce_MenuBarModel.h index 01e6023d6..a4b7d9c0e 100644 --- a/source/modules/juce_gui_basics/menus/juce_MenuBarModel.h +++ b/source/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/source/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/source/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 738aedb2f..530a49f7e 100644 --- a/source/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/source/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/source/modules/juce_gui_basics/menus/juce_PopupMenu.h b/source/modules/juce_gui_basics/menus/juce_PopupMenu.h index 276fb62a4..d3a91b94c 100644 --- a/source/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/source/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/source/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/source/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index b2595731a..13ce260eb 100644 --- a/source/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/misc/juce_BubbleComponent.h b/source/modules/juce_gui_basics/misc/juce_BubbleComponent.h index 4b03495c2..fe253274f 100644 --- a/source/modules/juce_gui_basics/misc/juce_BubbleComponent.h +++ b/source/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/source/modules/juce_gui_basics/misc/juce_DropShadower.cpp b/source/modules/juce_gui_basics/misc/juce_DropShadower.cpp index 42cac3e67..8f4fcb072 100644 --- a/source/modules/juce_gui_basics/misc/juce_DropShadower.cpp +++ b/source/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/source/modules/juce_gui_basics/misc/juce_DropShadower.h b/source/modules/juce_gui_basics/misc/juce_DropShadower.h index d201430b7..913760986 100644 --- a/source/modules/juce_gui_basics/misc/juce_DropShadower.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp b/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp index d5c9f3709..5f01eb8c9 100644 --- a/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.h b/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.h index ab6141cdc..dedf284f7 100644 --- a/source/modules/juce_gui_basics/mouse/juce_ComponentDragger.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp b/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp index 14bf227fe..4fc7e112d 100644 --- a/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h b/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h index 05793358e..437037d38 100644 --- a/source/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h b/source/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h index 886948e9f..b7be4d486 100644 --- a/source/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h b/source/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h index 465e234c9..e6491dcce 100644 --- a/source/modules/juce_gui_basics/mouse/juce_FileDragAndDropTarget.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_LassoComponent.h b/source/modules/juce_gui_basics/mouse/juce_LassoComponent.h index 77663e5e0..f2c278b11 100644 --- a/source/modules/juce_gui_basics/mouse/juce_LassoComponent.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp index 7716e519a..dad75c06d 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h b/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h index 0856fd656..4ad39b1de 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseCursor.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp index 799099564..126d0ada0 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseEvent.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseEvent.h b/source/modules/juce_gui_basics/mouse/juce_MouseEvent.h index 44a7a49f1..4643cc368 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseEvent.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp index 6ac495c0e..45b35219a 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h b/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h index 790c44b3a..f8c6a5e55 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseInactivityDetector.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 3717e0667..541d54218 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index 3a8d51ad2..b7e62e511 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseListener.cpp b/source/modules/juce_gui_basics/mouse/juce_MouseListener.cpp index abe9ff512..984a436f2 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseListener.cpp +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_MouseListener.h b/source/modules/juce_gui_basics/mouse/juce_MouseListener.h index fd467ba82..859b91dec 100644 --- a/source/modules/juce_gui_basics/mouse/juce_MouseListener.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/source/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index c78c97072..19211b015 100644 --- a/source/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h b/source/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h index 9cba6b261..088065c24 100644 --- a/source/modules/juce_gui_basics/mouse/juce_TextDragAndDropTarget.h +++ b/source/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/source/modules/juce_gui_basics/mouse/juce_TooltipClient.h b/source/modules/juce_gui_basics/mouse/juce_TooltipClient.h index 1219822a6..9f8c0b915 100644 --- a/source/modules/juce_gui_basics/mouse/juce_TooltipClient.h +++ b/source/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/source/modules/juce_gui_basics/native/juce_MultiTouchMapper.h b/source/modules/juce_gui_basics/native/juce_MultiTouchMapper.h index 5cca8b541..ed27ec197 100644 --- a/source/modules/juce_gui_basics/native/juce_MultiTouchMapper.h +++ b/source/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/source/modules/juce_gui_basics/native/juce_android_FileChooser.cpp b/source/modules/juce_gui_basics/native/juce_android_FileChooser.cpp index aa8ed4f72..27fb00d23 100644 --- a/source/modules/juce_gui_basics/native/juce_android_FileChooser.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp index f6970feac..54fa3ea60 100644 --- a/source/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/source/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index e9cb4a22d..d935d3cee 100644 --- a/source/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_ios_Windowing.mm b/source/modules/juce_gui_basics/native/juce_ios_Windowing.mm index a82990358..7007bcaef 100644 --- a/source/modules/juce_gui_basics/native/juce_ios_Windowing.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 8a485abc2..ceab19294 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_linux_X11.cpp b/source/modules/juce_gui_basics/native/juce_linux_X11.cpp index af009643d..e9625b65d 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_X11.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_linux_X11.h b/source/modules/juce_gui_basics/native/juce_linux_X11.h index 00c55bf12..f4235a7b9 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_X11.h +++ b/source/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/source/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp b/source/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp index 9c8e92b5b..8c3427b09 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_X11_Clipboard.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index 30367b17c..5b82036d7 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/source/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index f0f99d8d8..333850c5d 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/source/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index 8b5812cbe..2da59ea34 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm b/source/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm index 36e05219d..5cd37e0fb 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_MouseCursor.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 492bea9b1..1102b0c6d 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/source/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 3a6e57390..47b949054 100644 --- a/source/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/source/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/source/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/source/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index 53de33836..5db2b1266 100644 --- a/source/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/source/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/source/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/source/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 353263a82..bb352b23b 100644 --- a/source/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/source/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.getData())).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.getData())).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.getData()))); + results.add (File (String (files.get()))); } } + +} // namespace juce diff --git a/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 607d11b5d..3db70379e 100644 --- a/source/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/source/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.getData()); + return String (buffer.get()); } return {}; @@ -4166,3 +4198,5 @@ void MouseCursor::showInAllWindows() const { showInWindow (nullptr); } + +} // namespace juce diff --git a/source/modules/juce_gui_basics/positioning/juce_MarkerList.cpp b/source/modules/juce_gui_basics/positioning/juce_MarkerList.cpp index ee61180f0..7651dceed 100644 --- a/source/modules/juce_gui_basics/positioning/juce_MarkerList.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_MarkerList.h b/source/modules/juce_gui_basics/positioning/juce_MarkerList.h index 8d6da7f7e..c73f1f5ab 100644 --- a/source/modules/juce_gui_basics/positioning/juce_MarkerList.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp index ce7971693..fcb803baf 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h b/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h index 507dfcd49..55d3edfde 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinate.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index 7260710de..9afd38ee7 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h b/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h index 74abf4360..038f9dec6 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp index 92ad11fc4..3d9f6ed91 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h b/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h index 38ab861ea..afd88c9f0 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp index 5f9228c20..51895b298 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativePoint.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativePoint.h b/source/modules/juce_gui_basics/positioning/juce_RelativePoint.h index cb874f6e2..7bf446690 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativePoint.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp index 5f36d46ef..ee57e4889 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.h b/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.h index ff628db34..6e648a5fe 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativePointPath.h +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp b/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp index d2b73580e..574be9767 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp +++ b/source/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/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h b/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h index b634adc65..4113769de 100644 --- a/source/modules/juce_gui_basics/positioning/juce_RelativeRectangle.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp index bbf568a63..0e5dbdc08 100644 --- a/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h index 37e112c68..061541a70 100644 --- a/source/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp index 00343f65a..3d3a1b0ff 100644 --- a/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h index 64390c805..1415b8cd1 100644 --- a/source/modules/juce_gui_basics/properties/juce_ButtonPropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index 7c26d2636..c788ae392 100644 --- a/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h index c9ffe6d09..600a23cc7 100644 --- a/source/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp index 81ee114e9..19136a5e7 100644 --- a/source/modules/juce_gui_basics/properties/juce_PropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_PropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_PropertyComponent.h index c6e2ec6e2..263b3b5cf 100644 --- a/source/modules/juce_gui_basics/properties/juce_PropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp b/source/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp index a12c436a8..c2e5842d5 100644 --- a/source/modules/juce_gui_basics/properties/juce_PropertyPanel.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_PropertyPanel.h b/source/modules/juce_gui_basics/properties/juce_PropertyPanel.h index 24150eb1f..49ab8fde4 100644 --- a/source/modules/juce_gui_basics/properties/juce_PropertyPanel.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp index 4db6859a7..439ef36cf 100644 --- a/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h index 9a30dbbc2..944d6c1b9 100644 --- a/source/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 3193f110b..290b8fd47 100644 --- a/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h b/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h index 5a10ca6f5..8769ac1b9 100644 --- a/source/modules/juce_gui_basics/properties/juce_TextPropertyComponent.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/source/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 95702233a..2100c123b 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ComboBox.h b/source/modules/juce_gui_basics/widgets/juce_ComboBox.h index 09d02984f..209228762 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp b/source/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp index 77d2a9807..3dac30c5f 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ImageComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ImageComponent.h b/source/modules/juce_gui_basics/widgets/juce_ImageComponent.h index 3957d58f6..387263472 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ImageComponent.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_Label.cpp b/source/modules/juce_gui_basics/widgets/juce_Label.cpp index 7304090f0..403c7d3a4 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_Label.h b/source/modules/juce_gui_basics/widgets/juce_Label.h index 7b0aa30d6..34104cdf0 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Label.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 9c303a980..6bc513484 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/source/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -24,6 +24,9 @@ ============================================================================== */ +namespace juce +{ + class ListBox::RowComponent : public Component, public TooltipClient { @@ -788,16 +791,16 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee { bool eventWasUsed = false; - if (wheel.deltaX != 0.0f && viewport->getHorizontalScrollBar()->isVisible()) + if (wheel.deltaX != 0.0f && getHorizontalScrollBar().isVisible()) { eventWasUsed = true; - viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheel); + getHorizontalScrollBar().mouseWheelMove (e, wheel); } - if (wheel.deltaY != 0.0f && viewport->getVerticalScrollBar()->isVisible()) + if (wheel.deltaY != 0.0f && getVerticalScrollBar().isVisible()) { eventWasUsed = true; - viewport->getVerticalScrollBar()->mouseWheelMove (e, wheel); + getVerticalScrollBar().mouseWheelMove (e, wheel); } if (! eventWasUsed) @@ -831,8 +834,8 @@ void ListBox::setMinimumContentWidth (const int newMinimumWidth) int ListBox::getVisibleContentWidth() const noexcept { return viewport->getMaximumVisibleWidth(); } -ScrollBar* ListBox::getVerticalScrollBar() const noexcept { return viewport->getVerticalScrollBar(); } -ScrollBar* ListBox::getHorizontalScrollBar() const noexcept { return viewport->getHorizontalScrollBar(); } +ScrollBar& ListBox::getVerticalScrollBar() const noexcept { return viewport->getVerticalScrollBar(); } +ScrollBar& ListBox::getHorizontalScrollBar() const noexcept { return viewport->getHorizontalScrollBar(); } void ListBox::colourChanged() { @@ -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/source/modules/juce_gui_basics/widgets/juce_ListBox.h b/source/modules/juce_gui_basics/widgets/juce_ListBox.h index 31275dc68..3ff9865f3 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/source/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -379,11 +379,11 @@ public: /** Scrolls if necessary to make sure that a particular row is visible. */ void scrollToEnsureRowIsOnscreen (int row); - /** Returns a pointer to the vertical scrollbar. */ - ScrollBar* getVerticalScrollBar() const noexcept; + /** Returns a reference to the vertical scrollbar. */ + ScrollBar& getVerticalScrollBar() const noexcept; - /** Returns a pointer to the horizontal scrollbar. */ - ScrollBar* getHorizontalScrollBar() const noexcept; + /** Returns a reference to the horizontal scrollbar. */ + ScrollBar& getHorizontalScrollBar() const noexcept; /** Finds the row index that contains a given x,y position. The position is relative to the ListBox's top-left. @@ -598,3 +598,5 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBox) }; + +} // namespace juce diff --git a/source/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/source/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index c0ed84250..67f3e4885 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ProgressBar.h b/source/modules/juce_gui_basics/widgets/juce_ProgressBar.h index 5ce9410a3..d462be1d5 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ProgressBar.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_Slider.cpp b/source/modules/juce_gui_basics/widgets/juce_Slider.cpp index 5981b4a0b..5b40afb9c 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/source/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(); @@ -1598,6 +1602,10 @@ void Slider::mouseUp (const MouseEvent&) { pimpl->mouseUp(); } void Slider::mouseMove (const MouseEvent&) { pimpl->mouseMove(); } void Slider::mouseExit (const MouseEvent&) { pimpl->mouseExit(); } +// If popup display is enabled and set to show on mouse hover, this makes sure +// it is shown when dragging the mouse over a slider and releasing +void Slider::mouseEnter (const MouseEvent&) { pimpl->mouseMove(); } + void Slider::modifierKeysChanged (const ModifierKeys& modifiers) { if (isEnabled()) @@ -1621,3 +1629,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/source/modules/juce_gui_basics/widgets/juce_Slider.h b/source/modules/juce_gui_basics/widgets/juce_Slider.h index 63e583ab6..ff20d95bd 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/source/modules/juce_gui_basics/widgets/juce_Slider.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -910,6 +910,8 @@ public: void mouseMove (const MouseEvent&) override; /** @internal */ void mouseExit (const MouseEvent&) override; + /** @internal */ + void mouseEnter (const MouseEvent&) override; private: //============================================================================== @@ -940,3 +942,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/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 444e7d50c..b939a4ba7 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index 4efedbdf8..bccb5bbfe 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/source/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index b9b4b9f2a..f2d4b884b 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/source/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,28 +349,26 @@ 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()) - { - const Rectangle pos (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); + auto& scrollbar = getHorizontalScrollBar(); + 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(); - else if (pos.getRight() > x + w) - x += jmax (0.0, pos.getRight() - (x + w)); + if (pos.getX() < x) + x = pos.getX(); + else if (pos.getRight() > x + w) + x += jmax (0.0, pos.getRight() - (x + w)); - scrollbar->setCurrentRangeStart (x); - } + scrollbar.setCurrentRangeStart (x); } int TableListBox::getNumRows() @@ -461,10 +457,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 +468,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 +484,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/source/modules/juce_gui_basics/widgets/juce_TableListBox.h b/source/modules/juce_gui_basics/widgets/juce_TableListBox.h index 8454e959c..050d83101 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 133af341f..e07685f87 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/source/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 { @@ -36,7 +39,7 @@ struct TextAtom bool isWhitespace() const noexcept { return CharacterFunctions::isWhitespace (atomText[0]); } bool isNewLine() const noexcept { return atomText[0] == '\r' || atomText[0] == '\n'; } - String getText (const juce_wchar passwordCharacter) const + String getText (juce_wchar passwordCharacter) const { if (passwordCharacter == 0) return atomText; @@ -70,30 +73,29 @@ public: initialiseAtoms (text, passwordChar); } - UniformTextSection (const UniformTextSection& other) - : font (other.font), colour (other.colour) - { - atoms.addCopiesOf (other.atoms); - } + UniformTextSection (const UniformTextSection&) = default; + UniformTextSection (UniformTextSection&&) = default; + UniformTextSection& operator= (const UniformTextSection&) = delete; void append (UniformTextSection& other, const juce_wchar passwordChar) { - if (other.atoms.size() > 0) + if (! other.atoms.isEmpty()) { int i = 0; - if (auto* lastAtom = atoms.getLast()) + if (! atoms.isEmpty()) { - if (! CharacterFunctions::isWhitespace (lastAtom->atomText.getLastCharacter())) + auto& lastAtom = atoms.getReference (atoms.size() - 1); + + if (! CharacterFunctions::isWhitespace (lastAtom.atomText.getLastCharacter())) { - auto* first = other.atoms.getUnchecked(0); + auto& first = other.atoms.getReference(0); - if (! CharacterFunctions::isWhitespace (first->atomText[0])) + if (! CharacterFunctions::isWhitespace (first.atomText[0])) { - lastAtom->atomText += first->atomText; - lastAtom->numChars = (uint16) (lastAtom->numChars + first->numChars); - lastAtom->width = font.getStringWidthFloat (lastAtom->getText (passwordChar)); - delete first; + lastAtom.atomText += first.atomText; + lastAtom.numChars = (uint16) (lastAtom.numChars + first.numChars); + lastAtom.width = font.getStringWidthFloat (lastAtom.getText (passwordChar)); ++i; } } @@ -103,50 +105,48 @@ public: while (i < other.atoms.size()) { - atoms.add (other.atoms.getUnchecked(i)); + atoms.add (other.atoms.getReference(i)); ++i; } - - other.atoms.clear (false); } } - UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar) + UniformTextSection* split (int indexToBreakAt, juce_wchar passwordChar) { - UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar); + auto* section2 = new UniformTextSection (String(), font, colour, passwordChar); int index = 0; for (int i = 0; i < atoms.size(); ++i) { - auto* atom = atoms.getUnchecked(i); - auto nextIndex = index + atom->numChars; + auto& atom = atoms.getReference(i); + auto nextIndex = index + atom.numChars; if (index == indexToBreakAt) { for (int j = i; j < atoms.size(); ++j) section2->atoms.add (atoms.getUnchecked (j)); - atoms.removeRange (i, atoms.size(), false); + atoms.removeRange (i, atoms.size()); break; } - else if (indexToBreakAt >= index && indexToBreakAt < nextIndex) - { - auto* secondAtom = new TextAtom(); - secondAtom->atomText = atom->atomText.substring (indexToBreakAt - index); - secondAtom->width = font.getStringWidthFloat (secondAtom->getText (passwordChar)); - secondAtom->numChars = (uint16) secondAtom->atomText.length(); + if (indexToBreakAt >= index && indexToBreakAt < nextIndex) + { + TextAtom secondAtom; + secondAtom.atomText = atom.atomText.substring (indexToBreakAt - index); + secondAtom.width = font.getStringWidthFloat (secondAtom.getText (passwordChar)); + secondAtom.numChars = (uint16) secondAtom.atomText.length(); section2->atoms.add (secondAtom); - atom->atomText = atom->atomText.substring (0, indexToBreakAt - index); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) (indexToBreakAt - index); + atom.atomText = atom.atomText.substring (0, indexToBreakAt - index); + atom.width = font.getStringWidthFloat (atom.getText (passwordChar)); + atom.numChars = (uint16) (indexToBreakAt - index); for (int j = i + 1; j < atoms.size(); ++j) section2->atoms.add (atoms.getUnchecked (j)); - atoms.removeRange (i + 1, atoms.size(), false); + atoms.removeRange (i + 1, atoms.size()); break; } @@ -158,27 +158,27 @@ public: void appendAllText (MemoryOutputStream& mo) const { - for (int i = 0; i < atoms.size(); ++i) - mo << atoms.getUnchecked(i)->atomText; + for (auto& atom : atoms) + mo << atom.atomText; } - void appendSubstring (MemoryOutputStream& mo, const Range range) const + void appendSubstring (MemoryOutputStream& mo, Range range) const { int index = 0; - for (auto* atom : atoms) + for (auto& atom : atoms) { - auto nextIndex = index + atom->numChars; + auto nextIndex = index + atom.numChars; if (range.getStart() < nextIndex) { if (range.getEnd() <= index) break; - auto r = (range - index).getIntersectionWith (Range (0, (int) atom->numChars)); + auto r = (range - index).getIntersectionWith ({ 0, (int) atom.numChars }); if (! r.isEmpty()) - mo << atom->atomText.substring (r.getStart(), r.getEnd()); + mo << atom.atomText.substring (r.getStart(), r.getEnd()); } index = nextIndex; @@ -189,8 +189,8 @@ public: { int total = 0; - for (auto* atom : atoms) - total += atom->numChars; + for (auto& atom : atoms) + total += atom.numChars; return total; } @@ -201,15 +201,15 @@ public: { font = newFont; - for (auto* atom : atoms) - atom->width = newFont.getStringWidthFloat (atom->getText (passwordChar)); + for (auto& atom : atoms) + atom.width = newFont.getStringWidthFloat (atom.getText (passwordChar)); } } //============================================================================== Font font; Colour colour; - OwnedArray atoms; + Array atoms; private: void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) @@ -259,32 +259,31 @@ private: } } - auto* atom = atoms.add (new TextAtom()); - - atom->atomText = String (start, numChars); - atom->width = font.getStringWidthFloat (atom->getText (passwordChar)); - atom->numChars = (uint16) numChars; + TextAtom atom; + atom.atomText = String (start, numChars); + atom.width = font.getStringWidthFloat (atom.getText (passwordChar)); + atom.numChars = (uint16) numChars; + atoms.add (atom); } } - UniformTextSection& operator= (const UniformTextSection&); JUCE_LEAK_DETECTOR (UniformTextSection) }; //============================================================================== -class TextEditor::Iterator +struct TextEditor::Iterator { -public: - Iterator (const OwnedArray& sectionList, - float wrapWidth, juce_wchar passwordChar, float spacing) - : sections (sectionList), - wordWrapWidth (wrapWidth), - passwordCharacter (passwordChar), - lineSpacing (spacing) + Iterator (const TextEditor& ed) + : sections (ed.sections), + justification (ed.justification), + justificationWidth (ed.getJustificationWidth()), + wordWrapWidth (ed.getWordWrapWidth()), + passwordCharacter (ed.passwordCharacter), + lineSpacing (ed.lineSpacing) { jassert (wordWrapWidth > 0); - if (sections.size() > 0) + if (! sections.isEmpty()) { currentSection = sections.getUnchecked (sectionIndex); @@ -293,38 +292,20 @@ public: } } - Iterator (const Iterator& other) - : indexInText (other.indexInText), - lineY (other.lineY), - lineHeight (other.lineHeight), - maxDescent (other.maxDescent), - atomX (other.atomX), - atomRight (other.atomRight), - atom (other.atom), - currentSection (other.currentSection), - sections (other.sections), - sectionIndex (other.sectionIndex), - atomIndex (other.atomIndex), - wordWrapWidth (other.wordWrapWidth), - passwordCharacter (other.passwordCharacter), - lineSpacing (other.lineSpacing), - tempAtom (other.tempAtom) - { - } + Iterator (const Iterator&) = default; + Iterator& operator= (const Iterator&) = delete; //============================================================================== bool next() { if (atom == &tempAtom) { - const int numRemaining = tempAtom.atomText.length() - tempAtom.numChars; + auto numRemaining = tempAtom.atomText.length() - tempAtom.numChars; if (numRemaining > 0) { tempAtom.atomText = tempAtom.atomText.substring (tempAtom.numChars); - atomX = 0; - if (tempAtom.numChars > 0) lineY += lineHeight * lineSpacing; @@ -342,6 +323,7 @@ public: { tempAtom.numChars = (uint16) split; tempAtom.width = g.getGlyph (split - 1).getRight(); + atomX = getJustificationOffset (tempAtom.width); atomRight = atomX + tempAtom.width; return true; } @@ -371,13 +353,13 @@ public: } else { - auto* lastAtom = currentSection->atoms.getUnchecked (atomIndex); + auto& lastAtom = currentSection->atoms.getReference (atomIndex); - if (! lastAtom->isWhitespace()) + if (! lastAtom.isWhitespace()) { // handle the case where the last atom in a section is actually part of the same // word as the first atom of the next section... - float right = atomRight + lastAtom->width; + float right = atomRight + lastAtom.width; float lineHeight2 = lineHeight; float maxDescent2 = maxDescent; @@ -388,12 +370,12 @@ public: if (s->atoms.size() == 0) break; - auto* nextAtom = s->atoms.getUnchecked (0); + auto& nextAtom = s->atoms.getReference (0); - if (nextAtom->isWhitespace()) + if (nextAtom.isWhitespace()) break; - right += nextAtom->width; + right += nextAtom.width; lineHeight2 = jmax (lineHeight2, s->font.getHeight()); maxDescent2 = jmax (maxDescent2, s->font.getDescent()); @@ -423,7 +405,7 @@ public: beginNewLine(); } - atom = currentSection->atoms.getUnchecked (atomIndex); + atom = &(currentSection->atoms.getReference (atomIndex)); atomRight = atomX + atom->width; ++atomIndex; @@ -436,22 +418,22 @@ public: } else { - atomRight = atom->width; - - if (shouldWrap (atomRight)) // atom too big to fit on a line, so break it up.. + if (shouldWrap (atom->width)) // atom too big to fit on a line, so break it up.. { tempAtom = *atom; tempAtom.width = 0; tempAtom.numChars = 0; atom = &tempAtom; - if (atomX > 0) + if (atomX > justificationOffset) beginNewLine(); return next(); } beginNewLine(); + atomX = justificationOffset; + atomRight = atomX + atom->width; return true; } } @@ -461,20 +443,22 @@ public: void beginNewLine() { - atomX = 0; lineY += lineHeight * lineSpacing; + float lineWidth = 0; - int tempSectionIndex = sectionIndex; - int tempAtomIndex = atomIndex; + auto tempSectionIndex = sectionIndex; + auto tempAtomIndex = atomIndex; auto* section = sections.getUnchecked (tempSectionIndex); lineHeight = section->font.getHeight(); maxDescent = section->font.getDescent(); - float x = (atom != nullptr) ? atom->width : 0; + float nextLineWidth = (atom != nullptr) ? atom->width : 0.0f; - while (! shouldWrap (x)) + while (! shouldWrap (nextLineWidth)) { + lineWidth = nextLineWidth; + if (tempSectionIndex >= sections.size()) break; @@ -490,14 +474,13 @@ public: checkSize = true; } - auto* nextAtom = section->atoms.getUnchecked (tempAtomIndex); - - if (nextAtom == nullptr) + if (! isPositiveAndBelow (tempAtomIndex, section->atoms.size())) break; - x += nextAtom->width; + auto& nextAtom = section->atoms.getReference (tempAtomIndex); + nextLineWidth += nextAtom.width; - if (shouldWrap (x) || nextAtom->isNewLine()) + if (shouldWrap (nextLineWidth) || nextAtom.isNewLine()) break; if (checkSize) @@ -508,6 +491,20 @@ public: ++tempAtomIndex; } + + justificationOffset = getJustificationOffset (lineWidth); + atomX = justificationOffset; + } + + float getJustificationOffset (float lineWidth) const + { + if (justification.getOnlyHorizontalFlags() == Justification::horizontallyCentred) + return jmax (0.0f, (justificationWidth - lineWidth) * 0.5f); + + if (justification.getOnlyHorizontalFlags() == Justification::right) + return jmax (0.0f, justificationWidth - lineWidth); + + return 0; } //============================================================================== @@ -532,28 +529,26 @@ public: } } - void addSelection (RectangleList& area, const Range selected) const + void addSelection (RectangleList& area, Range selected) const { - const float startX = indexToX (selected.getStart()); - const float endX = indexToX (selected.getEnd()); + auto startX = indexToX (selected.getStart()); + auto endX = indexToX (selected.getEnd()); area.add (startX, lineY, endX - startX, lineHeight * lineSpacing); } - void drawUnderline (Graphics& g, const Range underline, const Colour colour) const + void drawUnderline (Graphics& g, Range underline, Colour colour) const { - const int startX = roundToInt (indexToX (underline.getStart())); - const int endX = roundToInt (indexToX (underline.getEnd())); - const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); + auto startX = roundToInt (indexToX (underline.getStart())); + auto endX = roundToInt (indexToX (underline.getEnd())); + auto baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); Graphics::ScopedSaveState state (g); - g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); - g.fillCheckerBoard (Rectangle (endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); + g.reduceClipRegion ({ startX, baselineY, endX - startX, 1 }); + g.fillCheckerBoard ({ endX, baselineY + 1 }, 3, 1, colour, Colours::transparentBlack); } - void drawSelectedText (Graphics& g, - const Range selected, - const Colour selectedTextColour) const + void drawSelectedText (Graphics& g, Range selected, Colour selectedTextColour) const { if (passwordCharacter != 0 || ! atom->isWhitespace()) { @@ -588,7 +583,7 @@ public: } //============================================================================== - float indexToX (const int indexToFind) const + float indexToX (int indexToFind) const { if (indexToFind <= indexInText) return atomX; @@ -607,7 +602,7 @@ public: return jmin (atomRight, g.getGlyph (indexToFind - indexInText).getLeft()); } - int xToIndex (const float xToFind) const + int xToIndex (float xToFind) const { if (xToFind <= atomX || atom->isNewLine()) return indexInText; @@ -620,7 +615,7 @@ public: atom->getText (passwordCharacter), atomX, 0.0f); - const int numGlyphs = g.getNumGlyphs(); + auto numGlyphs = g.getNumGlyphs(); int j; for (j = 0; j < numGlyphs; ++j) @@ -635,28 +630,26 @@ public: } //============================================================================== - bool getCharPosition (const int index, float& cx, float& cy, float& lineHeightFound) + bool getCharPosition (int index, Point& anchor, float& lineHeightFound) { while (next()) { if (indexInText + atom->numChars > index) { - cx = indexToX (index); - cy = lineY; + anchor = { indexToX (index), lineY }; lineHeightFound = lineHeight; return true; } } - cx = atomX; - cy = lineY; + anchor = { atomX, lineY }; lineHeightFound = lineHeight; return false; } //============================================================================== int indexInText = 0; - float lineY = 0, lineHeight = 0, maxDescent = 0; + float lineY = 0, justificationOffset = 0, lineHeight = 0, maxDescent = 0; float atomX = 0, atomRight = 0; const TextAtom* atom = nullptr; const UniformTextSection* currentSection = nullptr; @@ -664,13 +657,12 @@ public: private: const OwnedArray& sections; int sectionIndex = 0, atomIndex = 0; - const float wordWrapWidth; + Justification justification; + const float justificationWidth, wordWrapWidth; const juce_wchar passwordCharacter; const float lineSpacing; TextAtom tempAtom; - Iterator& operator= (const Iterator&) = delete; - void moveToEndOfLastAtom() { if (atom != nullptr) @@ -695,16 +687,10 @@ private: //============================================================================== -class TextEditor::InsertAction : public UndoableAction +struct TextEditor::InsertAction : public UndoableAction { -public: - InsertAction (TextEditor& ed, - const String& newText, - const int insertPos, - const Font& newFont, - const Colour newColour, - const int oldCaret, - const int newCaret) + InsertAction (TextEditor& ed, const String& newText, int insertPos, + const Font& newFont, Colour newColour, int oldCaret, int newCaret) : owner (ed), text (newText), insertIndex (insertPos), @@ -723,7 +709,7 @@ public: bool undo() override { - owner.remove (Range (insertIndex, insertIndex + text.length()), 0, oldCaretPos); + owner.remove ({ insertIndex, insertIndex + text.length() }, 0, oldCaretPos); return true; } @@ -743,13 +729,9 @@ private: }; //============================================================================== -class TextEditor::RemoveAction : public UndoableAction +struct TextEditor::RemoveAction : public UndoableAction { -public: - RemoveAction (TextEditor& ed, - const Range rangeToRemove, - const int oldCaret, - const int newCaret, + RemoveAction (TextEditor& ed, Range rangeToRemove, int oldCaret, int newCaret, const Array& oldSections) : owner (ed), range (rangeToRemove), @@ -792,11 +774,10 @@ private: }; //============================================================================== -class TextEditor::TextHolderComponent : public Component, - public Timer, - public Value::Listener +struct TextEditor::TextHolderComponent : public Component, + public Timer, + public Value::Listener { -public: TextHolderComponent (TextEditor& ed) : owner (ed) { setWantsKeyboardFocus (false); @@ -831,16 +812,14 @@ public: owner.textWasChangedByValue(); } -private: TextEditor& owner; JUCE_DECLARE_NON_COPYABLE (TextHolderComponent) }; //============================================================================== -class TextEditorViewport : public Viewport +struct TextEditor::TextEditorViewport : public Viewport { -public: TextEditorViewport (TextEditor& ed) : owner (ed) {} void visibleAreaChanged (const Rectangle&) override @@ -848,7 +827,7 @@ public: if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars // appear and disappear, causing the wrap width to change. { - const float wordWrapWidth = owner.getWordWrapWidth(); + auto wordWrapWidth = owner.getWordWrapWidth(); if (wordWrapWidth != lastWordWrapWidth) { @@ -879,7 +858,7 @@ namespace TextEditorDefs const int maxActionsPerTransaction = 100; - static int getCharacterCategory (const juce_wchar character) + static int getCharacterCategory (juce_wchar character) noexcept { return CharacterFunctions::isLetterOrDigit (character) ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); @@ -887,14 +866,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)); @@ -981,7 +956,7 @@ void TextEditor::setScrollbarsShown (bool shown) } } -void TextEditor::setReadOnly (const bool shouldBeReadOnly) +void TextEditor::setReadOnly (bool shouldBeReadOnly) { if (readOnly != shouldBeReadOnly) { @@ -1000,26 +975,35 @@ bool TextEditor::isTextInputActive() const return ! isReadOnly(); } -void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) +void TextEditor::setReturnKeyStartsNewLine (bool shouldStartNewLine) { returnKeyStartsNewLine = shouldStartNewLine; } -void TextEditor::setTabKeyUsedAsCharacter (const bool shouldTabKeyBeUsed) +void TextEditor::setTabKeyUsedAsCharacter (bool shouldTabKeyBeUsed) { tabKeyUsed = shouldTabKeyBeUsed; } -void TextEditor::setPopupMenuEnabled (const bool b) +void TextEditor::setPopupMenuEnabled (bool b) { popupMenuEnabled = b; } -void TextEditor::setSelectAllWhenFocused (const bool b) +void TextEditor::setSelectAllWhenFocused (bool b) { selectAllTextWhenFocused = b; } +void TextEditor::setJustification (Justification j) +{ + if (justification != j) + { + justification = j; + resized(); + } +} + //============================================================================== void TextEditor::setFont (const Font& newFont) { @@ -1057,16 +1041,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(); @@ -1083,7 +1059,7 @@ void TextEditor::enablementChanged() repaint(); } -void TextEditor::setCaretVisible (const bool shouldCaretBeVisible) +void TextEditor::setCaretVisible (bool shouldCaretBeVisible) { if (caretVisible != shouldCaretBeVisible) { @@ -1136,7 +1112,7 @@ void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) inputFilter.set (newFilter, takeOwnership); } -void TextEditor::setInputRestrictions (const int maxLen, const String& chars) +void TextEditor::setInputRestrictions (int maxLen, const String& chars) { setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true); } @@ -1147,7 +1123,7 @@ void TextEditor::setTextToShowWhenEmpty (const String& text, Colour colourToUse) colourForTextWhenEmpty = colourToUse; } -void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) +void TextEditor::setPasswordCharacter (juce_wchar newPasswordCharacter) { if (passwordCharacter != newPasswordCharacter) { @@ -1156,7 +1132,7 @@ void TextEditor::setPasswordCharacter (const juce_wchar newPasswordCharacter) } } -void TextEditor::setScrollBarThickness (const int newThicknessPixels) +void TextEditor::setScrollBarThickness (int newThicknessPixels) { viewport->setScrollBarThickness (newThicknessPixels); } @@ -1169,10 +1145,9 @@ void TextEditor::clear() undoManager.clearUndoHistory(); } -void TextEditor::setText (const String& newText, - const bool sendTextChangeMessage) +void TextEditor::setText (const String& newText, bool sendTextChangeMessage) { - const int newLength = newText.length(); + auto newLength = newText.length(); if (newLength != getTotalNumChars() || getText() != newText) { @@ -1182,7 +1157,7 @@ void TextEditor::setText (const String& newText, textValue = newText; auto oldCursorPos = caretPosition; - const bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); + bool cursorWasAtEnd = oldCursorPos >= getTotalNumChars(); clearInternal (nullptr); insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition); @@ -1264,21 +1239,20 @@ void TextEditor::timerCallbackInt() newTransaction(); } -void TextEditor::repaintText (const Range range) +void TextEditor::repaintText (Range range) { if (! range.isEmpty()) { - float x = 0, y = 0, lh = currentFont.getHeight(); - - const float wordWrapWidth = getWordWrapWidth(); + auto lh = currentFont.getHeight(); + auto wordWrapWidth = getWordWrapWidth(); if (wordWrapWidth > 0) { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (range.getStart(), x, y, lh); + Point anchor; + Iterator i (*this); + i.getCharPosition (range.getStart(), anchor, lh); - auto y1 = (int) y; + auto y1 = (int) anchor.y; int y2; if (range.getEnd() >= getTotalNumChars()) @@ -1287,8 +1261,8 @@ void TextEditor::repaintText (const Range range) } else { - i.getCharPosition (range.getEnd(), x, y, lh); - y2 = (int) (y + lh * 2.0f); + i.getCharPosition (range.getEnd(), anchor, lh); + y2 = (int) (anchor.y + lh * 2.0f); } textHolder->repaint (0, y1, textHolder->getWidth(), y2 - y1); @@ -1325,7 +1299,7 @@ void TextEditor::setCaretPosition (const int newIndex) void TextEditor::moveCaretToEnd() { - moveCaretTo (std::numeric_limits::max(), false); + setCaretPosition (std::numeric_limits::max()); } void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, @@ -1335,8 +1309,8 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, updateCaretPosition(); auto caretPos = getCaretRectangle(); - int vx = caretPos.getX() - desiredCaretX; - int vy = caretPos.getY() - desiredCaretY; + auto vx = caretPos.getX() - desiredCaretX; + auto vy = caretPos.getY() - desiredCaretY; if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) vx += desiredCaretX - proportionOfWidth (0.2f); @@ -1364,11 +1338,11 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, Rectangle TextEditor::getCaretRectangle() { - float cursorX, cursorY; - float cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) - getCharPosition (caretPosition, cursorX, cursorY, cursorHeight); + Point anchor; + auto cursorHeight = currentFont.getHeight(); // (in case the text is empty and the call below doesn't set this value) + getCharPosition (caretPosition, anchor, cursorHeight); - return { roundToInt (cursorX), roundToInt (cursorY), 2, roundToInt (cursorHeight) }; + return { roundToInt (anchor.x), roundToInt (anchor.y), 2, roundToInt (cursorHeight) }; } //============================================================================== @@ -1376,26 +1350,27 @@ enum { rightEdgeSpace = 2 }; float TextEditor::getWordWrapWidth() const { - return wordWrap ? (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)) + return wordWrap ? getJustificationWidth() : std::numeric_limits::max(); } -void TextEditor::updateTextHolderSize() +float TextEditor::getJustificationWidth() const { - const float wordWrapWidth = getWordWrapWidth(); + return (float) (viewport->getMaximumVisibleWidth() - (leftIndent + rightEdgeSpace + 1)); +} - if (wordWrapWidth > 0) +void TextEditor::updateTextHolderSize() +{ + if (getWordWrapWidth() > 0) { - float maxWidth = 0.0f; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + float maxWidth = getJustificationWidth(); + Iterator i (*this); while (i.next()) maxWidth = jmax (maxWidth, i.atomRight); - const int w = leftIndent + roundToInt (maxWidth); - const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, - currentFont.getHeight())); + auto w = leftIndent + roundToInt (maxWidth); + auto h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, currentFont.getHeight())); textHolder->setSize (w + rightEdgeSpace, h + 1); // (allows a bit of space for the cursor to be at the right-hand-edge) } @@ -1404,7 +1379,7 @@ void TextEditor::updateTextHolderSize() int TextEditor::getTextWidth() const { return textHolder->getWidth(); } int TextEditor::getTextHeight() const { return textHolder->getHeight(); } -void TextEditor::setIndents (const int newLeftIndent, const int newTopIndent) +void TextEditor::setIndents (int newLeftIndent, int newTopIndent) { leftIndent = newLeftIndent; topIndent = newTopIndent; @@ -1576,15 +1551,12 @@ void TextEditor::cut() //============================================================================== void TextEditor::drawContent (Graphics& g) { - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) + if (getWordWrapWidth() > 0) { g.setOrigin (leftIndent, topIndent); auto clip = g.getClipBounds(); Colour selectedTextColour; - - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); + Iterator i (*this); if (! selection.isEmpty()) { @@ -1594,7 +1566,7 @@ void TextEditor::drawContent (Graphics& g) while (i2.next() && i2.lineY < clip.getBottom()) { if (i2.lineY + i2.lineHeight >= clip.getY() - && selection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + && selection.intersects ({ i2.indexInText, i2.indexInText + i2.atom->numChars })) { i2.addSelection (selectionArea, selection); } @@ -1612,7 +1584,7 @@ void TextEditor::drawContent (Graphics& g) { if (i.lineY + i.lineHeight >= clip.getY()) { - if (selection.intersects (Range (i.indexInText, i.indexInText + i.atom->numChars))) + if (selection.intersects ({ i.indexInText, i.indexInText + i.atom->numChars })) { i.drawSelectedText (g, selection, selectedTextColour); lastSection = nullptr; @@ -1624,16 +1596,14 @@ void TextEditor::drawContent (Graphics& g) } } - for (int j = underlinedSections.size(); --j >= 0;) + for (auto& underlinedSection : underlinedSections) { - const Range underlinedSection = underlinedSections.getReference (j); - - Iterator i2 (sections, wordWrapWidth, passwordCharacter, lineSpacing); + Iterator i2 (*this); while (i2.next() && i2.lineY < clip.getBottom()) { if (i2.lineY + i2.lineHeight >= clip.getY() - && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) + && underlinedSection.intersects ({ i2.indexInText, i2.indexInText + i2.atom->numChars })) { i2.drawUnderline (g, underlinedSection, findColour (textColourId)); } @@ -1773,8 +1743,9 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) while (tokenEnd < totalLength) { + auto c = t[tokenEnd]; + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenEnd]; if (CharacterFunctions::isLetterOrDigit (c) || c > 128) ++tokenEnd; else @@ -1785,8 +1756,9 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) while (tokenStart > 0) { + auto c = t[tokenStart - 1]; + // (note the slight bodge here - it's because iswalnum only checks for alphabetic chars in the current locale) - const juce_wchar c = t [tokenStart - 1]; if (CharacterFunctions::isLetterOrDigit (c) || c > 128) --tokenStart; else @@ -1797,7 +1769,8 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) { while (tokenEnd < totalLength) { - const juce_wchar c = t [tokenEnd]; + auto c = t[tokenEnd]; + if (c != '\r' && c != '\n') ++tokenEnd; else @@ -1806,7 +1779,8 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) while (tokenStart > 0) { - const juce_wchar c = t [tokenStart - 1]; + auto c = t[tokenStart - 1]; + if (c != '\r' && c != '\n') --tokenStart; else @@ -1835,7 +1809,7 @@ bool TextEditor::moveCaretWithTransaction (const int newPos, const bool selectin bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) { - int pos = getCaretPosition(); + auto pos = getCaretPosition(); if (moveInWholeWordSteps) pos = findWordBreakBefore (pos); @@ -1847,7 +1821,7 @@ bool TextEditor::moveCaretLeft (bool moveInWholeWordSteps, bool selecting) bool TextEditor::moveCaretRight (bool moveInWholeWordSteps, bool selecting) { - int pos = getCaretPosition(); + auto pos = getCaretPosition(); if (moveInWholeWordSteps) pos = findWordBreakAfter (pos); @@ -1895,8 +1869,7 @@ bool TextEditor::pageDown (bool selecting) void TextEditor::scrollByLines (int deltaLines) { - if (auto* scrollbar = viewport->getVerticalScrollBar()) - scrollbar->moveScrollbarInSteps (deltaLines); + viewport->getVerticalScrollBar().moveScrollbarInSteps (deltaLines); } bool TextEditor::scrollDown() @@ -1938,7 +1911,7 @@ bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) if (moveInWholeWordSteps) moveCaretTo (findWordBreakBefore (getCaretPosition()), true); else if (selection.isEmpty() && selection.getStart() > 0) - selection = Range (selection.getEnd() - 1, selection.getEnd()); + selection = { selection.getEnd() - 1, selection.getEnd() }; cut(); return true; @@ -1947,7 +1920,7 @@ bool TextEditor::deleteBackwards (bool moveInWholeWordSteps) bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/) { if (selection.isEmpty() && selection.getStart() < getTotalNumChars()) - selection = Range (selection.getStart(), selection.getStart() + 1); + selection = { selection.getStart(), selection.getStart() + 1 }; cut(); return true; @@ -2002,7 +1975,9 @@ bool TextEditor::keyPressed (const KeyPress& key) newTransaction(); if (returnKeyStartsNewLine) + { insertTextAtCaret ("\n"); + } else { returnPressed(); @@ -2145,15 +2120,11 @@ UndoManager* TextEditor::getUndoManager() noexcept void TextEditor::clearInternal (UndoManager* const um) { - remove (Range (0, getTotalNumChars()), um, caretPosition); + remove ({ 0, getTotalNumChars() }, um, caretPosition); } -void TextEditor::insert (const String& text, - const int insertIndex, - const Font& font, - const Colour colour, - UndoManager* const um, - const int caretPositionToMoveTo) +void TextEditor::insert (const String& text, int insertIndex, const Font& font, + Colour colour, UndoManager* um, int caretPositionToMoveTo) { if (text.isNotEmpty()) { @@ -2167,8 +2138,8 @@ void TextEditor::insert (const String& text, } else { - repaintText (Range (insertIndex, getTotalNumChars())); // must do this before and after changing the data, in case - // a line gets moved due to word wrap + repaintText ({ insertIndex, getTotalNumChars() }); // must do this before and after changing the data, in case + // a line gets moved due to word wrap int index = 0; int nextIndex = 0; @@ -2182,7 +2153,8 @@ void TextEditor::insert (const String& text, sections.insert (i, new UniformTextSection (text, font, colour, passwordCharacter)); break; } - else if (insertIndex > index && insertIndex < nextIndex) + + if (insertIndex > index && insertIndex < nextIndex) { splitSection (i, insertIndex - index); sections.insert (i + 1, new UniformTextSection (text, font, colour, passwordCharacter)); @@ -2202,12 +2174,12 @@ void TextEditor::insert (const String& text, updateTextHolderSize(); moveCaretTo (caretPositionToMoveTo, false); - repaintText (Range (insertIndex, getTotalNumChars())); + repaintText ({ insertIndex, getTotalNumChars() }); } } } -void TextEditor::reinsert (const int insertIndex, const OwnedArray& sectionsToInsert) +void TextEditor::reinsert (int insertIndex, const OwnedArray& sectionsToInsert) { int index = 0; int nextIndex = 0; @@ -2223,7 +2195,8 @@ void TextEditor::reinsert (const int insertIndex, const OwnedArray index && insertIndex < nextIndex) + + if (insertIndex > index && insertIndex < nextIndex) { splitSection (i, insertIndex - index); @@ -2237,10 +2210,8 @@ void TextEditor::reinsert (const int insertIndex, const OwnedArray range, UndoManager* const um, const int care for (int i = 0; i < sections.size(); ++i) { - const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); + auto nextIndex = index + sections.getUnchecked(i)->getTotalLength(); if (range.getStart() > index && range.getStart() < nextIndex) { @@ -2282,12 +2253,11 @@ void TextEditor::remove (Range range, UndoManager* const um, const int care { Array removedSections; - for (int i = 0; i < sections.size(); ++i) + for (auto* section : sections) { if (range.getEnd() <= range.getStart()) break; - auto* section = sections.getUnchecked (i); auto nextIndex = index + section->getTotalLength(); if (range.getStart() <= index && range.getEnd() >= nextIndex) @@ -2309,8 +2279,7 @@ void TextEditor::remove (Range range, UndoManager* const um, const int care for (int i = 0; i < sections.size(); ++i) { auto* section = sections.getUnchecked (i); - - const int nextIndex = index + section->getTotalLength(); + auto nextIndex = index + section->getTotalLength(); if (remainingRange.getStart() <= index && remainingRange.getEnd() >= nextIndex) { @@ -2334,7 +2303,7 @@ void TextEditor::remove (Range range, UndoManager* const um, const int care moveCaretTo (caretPositionToMoveTo, false); - repaintText (Range (range.getStart(), getTotalNumChars())); + repaintText ({ range.getStart(), getTotalNumChars() }); } } } @@ -2345,8 +2314,8 @@ String TextEditor::getText() const MemoryOutputStream mo; mo.preallocate ((size_t) getTotalNumChars()); - for (int i = 0; i < sections.size(); ++i) - sections.getUnchecked (i)->appendAllText (mo); + for (auto* s : sections) + s->appendAllText (mo); return mo.toUTF8(); } @@ -2361,9 +2330,8 @@ String TextEditor::getTextInRange (const Range& range) const int index = 0; - for (int i = 0; i < sections.size(); ++i) + for (auto* s : sections) { - auto* s = sections.getUnchecked (i); auto nextIndex = index + s->getTotalLength(); if (range.getStart() < nextIndex) @@ -2391,8 +2359,8 @@ int TextEditor::getTotalNumChars() const { totalNumChars = 0; - for (int i = sections.size(); --i >= 0;) - totalNumChars += sections.getUnchecked (i)->getTotalLength(); + for (auto* s : sections) + totalNumChars += s->getTotalLength(); } return totalNumChars; @@ -2403,32 +2371,34 @@ bool TextEditor::isEmpty() const return getTotalNumChars() == 0; } -void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& lineHeight) const +void TextEditor::getCharPosition (int index, Point& anchor, float& lineHeight) const { - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0 && sections.size() > 0) + if (getWordWrapWidth() <= 0) { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - i.getCharPosition (index, cx, cy, lineHeight); + anchor = {}; + lineHeight = currentFont.getHeight(); } else { - cx = cy = 0; - lineHeight = currentFont.getHeight(); + Iterator i (*this); + + if (sections.isEmpty()) + { + anchor = { i.getJustificationOffset (0), 0 }; + lineHeight = currentFont.getHeight(); + } + else + { + i.getCharPosition (index, anchor, lineHeight); + } } } int TextEditor::indexAtPosition (const float x, const float y) { - const float wordWrapWidth = getWordWrapWidth(); - - if (wordWrapWidth > 0) + if (getWordWrapWidth() > 0) { - Iterator i (sections, wordWrapWidth, passwordCharacter, lineSpacing); - - while (i.next()) + for (Iterator i (*this); i.next();) { if (i.lineY + i.lineHeight > y) { @@ -2450,14 +2420,14 @@ int TextEditor::indexAtPosition (const float x, const float y) //============================================================================== int TextEditor::findWordBreakAfter (const int position) const { - auto t = getTextInRange (Range (position, position + 512)); + auto t = getTextInRange ({ position, position + 512 }); auto totalLength = t.length(); int i = 0; while (i < totalLength && CharacterFunctions::isWhitespace (t[i])) ++i; - const int type = TextEditorDefs::getCharacterCategory (t[i]); + auto type = TextEditorDefs::getCharacterCategory (t[i]); while (i < totalLength && type == TextEditorDefs::getCharacterCategory (t[i])) ++i; @@ -2474,7 +2444,7 @@ int TextEditor::findWordBreakBefore (const int position) const return 0; auto startOfBuffer = jmax (0, position - 512); - auto t = getTextInRange (Range (startOfBuffer, position)); + auto t = getTextInRange ({ startOfBuffer, position }); int i = position - startOfBuffer; @@ -2519,3 +2489,5 @@ void TextEditor::coalesceSimilarSections() } } } + +} // namespace juce diff --git a/source/modules/juce_gui_basics/widgets/juce_TextEditor.h b/source/modules/juce_gui_basics/widgets/juce_TextEditor.h index 30a646514..3315c583c 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/source/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -24,8 +24,8 @@ ============================================================================== */ -#pragma once - +namespace juce +{ //============================================================================== /** @@ -475,8 +475,10 @@ public: */ void setScrollToShowCursor (bool shouldScrollToShowCaret); - /** Sets the line spacing of the TextEditor. + /** Modifies the horizontal justification of the text within the editor window. */ + void setJustification (Justification newJustification); + /** Sets the line spacing of the TextEditor. The default (and minimum) value is 1.0 and values > 1.0 will increase the line spacing as a multiple of the line height e.g. for double-spacing call this method with an argument of 2.0. */ @@ -651,8 +653,6 @@ public: /** @internal */ void enablementChanged() override; /** @internal */ - void colourChanged() override; - /** @internal */ void lookAndFeelChanged() override; /** @internal */ void parentHierarchyChanged() override; @@ -682,17 +682,17 @@ protected: private: //============================================================================== - class Iterator; JUCE_PUBLIC_IN_DLL_BUILD (class UniformTextSection) - class TextHolderComponent; - class InsertAction; - class RemoveAction; - friend class InsertAction; - friend class RemoveAction; + struct Iterator; + struct TextHolderComponent; + struct TextEditorViewport; + struct InsertAction; + struct RemoveAction; ScopedPointer viewport; TextHolderComponent* textHolder; BorderSize borderSize { 1, 1, 1, 3 }; + Justification justification { Justification::left }; bool readOnly = false; bool caretVisible = true; @@ -723,18 +723,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); @@ -743,10 +745,10 @@ private: void coalesceSimilarSections(); void splitSection (int sectionIndex, int charToSplitAt); void clearInternal (UndoManager*); - void insert (const String&, int insertIndex, const Font&, const Colour, UndoManager*, int newCaretPos); + void insert (const String&, int insertIndex, const Font&, Colour, UndoManager*, int newCaretPos); void reinsert (int insertIndex, const OwnedArray&); - void remove (Range range, UndoManager*, int caretPositionToMoveTo); - void getCharPosition (int index, float& x, float& y, float& lineHeight) const; + void remove (Range, UndoManager*, int caretPositionToMoveTo); + void getCharPosition (int index, Point&, float& lineHeight) const; void updateCaretPosition(); void updateValueFromText(); void textWasChangedByValue(); @@ -754,11 +756,10 @@ private: int findWordBreakAfter (int position) const; int findWordBreakBefore (int position) const; bool moveCaretWithTransaction (int newPos, bool selecting); - friend class TextHolderComponent; - friend class TextEditorViewport; void drawContent (Graphics&); void updateTextHolderSize(); float getWordWrapWidth() const; + float getJustificationWidth() const; void timerCallbackInt(); void repaintText (Range); void scrollByLines (int deltaLines); @@ -770,3 +771,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/source/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/source/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 258d0e696..aa5126ae1 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_Toolbar.h b/source/modules/juce_gui_basics/widgets/juce_Toolbar.h index 106588635..4950dd5b3 100644 --- a/source/modules/juce_gui_basics/widgets/juce_Toolbar.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp b/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp index 707d63d2c..154ef827e 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index 76248b59f..662ca6bc2 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h b/source/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h index f9d152004..d6c4fdde8 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ToolbarItemFactory.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp b/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp index c0b47edb9..474e4742a 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h b/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h index 8321657d0..a281baa25 100644 --- a/source/modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.h +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/source/modules/juce_gui_basics/widgets/juce_TreeView.cpp index d4a24d59d..c34e7ec5f 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/source/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/source/modules/juce_gui_basics/widgets/juce_TreeView.h b/source/modules/juce_gui_basics/widgets/juce_TreeView.h index e2f407c9c..1db4dacd3 100644 --- a/source/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 87983568c..b019f7d34 100644 --- a/source/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_AlertWindow.h b/source/modules/juce_gui_basics/windows/juce_AlertWindow.h index cd8426cb7..e3f3ce569 100644 --- a/source/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_CallOutBox.cpp b/source/modules/juce_gui_basics/windows/juce_CallOutBox.cpp index 6ab46c14d..d867b8748 100644 --- a/source/modules/juce_gui_basics/windows/juce_CallOutBox.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_CallOutBox.h b/source/modules/juce_gui_basics/windows/juce_CallOutBox.h index 728b14af6..0a52efbf3 100644 --- a/source/modules/juce_gui_basics/windows/juce_CallOutBox.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/source/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 19e336199..feb9aacd0 100644 --- a/source/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/source/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 65e46e69c..819cc8d93 100644 --- a/source/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_DialogWindow.cpp b/source/modules/juce_gui_basics/windows/juce_DialogWindow.cpp index be3d9e58d..030bce8ae 100644 --- a/source/modules/juce_gui_basics/windows/juce_DialogWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_DialogWindow.h b/source/modules/juce_gui_basics/windows/juce_DialogWindow.h index 44b662b26..fba819e21 100644 --- a/source/modules/juce_gui_basics/windows/juce_DialogWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/source/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index ad5d6e786..c81be075a 100644 --- a/source/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/source/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 9c48db130..d6da6cd36 100644 --- a/source/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_NativeMessageBox.h b/source/modules/juce_gui_basics/windows/juce_NativeMessageBox.h index 2aa4d49e9..52e6d5187 100644 --- a/source/modules/juce_gui_basics/windows/juce_NativeMessageBox.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/source/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 278bdd810..b12c93bb3 100644 --- a/source/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/source/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 4e78c69ae..a30af7478 100644 --- a/source/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp b/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp index 57b3ba79a..eba08a01f 100644 --- a/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h b/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h index 78e913a90..d996157be 100644 --- a/source/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/source/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index abf71124a..65db7ff94 100644 --- a/source/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_TooltipWindow.h b/source/modules/juce_gui_basics/windows/juce_TooltipWindow.h index 42d60a33f..7ef54a5a3 100644 --- a/source/modules/juce_gui_basics/windows/juce_TooltipWindow.h +++ b/source/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/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp b/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp index c32ea2a37..1f0e13524 100644 --- a/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp +++ b/source/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/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.h b/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.h index 9ee8d9376..51b146d72 100644 --- a/source/modules/juce_gui_basics/windows/juce_TopLevelWindow.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp b/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp index 11555a2f0..778dde8f4 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h b/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h index 88111a8e8..0eaa42046 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h b/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h index f4ddfdf5e..9eb2d8d0d 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniserFunctions.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index 57bc14a2e..713b933cf 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.h b/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.h index f0fbd1a00..7c18a00f6 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index c001c9b4e..5d9feeb41 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index e0a1265c3..ffa33c4ea 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h b/source/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h index 18834c725..5e5e1ab3e 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeTokeniser.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp b/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp index d4d10478e..f01bdff66 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h b/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h index 35f63eef5..5628cfa59 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp b/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp index 974b7ce55..192598db5 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.cpp +++ b/source/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/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h b/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h index 20d06fba3..9fb3f8791 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_XMLCodeTokeniser.h +++ b/source/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/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp b/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp index 4c34585ca..2edffd32c 100644 --- a/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.cpp +++ b/source/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/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.h b/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.h index 1191f93c2..42e39270d 100644 --- a/source/modules/juce_gui_extra/documents/juce_FileBasedDocument.h +++ b/source/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/source/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h b/source/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h index ed1ce9734..b4a8f9cba 100644 --- a/source/modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h +++ b/source/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/source/modules/juce_gui_extra/embedding/juce_NSViewComponent.h b/source/modules/juce_gui_extra/embedding/juce_NSViewComponent.h index 896722bde..2db7fe5c9 100644 --- a/source/modules/juce_gui_extra/embedding/juce_NSViewComponent.h +++ b/source/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/source/modules/juce_gui_extra/embedding/juce_UIViewComponent.h b/source/modules/juce_gui_extra/embedding/juce_UIViewComponent.h index 4558bbd9a..d478aef28 100644 --- a/source/modules/juce_gui_extra/embedding/juce_UIViewComponent.h +++ b/source/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/source/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h b/source/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h index 8456e3d8d..e3935e451 100644 --- a/source/modules/juce_gui_extra/embedding/juce_XEmbedComponent.h +++ b/source/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/source/modules/juce_gui_extra/juce_gui_extra.cpp b/source/modules/juce_gui_extra/juce_gui_extra.cpp index f89e0a86e..457081d80 100644 --- a/source/modules/juce_gui_extra/juce_gui_extra.cpp +++ b/source/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/source/modules/juce_gui_extra/juce_gui_extra.h b/source/modules/juce_gui_extra/juce_gui_extra.h index c1162ba75..a5bcc30a7 100644 --- a/source/modules/juce_gui_extra/juce_gui_extra.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp b/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp index 6f461d066..424b97319 100644 --- a/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h b/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h index eeb29e152..9d8455277 100644 --- a/source/modules/juce_gui_extra/misc/juce_AnimatedAppComponent.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_AppleRemote.h b/source/modules/juce_gui_extra/misc/juce_AppleRemote.h index c784e7129..1f27dc9d1 100644 --- a/source/modules/juce_gui_extra/misc/juce_AppleRemote.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index 556dae356..a3aa07402 100644 --- a/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h b/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h index d63e10720..785d542a9 100644 --- a/source/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/source/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index 662fa0dc1..f41c64f84 100644 --- a/source/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_ColourSelector.h b/source/modules/juce_gui_extra/misc/juce_ColourSelector.h index 6d9aa2ef9..83c2fe622 100644 --- a/source/modules/juce_gui_extra/misc/juce_ColourSelector.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index 4b87b0759..c619b2412 100644 --- a/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h b/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h index e4207bc0b..e206c1e68 100644 --- a/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp b/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp index e87c817d9..f98cb4391 100644 --- a/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h b/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h index 4d44a740b..9121a5828 100644 --- a/source/modules/juce_gui_extra/misc/juce_LiveConstantEditor.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index e6f612e37..cb35ef516 100644 --- a/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.h b/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.h index 6000ed3d1..99de99500 100644 --- a/source/modules/juce_gui_extra/misc/juce_PreferencesPanel.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp b/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp index d7470f6c9..580b79aa7 100644 --- a/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h b/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h index fadcaf71e..02a24fe00 100644 --- a/source/modules/juce_gui_extra/misc/juce_RecentlyOpenedFilesList.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_SplashScreen.cpp b/source/modules/juce_gui_extra/misc/juce_SplashScreen.cpp index 654669091..a33477d81 100644 --- a/source/modules/juce_gui_extra/misc/juce_SplashScreen.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_SplashScreen.h b/source/modules/juce_gui_extra/misc/juce_SplashScreen.h index 62dfc5aac..bf16e5d0a 100644 --- a/source/modules/juce_gui_extra/misc/juce_SplashScreen.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp b/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp index 33ae30828..72c6c983f 100644 --- a/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h b/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h index c3f3930bf..6dd877ddd 100644 --- a/source/modules/juce_gui_extra/misc/juce_SystemTrayIconComponent.h +++ b/source/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/source/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h b/source/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h index f26a7309b..67a055f82 100644 --- a/source/modules/juce_gui_extra/misc/juce_WebBrowserComponent.h +++ b/source/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/source/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp b/source/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp index c236b4b3f..7fc51d7cc 100644 --- a/source/modules/juce_gui_extra/native/juce_android_WebBrowserComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm b/source/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm index 933f25ccf..6a954fd10 100644 --- a/source/modules/juce_gui_extra/native/juce_ios_UIViewComponent.mm +++ b/source/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/source/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp b/source/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp index 35eed3733..c60b9347d 100644 --- a/source/modules/juce_gui_extra/native/juce_linux_X11_SystemTrayIcon.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp b/source/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp index 07c64fbe2..6a8f0da89 100644 --- a/source/modules/juce_gui_extra/native/juce_linux_X11_WebBrowserComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp b/source/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp index d50a7704d..916b45333 100644 --- a/source/modules/juce_gui_extra/native/juce_linux_XEmbedComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm b/source/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm index b1283c052..bc07d3317 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_AppleRemote.mm +++ b/source/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/source/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/source/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index 9d3851243..c57277db6 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/source/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/source/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/source/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index d99665091..47dc7e87e 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/source/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/source/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/source/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp index 49cde5eb2..c7d893fa9 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 186445cee..03078226b 100644 --- a/source/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/source/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/source/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/source/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 188385b63..f0eec0ea4 100644 --- a/source/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp b/source/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp index 7e3f9e2a6..b1667be77 100644 --- a/source/modules/juce_gui_extra/native/juce_win32_SystemTrayIcon.cpp +++ b/source/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/source/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/source/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 5831a9cc0..7ca294913 100644 --- a/source/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/source/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