Permalink
Browse files

Minor fixes and clean-ups.

  • Loading branch information...
jules
jules committed Sep 26, 2012
1 parent 438e813 commit 53784490b2fa933603e99d78521a96fb239245d9
@@ -46,7 +46,6 @@ class IntrojucerApp : public JUCEApplication
{
LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
settings = new StoredSettings();
- settings->initialise();
if (commandLine.isNotEmpty())
{
@@ -42,18 +42,14 @@ PropertiesFile& getGlobalProperties()
StoredSettings::StoredSettings()
: appearance (true)
{
+ reload();
}
StoredSettings::~StoredSettings()
{
flush();
}
-void StoredSettings::initialise()
-{
- reload();
-}
-
PropertiesFile& StoredSettings::getGlobalProperties()
{
return *propertyFiles.getUnchecked (0);
@@ -36,8 +36,6 @@ class StoredSettings
StoredSettings();
~StoredSettings();
- void initialise();
-
PropertiesFile& getGlobalProperties();
PropertiesFile& getProjectProperties (const String& projectUID);
@@ -1088,6 +1088,11 @@ class WidgetsDemo : public Component,
transformSlider.addListener (this);
}
+ ~WidgetsDemo()
+ {
+ PopupMenu::dismissAllActiveMenus();
+ }
+
void resized()
{
tabs.setBounds (10, 40, getWidth() - 20, getHeight() - 50);
@@ -76,20 +76,16 @@ class Component::MouseListenerList
if (checker.shouldBailOut())
return;
+ if (MouseListenerList* const list = comp.mouseListeners)
{
- MouseListenerList* const list = comp.mouseListeners;
-
- if (list != nullptr)
+ for (int i = list->listeners.size(); --i >= 0;)
{
- for (int i = list->listeners.size(); --i >= 0;)
- {
- (list->listeners.getUnchecked(i)->*eventMethod) (e);
+ (list->listeners.getUnchecked(i)->*eventMethod) (e);
- if (checker.shouldBailOut())
- return;
+ if (checker.shouldBailOut())
+ return;
- i = jmin (i, list->listeners.size());
- }
+ i = jmin (i, list->listeners.size());
}
}
@@ -117,20 +113,16 @@ class Component::MouseListenerList
static void sendWheelEvent (Component& comp, Component::BailOutChecker& checker,
const MouseEvent& e, const MouseWheelDetails& wheel)
{
+ if (MouseListenerList* const list = comp.mouseListeners)
{
- MouseListenerList* const list = comp.mouseListeners;
-
- if (list != nullptr)
+ for (int i = list->listeners.size(); --i >= 0;)
{
- for (int i = list->listeners.size(); --i >= 0;)
- {
- list->listeners.getUnchecked(i)->mouseWheelMove (e, wheel);
+ list->listeners.getUnchecked(i)->mouseWheelMove (e, wheel);
- if (checker.shouldBailOut())
- return;
+ if (checker.shouldBailOut())
+ return;
- i = jmin (i, list->listeners.size());
- }
+ i = jmin (i, list->listeners.size());
}
}
@@ -162,8 +154,8 @@ class Component::MouseListenerList
class BailOutChecker2
{
public:
- BailOutChecker2 (Component::BailOutChecker& checker_, Component* const component)
- : checker (checker_), safePointer (component)
+ BailOutChecker2 (Component::BailOutChecker& boc, Component* const comp)
+ : checker (boc), safePointer (comp)
{
}
@@ -297,9 +289,7 @@ struct Component::ComponentHelpers
{
Rectangle<int> r (comp.getLocalBounds());
- Component* const p = comp.getParentComponent();
-
- if (p != nullptr)
+ if (Component* const p = comp.getParentComponent())
r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p)));
return r;
@@ -422,13 +412,8 @@ void Component::setName (const String& name)
componentName = name;
if (flags.hasHeavyweightPeerFlag)
- {
- ComponentPeer* const peer = getPeer();
-
- jassert (peer != nullptr);
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
peer->setTitle (name);
- }
BailOutChecker checker (this);
componentListeners.callChecked (checker, &ComponentListener::componentNameChanged, *this);
@@ -478,10 +463,7 @@ void Component::setVisible (bool shouldBeVisible)
if (safePointer != nullptr && flags.hasHeavyweightPeerFlag)
{
- ComponentPeer* const peer = getPeer();
-
- jassert (peer != nullptr);
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
{
peer->setVisible (shouldBeVisible);
internalHierarchyChanged();
@@ -518,9 +500,7 @@ bool Component::isShowing() const
//==============================================================================
void* Component::getWindowHandle() const
{
- const ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (const ComponentPeer* const peer = getPeer())
return peer->getNativeHandle();
return nullptr;
@@ -538,16 +518,11 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
else
styleWanted |= ComponentPeer::windowIsSemiTransparent;
- int currentStyleFlags = 0;
-
// don't use getPeer(), so that we only get the peer that's specifically
// for this comp, and not for one of its parents.
ComponentPeer* peer = ComponentPeer::getPeerFor (this);
- if (peer != nullptr)
- currentStyleFlags = peer->getStyleFlags();
-
- if (styleWanted != currentStyleFlags || ! flags.hasHeavyweightPeerFlag)
+ if (peer == nullptr || styleWanted != peer->getStyleFlags())
{
const WeakReference<Component> safePointer (this);
@@ -687,15 +662,8 @@ void Component::setOpaque (const bool shouldBeOpaque)
flags.opaqueFlag = shouldBeOpaque;
if (flags.hasHeavyweightPeerFlag)
- {
- const ComponentPeer* const peer = ComponentPeer::getPeerFor (this);
-
- if (peer != nullptr)
- {
- // to make it recreate the heavyweight window
- addToDesktop (peer->getStyleFlags());
- }
- }
+ if (const ComponentPeer* const peer = ComponentPeer::getPeerFor (this))
+ addToDesktop (peer->getStyleFlags()); // recreates the heavyweight window
repaint();
}
@@ -710,7 +678,7 @@ bool Component::isOpaque() const noexcept
class StandardCachedComponentImage : public CachedComponentImage
{
public:
- StandardCachedComponentImage (Component& owner_) noexcept : owner (owner_) {}
+ StandardCachedComponentImage (Component& c) noexcept : owner (c) {}
void paint (Graphics& g)
{
@@ -814,9 +782,7 @@ void Component::toFront (const bool setAsForeground)
if (flags.hasHeavyweightPeerFlag)
{
- ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
{
peer->toFront (setAsForeground);
@@ -936,10 +902,7 @@ void Component::setAlwaysOnTop (const bool shouldStayOnTop)
if (isOnDesktop())
{
- ComponentPeer* const peer = getPeer();
-
- jassert (peer != nullptr);
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
{
if (! peer->setAlwaysOnTop (shouldStayOnTop))
{
@@ -1076,9 +1039,7 @@ void Component::setBounds (const int x, const int y, int w, int h)
if (flags.hasHeavyweightPeerFlag)
{
- ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
{
if (wasMoved && wasResized)
peer->setBounds (getX(), getY(), getWidth(), getHeight(), false);
@@ -1332,12 +1293,8 @@ bool Component::contains (const Point<int>& point)
return parentComponent->contains (ComponentHelpers::convertToParentSpace (*this, point));
if (flags.hasHeavyweightPeerFlag)
- {
- const ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (const ComponentPeer* const peer = getPeer())
return peer->contains (point, true);
- }
}
return false;
@@ -1677,8 +1634,8 @@ void Component::exitModalState (const int returnValue)
class ExitModalStateMessage : public CallbackMessage
{
public:
- ExitModalStateMessage (Component* const target_, const int result_)
- : target (target_), result (result_) {}
+ ExitModalStateMessage (Component* const c, const int res)
+ : target (c), result (res) {}
void messageCallback()
{
@@ -1770,9 +1727,7 @@ void Component::setAlpha (const float newAlpha)
if (flags.hasHeavyweightPeerFlag)
{
- ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
peer->setAlpha (newAlpha);
}
else
@@ -1835,9 +1790,7 @@ void Component::internalRepaintUnchecked (const Rectangle<int>& area, const bool
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
- ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
peer->repaint (area);
}
else
@@ -2070,9 +2023,7 @@ void Component::sendLookAndFeelChange()
Colour Component::findColour (const int colourId, const bool inheritFromParent) const
{
- const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId));
-
- if (v != nullptr)
+ if (const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)))
return Colour ((uint32) static_cast <int> (*v));
if (inheritFromParent && parentComponent != nullptr
@@ -2123,8 +2074,8 @@ MarkerList* Component::getMarkers (bool /*xAxis*/)
}
//==============================================================================
-Component::Positioner::Positioner (Component& component_) noexcept
- : component (component_)
+Component::Positioner::Positioner (Component& c) noexcept
+ : component (c)
{
}
@@ -2225,9 +2176,7 @@ bool Component::canModalEventBeSentToComponent (const Component*)
void Component::internalModalInputAttempt()
{
- Component* const current = getCurrentlyModalComponent();
-
- if (current != nullptr)
+ if (Component* const current = getCurrentlyModalComponent())
current->inputAttemptWhenModal();
}
@@ -2237,8 +2186,8 @@ void Component::postCommandMessage (const int commandId)
class CustomCommandMessage : public CallbackMessage
{
public:
- CustomCommandMessage (Component* const target_, const int commandId_)
- : target (target_), commandId (commandId_) {}
+ CustomCommandMessage (Component* const c, const int command)
+ : target (c), commandId (command) {}
void messageCallback()
{
@@ -2552,12 +2501,11 @@ void Component::internalBroughtToFront()
// When brought to the front and there's a modal component blocking this one,
// we need to bring the modal one to the front instead..
- Component* const cm = getCurrentlyModalComponent();
-
- if (cm != nullptr && cm->getTopLevelComponent() != getTopLevelComponent())
- ModalComponentManager::getInstance()->bringModalComponentsToFront (false); // very important that this is false, otherwise in Windows,
- // non-front components can't get focus when another modal comp is
- // active, and therefore can't receive mouse-clicks
+ if (Component* const cm = getCurrentlyModalComponent())
+ if (cm->getTopLevelComponent() != getTopLevelComponent())
+ ModalComponentManager::getInstance()->bringModalComponentsToFront (false); // very important that this is false, otherwise in Windows,
+ // non-front components can't get focus when another modal comp is
+ // active, and therefore can't receive mouse-clicks
}
//==============================================================================
@@ -2662,9 +2610,7 @@ void Component::takeKeyboardFocus (const FocusChangeType cause)
if (currentlyFocusedComponent != this)
{
// get the focus onto our desktop window
- ComponentPeer* const peer = getPeer();
-
- if (peer != nullptr)
+ if (ComponentPeer* const peer = getPeer())
{
const WeakReference<Component> safePointer (this);
peer->grabFocus();
@@ -2831,9 +2777,7 @@ void Component::sendEnablementChangeMessage()
for (int i = getNumChildComponents(); --i >= 0;)
{
- Component* const c = getChildComponent (i);
-
- if (c != nullptr)
+ if (Component* const c = getChildComponent (i))
{
c->sendEnablementChangeMessage();

0 comments on commit 5378449

Please sign in to comment.