mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Minor clean-ups.
This commit is contained in:
parent
f13621a78d
commit
8ae91bb39a
14 changed files with 96 additions and 151 deletions
|
|
@ -528,9 +528,7 @@ Result FileOutputStream::truncate()
|
|||
//==============================================================================
|
||||
String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
|
||||
{
|
||||
const char* s = ::getenv (name.toUTF8());
|
||||
|
||||
if (s != nullptr)
|
||||
if (const char* s = ::getenv (name.toUTF8()))
|
||||
return String::fromUTF8 (s);
|
||||
|
||||
return defaultValue;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
class Button::RepeatTimer : public Timer
|
||||
{
|
||||
public:
|
||||
RepeatTimer (Button& owner_) : owner (owner_) {}
|
||||
RepeatTimer (Button& b) : owner (b) {}
|
||||
void timerCallback() { owner.repeatTimerCallback(); }
|
||||
|
||||
private:
|
||||
|
|
@ -192,26 +192,28 @@ void Button::setRadioGroupId (const int newGroupId)
|
|||
|
||||
void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification)
|
||||
{
|
||||
Component* const p = getParentComponent();
|
||||
|
||||
if (p != nullptr && radioGroupId != 0)
|
||||
if (Component* const p = getParentComponent())
|
||||
{
|
||||
WeakReference<Component> deletionWatcher (this);
|
||||
|
||||
for (int i = p->getNumChildComponents(); --i >= 0;)
|
||||
if (radioGroupId != 0)
|
||||
{
|
||||
Component* const c = p->getChildComponent (i);
|
||||
WeakReference<Component> deletionWatcher (this);
|
||||
|
||||
if (c != this)
|
||||
for (int i = p->getNumChildComponents(); --i >= 0;)
|
||||
{
|
||||
Button* const b = dynamic_cast <Button*> (c);
|
||||
Component* const c = p->getChildComponent (i);
|
||||
|
||||
if (b != nullptr && b->getRadioGroupId() == radioGroupId)
|
||||
if (c != this)
|
||||
{
|
||||
b->setToggleState (false, sendChangeNotification);
|
||||
if (Button* const b = dynamic_cast <Button*> (c))
|
||||
{
|
||||
if (b->getRadioGroupId() == radioGroupId)
|
||||
{
|
||||
b->setToggleState (false, sendChangeNotification);
|
||||
|
||||
if (deletionWatcher == nullptr)
|
||||
return;
|
||||
if (deletionWatcher == nullptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
TextButton::TextButton (const String& name,
|
||||
const String& toolTip)
|
||||
TextButton::TextButton (const String& name, const String& toolTip)
|
||||
: Button (name)
|
||||
{
|
||||
setTooltip (toolTip);
|
||||
|
|
@ -38,15 +37,17 @@ void TextButton::paintButton (Graphics& g,
|
|||
bool isMouseOverButton,
|
||||
bool isButtonDown)
|
||||
{
|
||||
getLookAndFeel().drawButtonBackground (g, *this,
|
||||
findColour (getToggleState() ? buttonOnColourId
|
||||
: buttonColourId),
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
|
||||
getLookAndFeel().drawButtonText (g, *this,
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
lf.drawButtonBackground (g, *this,
|
||||
findColour (getToggleState() ? buttonOnColourId
|
||||
: buttonColourId),
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
|
||||
lf.drawButtonText (g, *this,
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
}
|
||||
|
||||
void TextButton::colourChanged()
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
ToolbarButton::ToolbarButton (const int itemId_, const String& buttonText,
|
||||
Drawable* const normalImage_, Drawable* const toggledOnImage_)
|
||||
: ToolbarItemComponent (itemId_, buttonText, true),
|
||||
normalImage (normalImage_),
|
||||
toggledOnImage (toggledOnImage_),
|
||||
ToolbarButton::ToolbarButton (const int iid, const String& buttonText,
|
||||
Drawable* const normalIm, Drawable* const toggledOnIm)
|
||||
: ToolbarItemComponent (iid, buttonText, true),
|
||||
normalImage (normalIm),
|
||||
toggledOnImage (toggledOnIm),
|
||||
currentImage (nullptr)
|
||||
{
|
||||
jassert (normalImage_ != nullptr);
|
||||
jassert (normalImage != nullptr);
|
||||
}
|
||||
|
||||
ToolbarButton::~ToolbarButton()
|
||||
|
|
|
|||
|
|
@ -67,10 +67,8 @@ public:
|
|||
|
||||
bool useTimeslice (const int elapsed)
|
||||
{
|
||||
Component* const c = proxy != nullptr ? static_cast <Component*> (proxy)
|
||||
: static_cast <Component*> (component);
|
||||
|
||||
if (c != nullptr)
|
||||
if (Component* const c = proxy != nullptr ? static_cast <Component*> (proxy)
|
||||
: static_cast <Component*> (component))
|
||||
{
|
||||
msElapsed += elapsed;
|
||||
double newProgress = msElapsed / (double) msTotal;
|
||||
|
|
@ -146,9 +144,7 @@ public:
|
|||
setAlpha (c.getAlpha());
|
||||
setInterceptsMouseClicks (false, false);
|
||||
|
||||
Component* const parent = c.getParentComponent();
|
||||
|
||||
if (parent != nullptr)
|
||||
if (Component* const parent = c.getParentComponent())
|
||||
parent->addAndMakeVisible (this);
|
||||
else if (c.isOnDesktop() && c.getPeer() != nullptr)
|
||||
addToDesktop (c.getPeer()->getStyleFlags() | ComponentPeer::windowIgnoresKeyPresses);
|
||||
|
|
@ -282,9 +278,7 @@ void ComponentAnimator::cancelAllAnimations (const bool moveComponentsToTheirFin
|
|||
void ComponentAnimator::cancelAnimation (Component* const component,
|
||||
const bool moveComponentToItsFinalPosition)
|
||||
{
|
||||
AnimationTask* const at = findTaskFor (component);
|
||||
|
||||
if (at != nullptr)
|
||||
if (AnimationTask* const at = findTaskFor (component))
|
||||
{
|
||||
if (moveComponentToItsFinalPosition)
|
||||
at->moveToFinalDestination();
|
||||
|
|
@ -297,9 +291,8 @@ void ComponentAnimator::cancelAnimation (Component* const component,
|
|||
Rectangle<int> ComponentAnimator::getComponentDestination (Component* const component)
|
||||
{
|
||||
jassert (component != nullptr);
|
||||
AnimationTask* const at = findTaskFor (component);
|
||||
|
||||
if (at != nullptr)
|
||||
if (AnimationTask* const at = findTaskFor (component))
|
||||
return at->destination;
|
||||
|
||||
return component->getBounds();
|
||||
|
|
|
|||
|
|
@ -118,13 +118,10 @@ void ComponentMovementWatcher::componentVisibilityChanged (Component&)
|
|||
|
||||
void ComponentMovementWatcher::registerWithParentComps()
|
||||
{
|
||||
Component* p = component->getParentComponent();
|
||||
|
||||
while (p != nullptr)
|
||||
for (Component* p = component->getParentComponent(); p != nullptr; p = p->getParentComponent())
|
||||
{
|
||||
p->addComponentListener (this);
|
||||
registeredParentComps.add (p);
|
||||
p = p->getParentComponent();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,20 +36,18 @@ MultiDocumentPanelWindow::~MultiDocumentPanelWindow()
|
|||
//==============================================================================
|
||||
void MultiDocumentPanelWindow::maximiseButtonPressed()
|
||||
{
|
||||
MultiDocumentPanel* const owner = getOwner();
|
||||
|
||||
jassert (owner != nullptr); // these windows are only designed to be used inside a MultiDocumentPanel!
|
||||
if (owner != nullptr)
|
||||
if (MultiDocumentPanel* const owner = getOwner())
|
||||
owner->setLayoutMode (MultiDocumentPanel::MaximisedWindowsWithTabs);
|
||||
else
|
||||
jassertfalse; // these windows are only designed to be used inside a MultiDocumentPanel!
|
||||
}
|
||||
|
||||
void MultiDocumentPanelWindow::closeButtonPressed()
|
||||
{
|
||||
MultiDocumentPanel* const owner = getOwner();
|
||||
|
||||
jassert (owner != nullptr); // these windows are only designed to be used inside a MultiDocumentPanel!
|
||||
if (owner != nullptr)
|
||||
if (MultiDocumentPanel* const owner = getOwner())
|
||||
owner->closeDocument (getContentComponent(), true);
|
||||
else
|
||||
jassertfalse; // these windows are only designed to be used inside a MultiDocumentPanel!
|
||||
}
|
||||
|
||||
void MultiDocumentPanelWindow::activeWindowStatusChanged()
|
||||
|
|
@ -66,9 +64,7 @@ void MultiDocumentPanelWindow::broughtToFront()
|
|||
|
||||
void MultiDocumentPanelWindow::updateOrder()
|
||||
{
|
||||
MultiDocumentPanel* const owner = getOwner();
|
||||
|
||||
if (owner != nullptr)
|
||||
if (MultiDocumentPanel* const owner = getOwner())
|
||||
owner->updateOrder();
|
||||
}
|
||||
|
||||
|
|
@ -89,9 +85,7 @@ public:
|
|||
|
||||
void currentTabChanged (int, const String&)
|
||||
{
|
||||
MultiDocumentPanel* const owner = findParentComponentOfClass<MultiDocumentPanel>();
|
||||
|
||||
if (owner != nullptr)
|
||||
if (MultiDocumentPanel* const owner = findParentComponentOfClass<MultiDocumentPanel>())
|
||||
owner->updateOrder();
|
||||
}
|
||||
};
|
||||
|
|
@ -147,10 +141,10 @@ void MultiDocumentPanel::addWindow (Component* component)
|
|||
dw->setBackgroundColour (bkg.isVoid() ? backgroundColour : Colour ((uint32) static_cast <int> (bkg)));
|
||||
|
||||
int x = 4;
|
||||
Component* const topComp = getChildComponent (getNumChildComponents() - 1);
|
||||
|
||||
if (topComp != nullptr && topComp->getX() == x && topComp->getY() == x)
|
||||
x += 16;
|
||||
if (Component* const topComp = getChildComponent (getNumChildComponents() - 1))
|
||||
if (topComp->getX() == x && topComp->getY() == x)
|
||||
x += 16;
|
||||
|
||||
dw->setTopLeftPosition (x, x);
|
||||
|
||||
|
|
@ -246,12 +240,13 @@ bool MultiDocumentPanel::closeDocument (Component* component,
|
|||
{
|
||||
for (int i = getNumChildComponents(); --i >= 0;)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr && dw->getContentComponent() == component)
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
{
|
||||
ScopedPointer<MultiDocumentPanelWindow> (dw)->clearContentComponent();
|
||||
break;
|
||||
if (dw->getContentComponent() == component)
|
||||
{
|
||||
ScopedPointer<MultiDocumentPanelWindow> (dw)->clearContentComponent();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,12 +321,9 @@ Component* MultiDocumentPanel::getActiveDocument() const noexcept
|
|||
if (mode == FloatingWindows)
|
||||
{
|
||||
for (int i = getNumChildComponents(); --i >= 0;)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr && dw->isActiveWindow())
|
||||
return dw->getContentComponent();
|
||||
}
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
if (dw->isActiveWindow())
|
||||
return dw->getContentComponent();
|
||||
}
|
||||
|
||||
return components.getLast();
|
||||
|
|
@ -399,9 +391,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode)
|
|||
{
|
||||
for (int i = getNumChildComponents(); --i >= 0;)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr)
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
{
|
||||
dw->getContentComponent()->getProperties().set ("mdiDocumentPos_", dw->getWindowStateAsString());
|
||||
dw->clearContentComponent();
|
||||
|
|
@ -458,15 +448,9 @@ Component* MultiDocumentPanel::getContainerComp (Component* c) const
|
|||
if (mode == FloatingWindows)
|
||||
{
|
||||
for (int i = 0; i < getNumChildComponents(); ++i)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr && dw->getContentComponent() == c)
|
||||
{
|
||||
c = dw;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
if (dw->getContentComponent() == c)
|
||||
return dw;
|
||||
}
|
||||
|
||||
return c;
|
||||
|
|
@ -477,12 +461,8 @@ void MultiDocumentPanel::componentNameChanged (Component&)
|
|||
if (mode == FloatingWindows)
|
||||
{
|
||||
for (int i = 0; i < getNumChildComponents(); ++i)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr)
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
dw->setName (dw->getContentComponent()->getName());
|
||||
}
|
||||
}
|
||||
else if (tabComponent != nullptr)
|
||||
{
|
||||
|
|
@ -500,20 +480,14 @@ void MultiDocumentPanel::updateOrder()
|
|||
components.clear();
|
||||
|
||||
for (int i = 0; i < getNumChildComponents(); ++i)
|
||||
{
|
||||
MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i));
|
||||
|
||||
if (dw != nullptr)
|
||||
if (MultiDocumentPanelWindow* const dw = dynamic_cast <MultiDocumentPanelWindow*> (getChildComponent (i)))
|
||||
components.add (dw->getContentComponent());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tabComponent != nullptr)
|
||||
{
|
||||
Component* const current = tabComponent->getCurrentContentComponent();
|
||||
|
||||
if (current != nullptr)
|
||||
if (Component* const current = tabComponent->getCurrentContentComponent())
|
||||
{
|
||||
components.removeFirstMatchingValue (current);
|
||||
components.add (current);
|
||||
|
|
|
|||
|
|
@ -151,9 +151,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e)
|
|||
}
|
||||
else
|
||||
{
|
||||
Component::Positioner* const pos = component->getPositioner();
|
||||
|
||||
if (pos != nullptr)
|
||||
if (Component::Positioner* const pos = component->getPositioner())
|
||||
pos->applyNewBounds (newBounds);
|
||||
else
|
||||
component->setBounds (newBounds);
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e)
|
|||
}
|
||||
else
|
||||
{
|
||||
Component::Positioner* const pos = component->getPositioner();
|
||||
|
||||
if (pos != nullptr)
|
||||
if (Component::Positioner* const pos = component->getPositioner())
|
||||
pos->applyNewBounds (r);
|
||||
else
|
||||
component->setBounds (r);
|
||||
|
|
|
|||
|
|
@ -94,9 +94,7 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e)
|
|||
}
|
||||
else
|
||||
{
|
||||
Component::Positioner* const pos = component->getPositioner();
|
||||
|
||||
if (pos != nullptr)
|
||||
if (Component::Positioner* const pos = component->getPositioner())
|
||||
pos->applyNewBounds (newBounds);
|
||||
else
|
||||
component->setBounds (newBounds);
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ bool StretchableLayoutManager::getItemLayout (const int itemIndex,
|
|||
double& maximumSize,
|
||||
double& preferredSize) const
|
||||
{
|
||||
const ItemLayoutProperties* const layout = getInfoFor (itemIndex);
|
||||
|
||||
if (layout != nullptr)
|
||||
if (const ItemLayoutProperties* const layout = getInfoFor (itemIndex))
|
||||
{
|
||||
minimumSize = layout->minSize;
|
||||
maximumSize = layout->maxSize;
|
||||
|
|
@ -96,21 +94,15 @@ int StretchableLayoutManager::getItemCurrentPosition (const int itemIndex) const
|
|||
int pos = 0;
|
||||
|
||||
for (int i = 0; i < itemIndex; ++i)
|
||||
{
|
||||
const ItemLayoutProperties* const layout = getInfoFor (i);
|
||||
|
||||
if (layout != nullptr)
|
||||
if (const ItemLayoutProperties* const layout = getInfoFor (i))
|
||||
pos += layout->currentSize;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
int StretchableLayoutManager::getItemCurrentAbsoluteSize (const int itemIndex) const
|
||||
{
|
||||
const ItemLayoutProperties* const layout = getInfoFor (itemIndex);
|
||||
|
||||
if (layout != nullptr)
|
||||
if (const ItemLayoutProperties* const layout = getInfoFor (itemIndex))
|
||||
return layout->currentSize;
|
||||
|
||||
return 0;
|
||||
|
|
@ -118,9 +110,7 @@ int StretchableLayoutManager::getItemCurrentAbsoluteSize (const int itemIndex) c
|
|||
|
||||
double StretchableLayoutManager::getItemCurrentRelativeSize (const int itemIndex) const
|
||||
{
|
||||
const ItemLayoutProperties* const layout = getInfoFor (itemIndex);
|
||||
|
||||
if (layout != nullptr)
|
||||
if (const ItemLayoutProperties* const layout = getInfoFor (itemIndex))
|
||||
return -layout->currentSize / (double) totalSize;
|
||||
|
||||
return 0;
|
||||
|
|
@ -165,13 +155,9 @@ void StretchableLayoutManager::layOutComponents (Component** const components,
|
|||
|
||||
for (int i = 0; i < numComponents; ++i)
|
||||
{
|
||||
const ItemLayoutProperties* const layout = getInfoFor (i);
|
||||
|
||||
if (layout != nullptr)
|
||||
if (const ItemLayoutProperties* const layout = getInfoFor (i))
|
||||
{
|
||||
Component* const c = components[i];
|
||||
|
||||
if (c != nullptr)
|
||||
if (Component* const c = components[i])
|
||||
{
|
||||
if (i == numComponents - 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,6 +69,6 @@ void StretchableLayoutResizerBar::mouseDrag (const MouseEvent& e)
|
|||
|
||||
void StretchableLayoutResizerBar::hasBeenMoved()
|
||||
{
|
||||
if (getParentComponent() != nullptr)
|
||||
getParentComponent()->resized();
|
||||
if (Component* parent = getParentComponent())
|
||||
parent->resized();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,13 +259,14 @@ void TabbedButtonBar::addTab (const String& tabName,
|
|||
|
||||
void TabbedButtonBar::setTabName (const int tabIndex, const String& newName)
|
||||
{
|
||||
TabInfo* const tab = tabs [tabIndex];
|
||||
|
||||
if (tab != nullptr && tab->name != newName)
|
||||
if (TabInfo* const tab = tabs [tabIndex])
|
||||
{
|
||||
tab->name = newName;
|
||||
tab->button->setButtonText (newName);
|
||||
resized();
|
||||
if (tab->name != newName)
|
||||
{
|
||||
tab->name = newName;
|
||||
tab->button->setButtonText (newName);
|
||||
resized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,9 +440,7 @@ void TabbedButtonBar::resized()
|
|||
|
||||
for (int i = 0; i < tabs.size(); ++i)
|
||||
{
|
||||
TabBarButton* const tb = getTabButton (i);
|
||||
|
||||
if (tb != nullptr)
|
||||
if (TabBarButton* const tb = getTabButton (i))
|
||||
{
|
||||
const int bestLength = roundToInt (scale * tb->getBestTabLength (depth));
|
||||
|
||||
|
|
@ -486,12 +485,13 @@ Colour TabbedButtonBar::getTabBackgroundColour (const int tabIndex)
|
|||
|
||||
void TabbedButtonBar::setTabBackgroundColour (const int tabIndex, const Colour& newColour)
|
||||
{
|
||||
TabInfo* const tab = tabs [tabIndex];
|
||||
|
||||
if (tab != nullptr && tab->colour != newColour)
|
||||
if (TabInfo* const tab = tabs [tabIndex])
|
||||
{
|
||||
tab->colour = newColour;
|
||||
repaint();
|
||||
if (tab->colour != newColour)
|
||||
{
|
||||
tab->colour = newColour;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,15 +262,15 @@ void TabbedComponent::resized()
|
|||
content = BorderSize<int> (edgeIndent).subtractedFrom (outline.subtractedFrom (content));
|
||||
|
||||
for (int i = contentComponents.size(); --i >= 0;)
|
||||
if (contentComponents.getReference (i) != nullptr)
|
||||
contentComponents.getReference (i)->setBounds (content);
|
||||
if (Component* c = contentComponents.getReference(i))
|
||||
c->setBounds (content);
|
||||
}
|
||||
|
||||
void TabbedComponent::lookAndFeelChanged()
|
||||
{
|
||||
for (int i = contentComponents.size(); --i >= 0;)
|
||||
if (contentComponents.getReference (i) != nullptr)
|
||||
contentComponents.getReference (i)->lookAndFeelChanged();
|
||||
if (Component* c = contentComponents.getReference(i))
|
||||
c->lookAndFeelChanged();
|
||||
}
|
||||
|
||||
void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String& newTabName)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue