Browse Source

Minor clean-ups.

tags/2021-05-28
jules 13 years ago
parent
commit
164ab05bac
21 changed files with 109 additions and 210 deletions
  1. +1
    -2
      extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp
  2. +1
    -2
      extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp
  3. +6
    -9
      extras/Introjucer/Source/Application/jucer_MainWindow.cpp
  4. +8
    -17
      extras/Introjucer/Source/Project/jucer_ModulesPanel.h
  5. +1
    -3
      modules/juce_audio_formats/format/juce_AudioFormatReader.cpp
  6. +6
    -5
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm
  7. +10
    -40
      modules/juce_audio_processors/processors/juce_AudioProcessor.cpp
  8. +2
    -0
      modules/juce_audio_processors/processors/juce_AudioProcessor.h
  9. +3
    -6
      modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp
  10. +6
    -14
      modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp
  11. +1
    -5
      modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp
  12. +1
    -2
      modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp
  13. +1
    -2
      modules/juce_core/threads/juce_TimeSliceThread.cpp
  14. +9
    -26
      modules/juce_core/xml/juce_XmlElement.cpp
  15. +5
    -4
      modules/juce_core/zip/juce_ZipFile.cpp
  16. +8
    -4
      modules/juce_gui_basics/components/juce_Component.cpp
  17. +3
    -9
      modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp
  18. +18
    -33
      modules/juce_gui_basics/widgets/juce_Toolbar.cpp
  19. +13
    -20
      modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp
  20. +5
    -4
      modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp
  21. +1
    -3
      modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp

+ 1
- 2
extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp View File

@@ -315,9 +315,8 @@ struct AppearanceEditor
if (fontsToScan.size() == 0)
{
getAppSettings().monospacedFontNames = fontsFound;
DialogWindow* w = findParentComponentOfClass<DialogWindow>();
if (w != nullptr)
if (DialogWindow* w = findParentComponentOfClass<DialogWindow>())
w->setContentOwned (new EditorPanel(), false);
}
else


+ 1
- 2
extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp View File

@@ -45,9 +45,8 @@ void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Documen
if (document == closingDoc)
{
jassert (document != nullptr);
ProjectContentComponent* pcc = findParentComponentOfClass<ProjectContentComponent>();
if (pcc != nullptr)
if (ProjectContentComponent* pcc = findParentComponentOfClass<ProjectContentComponent>())
{
pcc->hideDocument (document);
return;


+ 6
- 9
extras/Introjucer/Source/Application/jucer_MainWindow.cpp View File

@@ -130,9 +130,7 @@ bool MainWindow::closeProject (Project* project)
project->getStoredProperties().setValue (getProjectWindowPosName(), getWindowStateAsString());
ProjectContentComponent* const pcc = getProjectContentComponent();
if (pcc != nullptr)
if (ProjectContentComponent* const pcc = getProjectContentComponent())
{
pcc->saveTreeViewState();
pcc->saveOpenDocumentList();
@@ -262,8 +260,8 @@ void MainWindow::activeWindowStatusChanged()
{
DocumentWindow::activeWindowStatusChanged();
if (getProjectContentComponent() != nullptr)
getProjectContentComponent()->updateMissingFileStatuses();
if (ProjectContentComponent* const pcc = getProjectContentComponent())
pcc->updateMissingFileStatuses();
IntrojucerApp::getApp().openDocumentManager.reloadModifiedFiles();
}
@@ -506,10 +504,9 @@ void MainWindowList::saveCurrentlyOpenProjectList()
Desktop& desktop = Desktop::getInstance();
for (int i = 0; i < desktop.getNumComponents(); ++i)
{
MainWindow* const mw = dynamic_cast <MainWindow*> (desktop.getComponent(i));
if (mw != nullptr && mw->getProject() != nullptr)
projects.add (mw->getProject()->getFile());
if (MainWindow* const mw = dynamic_cast <MainWindow*> (desktop.getComponent(i)))
if (Project* p = mw->getProject())
projects.add (p->getFile());
}
getAppSettings().setLastProjects (projects);


+ 8
- 17
extras/Introjucer/Source/Project/jucer_ModulesPanel.h View File

@@ -168,9 +168,7 @@ public:
if (rowIsSelected)
g.fillAll (findColour (TextEditor::highlightColourId));
const ModuleList::Module* const m = list.modules [rowNumber];
if (m != nullptr)
if (const ModuleList::Module* const m = list.modules [rowNumber])
{
const float tickSize = height * 0.7f;
@@ -210,9 +208,7 @@ public:
void flipRow (int row)
{
const ModuleList::Module* const m = list.modules [row];
if (m != nullptr)
if (const ModuleList::Module* const m = list.modules [row])
owner->setEnabled (m, ! owner->isEnabled (m));
}
@@ -246,9 +242,9 @@ public:
if (project.isModuleEnabled (moduleID))
{
const ModuleList::Module* m = moduleList.findModuleInfo (moduleID);
if (m != nullptr && moduleList.getExtraDependenciesNeeded (project, *m).size() > 0)
props.add (new MissingDependenciesComponent (project, moduleList, moduleID));
if (const ModuleList::Module* m = moduleList.findModuleInfo (moduleID))
if (moduleList.getExtraDependenciesNeeded (project, *m).size() > 0)
props.add (new MissingDependenciesComponent (project, moduleList, moduleID));
}
props.add (new BooleanPropertyComponent (project.shouldShowAllModuleFilesInProject (moduleID),
@@ -308,9 +304,7 @@ public:
g.setColour (Colours::white.withAlpha (0.4f));
g.fillRect (0, 0, getWidth(), getHeight() - 1);
const ModuleList::Module* module = moduleList.findModuleInfo (moduleID);
if (module != nullptr)
if (const ModuleList::Module* module = moduleList.findModuleInfo (moduleID))
{
String text;
text << module->name << newLine << "Version: " << module->version << newLine << newLine
@@ -341,9 +335,7 @@ public:
project (p), moduleList (list), moduleID (modID),
fixButton ("Enable Required Modules")
{
const ModuleList::Module* module = moduleList.findModuleInfo (moduleID);
if (module != nullptr)
if (const ModuleList::Module* module = moduleList.findModuleInfo (moduleID))
missingDependencies = moduleList.getExtraDependenciesNeeded (project, *module);
addAndMakeVisible (&fixButton);
@@ -375,8 +367,7 @@ public:
for (int i = missingDependencies.size(); --i >= 0;)
project.addModule (missingDependencies[i], isModuleCopiedLocally);
ModulesPanel* mp = findParentComponentOfClass<ModulesPanel>();
if (mp != nullptr)
if (ModulesPanel* mp = findParentComponentOfClass<ModulesPanel>())
mp->refresh();
}


+ 1
- 3
modules/juce_audio_formats/format/juce_AudioFormatReader.cpp View File

@@ -141,9 +141,7 @@ void AudioFormatReader::read (AudioSampleBuffer* buffer,
{
for (int j = 0; j < 2; ++j)
{
float* const d = reinterpret_cast <float*> (chans[j]);
if (d != nullptr)
if (float* const d = reinterpret_cast <float*> (chans[j]))
{
const float multiplier = 1.0f / 0x7fffffff;


+ 6
- 5
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -727,12 +727,13 @@ public:
{
for (CFIndex i = 0; i < CFArrayGetCount (presets); ++i)
{
const AUPreset* p = (const AUPreset*) CFArrayGetValueAtIndex (presets, i);
if (p != nullptr && p->presetNumber == index)
if (const AUPreset* p = (const AUPreset*) CFArrayGetValueAtIndex (presets, i))
{
s = String::fromCFString (p->presetName);
break;
if (p->presetNumber == index)
{
s = String::fromCFString (p->presetName);
break;
}
}
}


+ 10
- 40
modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -119,22 +119,19 @@ void AudioProcessor::setParameterNotifyingHost (const int parameterIndex,
sendParamChangeMessageToListeners (parameterIndex, newValue);
}
AudioProcessorListener* AudioProcessor::getListenerLocked (const int index) const noexcept
{
const ScopedLock sl (listenerLock);
return listeners [index];
}
void AudioProcessor::sendParamChangeMessageToListeners (const int parameterIndex, const float newValue)
{
jassert (isPositiveAndBelow (parameterIndex, getNumParameters()));
for (int i = listeners.size(); --i >= 0;)
{
AudioProcessorListener* l;
{
const ScopedLock sl (listenerLock);
l = listeners [i];
}
if (l != nullptr)
if (AudioProcessorListener* l = getListenerLocked (i))
l->audioProcessorParameterChanged (this, parameterIndex, newValue);
}
}
void AudioProcessor::beginParameterChangeGesture (int parameterIndex)
@@ -149,17 +146,8 @@ void AudioProcessor::beginParameterChangeGesture (int parameterIndex)
#endif
for (int i = listeners.size(); --i >= 0;)
{
AudioProcessorListener* l;
{
const ScopedLock sl (listenerLock);
l = listeners [i];
}
if (l != nullptr)
if (AudioProcessorListener* l = getListenerLocked (i))
l->audioProcessorParameterChangeGestureBegin (this, parameterIndex);
}
}
void AudioProcessor::endParameterChangeGesture (int parameterIndex)
@@ -175,33 +163,15 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex)
#endif
for (int i = listeners.size(); --i >= 0;)
{
AudioProcessorListener* l;
{
const ScopedLock sl (listenerLock);
l = listeners [i];
}
if (l != nullptr)
if (AudioProcessorListener* l = getListenerLocked (i))
l->audioProcessorParameterChangeGestureEnd (this, parameterIndex);
}
}
void AudioProcessor::updateHostDisplay()
{
for (int i = listeners.size(); --i >= 0;)
{
AudioProcessorListener* l;
{
const ScopedLock sl (listenerLock);
l = listeners [i];
}
if (l != nullptr)
if (AudioProcessorListener* l = getListenerLocked (i))
l->audioProcessorChanged (this);
}
}
String AudioProcessor::getParameterLabel (int) const { return String::empty; }


+ 2
- 0
modules/juce_audio_processors/processors/juce_AudioProcessor.h View File

@@ -634,6 +634,8 @@ private:
BigInteger changingParams;
#endif
AudioProcessorListener* getListenerLocked (int) const noexcept;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessor)
};


+ 3
- 6
modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp View File

@@ -789,9 +789,8 @@ private:
int recursionCheck) const noexcept
{
int index;
const Entry* const entry = findEntry (possibleDestinationId, index);
if (entry != nullptr)
if (const Entry* const entry = findEntry (possibleDestinationId, index))
{
const SortedSet<uint32>& srcNodes = entry->srcNodes;
@@ -917,10 +916,8 @@ void AudioProcessorGraph::Node::unprepare()
void AudioProcessorGraph::Node::setParentGraph (AudioProcessorGraph* const graph) const
{
AudioProcessorGraph::AudioGraphIOProcessor* const ioProc
= dynamic_cast <AudioProcessorGraph::AudioGraphIOProcessor*> (processor.get());
if (ioProc != nullptr)
if (AudioProcessorGraph::AudioGraphIOProcessor* const ioProc
= dynamic_cast <AudioProcessorGraph::AudioGraphIOProcessor*> (processor.get()))
ioProc->setParentGraph (graph);
}


+ 6
- 14
modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp View File

@@ -411,9 +411,7 @@ public:
updateControlPanelButton();
AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice();
if (currentDevice != nullptr)
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
{
if (setup.maxNumOutputChannels > 0
&& setup.minNumOutputChannels < setup.manager->getCurrentAudioDevice()->getOutputChannelNames().size())
@@ -688,9 +686,7 @@ public:
{
items.clear();
AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice();
if (currentDevice != nullptr)
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
{
if (type == audioInputType)
items = currentDevice->getInputChannelNames();
@@ -1041,9 +1037,7 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha
{
if (comboBoxThatHasChanged == deviceTypeDropDown)
{
AudioIODeviceType* const type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1];
if (type != nullptr)
if (AudioIODeviceType* const type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1])
{
audioDeviceSettingsComp = nullptr;
@@ -1074,11 +1068,9 @@ void AudioDeviceSelectorComponent::updateAllControls()
audioDeviceSettingsCompType = deviceManager.getCurrentAudioDeviceType();
audioDeviceSettingsComp = nullptr;
AudioIODeviceType* const type
= deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown == nullptr
? 0 : deviceTypeDropDown->getSelectedId() - 1];
if (type != nullptr)
if (AudioIODeviceType* const type
= deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown == nullptr
? 0 : deviceTypeDropDown->getSelectedId() - 1])
{
AudioDeviceSetupDetails details;
details.manager = &deviceManager;


+ 1
- 5
modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp View File

@@ -211,12 +211,8 @@ private:
void createReader()
{
if (reader == nullptr && source != nullptr)
{
InputStream* audioFileStream = source->createInputStream();
if (audioFileStream != nullptr)
if (InputStream* audioFileStream = source->createInputStream())
reader = owner.formatManagerToUse.createReaderFor (audioFileStream);
}
}
bool readNextBlock()


+ 1
- 2
modules/juce_audio_utils/gui/juce_AudioThumbnailCache.cpp View File

@@ -99,9 +99,8 @@ int AudioThumbnailCache::findOldestThumb() const
bool AudioThumbnailCache::loadThumb (AudioThumbnailBase& thumb, const int64 hashCode)
{
const ScopedLock sl (lock);
ThumbnailCacheEntry* te = findThumbFor (hashCode);
if (te != nullptr)
if (ThumbnailCacheEntry* te = findThumbFor (hashCode))
{
te->lastUsed = Time::getMillisecondCounter();


+ 1
- 2
modules/juce_core/threads/juce_TimeSliceThread.cpp View File

@@ -125,8 +125,7 @@ void TimeSliceThread::run()
index = clients.size() > 0 ? ((index + 1) % clients.size()) : 0;
TimeSliceClient* const firstClient = getNextClient (index);
if (firstClient != nullptr)
if (TimeSliceClient* const firstClient = getNextClient (index))
nextClientTime = firstClient->nextCallTime;
}


+ 9
- 26
modules/juce_core/xml/juce_XmlElement.cpp View File

@@ -254,7 +254,6 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
{
outputStream.writeByte ('>');
bool lastWasTextNode = false;
for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem)
@@ -500,9 +499,7 @@ void XmlElement::setAttribute (const String& attributeName, const String& value)
}
else
{
XmlAttributeNode* att = attributes;
for (;;)
for (XmlAttributeNode* att = attributes; ; att = att->nextListItem)
{
if (att->hasName (attributeName))
{
@@ -514,8 +511,6 @@ void XmlElement::setAttribute (const String& attributeName, const String& value)
att->nextListItem = new XmlAttributeNode (attributeName, value);
break;
}
att = att->nextListItem;
}
}
}
@@ -532,17 +527,15 @@ void XmlElement::setAttribute (const String& attributeName, const double number)
void XmlElement::removeAttribute (const String& attributeName) noexcept
{
LinkedListPointer<XmlAttributeNode>* att = &attributes;
while (att->get() != nullptr)
for (LinkedListPointer<XmlAttributeNode>* att = &attributes;
att->get() != nullptr;
att = &(att->get()->nextListItem))
{
if (att->get()->hasName (attributeName))
{
delete att->removeNext();
break;
}
att = &(att->get()->nextListItem);
}
}
@@ -599,9 +592,7 @@ bool XmlElement::replaceChildElement (XmlElement* const currentChildElement,
{
if (newNode != nullptr)
{
LinkedListPointer<XmlElement>* const p = firstChildElement.findPointerTo (currentChildElement);
if (p != nullptr)
if (LinkedListPointer<XmlElement>* const p = firstChildElement.findPointerTo (currentChildElement))
{
if (currentChildElement != newNode)
delete p->replaceNext (newNode);
@@ -705,9 +696,7 @@ void XmlElement::deleteAllChildElements() noexcept
void XmlElement::deleteAllChildElementsWithTagName (const String& name) noexcept
{
XmlElement* child = firstChildElement;
while (child != nullptr)
for (XmlElement* child = firstChildElement; child != nullptr;)
{
XmlElement* const nextChild = child->nextListItem;
@@ -733,9 +722,7 @@ XmlElement* XmlElement::findParentElementOf (const XmlElement* const elementToLo
if (elementToLookFor == child)
return this;
XmlElement* const found = child->findParentElementOf (elementToLookFor);
if (found != nullptr)
if (XmlElement* const found = child->findParentElementOf (elementToLookFor))
return found;
}
@@ -801,9 +788,7 @@ String XmlElement::getAllSubText() const
String XmlElement::getChildElementAllSubText (const String& childTagName,
const String& defaultReturnValue) const
{
const XmlElement* const child = getChildByName (childTagName);
if (child != nullptr)
if (const XmlElement* const child = getChildByName (childTagName))
return child->getAllSubText();
return defaultReturnValue;
@@ -823,9 +808,7 @@ void XmlElement::addTextElement (const String& text)
void XmlElement::deleteAllTextElements() noexcept
{
XmlElement* child = firstChildElement;
while (child != nullptr)
for (XmlElement* child = firstChildElement; child != nullptr;)
{
XmlElement* const next = child->nextListItem;


+ 5
- 4
modules/juce_core/zip/juce_ZipFile.cpp View File

@@ -265,8 +265,10 @@ int ZipFile::getNumEntries() const noexcept
const ZipFile::ZipEntry* ZipFile::getEntry (const int index) const noexcept
{
ZipEntryHolder* const zei = entries [index];
return zei != nullptr ? &(zei->entry) : nullptr;
if (ZipEntryHolder* const zei = entries [index])
return &(zei->entry);
return nullptr;
}
int ZipFile::getIndexOfFileName (const String& fileName) const noexcept
@@ -285,10 +287,9 @@ const ZipFile::ZipEntry* ZipFile::getEntry (const String& fileName) const noexce
InputStream* ZipFile::createStreamForEntry (const int index)
{
ZipEntryHolder* const zei = entries[index];
InputStream* stream = nullptr;
if (zei != nullptr)
if (ZipEntryHolder* const zei = entries[index])
{
stream = new ZipInputStream (*this, *zei);


+ 8
- 4
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -358,8 +358,10 @@ struct Component::ComponentHelpers
static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp)
{
return comp.getParentComponent() != nullptr ? comp.getParentComponent()->getLocalBounds()
: Desktop::getInstance().getDisplays().getMainDisplay().userArea;
if (Component* p = comp.getParentComponent())
return p->getLocalBounds();
return Desktop::getInstance().getDisplays().getMainDisplay().userArea;
}
};
@@ -498,8 +500,10 @@ bool Component::isShowing() const
if (parentComponent != nullptr)
return parentComponent->isShowing();
const ComponentPeer* const peer = getPeer();
return peer != nullptr && ! peer->isMinimised();
if (const ComponentPeer* const peer = getPeer())
return ! peer->isMinimised();
return false;
}


+ 3
- 9
modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp View File

@@ -383,9 +383,7 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF
for (int i = columns.size(); --i >= 0;)
columns.getUnchecked(i)->propertyFlags &= ~(sortedForwards | sortedBackwards);
ColumnInfo* const ci = getInfoForId (columnId);
if (ci != nullptr)
if (ColumnInfo* const ci = getInfoForId (columnId))
ci->propertyFlags |= (sortForwards ? sortedForwards : sortedBackwards);
reSortTable();
@@ -451,9 +449,7 @@ void TableHeaderComponent::restoreFromString (const String& storedVersion)
{
const int tabId = col->getIntAttribute ("id");
ColumnInfo* const ci = getInfoForId (tabId);
if (ci != nullptr)
if (ColumnInfo* const ci = getInfoForId (tabId))
{
columns.move (columns.indexOf (ci), index);
ci->width = col->getIntAttribute ("width");
@@ -609,9 +605,7 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e)
if (columnIdBeingResized != 0)
{
const ColumnInfo* const ci = getInfoForId (columnIdBeingResized);
if (ci != nullptr)
if (const ColumnInfo* const ci = getInfoForId (columnIdBeingResized))
{
int w = jlimit (ci->minimumWidth, ci->maximumWidth,
initialColumnWidth + e.getDistanceFromDragStartX());


+ 18
- 33
modules/juce_gui_basics/widgets/juce_Toolbar.cpp View File

@@ -175,9 +175,7 @@ public:
{
for (int i = 0; i < getNumChildComponents(); ++i)
{
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (getChildComponent (i));
if (tc != nullptr)
if (ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (getChildComponent (i)))
{
tc->setVisible (false);
const int index = oldIndexes.remove (i);
@@ -199,9 +197,7 @@ public:
for (int i = 0; i < getNumChildComponents(); ++i)
{
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (getChildComponent (i));
if (tc != nullptr)
if (ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (getChildComponent (i)))
{
int preferredSize = 1, minSize = 1, maxSize = 1;
@@ -290,18 +286,16 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory,
// An ID can't be zero - this might indicate a mistake somewhere?
jassert (itemId != 0);
ToolbarItemComponent* const tc = createItem (factory, itemId);
if (tc != nullptr)
if (ToolbarItemComponent* const tc = createItem (factory, itemId))
{
#if JUCE_DEBUG
#if JUCE_DEBUG
Array <int> allowedIds;
factory.getAllToolbarItemIds (allowedIds);
// If your factory can create an item for a given ID, it must also return
// that ID from its getAllToolbarItemIds() method!
jassert (allowedIds.contains (itemId));
#endif
#endif
items.insert (insertIndex, tc);
addAndMakeVisible (tc, insertIndex);
@@ -548,17 +542,13 @@ bool Toolbar::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr)
if (ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
{
if (! items.contains (tc))
{
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
{
ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>();
if (palette != nullptr)
if (ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
palette->replaceComponent (tc);
}
else
@@ -582,9 +572,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
const Rectangle<int> current (Desktop::getInstance().getAnimator()
.getComponentDestination (getChildComponent (newIndex)));
ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1);
if (prev != nullptr)
if (ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1))
{
const Rectangle<int> previousPos (Desktop::getInstance().getAnimator().getComponentDestination (prev));
@@ -595,8 +584,7 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
}
}
ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1);
if (next != nullptr)
if (ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1))
{
const Rectangle<int> nextPos (Desktop::getInstance().getAnimator().getComponentDestination (next));
@@ -621,21 +609,20 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
{
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr && isParentOf (tc))
if (ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
{
items.removeObject (tc, false);
removeChildComponent (tc);
updateAllItemPositions (true);
if (isParentOf (tc))
{
items.removeObject (tc, false);
removeChildComponent (tc);
updateAllItemPositions (true);
}
}
}
void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
{
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());
if (tc != nullptr)
if (ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
tc->setState (Button::buttonNormal);
}
@@ -784,9 +771,7 @@ private:
{
Colour background;
DialogWindow* const dw = findParentComponentOfClass<DialogWindow>();
if (dw != nullptr)
if (DialogWindow* const dw = findParentComponentOfClass<DialogWindow>())
background = dw->getBackgroundColour();
g.setColour (background.contrasting().withAlpha (0.3f));


+ 13
- 20
modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.cpp View File

@@ -45,24 +45,23 @@ public:
void paint (Graphics& g)
{
ToolbarItemComponent* const tc = getToolbarItemComponent();
if (isMouseOverOrDragging()
&& tc != nullptr
&& tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar)
if (ToolbarItemComponent* const tc = getToolbarItemComponent())
{
g.setColour (findColour (Toolbar::editingModeOutlineColourId, true));
g.drawRect (0, 0, getWidth(), getHeight(),
jmin (2, (getWidth() - 1) / 2, (getHeight() - 1) / 2));
if (isMouseOverOrDragging()
&& tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar)
{
g.setColour (findColour (Toolbar::editingModeOutlineColourId, true));
g.drawRect (0, 0, getWidth(), getHeight(),
jmin (2, (getWidth() - 1) / 2, (getHeight() - 1) / 2));
}
}
}
void mouseDown (const MouseEvent& e)
{
isDragging = false;
ToolbarItemComponent* const tc = getToolbarItemComponent();
if (tc != nullptr)
if (ToolbarItemComponent* const tc = getToolbarItemComponent())
{
tc->dragOffsetX = e.x;
tc->dragOffsetY = e.y;
@@ -74,15 +73,12 @@ public:
if (! (isDragging || e.mouseWasClicked()))
{
isDragging = true;
DragAndDropContainer* const dnd = DragAndDropContainer::findParentDragContainerFor (this);
if (dnd != nullptr)
if (DragAndDropContainer* const dnd = DragAndDropContainer::findParentDragContainerFor (this))
{
dnd->startDragging (Toolbar::toolbarDragDescriptor, getParentComponent(), Image::null, true);
ToolbarItemComponent* const tc = getToolbarItemComponent();
if (tc != nullptr)
if (ToolbarItemComponent* const tc = getToolbarItemComponent())
{
tc->isBeingDragged = true;
@@ -96,15 +92,12 @@ public:
void mouseUp (const MouseEvent&)
{
isDragging = false;
ToolbarItemComponent* const tc = getToolbarItemComponent();
if (tc != nullptr)
if (ToolbarItemComponent* const tc = getToolbarItemComponent())
{
tc->isBeingDragged = false;
Toolbar* const tb = tc->getToolbar();
if (tb != nullptr)
if (Toolbar* const tb = tc->getToolbar())
tb->updateAllItemPositions (true);
else if (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar)
delete tc;


+ 5
- 4
modules/juce_gui_basics/widgets/juce_ToolbarItemPalette.cpp View File

@@ -47,15 +47,16 @@ ToolbarItemPalette::~ToolbarItemPalette()
//==============================================================================
void ToolbarItemPalette::addComponent (const int itemId, const int index)
{
ToolbarItemComponent* const tc = Toolbar::createItem (factory, itemId);
jassert (tc != nullptr);
if (tc != nullptr)
if (ToolbarItemComponent* const tc = Toolbar::createItem (factory, itemId))
{
items.insert (index, tc);
viewport.getViewedComponent()->addAndMakeVisible (tc, index);
tc->setEditingMode (ToolbarItemComponent::editableOnPalette);
}
else
{
jassertfalse;
}
}
void ToolbarItemPalette::replaceComponent (ToolbarItemComponent* const comp)


+ 1
- 3
modules/juce_gui_basics/windows/juce_TopLevelWindow.cpp View File

@@ -128,9 +128,7 @@ juce_ImplementSingleton_SingleThreaded (TopLevelWindowManager)
void juce_checkCurrentlyFocusedTopLevelWindow();
void juce_checkCurrentlyFocusedTopLevelWindow()
{
TopLevelWindowManager* const wm = TopLevelWindowManager::getInstanceWithoutCreating();
if (wm != nullptr)
if (TopLevelWindowManager* const wm = TopLevelWindowManager::getInstanceWithoutCreating())
wm->checkFocusAsync();
}


Loading…
Cancel
Save