Browse Source

Minor fixes and clean-ups.

tags/2021-05-28
jules 13 years ago
parent
commit
53784490b2
5 changed files with 49 additions and 107 deletions
  1. +0
    -1
      extras/Introjucer/Source/Application/jucer_Application.h
  2. +1
    -5
      extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp
  3. +0
    -2
      extras/Introjucer/Source/Utility/jucer_StoredSettings.h
  4. +5
    -0
      extras/JuceDemo/Source/demos/WidgetsDemo.cpp
  5. +43
    -99
      modules/juce_gui_basics/components/juce_Component.cpp

+ 0
- 1
extras/Introjucer/Source/Application/jucer_Application.h View File

@@ -46,7 +46,6 @@ public:
{
LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
settings = new StoredSettings();
settings->initialise();
if (commandLine.isNotEmpty())
{


+ 1
- 5
extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp View File

@@ -42,6 +42,7 @@ PropertiesFile& getGlobalProperties()
StoredSettings::StoredSettings()
: appearance (true)
{
reload();
}
StoredSettings::~StoredSettings()
@@ -49,11 +50,6 @@ StoredSettings::~StoredSettings()
flush();
}
void StoredSettings::initialise()
{
reload();
}
PropertiesFile& StoredSettings::getGlobalProperties()
{
return *propertyFiles.getUnchecked (0);


+ 0
- 2
extras/Introjucer/Source/Utility/jucer_StoredSettings.h View File

@@ -36,8 +36,6 @@ public:
StoredSettings();
~StoredSettings();
void initialise();
PropertiesFile& getGlobalProperties();
PropertiesFile& getProjectProperties (const String& projectUID);


+ 5
- 0
extras/JuceDemo/Source/demos/WidgetsDemo.cpp View File

@@ -1088,6 +1088,11 @@ public:
transformSlider.addListener (this);
}
~WidgetsDemo()
{
PopupMenu::dismissAllActiveMenus();
}
void resized()
{
tabs.setBounds (10, 40, getWidth() - 20, getHeight() - 50);


+ 43
- 99
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -76,20 +76,16 @@ public:
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 @@ public:
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 @@ private:
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();


Loading…
Cancel
Save