Browse Source

Minor clean-ups.

tags/2021-05-28
jules 13 years ago
parent
commit
7a3453f48b
32 changed files with 220 additions and 278 deletions
  1. +2
    -2
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h
  2. +17
    -19
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h
  3. +9
    -9
      modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp
  4. +3
    -9
      modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm
  5. +1
    -3
      modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm
  6. +2
    -5
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  7. +5
    -4
      modules/juce_audio_formats/sampler/juce_Sampler.cpp
  8. +8
    -8
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  9. +15
    -15
      modules/juce_core/containers/juce_ReferenceCountedArray.h
  10. +14
    -12
      modules/juce_core/maths/juce_Expression.cpp
  11. +3
    -4
      modules/juce_core/text/juce_String.cpp
  12. +1
    -3
      modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp
  13. +3
    -4
      modules/juce_graphics/fonts/juce_CustomTypeface.cpp
  14. +2
    -2
      modules/juce_graphics/native/juce_RenderingHelpers.h
  15. +7
    -5
      modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp
  16. +4
    -13
      modules/juce_gui_basics/components/juce_Desktop.cpp
  17. +2
    -4
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  18. +6
    -15
      modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp
  19. +6
    -6
      modules/juce_gui_basics/layout/juce_ScrollBar.cpp
  20. +3
    -7
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp
  21. +2
    -2
      modules/juce_gui_basics/misc/juce_BubbleComponent.cpp
  22. +20
    -23
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  23. +1
    -2
      modules/juce_gui_basics/native/juce_mac_FileChooser.mm
  24. +4
    -8
      modules/juce_gui_basics/positioning/juce_MarkerList.cpp
  25. +2
    -2
      modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp
  26. +17
    -32
      modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp
  27. +1
    -3
      modules/juce_gui_basics/properties/juce_PropertyComponent.cpp
  28. +1
    -3
      modules/juce_gui_basics/properties/juce_PropertyPanel.cpp
  29. +33
    -28
      modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp
  30. +14
    -14
      modules/juce_gui_basics/windows/juce_DocumentWindow.cpp
  31. +3
    -3
      modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h
  32. +9
    -9
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp

+ 2
- 2
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h View File

@@ -1284,8 +1284,8 @@ protected:
String getProjectType() const
{
if (projectType.isGUIApplication() || projectType.isCommandLineApp()) return "Application";
else if (isLibraryDLL()) return "DynamicLibrary";
else if (projectType.isLibrary()) return "StaticLibrary";
if (isLibraryDLL()) return "DynamicLibrary";
if (projectType.isLibrary()) return "StaticLibrary";
jassertfalse;
return String::empty;


+ 17
- 19
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h View File

@@ -65,10 +65,8 @@ public:
static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings)
{
if (settings.hasType (getValueTreeTypeName (false)))
return new XCodeProjectExporter (project, settings, false);
else if (settings.hasType (getValueTreeTypeName (true)))
return new XCodeProjectExporter (project, settings, true);
if (settings.hasType (getValueTreeTypeName (false))) return new XCodeProjectExporter (project, settings, false);
if (settings.hasType (getValueTreeTypeName (true))) return new XCodeProjectExporter (project, settings, true);
return nullptr;
}
@@ -981,21 +979,21 @@ public:
private:
static String getFileType (const RelativePath& file)
{
if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp";
else if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
else if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
else if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
else if (file.hasFileExtension (".framework")) return "wrapper.framework";
else if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
else if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
else if (file.hasFileExtension ("html;htm")) return "text.html";
else if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
else if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
else if (file.hasFileExtension ("plist")) return "text.plist.xml";
else if (file.hasFileExtension ("app")) return "wrapper.application";
else if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
else if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
else if (file.hasFileExtension ("a")) return "archive.ar";
if (file.hasFileExtension ("cpp;cc;cxx")) return "sourcecode.cpp.cpp";
if (file.hasFileExtension (".mm")) return "sourcecode.cpp.objcpp";
if (file.hasFileExtension (".m")) return "sourcecode.c.objc";
if (file.hasFileExtension (headerFileExtensions)) return "sourcecode.c.h";
if (file.hasFileExtension (".framework")) return "wrapper.framework";
if (file.hasFileExtension (".jpeg;.jpg")) return "image.jpeg";
if (file.hasFileExtension ("png;gif")) return "image" + file.getFileExtension();
if (file.hasFileExtension ("html;htm")) return "text.html";
if (file.hasFileExtension ("xml;zip;wav")) return "file" + file.getFileExtension();
if (file.hasFileExtension ("txt;rtf")) return "text" + file.getFileExtension();
if (file.hasFileExtension ("plist")) return "text.plist.xml";
if (file.hasFileExtension ("app")) return "wrapper.application";
if (file.hasFileExtension ("component;vst;plugin")) return "wrapper.cfbundle";
if (file.hasFileExtension ("xcodeproj")) return "wrapper.pb-project";
if (file.hasFileExtension ("a")) return "archive.ar";
return "file" + file.getFileExtension();
}


+ 9
- 9
modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp View File

@@ -286,16 +286,16 @@ void Synthesiser::noteOff (const int midiChannel,
if (voice->getCurrentlyPlayingNote() == midiNoteNumber)
{
SynthesiserSound* const sound = voice->getCurrentlyPlayingSound();
if (sound != nullptr
&& sound->appliesToNote (midiNoteNumber)
&& sound->appliesToChannel (midiChannel))
if (SynthesiserSound* const sound = voice->getCurrentlyPlayingSound())
{
voice->keyIsDown = false;
if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown))
stopVoice (voice, allowTailOff);
if (sound->appliesToNote (midiNoteNumber)
&& sound->appliesToChannel (midiChannel))
{
voice->keyIsDown = false;
if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown))
stopVoice (voice, allowTailOff);
}
}
}
}


+ 3
- 9
modules/juce_audio_devices/native/juce_mac_AudioCDBurner.mm View File

@@ -93,9 +93,7 @@ private:
static BOOL prepareTrack (id self, SEL, DRTrack*, DRBurn*, NSDictionary*)
{
AudioSourceHolder* const source = getSource (self);
if (source != nullptr)
if (AudioSourceHolder* const source = getSource (self))
{
source->source->prepareToPlay (44100 / 75, 44100);
source->readPosition = 0;
@@ -106,9 +104,7 @@ private:
static BOOL prepareTrackForVerification (id self, SEL, DRTrack*)
{
AudioSourceHolder* const source = getSource (self);
if (source != nullptr)
if (AudioSourceHolder* const source = getSource (self))
source->source->prepareToPlay (44100 / 75, 44100);
return true;
@@ -118,9 +114,7 @@ private:
uint32_t bufferLength, uint64_t /*address*/,
uint32_t /*blockSize*/, uint32_t* /*flags*/)
{
AudioSourceHolder* const source = getSource (self);
if (source != nullptr)
if (AudioSourceHolder* const source = getSource (self))
{
const int numSamples = jmin ((int) bufferLength / 4,
(source->lengthInFrames * (44100 / 75)) - source->readPosition);


+ 1
- 3
modules/juce_audio_devices/native/juce_mac_AudioCDReader.mm View File

@@ -199,9 +199,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta
{
reader = nullptr;
FileInputStream* const in = tracks [track].createInputStream();
if (in != nullptr)
if (FileInputStream* const in = tracks [track].createInputStream())
{
BufferedInputStream* const bin = new BufferedInputStream (in, 65536, true);


+ 2
- 5
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -432,9 +432,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback)
if (CHECK_ERROR (MIDIObjectGetStringProperty (endPoint, kMIDIPropertyName, &name)))
{
MIDIClientRef client = getGlobalMidiClient();
if (client != 0)
if (MIDIClientRef client = getGlobalMidiClient())
{
MIDIPortRef port;
ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback));
@@ -473,9 +471,8 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba
using namespace CoreMidiHelpers;
MidiInput* mi = nullptr;
MIDIClientRef client = getGlobalMidiClient();
if (client != 0)
if (MIDIClientRef client = getGlobalMidiClient())
{
ScopedPointer <MidiPortAndCallback> mpc (new MidiPortAndCallback (*callback));
mpc->active = false;


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

@@ -96,10 +96,7 @@ void SamplerVoice::startNote (const int midiNoteNumber,
SynthesiserSound* s,
const int /*currentPitchWheelPosition*/)
{
const SamplerSound* const sound = dynamic_cast <const SamplerSound*> (s);
jassert (sound != nullptr); // this object can only play SamplerSounds!
if (sound != nullptr)
if (const SamplerSound* const sound = dynamic_cast <const SamplerSound*> (s))
{
pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0)
* sound->sourceSampleRate / getSampleRate();
@@ -127,6 +124,10 @@ void SamplerVoice::startNote (const int midiNoteNumber,
else
releaseDelta = 0.0f;
}
else
{
jassertfalse; // this object can only play SamplerSounds!
}
}
void SamplerVoice::stopNote (const bool allowTailOff)


+ 8
- 8
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -857,14 +857,14 @@ struct ConnectionSorter
static int compareElements (const AudioProcessorGraph::Connection* const first,
const AudioProcessorGraph::Connection* const second) noexcept
{
if (first->sourceNodeId < second->sourceNodeId) return -1;
else if (first->sourceNodeId > second->sourceNodeId) return 1;
else if (first->destNodeId < second->destNodeId) return -1;
else if (first->destNodeId > second->destNodeId) return 1;
else if (first->sourceChannelIndex < second->sourceChannelIndex) return -1;
else if (first->sourceChannelIndex > second->sourceChannelIndex) return 1;
else if (first->destChannelIndex < second->destChannelIndex) return -1;
else if (first->destChannelIndex > second->destChannelIndex) return 1;
if (first->sourceNodeId < second->sourceNodeId) return -1;
if (first->sourceNodeId > second->sourceNodeId) return 1;
if (first->destNodeId < second->destNodeId) return -1;
if (first->destNodeId > second->destNodeId) return 1;
if (first->sourceChannelIndex < second->sourceChannelIndex) return -1;
if (first->sourceChannelIndex > second->sourceChannelIndex) return 1;
if (first->destChannelIndex < second->destChannelIndex) return -1;
if (first->destChannelIndex > second->destChannelIndex) return 1;
return 0;
}


+ 15
- 15
modules/juce_core/containers/juce_ReferenceCountedArray.h View File

@@ -69,8 +69,8 @@ public:
memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*));
for (int i = numUsed; --i >= 0;)
if (data.elements[i] != nullptr)
data.elements[i]->incReferenceCount();
if (ObjectClass* o = data.elements[i])
o->incReferenceCount();
}
/** Creates a copy of another array */
@@ -83,8 +83,8 @@ public:
memcpy (data.elements, other.getRawDataPointer(), numUsed * sizeof (ObjectClass*));
for (int i = numUsed; --i >= 0;)
if (data.elements[i] != nullptr)
data.elements[i]->incReferenceCount();
if (ObjectClass* o = data.elements[i])
o->incReferenceCount();
}
/** Copies another array into this one.
@@ -126,8 +126,8 @@ public:
const ScopedLockType lock (getLock());
while (numUsed > 0)
if (data.elements [--numUsed] != nullptr)
data.elements [numUsed]->decReferenceCount();
if (ObjectClass* o = data.elements [--numUsed])
o->decReferenceCount();
jassert (numUsed == 0);
data.setAllocatedSize (0);
@@ -382,8 +382,8 @@ public:
if (indexToChange < numUsed)
{
if (data.elements [indexToChange] != nullptr)
data.elements [indexToChange]->decReferenceCount();
if (ObjectClass* o = data.elements [indexToChange])
o->decReferenceCount();
data.elements [indexToChange] = newObject;
}
@@ -531,8 +531,8 @@ public:
{
ObjectClass** const e = data.elements + indexToRemove;
if (*e != nullptr)
(*e)->decReferenceCount();
if (ObjectClass* o = *e)
o->decReferenceCount();
--numUsed;
const int numberToShift = numUsed - indexToRemove;
@@ -563,10 +563,10 @@ public:
{
ObjectClass** const e = data.elements + indexToRemove;
if (*e != nullptr)
if (ObjectClass* o = *e)
{
removedItem = *e;
(*e)->decReferenceCount();
removedItem = o;
o->decReferenceCount();
}
--numUsed;
@@ -624,9 +624,9 @@ public:
int i;
for (i = start; i < endIndex; ++i)
{
if (data.elements[i] != nullptr)
if (ObjectClass* o = data.elements[i])
{
data.elements[i]->decReferenceCount();
o->decReferenceCount();
data.elements[i] = nullptr; // (in case one of the destructors accesses this array and hits a dangling pointer)
}
}


+ 14
- 12
modules/juce_core/maths/juce_Expression.cpp View File

@@ -877,7 +877,8 @@ struct Expression::Helpers
throw ParseError ("Expected \")\"");
}
else if (readOperator ("."))
if (readOperator ("."))
{
TermPtr rhs (readSymbolOrFunction());
@@ -889,11 +890,10 @@ struct Expression::Helpers
return new DotOperator (new SymbolTerm (identifier), rhs);
}
else // just a symbol..
{
jassert (identifier.trim() == identifier);
return new SymbolTerm (identifier);
}
// just a symbol..
jassert (identifier.trim() == identifier);
return new SymbolTerm (identifier);
}
return TermPtr();
@@ -1146,7 +1146,8 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do
return v;
}
else if (functionName == "max")
if (functionName == "max")
{
double v = parameters[0];
for (int i = 1; i < numParams; ++i)
@@ -1154,12 +1155,13 @@ double Expression::Scope::evaluateFunction (const String& functionName, const do
return v;
}
else if (numParams == 1)
if (numParams == 1)
{
if (functionName == "sin") return sin (parameters[0]);
else if (functionName == "cos") return cos (parameters[0]);
else if (functionName == "tan") return tan (parameters[0]);
else if (functionName == "abs") return std::abs (parameters[0]);
if (functionName == "sin") return sin (parameters[0]);
if (functionName == "cos") return cos (parameters[0]);
if (functionName == "tan") return tan (parameters[0]);
if (functionName == "abs") return std::abs (parameters[0]);
}
}


+ 3
- 4
modules/juce_core/text/juce_String.cpp View File

@@ -2070,10 +2070,9 @@ String String::fromUTF8 (const char* const buffer, int bufferSizeBytes)
{
if (buffer != nullptr)
{
if (bufferSizeBytes < 0)
return String (CharPointer_UTF8 (buffer));
else if (bufferSizeBytes > 0)
return String (CharPointer_UTF8 (buffer), CharPointer_UTF8 (buffer + bufferSizeBytes));
if (bufferSizeBytes < 0) return String (CharPointer_UTF8 (buffer));
if (bufferSizeBytes > 0) return String (CharPointer_UTF8 (buffer),
CharPointer_UTF8 (buffer + bufferSizeBytes));
}
return String::empty;


+ 1
- 3
modules/juce_data_structures/app_properties/juce_PropertiesFile.cpp View File

@@ -223,9 +223,7 @@ bool PropertiesFile::saveAsXml()
e->setAttribute (PropertyFileConstants::nameAttribute, getAllProperties().getAllKeys() [i]);
// if the value seems to contain xml, store it as such..
XmlElement* const childElement = XmlDocument::parse (getAllProperties().getAllValues() [i]);
if (childElement != nullptr)
if (XmlElement* const childElement = XmlDocument::parse (getAllProperties().getAllValues() [i]))
e->addChildElement (childElement);
else
e->setAttribute (PropertyFileConstants::valueAttribute,


+ 3
- 4
modules/juce_graphics/fonts/juce_CustomTypeface.cpp View File

@@ -194,11 +194,10 @@ void CustomTypeface::addKerningPair (const juce_wchar char1, const juce_wchar ch
{
if (extraAmount != 0)
{
GlyphInfo* const g = findGlyph (char1, true);
jassert (g != nullptr); // can only add kerning pairs for characters that exist!
if (g != nullptr)
if (GlyphInfo* const g = findGlyph (char1, true))
g->addKerningPair (char2, extraAmount);
else
jassertfalse; // can only add kerning pairs for characters that exist!
}
}


+ 2
- 2
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -2171,8 +2171,8 @@ public:
{
if (transform.isOnlyTranslated)
return clip->clipRegionIntersects (transform.translated (r));
else
return getClipBounds().intersects (r);
return getClipBounds().intersects (r);
}
return false;


+ 7
- 5
modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp View File

@@ -125,17 +125,19 @@ const ApplicationCommandInfo* ApplicationCommandManager::getCommandForID (const
String ApplicationCommandManager::getNameOfCommand (const CommandID commandID) const noexcept
{
const ApplicationCommandInfo* const ci = getCommandForID (commandID);
if (const ApplicationCommandInfo* const ci = getCommandForID (commandID))
return ci->shortName;
return ci != nullptr ? ci->shortName : String::empty;
return String::empty;
}
String ApplicationCommandManager::getDescriptionOfCommand (const CommandID commandID) const noexcept
{
const ApplicationCommandInfo* const ci = getCommandForID (commandID);
if (const ApplicationCommandInfo* const ci = getCommandForID (commandID))
return ci->description.isNotEmpty() ? ci->description
: ci->shortName;
return ci != nullptr ? (ci->description.isNotEmpty() ? ci->description : ci->shortName)
: String::empty;
return String::empty;
}
StringArray ApplicationCommandManager::getCommandCategories() const


+ 4
- 13
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -101,12 +101,8 @@ void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel)
currentLookAndFeel = newDefaultLookAndFeel;
for (int i = getNumComponents(); --i >= 0;)
{
Component* const c = getComponent (i);
if (c != nullptr)
if (Component* const c = getComponent (i))
c->sendLookAndFeelChange();
}
}
//==============================================================================
@@ -304,9 +300,7 @@ void Desktop::sendMouseMove()
lastFakeMouseMove = getMousePosition();
Component* const target = findComponentAt (lastFakeMouseMove);
if (target != nullptr)
if (Component* const target = findComponentAt (lastFakeMouseMove))
{
Component::BailOutChecker checker (target);
const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove));
@@ -405,11 +399,8 @@ void Desktop::Displays::refresh()
if (oldDisplays != displays)
{
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
{
ComponentPeer* const p = ComponentPeer::getPeer (i);
if (p != nullptr)
p->handleScreenSizeChange();
}
if (ComponentPeer* const peer = ComponentPeer::getPeer (i))
peer->handleScreenSizeChange();
}
}


+ 2
- 4
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -125,9 +125,8 @@ bool DirectoryContentsList::getFileInfo (const int index,
FileInfo& result) const
{
const ScopedLock sl (fileListLock);
const FileInfo* const info = files [index];
if (info != nullptr)
if (const FileInfo* const info = files [index])
{
result = *info;
return true;
@@ -139,9 +138,8 @@ bool DirectoryContentsList::getFileInfo (const int index,
File DirectoryContentsList::getFile (const int index) const
{
const ScopedLock sl (fileListLock);
const FileInfo* const info = files [index];
if (info != nullptr)
if (const FileInfo* const info = files [index])
return root.getChildFile (info->filename);
return File::nonexistent;


+ 6
- 15
modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp View File

@@ -52,12 +52,8 @@ namespace ComponentBuilderHelpers
return &c;
for (int i = c.getNumChildComponents(); --i >= 0;)
{
Component* const child = findComponentWithID (*c.getChildComponent (i), compId);
if (child != nullptr)
if (Component* const child = findComponentWithID (*c.getChildComponent (i), compId))
return child;
}
return nullptr;
}
@@ -73,9 +69,7 @@ namespace ComponentBuilderHelpers
static void updateComponent (ComponentBuilder& builder, const ValueTree& state)
{
Component* topLevelComp = builder.getManagedComponent();
if (topLevelComp != nullptr)
if (Component* topLevelComp = builder.getManagedComponent())
{
ComponentBuilder::TypeHandler* const type = builder.getHandlerForState (state);
const String uid (getStateId (state));
@@ -88,9 +82,7 @@ namespace ComponentBuilderHelpers
}
else
{
Component* const changedComp = findComponentWithID (*topLevelComp, uid);
if (changedComp != nullptr)
if (Component* const changedComp = findComponentWithID (*topLevelComp, uid))
type->updateComponentFromState (changedComp, state);
}
}
@@ -264,11 +256,10 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree
if (c == nullptr)
{
TypeHandler* const type = getHandlerForState (childState);
jassert (type != nullptr);
if (type != nullptr)
if (TypeHandler* const type = getHandlerForState (childState))
c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent);
else
jassertfalse;
}
if (c != nullptr)


+ 6
- 6
modules/juce_gui_basics/layout/juce_ScrollBar.cpp View File

@@ -410,12 +410,12 @@ bool ScrollBar::keyPressed (const KeyPress& key)
{
if (isVisible())
{
if (key == KeyPress::upKey || key == KeyPress::leftKey) return moveScrollbarInSteps (-1);
else if (key == KeyPress::downKey || key == KeyPress::rightKey) return moveScrollbarInSteps (1);
else if (key == KeyPress::pageUpKey) return moveScrollbarInPages (-1);
else if (key == KeyPress::pageDownKey) return moveScrollbarInPages (1);
else if (key == KeyPress::homeKey) return scrollToTop();
else if (key == KeyPress::endKey) return scrollToBottom();
if (key == KeyPress::upKey || key == KeyPress::leftKey) return moveScrollbarInSteps (-1);
if (key == KeyPress::downKey || key == KeyPress::rightKey) return moveScrollbarInSteps (1);
if (key == KeyPress::pageUpKey) return moveScrollbarInPages (-1);
if (key == KeyPress::pageDownKey) return moveScrollbarInPages (1);
if (key == KeyPress::homeKey) return scrollToTop();
if (key == KeyPress::endKey) return scrollToBottom();
}
return false;


+ 3
- 7
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp View File

@@ -2045,9 +2045,7 @@ int LookAndFeel::getTabButtonBestWidth (TabBarButton& button, int tabDepth)
int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim())
+ getTabButtonOverlap (tabDepth) * 2;
Component* const extraComponent = button.getExtraComponent();
if (extraComponent != nullptr)
if (Component* const extraComponent = button.getExtraComponent())
width += button.getTabbedButtonBar().isVertical() ? extraComponent->getHeight()
: extraComponent->getWidth();
@@ -2526,10 +2524,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height,
}
else
{
const Drawable* d = isDirectory ? getDefaultFolderImage()
: getDefaultDocumentFileImage();
if (d != nullptr)
if (const Drawable* d = isDirectory ? getDefaultFolderImage()
: getDefaultDocumentFileImage())
d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, height - 4.0f),
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
}


+ 2
- 2
modules/juce_gui_basics/misc/juce_BubbleComponent.cpp View File

@@ -54,8 +54,8 @@ void BubbleComponent::setPosition (Component* componentToPointTo)
{
jassert (componentToPointTo != nullptr);
if (getParentComponent() != nullptr)
setPosition (getParentComponent()->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds()));
if (Component* p = getParentComponent())
setPosition (p->getLocalArea (componentToPointTo, componentToPointTo->getLocalBounds()));
else
setPosition (componentToPointTo->getScreenBounds());
}


+ 20
- 23
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -67,10 +67,9 @@ public:
{
mouseDragSource->removeMouseListener (this);
DragAndDropTarget* const current = getCurrentlyOver();
if (current != nullptr && current->isInterestedInDragSource (sourceDetails))
current->itemDragExit (sourceDetails);
if (DragAndDropTarget* const current = getCurrentlyOver())
if (current->isInterestedInDragSource (sourceDetails))
current->itemDragExit (sourceDetails);
}
}
@@ -103,8 +102,8 @@ public:
if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback
dismissWithAnimation (finalTarget == nullptr);
if (getParentComponent() != nullptr)
getParentComponent()->removeChildComponent (this);
if (Component* parent = getParentComponent())
parent->removeChildComponent (this);
if (finalTarget != nullptr)
{
@@ -135,11 +134,9 @@ public:
if (newTargetComp != currentlyOverComp)
{
DragAndDropTarget* const lastTarget = getCurrentlyOver();
if (lastTarget != nullptr && details.sourceComponent != nullptr
&& lastTarget->isInterestedInDragSource (details))
lastTarget->itemDragExit (details);
if (DragAndDropTarget* const lastTarget = getCurrentlyOver())
if (details.sourceComponent != nullptr && lastTarget->isInterestedInDragSource (details))
lastTarget->itemDragExit (details);
currentlyOverComp = newTargetComp;
@@ -206,13 +203,14 @@ private:
while (hit != nullptr)
{
DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit);
if (ddt != nullptr && ddt->isInterestedInDragSource (details))
if (DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit))
{
relativePos = hit->getLocalPoint (nullptr, screenPos);
resultComponent = hit;
return ddt;
if (ddt->isInterestedInDragSource (details))
{
relativePos = hit->getLocalPoint (nullptr, screenPos);
resultComponent = hit;
return ddt;
}
}
hit = hit->getParentComponent();
@@ -226,18 +224,17 @@ private:
{
Point<int> newPos (screenPos - imageOffset);
if (getParentComponent() != nullptr)
newPos = getParentComponent()->getLocalPoint (nullptr, newPos);
if (Component* p = getParentComponent())
newPos = p->getLocalPoint (nullptr, newPos);
setTopLeftPosition (newPos);
}
void sendDragMove (DragAndDropTarget::SourceDetails& details) const
{
DragAndDropTarget* const target = getCurrentlyOver();
if (target != nullptr && target->isInterestedInDragSource (details))
target->itemDragMove (details);
if (DragAndDropTarget* const target = getCurrentlyOver())
if (target->isInterestedInDragSource (details))
target->itemDragMove (details);
}
struct ExternalDragAndDropMessage : public CallbackMessage


+ 1
- 2
modules/juce_gui_basics/native/juce_mac_FileChooser.mm View File

@@ -91,8 +91,7 @@ public:
TemporaryMainMenuWithStandardCommands()
: oldMenu (MenuBarModel::getMacMainMenu()), oldAppleMenu (nullptr)
{
const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu();
if (appleMenu != nullptr)
if (const PopupMenu* appleMenu = MenuBarModel::getMacExtraAppleItemsMenu())
oldAppleMenu = new PopupMenu (*appleMenu);
MenuBarModel::setMacMainMenu (nullptr);


+ 4
- 8
modules/juce_gui_basics/positioning/juce_MarkerList.cpp View File

@@ -245,15 +245,11 @@ void MarkerList::ValueTreeWrapper::removeMarker (const ValueTree& marker, UndoMa
double MarkerList::getMarkerPosition (const Marker& marker, Component* parentComponent) const
{
if (parentComponent != nullptr)
{
RelativeCoordinatePositionerBase::ComponentScope scope (*parentComponent);
return marker.position.resolve (&scope);
}
else
{
if (parentComponent == nullptr)
return marker.position.resolve (nullptr);
}
RelativeCoordinatePositionerBase::ComponentScope scope (*parentComponent);
return marker.position.resolve (&scope);
}
//==============================================================================


+ 2
- 2
modules/juce_gui_basics/positioning/juce_RelativeCoordinate.cpp View File

@@ -116,8 +116,8 @@ double RelativeCoordinate::resolve (const Expression::Scope* scope) const
{
if (scope != nullptr)
return term.evaluate (*scope);
else
return term.evaluate();
return term.evaluate();
}
catch (Expression::ParseError&)
{}


+ 17
- 32
modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp View File

@@ -38,9 +38,8 @@ public:
}
MarkerList* list;
const MarkerList::Marker* const marker = findMarker (component, symbol, list);
if (marker != nullptr)
if (const MarkerList::Marker* const marker = findMarker (component, symbol, list))
return Expression (marker->position.getExpression().evaluate (*this));
return Expression::Scope::getSymbolValue (symbol);
@@ -50,9 +49,7 @@ public:
{
if (scopeName == RelativeCoordinate::Strings::parent)
{
Component* const parent = component.getParentComponent();
if (parent != nullptr)
if (Component* const parent = component.getParentComponent())
{
visitor.visit (MarkerListScope (*parent));
return;
@@ -113,14 +110,11 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con
default: break;
}
Component* const parent = component.getParentComponent();
if (parent != nullptr)
if (Component* const parent = component.getParentComponent())
{
MarkerList* list;
const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list);
if (marker != nullptr)
if (const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list))
{
MarkerListScope scope (*parent);
return Expression (marker->position.getExpression().evaluate (scope));
@@ -132,11 +126,9 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con
void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const String& scopeName, Visitor& visitor) const
{
Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
? component.getParentComponent()
: findSiblingComponent (scopeName);
if (targetComp != nullptr)
if (Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
? component.getParentComponent()
: findSiblingComponent (scopeName))
visitor.visit (ComponentScope (*targetComp));
else
Expression::Scope::visitRelativeScope (scopeName, visitor);
@@ -149,10 +141,10 @@ String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const
Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) const
{
Component* const parent = component.getParentComponent();
if (Component* const parent = component.getParentComponent())
return parent->findChildWithID (componentID);
return parent != nullptr ? parent->findChildWithID (componentID)
: nullptr;
return nullptr;
}
//==============================================================================
@@ -180,14 +172,11 @@ public:
break;
default:
{
Component* const parent = component.getParentComponent();
if (parent != nullptr)
if (Component* const parent = component.getParentComponent())
{
MarkerList* list;
const MarkerList::Marker* marker = MarkerListScope::findMarker (*parent, symbol, list);
if (marker != nullptr)
if (MarkerListScope::findMarker (*parent, symbol, list) != nullptr)
{
positioner.registerMarkerListListener (list);
}
@@ -199,8 +188,7 @@ public:
ok = false;
}
}
}
break;
break;
}
return ComponentScope::getSymbolValue (symbol);
@@ -208,19 +196,16 @@ public:
void visitRelativeScope (const String& scopeName, Visitor& visitor) const
{
Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
? component.getParentComponent()
: findSiblingComponent (scopeName);
if (targetComp != nullptr)
if (Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
? component.getParentComponent()
: findSiblingComponent (scopeName))
{
visitor.visit (DependencyFinderScope (*targetComp, positioner, ok));
}
else
{
// The named component doesn't exist, so we'll watch the parent for changes in case it appears later..
Component* const parent = component.getParentComponent();
if (parent != nullptr)
if (Component* const parent = component.getParentComponent())
positioner.registerComponentListener (*parent);
positioner.registerComponentListener (component);


+ 1
- 3
modules/juce_gui_basics/properties/juce_PropertyComponent.cpp View File

@@ -31,7 +31,6 @@ PropertyComponent::PropertyComponent (const String& name, const int preferredHei
PropertyComponent::~PropertyComponent() {}
//==============================================================================
void PropertyComponent::paint (Graphics& g)
{
LookAndFeel& lf = getLookAndFeel();
@@ -42,8 +41,7 @@ void PropertyComponent::paint (Graphics& g)
void PropertyComponent::resized()
{
Component* const c = getChildComponent(0);
if (c != nullptr)
if (Component* const c = getChildComponent(0))
c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this));
}


+ 1
- 3
modules/juce_gui_basics/properties/juce_PropertyPanel.cpp View File

@@ -87,9 +87,7 @@ public:
for (int i = propertyComps.size(); --i >= 0;)
propertyComps.getUnchecked(i)->setVisible (open);
PropertyPanel* const pp = findParentComponentOfClass<PropertyPanel>();
if (pp != nullptr)
if (PropertyPanel* const pp = findParentComponentOfClass<PropertyPanel>())
pp->resized();
}
}


+ 33
- 28
modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp View File

@@ -87,26 +87,27 @@ int TableHeaderComponent::getNumColumns (const bool onlyCountVisibleColumns) con
return num;
}
else
{
return columns.size();
}
return columns.size();
}
String TableHeaderComponent::getColumnName (const int columnId) const
{
const ColumnInfo* const ci = getInfoForId (columnId);
return ci != nullptr ? ci->name : String::empty;
if (const ColumnInfo* const ci = getInfoForId (columnId))
return ci->name;
return String::empty;
}
void TableHeaderComponent::setColumnName (const int columnId, const String& newName)
{
ColumnInfo* const ci = getInfoForId (columnId);
if (ci != nullptr && ci->name != newName)
if (ColumnInfo* const ci = getInfoForId (columnId))
{
ci->name = newName;
sendColumnsChanged();
if (ci->name != newName)
{
ci->name = newName;
sendColumnsChanged();
}
}
}
@@ -173,8 +174,10 @@ void TableHeaderComponent::moveColumn (const int columnId, int newIndex)
int TableHeaderComponent::getColumnWidth (const int columnId) const
{
const ColumnInfo* const ci = getInfoForId (columnId);
return ci != nullptr ? ci->width : 0;
if (const ColumnInfo* const ci = getInfoForId (columnId))
return ci->width;
return 0;
}
void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidth)
@@ -233,8 +236,10 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis
if (onlyCountVisibleColumns)
index = visibleIndexToTotalIndex (index);
const ColumnInfo* const ci = columns [index];
return (ci != nullptr) ? ci->id : 0;
if (const ColumnInfo* const ci = columns [index])
return ci->id;
return 0;
}
Rectangle<int> TableHeaderComponent::getColumnPosition (const int index) const
@@ -355,17 +360,18 @@ void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetT
void TableHeaderComponent::setColumnVisible (const int columnId, const bool shouldBeVisible)
{
ColumnInfo* const ci = getInfoForId (columnId);
if (ci != nullptr && shouldBeVisible != ci->isVisible())
if (ColumnInfo* const ci = getInfoForId (columnId))
{
if (shouldBeVisible)
ci->propertyFlags |= visible;
else
ci->propertyFlags &= ~visible;
if (shouldBeVisible != ci->isVisible())
{
if (shouldBeVisible)
ci->propertyFlags |= visible;
else
ci->propertyFlags &= ~visible;
sendColumnsChanged();
resized();
sendColumnsChanged();
resized();
}
}
}
@@ -481,10 +487,9 @@ void TableHeaderComponent::removeListener (Listener* const listenerToRemove)
//==============================================================================
void TableHeaderComponent::columnClicked (int columnId, const ModifierKeys& mods)
{
const ColumnInfo* const ci = getInfoForId (columnId);
if (ci != nullptr && (ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu())
setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0);
if (const ColumnInfo* const ci = getInfoForId (columnId))
if ((ci->propertyFlags & sortable) != 0 && ! mods.isPopupMenu())
setSortColumnId (columnId, (ci->propertyFlags & sortedForwards) == 0);
}
void TableHeaderComponent::addMenuItems (PopupMenu& menu, const int /*columnIdClicked*/)


+ 14
- 14
modules/juce_gui_basics/windows/juce_DocumentWindow.cpp View File

@@ -210,12 +210,12 @@ void DocumentWindow::paint (Graphics& g)
for (int i = 0; i < 3; ++i)
{
if (titleBarButtons[i] != nullptr)
if (Button* const b = titleBarButtons[i])
{
if (positionTitleBarButtonsOnLeft)
titleSpaceX1 = jmax (titleSpaceX1, titleBarButtons[i]->getRight() + (getWidth() - titleBarButtons[i]->getRight()) / 8);
titleSpaceX1 = jmax (titleSpaceX1, b->getRight() + (getWidth() - b->getRight()) / 8);
else
titleSpaceX2 = jmin (titleSpaceX2, titleBarButtons[i]->getX() - (titleBarButtons[i]->getX() / 8));
titleSpaceX2 = jmin (titleSpaceX2, b->getX() - (b->getX() / 8));
}
}
@@ -232,8 +232,8 @@ void DocumentWindow::resized()
{
ResizableWindow::resized();
if (titleBarButtons[1] != nullptr)
titleBarButtons[1]->setToggleState (isFullScreen(), false);
if (Button* const b = getMaximiseButton())
b->setToggleState (isFullScreen(), false);
const Rectangle<int> titleBarArea (getTitleBarArea());
@@ -311,25 +311,25 @@ void DocumentWindow::lookAndFeelChanged()
for (int i = 0; i < 3; ++i)
{
if (titleBarButtons[i] != nullptr)
if (Button* const b = titleBarButtons[i])
{
if (buttonListener == nullptr)
buttonListener = new ButtonListenerProxy (*this);
titleBarButtons[i]->addListener (buttonListener);
titleBarButtons[i]->setWantsKeyboardFocus (false);
b->addListener (buttonListener);
b->setWantsKeyboardFocus (false);
// (call the Component method directly to avoid the assertion in ResizableWindow)
Component::addAndMakeVisible (titleBarButtons[i]);
Component::addAndMakeVisible (b);
}
}
if (getCloseButton() != nullptr)
if (Button* const b = getCloseButton())
{
#if JUCE_MAC
getCloseButton()->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0));
b->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0));
#else
getCloseButton()->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0));
b->addShortcut (KeyPress (KeyPress::F4Key, ModifierKeys::altModifier, 0));
#endif
}
}
@@ -349,8 +349,8 @@ void DocumentWindow::activeWindowStatusChanged()
ResizableWindow::activeWindowStatusChanged();
for (int i = numElementsInArray (titleBarButtons); --i >= 0;)
if (titleBarButtons[i] != nullptr)
titleBarButtons[i]->setEnabled (isActiveWindow());
if (Button* const b = titleBarButtons[i])
b->setEnabled (isActiveWindow());
if (menuBar != nullptr)
menuBar->setEnabled (isActiveWindow());


+ 3
- 3
modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h View File

@@ -160,10 +160,10 @@ public:
if (w != getWidth() || h != getHeight())
{
startTimer (50);
setSize (w, h);
if (getParentComponent() != nullptr)
getParentComponent()->setSize (w, h);
if (Component* p = getParentComponent())
p->setSize (w, h);
}
else
{


+ 9
- 9
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -570,16 +570,14 @@ Component* OpenGLContext::getTargetComponent() const noexcept
OpenGLContext* OpenGLContext::getCurrentContext()
{
#if JUCE_ANDROID
NativeContext* const nc = NativeContext::getActiveContext();
if (nc == nullptr)
return nullptr;
CachedImage* currentContext = CachedImage::get (nc->component);
if (NativeContext* const nc = NativeContext::getActiveContext())
if (CachedImage* currentContext = CachedImage::get (nc->component))
#else
CachedImage* currentContext = dynamic_cast <CachedImage*> (Thread::getCurrentThread());
if (CachedImage* currentContext = dynamic_cast <CachedImage*> (Thread::getCurrentThread()))
#endif
return &currentContext->context;
return currentContext != nullptr ? &currentContext->context : nullptr;
return nullptr;
}
bool OpenGLContext::makeActive() const noexcept { return nativeContext != nullptr && nativeContext->makeActive(); }
@@ -620,8 +618,10 @@ void* OpenGLContext::getRawContext() const noexcept
OpenGLContext::CachedImage* OpenGLContext::getCachedImage() const noexcept
{
Component* const comp = getTargetComponent();
return comp != nullptr ? CachedImage::get (*comp) : nullptr;
if (Component* const comp = getTargetComponent())
return CachedImage::get (*comp);
return nullptr;
}
bool OpenGLContext::areShadersAvailable() const


Loading…
Cancel
Save