Browse Source

Misc minor cleanups and comment fixes.

tags/2021-05-28
jules 12 years ago
parent
commit
b093f47a8c
27 changed files with 227 additions and 299 deletions
  1. +2
    -4
      modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
  2. +3
    -3
      modules/juce_audio_basics/midi/juce_MidiBuffer.h
  3. +2
    -3
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp
  4. +17
    -17
      modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp
  5. +2
    -3
      modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp
  6. +15
    -25
      modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp
  7. +25
    -27
      modules/juce_audio_basics/synthesisers/juce_Synthesiser.h
  8. +2
    -2
      modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp
  9. +13
    -16
      modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp
  10. +2
    -2
      modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h
  11. +1
    -1
      modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp
  12. +3
    -6
      modules/juce_audio_formats/format/juce_AudioSubsectionReader.h
  13. +5
    -5
      modules/juce_audio_formats/sampler/juce_Sampler.cpp
  14. +13
    -20
      modules/juce_audio_formats/sampler/juce_Sampler.h
  15. +32
    -40
      modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp
  16. +2
    -1
      modules/juce_core/xml/juce_XmlDocument.cpp
  17. +1
    -0
      modules/juce_events/native/juce_ios_MessageManager.mm
  18. +26
    -43
      modules/juce_gui_basics/buttons/juce_Button.cpp
  19. +20
    -20
      modules/juce_gui_basics/buttons/juce_Button.h
  20. +2
    -3
      modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h
  21. +3
    -3
      modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp
  22. +12
    -12
      modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h
  23. +13
    -25
      modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp
  24. +6
    -10
      modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h
  25. +1
    -1
      modules/juce_gui_basics/native/juce_mac_MainMenu.mm
  26. +1
    -1
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp
  27. +3
    -6
      modules/juce_gui_basics/widgets/juce_ComboBox.h

+ 2
- 4
modules/juce_audio_basics/midi/juce_MidiBuffer.cpp View File

@@ -240,9 +240,8 @@ uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const noe
}
//==============================================================================
MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) noexcept
: buffer (buffer_),
data (buffer_.getData())
MidiBuffer::Iterator::Iterator (const MidiBuffer& b) noexcept
: buffer (b), data (b.getData())
{
}
@@ -250,7 +249,6 @@ MidiBuffer::Iterator::~Iterator() noexcept
{
}
//==============================================================================
void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) noexcept
{
data = buffer.getData();


+ 3
- 3
modules/juce_audio_basics/midi/juce_MidiBuffer.h View File

@@ -51,10 +51,10 @@ public:
explicit MidiBuffer (const MidiMessage& message) noexcept;
/** Creates a copy of another MidiBuffer. */
MidiBuffer (const MidiBuffer& other) noexcept;
MidiBuffer (const MidiBuffer&) noexcept;
/** Makes a copy of another MidiBuffer. */
MidiBuffer& operator= (const MidiBuffer& other) noexcept;
MidiBuffer& operator= (const MidiBuffer&) noexcept;
/** Destructor */
~MidiBuffer();
@@ -176,7 +176,7 @@ public:
public:
//==============================================================================
/** Creates an Iterator for this MidiBuffer. */
Iterator (const MidiBuffer& buffer) noexcept;
Iterator (const MidiBuffer&) noexcept;
/** Destructor. */
~Iterator() noexcept;


+ 2
- 3
modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp View File

@@ -284,7 +284,7 @@ void MidiMessageSequence::createControllerUpdatesForTime (const int channelNumbe
{
bool doneProg = false;
bool donePitchWheel = false;
Array <int> doneControllers;
Array<int> doneControllers;
doneControllers.ensureStorageAllocated (32);
for (int i = list.size(); --i >= 0;)
@@ -324,8 +324,7 @@ void MidiMessageSequence::createControllerUpdatesForTime (const int channelNumbe
//==============================================================================
MidiMessageSequence::MidiEventHolder::MidiEventHolder (const MidiMessage& mm)
: message (mm),
noteOffObject (nullptr)
: message (mm), noteOffObject (nullptr)
{
}


+ 17
- 17
modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp View File

@@ -22,16 +22,16 @@
==============================================================================
*/
BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* source_,
TimeSliceThread& backgroundThread_,
BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* s,
TimeSliceThread& thread,
const bool deleteSourceWhenDeleted,
const int numberOfSamplesToBuffer_,
const int numberOfChannels_)
: source (source_, deleteSourceWhenDeleted),
backgroundThread (backgroundThread_),
numberOfSamplesToBuffer (jmax (1024, numberOfSamplesToBuffer_)),
numberOfChannels (numberOfChannels_),
buffer (numberOfChannels_, 0),
const int bufferSizeSamples,
const int numChannels)
: source (s, deleteSourceWhenDeleted),
backgroundThread (thread),
numberOfSamplesToBuffer (jmax (1024, bufferSizeSamples)),
numberOfChannels (numChannels),
buffer (numChannels, 0),
bufferValidStart (0),
bufferValidEnd (0),
nextPlayPos (0),
@@ -39,10 +39,10 @@ BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* source_,
wasSourceLooping (false),
isPrepared (false)
{
jassert (source_ != nullptr);
jassert (source != nullptr);
jassert (numberOfSamplesToBuffer_ > 1024); // not much point using this class if you're
// not using a larger buffer..
jassert (numberOfSamplesToBuffer > 1024); // not much point using this class if you're
// not using a larger buffer..
}
BufferingAudioSource::~BufferingAudioSource()
@@ -51,20 +51,20 @@ BufferingAudioSource::~BufferingAudioSource()
}
//==============================================================================
void BufferingAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate_)
void BufferingAudioSource::prepareToPlay (int samplesPerBlockExpected, double newSampleRate)
{
const int bufferSizeNeeded = jmax (samplesPerBlockExpected * 2, numberOfSamplesToBuffer);
if (sampleRate_ != sampleRate
if (newSampleRate != sampleRate
|| bufferSizeNeeded != buffer.getNumSamples()
|| ! isPrepared)
{
backgroundThread.removeTimeSliceClient (this);
isPrepared = true;
sampleRate = sampleRate_;
sampleRate = newSampleRate;
source->prepareToPlay (samplesPerBlockExpected, sampleRate_);
source->prepareToPlay (samplesPerBlockExpected, newSampleRate);
buffer.setSize (numberOfChannels, bufferSizeNeeded);
buffer.clear();
@@ -74,7 +74,7 @@ void BufferingAudioSource::prepareToPlay (int samplesPerBlockExpected, double sa
backgroundThread.addTimeSliceClient (this);
while (bufferValidEnd - bufferValidStart < jmin (((int) sampleRate_) / 4,
while (bufferValidEnd - bufferValidStart < jmin (((int) newSampleRate) / 4,
buffer.getNumSamples() / 2))
{
backgroundThread.moveToFrontOfQueue (this);


+ 2
- 3
modules/juce_audio_basics/sources/juce_ToneGeneratorAudioSource.cpp View File

@@ -48,12 +48,11 @@ void ToneGeneratorAudioSource::setFrequency (const double newFrequencyHz)
}
//==============================================================================
void ToneGeneratorAudioSource::prepareToPlay (int /*samplesPerBlockExpected*/,
double sampleRate_)
void ToneGeneratorAudioSource::prepareToPlay (int /*samplesPerBlockExpected*/, double rate)
{
currentPhase = 0.0;
phasePerSample = 0.0;
sampleRate = sampleRate_;
sampleRate = rate;
}
void ToneGeneratorAudioSource::releaseResources()


+ 15
- 25
modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp View File

@@ -22,13 +22,8 @@
==============================================================================
*/
SynthesiserSound::SynthesiserSound()
{
}
SynthesiserSound::~SynthesiserSound()
{
}
SynthesiserSound::SynthesiserSound() {}
SynthesiserSound::~SynthesiserSound() {}
//==============================================================================
SynthesiserVoice::SynthesiserVoice()
@@ -118,9 +113,9 @@ void Synthesiser::removeSound (const int index)
sounds.remove (index);
}
void Synthesiser::setNoteStealingEnabled (const bool shouldStealNotes_)
void Synthesiser::setNoteStealingEnabled (const bool shouldSteal)
{
shouldStealNotes = shouldStealNotes_;
shouldStealNotes = shouldSteal;
}
//==============================================================================
@@ -139,10 +134,8 @@ void Synthesiser::setCurrentPlaybackSampleRate (const double newRate)
}
}
void Synthesiser::renderNextBlock (AudioSampleBuffer& outputBuffer,
const MidiBuffer& midiData,
int startSample,
int numSamples)
void Synthesiser::renderNextBlock (AudioSampleBuffer& outputBuffer, const MidiBuffer& midiData,
int startSample, int numSamples)
{
// must set the sample rate before using this!
jassert (sampleRate != 0);
@@ -180,15 +173,11 @@ void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
if (m.isNoteOn())
{
noteOn (m.getChannel(),
m.getNoteNumber(),
m.getFloatVelocity());
noteOn (m.getChannel(), m.getNoteNumber(), m.getFloatVelocity());
}
else if (m.isNoteOff())
{
noteOff (m.getChannel(),
m.getNoteNumber(),
true);
noteOff (m.getChannel(), m.getNoteNumber(), true);
}
else if (m.isAllNotesOff() || m.isAllSoundOff())
{
@@ -204,9 +193,7 @@ void Synthesiser::handleMidiEvent (const MidiMessage& m)
}
else if (m.isController())
{
handleController (m.getChannel(),
m.getControllerNumber(),
m.getControllerValue());
handleController (m.getChannel(), m.getControllerNumber(), m.getControllerValue());
}
}
@@ -406,9 +393,12 @@ SynthesiserVoice* Synthesiser::findFreeVoice (SynthesiserSound* soundToPlay,
const ScopedLock sl (lock);
for (int i = voices.size(); --i >= 0;)
if (voices.getUnchecked (i)->getCurrentlyPlayingNote() < 0
&& voices.getUnchecked (i)->canPlaySound (soundToPlay))
return voices.getUnchecked (i);
{
SynthesiserVoice* const voice = voices.getUnchecked (i);
if (voice->getCurrentlyPlayingNote() < 0 && voice->canPlaySound (soundToPlay))
return voice;
}
if (stealIfNoneAvailable)
{


+ 25
- 27
modules/juce_audio_basics/synthesisers/juce_Synthesiser.h View File

@@ -64,9 +64,8 @@ public:
*/
virtual bool appliesToChannel (const int midiChannel) = 0;
/**
*/
typedef ReferenceCountedObjectPtr <SynthesiserSound> Ptr;
/** The class is reference-counted, so this is a handy pointer class for it. */
typedef ReferenceCountedObjectPtr<SynthesiserSound> Ptr;
private:
@@ -96,16 +95,14 @@ public:
//==============================================================================
/** Returns the midi note that this voice is currently playing.
Returns a value less than 0 if no note is playing.
*/
int getCurrentlyPlayingNote() const { return currentlyPlayingNote; }
int getCurrentlyPlayingNote() const noexcept { return currentlyPlayingNote; }
/** Returns the sound that this voice is currently playing.
Returns nullptr if it's not playing.
*/
SynthesiserSound::Ptr getCurrentlyPlayingSound() const { return currentlyPlayingSound; }
SynthesiserSound::Ptr getCurrentlyPlayingSound() const noexcept { return currentlyPlayingSound; }
/** Must return true if this voice object is capable of playing the given sound.
@@ -116,16 +113,16 @@ public:
of voice and sound, or it might check the type of the sound object passed-in and
see if it's one that it understands.
*/
virtual bool canPlaySound (SynthesiserSound* sound) = 0;
virtual bool canPlaySound (SynthesiserSound*) = 0;
/** Called to start a new note.
This will be called during the rendering callback, so must be fast and thread-safe.
*/
virtual void startNote (const int midiNoteNumber,
const float velocity,
virtual void startNote (int midiNoteNumber,
float velocity,
SynthesiserSound* sound,
const int currentPitchWheelPosition) = 0;
int currentPitchWheelPosition) = 0;
/** Called to stop a note.
@@ -140,20 +137,17 @@ public:
finishes playing (during the rendering callback), it must make sure that it calls
clearCurrentNote().
*/
virtual void stopNote (const bool allowTailOff) = 0;
virtual void stopNote (bool allowTailOff) = 0;
/** Called to let the voice know that the pitch wheel has been moved.
This will be called during the rendering callback, so must be fast and thread-safe.
*/
virtual void pitchWheelMoved (const int newValue) = 0;
virtual void pitchWheelMoved (int newValue) = 0;
/** Called to let the voice know that a midi controller has been moved.
This will be called during the rendering callback, so must be fast and thread-safe.
*/
virtual void controllerMoved (const int controllerNumber,
const int newValue) = 0;
virtual void controllerMoved (int controllerNumber, int newValue) = 0;
//==============================================================================
/** Renders the next block of data for this voice.
@@ -273,7 +267,7 @@ public:
void clearVoices();
/** Returns the number of voices that have been added. */
int getNumVoices() const { return voices.size(); }
int getNumVoices() const noexcept { return voices.size(); }
/** Returns one of the voices that have been added. */
SynthesiserVoice* getVoice (int index) const;
@@ -296,10 +290,10 @@ public:
void clearSounds();
/** Returns the number of sounds that have been added to the synth. */
int getNumSounds() const { return sounds.size(); }
int getNumSounds() const noexcept { return sounds.size(); }
/** Returns one of the sounds. */
SynthesiserSound* getSound (int index) const { return sounds [index]; }
SynthesiserSound* getSound (int index) const noexcept { return sounds [index]; }
/** Adds a new sound to the synthesiser.
@@ -323,7 +317,7 @@ public:
/** Returns true if note-stealing is enabled.
@see setNoteStealingEnabled
*/
bool isNoteStealingEnabled() const { return shouldStealNotes; }
bool isNoteStealingEnabled() const noexcept { return shouldStealNotes; }
//==============================================================================
/** Triggers a note-on event.
@@ -376,7 +370,7 @@ public:
virtual void allNotesOff (int midiChannel,
bool allowTailOff);
/** Sends a pitch-wheel message.
/** Sends a pitch-wheel message to any active voices.
This will send a pitch-wheel message to any voices that are playing sounds on
the given midi channel.
@@ -390,7 +384,7 @@ public:
virtual void handlePitchWheel (int midiChannel,
int wheelValue);
/** Sends a midi controller message.
/** Sends a midi controller message to any active voices.
This will send a midi controller message to any voices that are playing sounds on
the given midi channel.
@@ -406,13 +400,17 @@ public:
int controllerNumber,
int controllerValue);
/** Handles a sustain pedal event. */
virtual void handleSustainPedal (int midiChannel, bool isDown);
/** Handles a sostenuto pedal event. */
virtual void handleSostenutoPedal (int midiChannel, bool isDown);
/** Can be overridden to handle soft pedal events. */
virtual void handleSoftPedal (int midiChannel, bool isDown);
//==============================================================================
/** Tells the synthesiser what the sample rate is for the audio it's being used to
render.
/** Tells the synthesiser what the sample rate is for the audio it's being used to render.
This value is propagated to the voices so that they can use it to render the correct
pitches.
@@ -441,8 +439,8 @@ protected:
/** This is used to control access to the rendering callback and the note trigger methods. */
CriticalSection lock;
OwnedArray <SynthesiserVoice> voices;
ReferenceCountedArray <SynthesiserSound> sounds;
OwnedArray<SynthesiserVoice> voices;
ReferenceCountedArray<SynthesiserSound> sounds;
/** The last pitch-wheel values for each midi channel. */
int lastPitchWheelValues [16];


+ 2
- 2
modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp View File

@@ -608,10 +608,10 @@ private:
class AiffAudioFormatWriter : public AudioFormatWriter
{
public:
AiffAudioFormatWriter (OutputStream* out, double sampleRate_,
AiffAudioFormatWriter (OutputStream* out, double rate,
unsigned int numChans, unsigned int bits,
const StringPairArray& metadataValues)
: AudioFormatWriter (out, TRANS (aiffFormatName), sampleRate_, numChans, bits),
: AudioFormatWriter (out, TRANS (aiffFormatName), rate, numChans, bits),
lengthInSamples (0),
bytesWritten (0),
writeFailed (false)


+ 13
- 16
modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp View File

@@ -247,34 +247,34 @@ public:
static FlacNamespace::FLAC__StreamDecoderReadStatus readCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__byte buffer[], size_t* bytes, void* client_data)
{
using namespace FlacNamespace;
*bytes = (size_t) static_cast <const FlacReader*> (client_data)->input->read (buffer, (int) *bytes);
*bytes = (size_t) static_cast<const FlacReader*> (client_data)->input->read (buffer, (int) *bytes);
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
static FlacNamespace::FLAC__StreamDecoderSeekStatus seekCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64 absolute_byte_offset, void* client_data)
{
using namespace FlacNamespace;
static_cast <const FlacReader*> (client_data)->input->setPosition ((int) absolute_byte_offset);
static_cast<const FlacReader*> (client_data)->input->setPosition ((int) absolute_byte_offset);
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
}
static FlacNamespace::FLAC__StreamDecoderTellStatus tellCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* absolute_byte_offset, void* client_data)
{
using namespace FlacNamespace;
*absolute_byte_offset = (uint64) static_cast <const FlacReader*> (client_data)->input->getPosition();
*absolute_byte_offset = (uint64) static_cast<const FlacReader*> (client_data)->input->getPosition();
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
}
static FlacNamespace::FLAC__StreamDecoderLengthStatus lengthCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* stream_length, void* client_data)
{
using namespace FlacNamespace;
*stream_length = (uint64) static_cast <const FlacReader*> (client_data)->input->getTotalLength();
*stream_length = (uint64) static_cast<const FlacReader*> (client_data)->input->getTotalLength();
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
}
static FlacNamespace::FLAC__bool eofCallback_ (const FlacNamespace::FLAC__StreamDecoder*, void* client_data)
{
return static_cast <const FlacReader*> (client_data)->input->isExhausted();
return static_cast<const FlacReader*> (client_data)->input->isExhausted();
}
static FlacNamespace::FLAC__StreamDecoderWriteStatus writeCallback_ (const FlacNamespace::FLAC__StreamDecoder*,
@@ -283,7 +283,7 @@ public:
void* client_data)
{
using namespace FlacNamespace;
static_cast <FlacReader*> (client_data)->useSamples (buffer, (int) frame->header.blocksize);
static_cast<FlacReader*> (client_data)->useSamples (buffer, (int) frame->header.blocksize);
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
@@ -291,7 +291,7 @@ public:
const FlacNamespace::FLAC__StreamMetadata* metadata,
void* client_data)
{
static_cast <FlacReader*> (client_data)->useMetadata (metadata->data.stream_info);
static_cast<FlacReader*> (client_data)->useMetadata (metadata->data.stream_info);
}
static void errorCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__StreamDecoderErrorStatus, void*)
@@ -312,11 +312,8 @@ private:
class FlacWriter : public AudioFormatWriter
{
public:
//==============================================================================
FlacWriter (OutputStream* const out, double sampleRate_,
uint32 numChannels_, uint32 bitsPerSample_, int qualityOptionIndex)
: AudioFormatWriter (out, TRANS (flacFormatName),
sampleRate_, numChannels_, bitsPerSample_)
FlacWriter (OutputStream* const out, double rate, uint32 numChans, uint32 bits, int qualityOptionIndex)
: AudioFormatWriter (out, TRANS (flacFormatName), rate, numChans, bits)
{
using namespace FlacNamespace;
encoder = FLAC__stream_encoder_new();
@@ -382,7 +379,7 @@ public:
destData[j] = (samplesToWrite[i][j] >> bitsToShift);
}
samplesToWrite = const_cast <const int**> (channels.getData());
samplesToWrite = const_cast<const int**> (channels.getData());
}
return FLAC__stream_encoder_process (encoder, (const FLAC__int32**) samplesToWrite, (size_t) numSamples) != 0;
@@ -444,7 +441,7 @@ public:
void* client_data)
{
using namespace FlacNamespace;
return static_cast <FlacWriter*> (client_data)->writeData (buffer, (int) bytes)
return static_cast<FlacWriter*> (client_data)->writeData (buffer, (int) bytes)
? FLAC__STREAM_ENCODER_WRITE_STATUS_OK
: FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
}
@@ -461,13 +458,13 @@ public:
if (client_data == nullptr)
return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
*absolute_byte_offset = (FLAC__uint64) static_cast <FlacWriter*> (client_data)->output->getPosition();
*absolute_byte_offset = (FLAC__uint64) static_cast<FlacWriter*> (client_data)->output->getPosition();
return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
}
static void encodeMetadataCallback (const FlacNamespace::FLAC__StreamEncoder*, const FlacNamespace::FLAC__StreamMetadata* metadata, void* client_data)
{
static_cast <FlacWriter*> (client_data)->writeMetaData (metadata);
static_cast<FlacWriter*> (client_data)->writeMetaData (metadata);
}
bool ok;


+ 2
- 2
modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h View File

@@ -29,7 +29,7 @@
An AudioFormat class which can use an installed version of the LAME mp3
encoder to encode a file.
This format can't read mp3s, it just writes them. Internally, the
This format can't read MP3s, it just writes them. Internally, the
AudioFormatWriter object that is returned writes the incoming audio data
to a temporary WAV file, and then when the writer is deleted, it invokes
the LAME executable to convert the data to an MP3, whose data is then
@@ -44,7 +44,7 @@ public:
/** Creates a LAMEEncoderAudioFormat that expects to find a working LAME
executable at the location given.
*/
LAMEEncoderAudioFormat (const File& lameApplicationToUse);
LAMEEncoderAudioFormat (const File& lameExecutableToUse);
~LAMEEncoderAudioFormat();
bool canHandleFile (const File&);


+ 1
- 1
modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp View File

@@ -490,7 +490,7 @@ int OggVorbisAudioFormat::estimateOggFileQuality (const File& source)
{
if (FileInputStream* const in = source.createInputStream())
{
ScopedPointer <AudioFormatReader> r (createReaderFor (in, true));
ScopedPointer<AudioFormatReader> r (createReaderFor (in, true));
if (r != nullptr)
{


+ 3
- 6
modules/juce_audio_formats/format/juce_AudioSubsectionReader.h View File

@@ -67,12 +67,9 @@ public:
bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
int64 startSampleInFile, int numSamples) override;
void readMaxLevels (int64 startSample,
int64 numSamples,
float& lowestLeft,
float& highestLeft,
float& lowestRight,
float& highestRight) override;
void readMaxLevels (int64 startSample, int64 numSamples,
float& lowestLeft, float& highestLeft,
float& lowestRight, float& highestRight) override;
private:


+ 5
- 5
modules/juce_audio_formats/sampler/juce_Sampler.cpp View File

@@ -22,15 +22,15 @@
==============================================================================
*/
SamplerSound::SamplerSound (const String& name_,
SamplerSound::SamplerSound (const String& soundName,
AudioFormatReader& source,
const BigInteger& midiNotes_,
const BigInteger& notes,
const int midiNoteForNormalPitch,
const double attackTimeSecs,
const double releaseTimeSecs,
const double maxSampleLengthSeconds)
: name (name_),
midiNotes (midiNotes_),
: name (soundName),
midiNotes (notes),
midiRootNote (midiNoteForNormalPitch)
{
sourceSampleRate = source.sampleRate;
@@ -85,7 +85,7 @@ SamplerVoice::~SamplerVoice()
bool SamplerVoice::canPlaySound (SynthesiserSound* sound)
{
return dynamic_cast <const SamplerSound*> (sound) != nullptr;
return dynamic_cast<const SamplerSound*> (sound) != nullptr;
}
void SamplerVoice::startNote (const int midiNoteNumber,


+ 13
- 20
modules/juce_audio_formats/sampler/juce_Sampler.h View File

@@ -73,17 +73,17 @@ public:
//==============================================================================
/** Returns the sample's name */
const String& getName() const { return name; }
const String& getName() const noexcept { return name; }
/** Returns the audio sample data.
This could be 0 if there was a problem loading it.
This could return nullptr if there was a problem loading the data.
*/
AudioSampleBuffer* getAudioData() const { return data; }
AudioSampleBuffer* getAudioData() const noexcept { return data; }
//==============================================================================
bool appliesToNote (const int midiNoteNumber);
bool appliesToChannel (const int midiChannel);
bool appliesToNote (const int midiNoteNumber) override;
bool appliesToChannel (const int midiChannel) override;
private:
@@ -91,7 +91,7 @@ private:
friend class SamplerVoice;
String name;
ScopedPointer <AudioSampleBuffer> data;
ScopedPointer<AudioSampleBuffer> data;
double sourceSampleRate;
BigInteger midiNotes;
int length, attackSamples, releaseSamples;
@@ -114,29 +114,22 @@ class JUCE_API SamplerVoice : public SynthesiserVoice
{
public:
//==============================================================================
/** Creates a SamplerVoice.
*/
/** Creates a SamplerVoice. */
SamplerVoice();
/** Destructor. */
~SamplerVoice();
//==============================================================================
bool canPlaySound (SynthesiserSound* sound);
void startNote (const int midiNoteNumber,
const float velocity,
SynthesiserSound* sound,
const int currentPitchWheelPosition);
bool canPlaySound (SynthesiserSound*) override;
void stopNote (const bool allowTailOff);
void startNote (int midiNoteNumber, float velocity, SynthesiserSound*, int pitchWheel) override;
void stopNote (bool allowTailOff) override;
void pitchWheelMoved (const int newValue);
void controllerMoved (const int controllerNumber,
const int newValue);
void pitchWheelMoved (int newValue);
void controllerMoved (int controllerNumber, int newValue) override;
void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples);
void renderNextBlock (AudioSampleBuffer&, int startSample, int numSamples) override;
private:


+ 32
- 40
modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp View File

@@ -26,22 +26,21 @@ class SimpleDeviceManagerInputLevelMeter : public Component,
public Timer
{
public:
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager* const manager_)
: manager (manager_),
level (0)
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager& m)
: manager (m), level (0)
{
startTimer (50);
manager->enableInputLevelMeasurement (true);
manager.enableInputLevelMeasurement (true);
}
~SimpleDeviceManagerInputLevelMeter()
{
manager->enableInputLevelMeasurement (false);
manager.enableInputLevelMeasurement (false);
}
void timerCallback() override
{
const float newLevel = (float) manager->getCurrentInputLevel();
const float newLevel = (float) manager.getCurrentInputLevel();
if (std::abs (level - newLevel) > 0.005f)
{
@@ -57,7 +56,7 @@ public:
}
private:
AudioDeviceManager* const manager;
AudioDeviceManager& manager;
float level;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SimpleDeviceManagerInputLevelMeter)
@@ -195,11 +194,9 @@ class AudioDeviceSettingsPanel : public Component,
private ButtonListener
{
public:
AudioDeviceSettingsPanel (AudioIODeviceType* type_,
AudioDeviceSetupDetails& setup_,
AudioDeviceSettingsPanel (AudioIODeviceType& t, AudioDeviceSetupDetails& setupDetails,
const bool hideAdvancedOptionsWithButton)
: type (type_),
setup (setup_)
: type (t), setup (setupDetails)
{
if (hideAdvancedOptionsWithButton)
{
@@ -207,7 +204,7 @@ public:
showAdvancedSettingsButton->addListener (this);
}
type->scanForDevices();
type.scanForDevices();
setup.manager->addChangeListener (this);
updateAllControls();
@@ -320,7 +317,7 @@ public:
config.inputDeviceName = inputDeviceDropDown->getSelectedId() < 0 ? String::empty
: inputDeviceDropDown->getText();
if (! type->hasSeparateInputsAndOutputs())
if (! type.hasSeparateInputsAndOutputs())
config.inputDeviceName = config.outputDeviceName;
if (comboBoxThatHasChanged == inputDeviceDropDown)
@@ -354,26 +351,24 @@ public:
}
if (error.isNotEmpty())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Error when trying to open audio device!",
TRANS ("Error when trying to open audio device!"),
error);
}
}
bool showDeviceControlPanel()
{
AudioIODevice* const device = setup.manager->getCurrentAudioDevice();
if (device == nullptr)
return false;
if (AudioIODevice* const device = setup.manager->getCurrentAudioDevice())
{
Component modalWindow (String::empty);
modalWindow.setOpaque (true);
modalWindow.addToDesktop (0);
modalWindow.enterModalState();
Component modalWindow (String::empty);
modalWindow.setOpaque (true);
modalWindow.addToDesktop (0);
modalWindow.enterModalState();
return device->showControlPanel();
}
return device->showControlPanel();
return false;
}
void buttonClicked (Button* button) override
@@ -476,7 +471,7 @@ public:
}
private:
AudioIODeviceType* const type;
AudioIODeviceType& type;
const AudioDeviceSetupDetails setup;
ScopedPointer<ComboBox> outputDeviceDropDown, inputDeviceDropDown, sampleRateDropDown, bufferSizeDropDown;
@@ -491,7 +486,7 @@ private:
{
AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice();
const int index = type->getIndexOfDevice (currentDevice, isInput);
const int index = type.getIndexOfDevice (currentDevice, isInput);
box->setSelectedId (index + 1, dontSendNotification);
@@ -502,7 +497,7 @@ private:
void addNamesToDeviceBox (ComboBox& combo, bool isInputs)
{
const StringArray devs (type->getDeviceNames (isInputs));
const StringArray devs (type.getDeviceNames (isInputs));
combo.clear (dontSendNotification);
@@ -540,7 +535,7 @@ private:
void updateOutputsComboBox()
{
if (setup.maxNumOutputChannels > 0 || ! type->hasSeparateInputsAndOutputs())
if (setup.maxNumOutputChannels > 0 || ! type.hasSeparateInputsAndOutputs())
{
if (outputDeviceDropDown == nullptr)
{
@@ -549,8 +544,8 @@ private:
addAndMakeVisible (outputDeviceDropDown);
outputDeviceLabel = new Label (String::empty,
type->hasSeparateInputsAndOutputs() ? TRANS ("output:")
: TRANS ("device:"));
type.hasSeparateInputsAndOutputs() ? TRANS ("output:")
: TRANS ("device:"));
outputDeviceLabel->attachToComponent (outputDeviceDropDown, true);
if (setup.maxNumOutputChannels > 0)
@@ -568,7 +563,7 @@ private:
void updateInputsComboBox()
{
if (setup.maxNumInputChannels > 0 && type->hasSeparateInputsAndOutputs())
if (setup.maxNumInputChannels > 0 && type.hasSeparateInputsAndOutputs())
{
if (inputDeviceDropDown == nullptr)
{
@@ -580,7 +575,7 @@ private:
inputDeviceLabel->attachToComponent (inputDeviceDropDown, true);
addAndMakeVisible (inputLevelMeter
= new SimpleDeviceManagerInputLevelMeter (setup.manager));
= new SimpleDeviceManagerInputLevelMeter (*setup.manager));
}
addNamesToDeviceBox (*inputDeviceDropDown, true);
@@ -663,13 +658,10 @@ public:
};
//==============================================================================
ChannelSelectorListBox (const AudioDeviceSetupDetails& setup_,
const BoxType type_,
const String& noItemsMessage_)
ChannelSelectorListBox (const AudioDeviceSetupDetails& setupDetails,
const BoxType boxType, const String& noItemsText)
: ListBox (String::empty, nullptr),
setup (setup_),
type (type_),
noItemsMessage (noItemsMessage_)
setup (setupDetails), type (boxType), noItemsMessage (noItemsText)
{
refresh();
setModel (this);
@@ -1073,7 +1065,7 @@ void AudioDeviceSelectorComponent::updateAllControls()
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (type, details, hideAdvancedOptionsWithButton);
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton);
if (audioDeviceSettingsComp != nullptr)
{


+ 2
- 1
modules/juce_core/xml/juce_XmlDocument.cpp View File

@@ -516,7 +516,8 @@ void XmlDocument::readChildElements (XmlElement* parent)
break;
}
else if (c1 == '!' && CharacterFunctions::compareUpTo (input + 2, CharPointer_ASCII ("[CDATA["), 7) == 0)
if (c1 == '!' && CharacterFunctions::compareUpTo (input + 2, CharPointer_ASCII ("[CDATA["), 7) == 0)
{
input += 9;
const String::CharPointerType inputStart (input);


+ 1
- 0
modules/juce_events/native/juce_ios_MessageManager.mm View File

@@ -83,4 +83,5 @@ bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* cons
void MessageManager::broadcastMessage (const String&)
{
// N/A on current iOS
}

+ 26
- 43
modules/juce_gui_basics/buttons/juce_Button.cpp View File

@@ -93,7 +93,7 @@ String Button::getTooltip()
{
String tt (commandManagerToUse->getDescriptionOfCommand (commandID));
Array <KeyPress> keyPresses (commandManagerToUse->getKeyMappings()->getKeyPressesAssignedToCommand (commandID));
Array<KeyPress> keyPresses (commandManagerToUse->getKeyMappings()->getKeyPressesAssignedToCommand (commandID));
for (int i = 0; i < keyPresses.size(); ++i)
{
@@ -113,18 +113,17 @@ String Button::getTooltip()
return SettableTooltipClient::getTooltip();
}
void Button::setConnectedEdges (const int connectedEdgeFlags_)
void Button::setConnectedEdges (const int newFlags)
{
if (connectedEdgeFlags != connectedEdgeFlags_)
if (connectedEdgeFlags != newFlags)
{
connectedEdgeFlags = connectedEdgeFlags_;
connectedEdgeFlags = newFlags;
repaint();
}
}
//==============================================================================
void Button::setToggleState (const bool shouldBeOn,
const NotificationType notification)
void Button::setToggleState (const bool shouldBeOn, const NotificationType notification)
{
if (shouldBeOn != lastToggleState)
{
@@ -272,19 +271,10 @@ void Button::setState (const ButtonState newState)
}
}
bool Button::isDown() const noexcept
{
return buttonState == buttonDown;
}
bool Button::isDown() const noexcept { return buttonState == buttonDown; }
bool Button::isOver() const noexcept { return buttonState != buttonNormal; }
bool Button::isOver() const noexcept
{
return buttonState != buttonNormal;
}
void Button::buttonStateChanged()
{
}
void Button::buttonStateChanged() {}
uint32 Button::getMillisecondsSinceButtonDown() const noexcept
{
@@ -401,15 +391,8 @@ void Button::paint (Graphics& g)
}
//==============================================================================
void Button::mouseEnter (const MouseEvent&)
{
updateState (true, false);
}
void Button::mouseExit (const MouseEvent&)
{
updateState (false, false);
}
void Button::mouseEnter (const MouseEvent&) { updateState (true, false); }
void Button::mouseExit (const MouseEvent&) { updateState (false, false); }
void Button::mouseDown (const MouseEvent& e)
{
@@ -428,9 +411,10 @@ void Button::mouseDown (const MouseEvent& e)
void Button::mouseUp (const MouseEvent& e)
{
const bool wasDown = isDown();
const bool wasOver = isOver();
updateState (isMouseOver(), false);
if (wasDown && isOver() && ! triggerOnMouseDown)
if (wasDown && wasOver && ! triggerOnMouseDown)
internalClickCallback (e.mods);
}
@@ -478,19 +462,18 @@ void Button::parentHierarchyChanged()
}
//==============================================================================
void Button::setCommandToTrigger (ApplicationCommandManager* const commandManagerToUse_,
const int commandID_,
const bool generateTooltip_)
void Button::setCommandToTrigger (ApplicationCommandManager* const newCommandManager,
const int newCommandID, const bool generateTip)
{
commandID = commandID_;
generateTooltip = generateTooltip_;
commandID = newCommandID;
generateTooltip = generateTip;
if (commandManagerToUse != commandManagerToUse_)
if (commandManagerToUse != newCommandManager)
{
if (commandManagerToUse != nullptr)
commandManagerToUse->removeListener (this);
commandManagerToUse = commandManagerToUse_;
commandManagerToUse = newCommandManager;
if (commandManagerToUse != nullptr)
commandManagerToUse->addListener (this);
@@ -523,12 +506,15 @@ void Button::applicationCommandListChanged()
{
ApplicationCommandInfo info (0);
ApplicationCommandTarget* const target = commandManagerToUse->getTargetForCommand (commandID, info);
setEnabled (target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0);
if (target != nullptr)
if (commandManagerToUse->getTargetForCommand (commandID, info) != nullptr)
{
setEnabled ((info.flags & ApplicationCommandInfo::isDisabled) == 0);
setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, dontSendNotification);
}
else
{
setEnabled (false);
}
}
}
@@ -547,18 +533,15 @@ void Button::addShortcut (const KeyPress& key)
void Button::clearShortcuts()
{
shortcuts.clear();
parentHierarchyChanged();
}
bool Button::isShortcutPressed() const
{
if (! isCurrentlyBlockedByAnotherModalComponent())
{
for (int i = shortcuts.size(); --i >= 0;)
if (shortcuts.getReference(i).isCurrentlyDown())
return true;
}
return false;
}


+ 20
- 20
modules/juce_gui_basics/buttons/juce_Button.h View File

@@ -68,13 +68,13 @@ public:
const String& getButtonText() const { return text; }
//==============================================================================
/** Returns true if the button is currently being held down by the mouse.
/** Returns true if the button is currently being held down.
@see isOver
*/
bool isDown() const noexcept;
/** Returns true if the mouse is currently over the button.
This will be also be true if the mouse is being held down.
This will be also be true if the button is being held down.
@see isDown
*/
bool isOver() const noexcept;
@@ -95,8 +95,7 @@ public:
sendNotificationAsync is not supported
@see getToggleState, setRadioGroupId
*/
void setToggleState (bool shouldBeOn,
NotificationType notification);
void setToggleState (bool shouldBeOn, NotificationType notification);
/** Returns true if the button is 'on'.
@@ -122,7 +121,7 @@ public:
If set to true, then before the clicked() callback occurs, the toggle-state
of the button is flipped.
*/
void setClickingTogglesState (bool shouldToggle) noexcept;
void setClickingTogglesState (bool shouldAutoToggleOnClick) noexcept;
/** Returns true if this button is set to be an automatic toggle-button.
This returns the last value that was passed to setClickingTogglesState().
@@ -202,7 +201,7 @@ public:
Obviously be careful that the ApplicationCommandManager doesn't get deleted
before this button is. To disable the command triggering, call this method and
pass 0 for the parameters.
pass nullptr as the command manager.
If generateTooltip is true, then the button's tooltip will be automatically
generated based on the name of this command and its current shortcut key.
@@ -226,7 +225,7 @@ public:
@see clearShortcuts
*/
void addShortcut (const KeyPress& key);
void addShortcut (const KeyPress&);
/** Removes all key shortcuts that had been set for this button.
@see addShortcut
@@ -236,7 +235,7 @@ public:
/** Returns true if the given keypress is a shortcut for this button.
@see addShortcut
*/
bool isRegisteredForShortcut (const KeyPress& key) const;
bool isRegisteredForShortcut (const KeyPress&) const;
//==============================================================================
/** Sets an auto-repeat speed for the button when it is held down.
@@ -274,12 +273,13 @@ public:
//==============================================================================
/** Sets the tooltip for this button.
@see TooltipClient, TooltipWindow
*/
void setTooltip (const String& newTooltip) override;
// (implementation of the TooltipClient method)
/** Returns the tooltip set by setTooltip(), or the description corresponding to
the currently mapped command if one is enabled (see setCommandToTrigger).
*/
String getTooltip() override;
@@ -347,7 +347,7 @@ public:
The state that you set here will only last until it is automatically changed when the mouse
enters or exits the button, or the mouse-button is pressed or released.
*/
void setState (const ButtonState newState);
void setState (ButtonState newState);
// This method's parameters have changed - see the new version.
JUCE_DEPRECATED (void setToggleState (bool, bool));
@@ -442,10 +442,10 @@ protected:
private:
//==============================================================================
Array <KeyPress> shortcuts;
Array<KeyPress> shortcuts;
WeakReference<Component> keySource;
String text;
ListenerList <Listener> buttonListeners;
ListenerList<Listener> buttonListeners;
class RepeatTimer;
friend class RepeatTimer;
@@ -458,13 +458,13 @@ private:
ButtonState buttonState;
Value isOn;
bool lastToggleState : 1;
bool clickTogglesState : 1;
bool needsToRelease : 1;
bool needsRepainting : 1;
bool isKeyDown : 1;
bool triggerOnMouseDown : 1;
bool generateTooltip : 1;
bool lastToggleState;
bool clickTogglesState;
bool needsToRelease;
bool needsRepainting;
bool isKeyDown;
bool triggerOnMouseDown;
bool generateTooltip;
void repeatTimerCallback();
RepeatTimer& getRepeatTimer();


+ 2
- 3
modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.h View File

@@ -77,8 +77,7 @@ struct JUCE_API ApplicationCommandInfo
myinfo.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier));
@endcode
*/
void addDefaultKeypress (int keyCode,
ModifierKeys modifiers) noexcept;
void addDefaultKeypress (int keyCode, ModifierKeys modifiers) noexcept;
//==============================================================================
/** The command's unique ID number.
@@ -123,7 +122,7 @@ struct JUCE_API ApplicationCommandInfo
@see addDefaultKeypress
*/
Array <KeyPress> defaultKeypresses;
Array<KeyPress> defaultKeypresses;
//==============================================================================
/** Flags describing the ways in which this command should be used.


+ 3
- 3
modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp View File

@@ -77,7 +77,7 @@ void ApplicationCommandManager::registerAllCommandsForTarget (ApplicationCommand
{
if (target != nullptr)
{
Array <CommandID> commandIDs;
Array<CommandID> commandIDs;
target->getAllCommands (commandIDs);
for (int i = 0; i < commandIDs.size(); ++i)
@@ -99,7 +99,7 @@ void ApplicationCommandManager::removeCommand (const CommandID commandID)
commands.remove (i);
triggerAsyncUpdate();
const Array <KeyPress> keys (keyMappings->getKeyPressesAssignedToCommand (commandID));
const Array<KeyPress> keys (keyMappings->getKeyPressesAssignedToCommand (commandID));
for (int j = keys.size(); --j >= 0;)
keyMappings->removeKeyPress (keys.getReference (j));
@@ -151,7 +151,7 @@ StringArray ApplicationCommandManager::getCommandCategories() const
Array<CommandID> ApplicationCommandManager::getCommandsInCategory (const String& categoryName) const
{
Array <CommandID> results;
Array<CommandID> results;
for (int i = 0; i < commands.size(); ++i)
if (commands.getUnchecked(i)->categoryName == categoryName)


+ 12
- 12
modules/juce_gui_basics/commands/juce_ApplicationCommandManager.h View File

@@ -239,7 +239,7 @@ public:
either use setFirstCommandTarget() to specify a single target, or override this method
if you need more complex logic to choose one.
It may return 0 if no targets are available.
It may return nullptr if no targets are available.
@see getTargetForCommand, invoke, invokeDirectly
*/
@@ -247,11 +247,11 @@ public:
/** Sets a target to be returned by getFirstCommandTarget().
If this is set to 0, then getFirstCommandTarget() will by default return the
If this is set to nullptr, then getFirstCommandTarget() will by default return the
result of findDefaultComponentTarget().
If you use this to set a target, make sure you call setFirstCommandTarget (0) before
deleting the target object.
If you use this to set a target, make sure you call setFirstCommandTarget(nullptr)
before deleting the target object.
*/
void setFirstCommandTarget (ApplicationCommandTarget* newTarget) noexcept;
@@ -262,7 +262,7 @@ public:
ApplicationCommandTarget::getNextCommandTarget() to find the next one to try, and
so on until no more are available.
If no targets are found that can perform the command, this method will return 0.
If no targets are found that can perform the command, this method will return nullptr.
If a target is found, then it will get the target to fill-in the upToDateInfo
structure with the latest info about that command, so that the caller can see
@@ -292,17 +292,17 @@ public:
/** Examines this component and all its parents in turn, looking for the first one
which is a ApplicationCommandTarget.
Returns the first ApplicationCommandTarget that it finds, or nullptr if none of them implement
that class.
Returns the first ApplicationCommandTarget that it finds, or nullptr if none of them
implement that class.
*/
static ApplicationCommandTarget* findTargetForComponent (Component* component);
static ApplicationCommandTarget* findTargetForComponent (Component*);
private:
//==============================================================================
OwnedArray <ApplicationCommandInfo> commands;
ListenerList <ApplicationCommandManagerListener> listeners;
ScopedPointer <KeyPressMappingSet> keyMappings;
OwnedArray<ApplicationCommandInfo> commands;
ListenerList<ApplicationCommandManagerListener> listeners;
ScopedPointer<KeyPressMappingSet> keyMappings;
ApplicationCommandTarget* firstTarget;
void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo&);
@@ -335,7 +335,7 @@ public:
virtual ~ApplicationCommandManagerListener() {}
/** Called when an app command is about to be invoked. */
virtual void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info) = 0;
virtual void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo&) = 0;
/** Called when commands are registered or deregistered from the
command manager, or when commands are made active or inactive.


+ 13
- 25
modules/juce_gui_basics/commands/juce_KeyPressMappingSet.cpp View File

@@ -29,8 +29,7 @@ KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager& cm)
}
KeyPressMappingSet::KeyPressMappingSet (const KeyPressMappingSet& other)
: KeyListener(), ChangeBroadcaster(), FocusChangeListener(),
commandManager (other.commandManager)
: KeyListener(), ChangeBroadcaster(), FocusChangeListener(), commandManager (other.commandManager)
{
Desktop::getInstance().addFocusChangeListener (this);
}
@@ -50,9 +49,7 @@ Array<KeyPress> KeyPressMappingSet::getKeyPressesAssignedToCommand (const Comman
return Array<KeyPress>();
}
void KeyPressMappingSet::addKeyPress (const CommandID commandID,
const KeyPress& newKeyPress,
int insertIndex)
void KeyPressMappingSet::addKeyPress (const CommandID commandID, const KeyPress& newKeyPress, int insertIndex)
{
// If you specify an upper-case letter but no shift key, how is the user supposed to press it!?
// Stick to lower-case letters when defining a keypress, to avoid ambiguity.
@@ -88,20 +85,18 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID,
}
}
static void addKeyPresses (KeyPressMappingSet& set, const ApplicationCommandInfo* const ci)
{
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
set.addKeyPress (ci->commandID, ci->defaultKeypresses.getReference (j));
}
void KeyPressMappingSet::resetToDefaultMappings()
{
mappings.clear();
for (int i = 0; i < commandManager.getNumCommands(); ++i)
{
const ApplicationCommandInfo* const ci = commandManager.getCommandForIndex (i);
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
{
addKeyPress (ci->commandID,
ci->defaultKeypresses.getReference (j));
}
}
addKeyPresses (*this, commandManager.getCommandForIndex (i));
sendChangeMessage();
}
@@ -110,13 +105,8 @@ void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID)
{
clearAllKeyPresses (commandID);
const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID);
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
{
addKeyPress (ci->commandID,
ci->defaultKeypresses.getReference (j));
}
if (const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID))
addKeyPresses (*this, ci);
}
void KeyPressMappingSet::clearAllKeyPresses()
@@ -333,10 +323,8 @@ bool KeyPressMappingSet::keyPressed (const KeyPress& key, Component* const origi
invokeCommand (cm.commandID, key, true, 0, originatingComponent);
return true;
}
else
{
commandWasDisabled = true;
}
commandWasDisabled = true;
}
}
}


+ 6
- 10
modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h View File

@@ -99,10 +99,10 @@ public:
@see ApplicationCommandManager
*/
explicit KeyPressMappingSet (ApplicationCommandManager& commandManager);
explicit KeyPressMappingSet (ApplicationCommandManager&);
/** Creates an copy of a KeyPressMappingSet. */
KeyPressMappingSet (const KeyPressMappingSet& other);
KeyPressMappingSet (const KeyPressMappingSet&);
/** Destructor. */
~KeyPressMappingSet();
@@ -135,13 +135,11 @@ public:
int insertIndex = -1);
/** Reset all mappings to the defaults, as dictated by the ApplicationCommandManager.
@see resetToDefaultMapping
*/
void resetToDefaultMappings();
/** Resets all key-mappings to the defaults for a particular command.
@see resetToDefaultMappings
*/
void resetToDefaultMapping (CommandID commandID);
@@ -153,14 +151,12 @@ public:
void clearAllKeyPresses (CommandID commandID);
/** Removes one of the keypresses that are assigned to a command.
See the getKeyPressesAssignedToCommand() for the list of keypresses to
which the keyPressIndex refers.
*/
void removeKeyPress (CommandID commandID, int keyPressIndex);
/** Removes a keypress from any command that it may be assigned to.
*/
/** Removes a keypress from any command that it may be assigned to. */
void removeKeyPress (const KeyPress& keypress);
/** Returns true if the given command is linked to this key. */
@@ -224,11 +220,11 @@ private:
struct CommandMapping
{
CommandID commandID;
Array <KeyPress> keypresses;
Array<KeyPress> keypresses;
bool wantsKeyUpDownCallbacks;
};
OwnedArray <CommandMapping> mappings;
OwnedArray<CommandMapping> mappings;
struct KeyPressTime
{
@@ -236,7 +232,7 @@ private:
uint32 timeWhenPressed;
};
OwnedArray <KeyPressTime> keysDown;
OwnedArray<KeyPressTime> keysDown;
void invokeCommand (const CommandID, const KeyPress&, const bool isKeyDown,
const int millisecsSinceKeyPressed, Component* originator) const;


+ 1
- 1
modules/juce_gui_basics/native/juce_mac_MainMenu.mm View File

@@ -261,7 +261,7 @@ public:
if (iter.commandManager != nullptr)
{
const Array <KeyPress> keyPresses (iter.commandManager->getKeyMappings()
const Array<KeyPress> keyPresses (iter.commandManager->getKeyMappings()
->getKeyPressesAssignedToCommand (iter.itemId));
if (keyPresses.size() > 0)


+ 1
- 1
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -3182,7 +3182,7 @@ void Desktop::Displays::findDisplays (float masterScale)
// make sure the first in the list is the main monitor
for (int i = 1; i < monitors.size(); ++i)
if (monitors.getReference(i).getX() == 0 && monitors.getReference(i).getY() == 0)
if (monitors.getReference(i).getPosition().isOrigin())
monitors.swap (i, 0);
if (monitors.size() == 0)


+ 3
- 6
modules/juce_gui_basics/widgets/juce_ComboBox.h View File

@@ -287,18 +287,15 @@ public:
//==============================================================================
/** Sets a message to display when there is no item currently selected.
@see getTextWhenNothingSelected
*/
void setTextWhenNothingSelected (const String& newMessage);
/** Returns the text that is shown when no item is selected.
@see setTextWhenNothingSelected
*/
String getTextWhenNothingSelected() const;
/** Sets the message to show when there are no items in the list, and the user clicks
on the drop-down box.
@@ -382,7 +379,7 @@ private:
//==============================================================================
struct ItemInfo
{
ItemInfo (const String& name, int itemId, bool isEnabled, bool isHeading);
ItemInfo (const String&, int itemId, bool isEnabled, bool isHeading);
bool isSeparator() const noexcept;
bool isRealItem() const noexcept;
@@ -399,8 +396,8 @@ private:
ScopedPointer<Label> label;
String textWhenNothingSelected, noChoicesMessage;
ItemInfo* getItemForId (int itemId) const noexcept;
ItemInfo* getItemForIndex (int index) const noexcept;
ItemInfo* getItemForId (int) const noexcept;
ItemInfo* getItemForIndex (int) const noexcept;
bool selectIfEnabled (int index);
bool nudgeSelectedItem (int delta);
void sendChange (NotificationType);


Loading…
Cancel
Save