mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Some misc cleanups, mainly around WeakReference usage and rectangles
This commit is contained in:
parent
47535718dc
commit
7ab4d1708b
28 changed files with 136 additions and 135 deletions
|
|
@ -195,7 +195,7 @@ void PluginListComponent::setNumberOfThreadsForScanning (int num)
|
|||
|
||||
void PluginListComponent::resized()
|
||||
{
|
||||
Rectangle<int> r (getLocalBounds().reduced (2));
|
||||
auto r = getLocalBounds().reduced (2);
|
||||
|
||||
optionsButton.setBounds (r.removeFromBottom (24));
|
||||
optionsButton.changeWidthToFitText (24);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ namespace juce
|
|||
|
||||
struct AudioVisualiserComponent::ChannelInfo
|
||||
{
|
||||
ChannelInfo (AudioVisualiserComponent& o, int bufferSize)
|
||||
: owner (o), nextSample (0), subSample (0)
|
||||
ChannelInfo (AudioVisualiserComponent& o, int bufferSize) : owner (o)
|
||||
{
|
||||
setBufferSize (bufferSize);
|
||||
clear();
|
||||
|
|
@ -38,20 +37,20 @@ struct AudioVisualiserComponent::ChannelInfo
|
|||
|
||||
void clear() noexcept
|
||||
{
|
||||
for (int i = 0; i < levels.size(); ++i)
|
||||
levels.getReference(i) = Range<float>();
|
||||
for (auto& l : levels)
|
||||
l = {};
|
||||
|
||||
value = Range<float>();
|
||||
value = {};
|
||||
subSample = 0;
|
||||
}
|
||||
|
||||
void pushSamples (const float* inputSamples, const int num) noexcept
|
||||
void pushSamples (const float* inputSamples, int num) noexcept
|
||||
{
|
||||
for (int i = 0; i < num; ++i)
|
||||
pushSample (inputSamples[i]);
|
||||
}
|
||||
|
||||
void pushSample (const float newSample) noexcept
|
||||
void pushSample (float newSample) noexcept
|
||||
{
|
||||
if (--subSample <= 0)
|
||||
{
|
||||
|
|
@ -69,7 +68,7 @@ struct AudioVisualiserComponent::ChannelInfo
|
|||
void setBufferSize (int newSize)
|
||||
{
|
||||
levels.removeRange (newSize, levels.size());
|
||||
levels.insertMultiple (-1, Range<float>(), newSize - levels.size());
|
||||
levels.insertMultiple (-1, {}, newSize - levels.size());
|
||||
|
||||
if (nextSample >= newSize)
|
||||
nextSample = 0;
|
||||
|
|
@ -78,13 +77,13 @@ struct AudioVisualiserComponent::ChannelInfo
|
|||
AudioVisualiserComponent& owner;
|
||||
Array<Range<float>> levels;
|
||||
Range<float> value;
|
||||
int nextSample, subSample;
|
||||
int nextSample = 0, subSample = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChannelInfo)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
AudioVisualiserComponent::AudioVisualiserComponent (const int initialNumChannels)
|
||||
AudioVisualiserComponent::AudioVisualiserComponent (int initialNumChannels)
|
||||
: numSamples (1024),
|
||||
inputSamplesPerBlock (256),
|
||||
backgroundColour (Colours::black),
|
||||
|
|
@ -99,7 +98,7 @@ AudioVisualiserComponent::~AudioVisualiserComponent()
|
|||
{
|
||||
}
|
||||
|
||||
void AudioVisualiserComponent::setNumChannels (const int numChannels)
|
||||
void AudioVisualiserComponent::setNumChannels (int numChannels)
|
||||
{
|
||||
channels.clear();
|
||||
|
||||
|
|
@ -111,14 +110,14 @@ void AudioVisualiserComponent::setBufferSize (int newNumSamples)
|
|||
{
|
||||
numSamples = newNumSamples;
|
||||
|
||||
for (int i = 0; i < channels.size(); ++i)
|
||||
channels.getUnchecked(i)->setBufferSize (newNumSamples);
|
||||
for (auto* c : channels)
|
||||
c->setBufferSize (newNumSamples);
|
||||
}
|
||||
|
||||
void AudioVisualiserComponent::clear()
|
||||
{
|
||||
for (int i = 0; i < channels.size(); ++i)
|
||||
channels.getUnchecked(i)->clear();
|
||||
for (auto* c : channels)
|
||||
c->clear();
|
||||
}
|
||||
|
||||
void AudioVisualiserComponent::pushBuffer (const float** d, int numChannels, int num)
|
||||
|
|
@ -138,7 +137,7 @@ void AudioVisualiserComponent::pushBuffer (const AudioBuffer<float>& buffer)
|
|||
|
||||
void AudioVisualiserComponent::pushBuffer (const AudioSourceChannelInfo& buffer)
|
||||
{
|
||||
const int numChannels = jmin (buffer.buffer->getNumChannels(), channels.size());
|
||||
auto numChannels = jmin (buffer.buffer->getNumChannels(), channels.size());
|
||||
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
channels.getUnchecked(i)->pushSamples (buffer.buffer->getReadPointer (i, buffer.startSample),
|
||||
|
|
@ -179,27 +178,24 @@ void AudioVisualiserComponent::paint (Graphics& g)
|
|||
{
|
||||
g.fillAll (backgroundColour);
|
||||
|
||||
Rectangle<float> r (getLocalBounds().toFloat());
|
||||
const float channelHeight = r.getHeight() / channels.size();
|
||||
auto r = getLocalBounds().toFloat();
|
||||
auto channelHeight = r.getHeight() / channels.size();
|
||||
|
||||
g.setColour (waveformColour);
|
||||
|
||||
for (int i = 0; i < channels.size(); ++i)
|
||||
{
|
||||
const ChannelInfo& c = *channels.getUnchecked(i);
|
||||
|
||||
for (auto* c : channels)
|
||||
paintChannel (g, r.removeFromTop (channelHeight),
|
||||
c.levels.begin(), c.levels.size(), c.nextSample);
|
||||
}
|
||||
c->levels.begin(), c->levels.size(), c->nextSample);
|
||||
}
|
||||
|
||||
void AudioVisualiserComponent::getChannelAsPath (Path& path, const Range<float>* levels, int numLevels, int nextSample)
|
||||
void AudioVisualiserComponent::getChannelAsPath (Path& path, const Range<float>* levels,
|
||||
int numLevels, int nextSample)
|
||||
{
|
||||
path.preallocateSpace (4 * numLevels + 8);
|
||||
|
||||
for (int i = 0; i < numLevels; ++i)
|
||||
{
|
||||
const float level = -(levels[(nextSample + i) % numLevels].getEnd());
|
||||
auto level = -(levels[(nextSample + i) % numLevels].getEnd());
|
||||
|
||||
if (i == 0)
|
||||
path.startNewSubPath (0.0f, level);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
void messageCallback() override
|
||||
{
|
||||
if (const ActionBroadcaster* const b = broadcaster)
|
||||
if (auto b = broadcaster.get())
|
||||
if (b->actionListeners.contains (listener))
|
||||
listener->actionListenerCallback (message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,8 +351,8 @@ void LowLevelGraphicsPostScriptRenderer::fillRect (const Rectangle<float>& r)
|
|||
writeClip();
|
||||
writeColour (stateStack.getLast()->fillType.colour);
|
||||
|
||||
Rectangle<float> r2 (r.translated ((float) stateStack.getLast()->xOffset,
|
||||
(float) stateStack.getLast()->yOffset));
|
||||
auto r2 = r.translated ((float) stateStack.getLast()->xOffset,
|
||||
(float) stateStack.getLast()->yOffset);
|
||||
|
||||
out << r2.getX() << ' ' << -r2.getBottom() << ' ' << r2.getWidth() << ' ' << r2.getHeight() << " rectfill\n";
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ void LowLevelGraphicsPostScriptRenderer::fillPath (const Path& path, const Affin
|
|||
out << "clip\n";
|
||||
}
|
||||
|
||||
const Rectangle<int> bounds (stateStack.getLast()->clip.getBounds());
|
||||
auto bounds = stateStack.getLast()->clip.getBounds();
|
||||
|
||||
// ideally this would draw lots of lines or ellipses to approximate the gradient, but for the
|
||||
// time-being, this just fills it with the average colour..
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ void DropShadow::drawForPath (Graphics& g, const Path& path) const
|
|||
{
|
||||
jassert (radius > 0);
|
||||
|
||||
const Rectangle<int> area ((path.getBounds().getSmallestIntegerContainer() + offset)
|
||||
.expanded (radius + 1)
|
||||
.getIntersection (g.getClipBounds().expanded (radius + 1)));
|
||||
auto area = (path.getBounds().getSmallestIntegerContainer() + offset)
|
||||
.expanded (radius + 1)
|
||||
.getIntersection (g.getClipBounds().expanded (radius + 1));
|
||||
|
||||
if (area.getWidth() > 2 && area.getHeight() > 2)
|
||||
{
|
||||
|
|
@ -142,11 +142,11 @@ void DropShadow::drawForRectangle (Graphics& g, const Rectangle<int>& targetArea
|
|||
const float radiusInset = (radius + 1) / 2.0f;
|
||||
const float expandedRadius = radius + radiusInset;
|
||||
|
||||
const Rectangle<float> area (targetArea.toFloat().reduced (radiusInset) + offset.toFloat());
|
||||
auto area = targetArea.toFloat().reduced (radiusInset) + offset.toFloat();
|
||||
|
||||
Rectangle<float> r (area.expanded (expandedRadius));
|
||||
Rectangle<float> top (r.removeFromTop (expandedRadius));
|
||||
Rectangle<float> bottom (r.removeFromBottom (expandedRadius));
|
||||
auto r = area.expanded (expandedRadius);
|
||||
auto top = r.removeFromTop (expandedRadius);
|
||||
auto bottom = r.removeFromBottom (expandedRadius);
|
||||
|
||||
drawShadowSection (g, cg, top.removeFromLeft (expandedRadius), true, 1.0f, 1.0f, 0, 1.0f);
|
||||
drawShadowSection (g, cg, top.removeFromRight (expandedRadius), true, 0, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
|||
|
|
@ -674,8 +674,8 @@ void Path::addBubble (Rectangle<float> bodyArea,
|
|||
|
||||
startNewSubPath (bodyArea.getX() + cornerSizeW, bodyArea.getY());
|
||||
|
||||
const Rectangle<float> targetLimit (bodyArea.reduced (jmin (halfW - 1.0f, cornerSizeW + arrowBaseWidth),
|
||||
jmin (halfH - 1.0f, cornerSizeH + arrowBaseWidth)));
|
||||
auto targetLimit = bodyArea.reduced (jmin (halfW - 1.0f, cornerSizeW + arrowBaseWidth),
|
||||
jmin (halfH - 1.0f, cornerSizeH + arrowBaseWidth));
|
||||
|
||||
if (Rectangle<float> (targetLimit.getX(), maximumArea.getY(),
|
||||
targetLimit.getWidth(), bodyArea.getY() - maximumArea.getY()).contains (arrowTip))
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void ShapeButton::setShape (const Path& newShape,
|
|||
|
||||
if (resizeNowToFitThisShape)
|
||||
{
|
||||
Rectangle<float> newBounds (shape.getBounds());
|
||||
auto newBounds = shape.getBounds();
|
||||
|
||||
if (hasShadow)
|
||||
newBounds = newBounds.expanded (4.0f);
|
||||
|
|
@ -105,7 +105,9 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto
|
|||
isButtonDown = false;
|
||||
}
|
||||
|
||||
Rectangle<float> r (border.subtractedFrom (getLocalBounds()).toFloat().reduced (outlineWidth * 0.5f));
|
||||
auto r = border.subtractedFrom (getLocalBounds())
|
||||
.toFloat()
|
||||
.reduced (outlineWidth * 0.5f);
|
||||
|
||||
if (getComponentEffect() != nullptr)
|
||||
r = r.reduced (2.0f);
|
||||
|
|
@ -118,7 +120,7 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto
|
|||
sizeReductionWhenPressed * r.getHeight());
|
||||
}
|
||||
|
||||
const AffineTransform trans (shape.getTransformToScaleToFit (r, maintainShapeProportions));
|
||||
auto trans = shape.getTransformToScaleToFit (r, maintainShapeProportions);
|
||||
|
||||
if (isButtonDown) g.setColour (getToggleState() && useOnColours ? downColourOn : downColour);
|
||||
else if (isMouseOverButton) g.setColour (getToggleState() && useOnColours ? overColourOn : overColour);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ TextButton::~TextButton()
|
|||
|
||||
void TextButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
|
||||
{
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
lf.drawButtonBackground (g, *this,
|
||||
findColour (getToggleState() ? buttonOnColourId : buttonColourId),
|
||||
|
|
|
|||
|
|
@ -2013,8 +2013,8 @@ void Component::setComponentEffect (ImageEffectFilter* newEffect)
|
|||
LookAndFeel& Component::getLookAndFeel() const noexcept
|
||||
{
|
||||
for (auto* c = this; c != nullptr; c = c->parentComponent)
|
||||
if (c->lookAndFeel != nullptr)
|
||||
return *(c->lookAndFeel);
|
||||
if (auto lf = c->lookAndFeel.get())
|
||||
return *lf;
|
||||
|
||||
return LookAndFeel::getDefaultLookAndFeel();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,15 +91,16 @@ Component* Desktop::findComponentAt (Point<int> screenPosition) const
|
|||
//==============================================================================
|
||||
LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept
|
||||
{
|
||||
if (currentLookAndFeel == nullptr)
|
||||
{
|
||||
if (defaultLookAndFeel == nullptr)
|
||||
defaultLookAndFeel.reset (new LookAndFeel_V4());
|
||||
if (auto lf = currentLookAndFeel.get())
|
||||
return *lf;
|
||||
|
||||
currentLookAndFeel = defaultLookAndFeel.get();
|
||||
}
|
||||
if (defaultLookAndFeel == nullptr)
|
||||
defaultLookAndFeel.reset (new LookAndFeel_V4());
|
||||
|
||||
return *currentLookAndFeel;
|
||||
auto lf = defaultLookAndFeel.get();
|
||||
jassert (lf != nullptr);
|
||||
currentLookAndFeel = lf;
|
||||
return *lf;
|
||||
}
|
||||
|
||||
void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel)
|
||||
|
|
@ -193,7 +194,7 @@ void Desktop::handleAsyncUpdate()
|
|||
// The component may be deleted during this operation, but we'll use a SafePointer rather than a
|
||||
// BailOutChecker so that any remaining listeners will still get a callback (with a null pointer).
|
||||
WeakReference<Component> currentFocus (Component::getCurrentlyFocusedComponent());
|
||||
focusListeners.call ([&] (FocusChangeListener& l) { l.globalFocusChanged (currentFocus); });
|
||||
focusListeners.call ([&] (FocusChangeListener& l) { l.globalFocusChanged (currentFocus.get()); });
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class JUCE_API ComponentMovementWatcher : public ComponentListener
|
|||
public:
|
||||
//==============================================================================
|
||||
/** Creates a ComponentMovementWatcher to watch a given target component. */
|
||||
ComponentMovementWatcher (Component* component);
|
||||
ComponentMovementWatcher (Component* componentToWatch);
|
||||
|
||||
/** Destructor. */
|
||||
~ComponentMovementWatcher();
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
virtual void componentVisibilityChanged() = 0;
|
||||
|
||||
/** Returns the component that's being watched. */
|
||||
Component* getComponent() const noexcept { return component; }
|
||||
Component* getComponent() const noexcept { return component.get(); }
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
|
|
|
|||
|
|
@ -27,10 +27,8 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
ResizableBorderComponent::Zone::Zone() noexcept : zone (0) {}
|
||||
|
||||
ResizableBorderComponent::Zone::Zone (const int zoneFlags) noexcept : zone (zoneFlags) {}
|
||||
|
||||
ResizableBorderComponent::Zone::Zone() noexcept {}
|
||||
ResizableBorderComponent::Zone::Zone (int zoneFlags) noexcept : zone (zoneFlags) {}
|
||||
ResizableBorderComponent::Zone::Zone (const ResizableBorderComponent::Zone& other) noexcept : zone (other.zone) {}
|
||||
|
||||
ResizableBorderComponent::Zone& ResizableBorderComponent::Zone::operator= (const ResizableBorderComponent::Zone& other) noexcept
|
||||
|
|
@ -42,8 +40,8 @@ ResizableBorderComponent::Zone& ResizableBorderComponent::Zone::operator= (const
|
|||
bool ResizableBorderComponent::Zone::operator== (const ResizableBorderComponent::Zone& other) const noexcept { return zone == other.zone; }
|
||||
bool ResizableBorderComponent::Zone::operator!= (const ResizableBorderComponent::Zone& other) const noexcept { return zone != other.zone; }
|
||||
|
||||
ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (const Rectangle<int>& totalSize,
|
||||
const BorderSize<int>& border,
|
||||
ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (Rectangle<int> totalSize,
|
||||
BorderSize<int> border,
|
||||
Point<int> position)
|
||||
{
|
||||
int z = 0;
|
||||
|
|
@ -51,13 +49,15 @@ ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBor
|
|||
if (totalSize.contains (position)
|
||||
&& ! border.subtractedFrom (totalSize).contains (position))
|
||||
{
|
||||
const int minW = jmax (totalSize.getWidth() / 10, jmin (10, totalSize.getWidth() / 3));
|
||||
auto minW = jmax (totalSize.getWidth() / 10, jmin (10, totalSize.getWidth() / 3));
|
||||
|
||||
if (position.x < jmax (border.getLeft(), minW) && border.getLeft() > 0)
|
||||
z |= left;
|
||||
else if (position.x >= totalSize.getWidth() - jmax (border.getRight(), minW) && border.getRight() > 0)
|
||||
z |= right;
|
||||
|
||||
const int minH = jmax (totalSize.getHeight() / 10, jmin (10, totalSize.getHeight() / 3));
|
||||
auto minH = jmax (totalSize.getHeight() / 10, jmin (10, totalSize.getHeight() / 3));
|
||||
|
||||
if (position.y < jmax (border.getTop(), minH) && border.getTop() > 0)
|
||||
z |= top;
|
||||
else if (position.y >= totalSize.getHeight() - jmax (border.getBottom(), minH) && border.getBottom() > 0)
|
||||
|
|
@ -69,7 +69,7 @@ ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBor
|
|||
|
||||
MouseCursor ResizableBorderComponent::Zone::getMouseCursor() const noexcept
|
||||
{
|
||||
MouseCursor::StandardCursorType mc = MouseCursor::NormalCursor;
|
||||
auto mc = MouseCursor::NormalCursor;
|
||||
|
||||
switch (zone)
|
||||
{
|
||||
|
|
@ -141,7 +141,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e)
|
|||
return;
|
||||
}
|
||||
|
||||
const Rectangle<int> newBounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart()));
|
||||
auto newBounds = mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart());
|
||||
|
||||
if (constrainer != nullptr)
|
||||
{
|
||||
|
|
@ -153,8 +153,8 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Component::Positioner* const pos = component->getPositioner())
|
||||
pos->applyNewBounds (newBounds);
|
||||
if (auto positioner = component->getPositioner())
|
||||
positioner->applyNewBounds (newBounds);
|
||||
else
|
||||
component->setBounds (newBounds);
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ BorderSize<int> ResizableBorderComponent::getBorderThickness() const
|
|||
|
||||
void ResizableBorderComponent::updateMouseZone (const MouseEvent& e)
|
||||
{
|
||||
Zone newZone (Zone::fromPositionOnBorder (getLocalBounds(), borderSize, e.getPosition()));
|
||||
auto newZone = Zone::fromPositionOnBorder (getLocalBounds(), borderSize, e.getPosition());
|
||||
|
||||
if (mouseZone != newZone)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ public:
|
|||
/** Given a point within a rectangle with a resizable border, this returns the
|
||||
zone that the point lies within.
|
||||
*/
|
||||
static Zone fromPositionOnBorder (const Rectangle<int>& totalSize,
|
||||
const BorderSize<int>& border,
|
||||
static Zone fromPositionOnBorder (Rectangle<int> totalSize,
|
||||
BorderSize<int> border,
|
||||
Point<int> position);
|
||||
|
||||
/** Returns an appropriate mouse-cursor for this resize zone. */
|
||||
|
|
@ -160,7 +160,7 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
int zone;
|
||||
int zone = centre;
|
||||
};
|
||||
|
||||
/** Returns the zone in which the mouse was last seen. */
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e)
|
|||
return;
|
||||
}
|
||||
|
||||
Rectangle<int> newBounds (originalBounds);
|
||||
auto newBounds = originalBounds;
|
||||
|
||||
switch (edge)
|
||||
{
|
||||
|
|
@ -98,8 +98,8 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Component::Positioner* const pos = component->getPositioner())
|
||||
pos->applyNewBounds (newBounds);
|
||||
if (auto positioner = component->getPositioner())
|
||||
positioner->applyNewBounds (newBounds);
|
||||
else
|
||||
component->setBounds (newBounds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ void ScrollBar::resized()
|
|||
|
||||
if (upButton != nullptr)
|
||||
{
|
||||
Rectangle<int> r (getLocalBounds());
|
||||
auto r = getLocalBounds();
|
||||
|
||||
if (vertical)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ namespace TabbedComponentHelpers
|
|||
{
|
||||
const Identifier deleteComponentId ("deleteByTabComp_");
|
||||
|
||||
static void deleteIfNecessary (Component* const comp)
|
||||
static void deleteIfNecessary (Component* comp)
|
||||
{
|
||||
if (comp != nullptr && (bool) comp->getProperties() [deleteComponentId])
|
||||
delete comp;
|
||||
}
|
||||
|
||||
static Rectangle<int> getTabArea (Rectangle<int>& content, BorderSize<int>& outline,
|
||||
const TabbedButtonBar::Orientation orientation, const int tabDepth)
|
||||
TabbedButtonBar::Orientation orientation, int tabDepth)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar
|
|||
owner.popupMenuClickOnTab (tabIndex, tabName);
|
||||
}
|
||||
|
||||
Colour getTabBackgroundColour (const int tabIndex)
|
||||
Colour getTabBackgroundColour (int tabIndex)
|
||||
{
|
||||
return owner.tabs->getTabBackgroundColour (tabIndex);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar
|
|||
|
||||
|
||||
//==============================================================================
|
||||
TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation)
|
||||
TabbedComponent::TabbedComponent (TabbedButtonBar::Orientation orientation)
|
||||
{
|
||||
tabs.reset (new ButtonBar (*this, orientation));
|
||||
addAndMakeVisible (tabs.get());
|
||||
|
|
@ -101,7 +101,7 @@ TabbedComponent::~TabbedComponent()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void TabbedComponent::setOrientation (const TabbedButtonBar::Orientation orientation)
|
||||
void TabbedComponent::setOrientation (TabbedButtonBar::Orientation orientation)
|
||||
{
|
||||
tabs->setOrientation (orientation);
|
||||
resized();
|
||||
|
|
@ -112,7 +112,7 @@ TabbedButtonBar::Orientation TabbedComponent::getOrientation() const noexcept
|
|||
return tabs->getOrientation();
|
||||
}
|
||||
|
||||
void TabbedComponent::setTabBarDepth (const int newDepth)
|
||||
void TabbedComponent::setTabBarDepth (int newDepth)
|
||||
{
|
||||
if (tabDepth != newDepth)
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ void TabbedComponent::setTabBarDepth (const int newDepth)
|
|||
}
|
||||
}
|
||||
|
||||
TabBarButton* TabbedComponent::createTabButton (const String& tabName, const int /*tabIndex*/)
|
||||
TabBarButton* TabbedComponent::createTabButton (const String& tabName, int /*tabIndex*/)
|
||||
{
|
||||
return new TabBarButton (tabName, *tabs);
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ void TabbedComponent::clearTabs()
|
|||
if (panelComponent != nullptr)
|
||||
{
|
||||
panelComponent->setVisible (false);
|
||||
removeChildComponent (panelComponent);
|
||||
removeChildComponent (panelComponent.get());
|
||||
panelComponent = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -146,9 +146,9 @@ void TabbedComponent::clearTabs()
|
|||
|
||||
void TabbedComponent::addTab (const String& tabName,
|
||||
Colour tabBackgroundColour,
|
||||
Component* const contentComponent,
|
||||
const bool deleteComponentWhenNotNeeded,
|
||||
const int insertIndex)
|
||||
Component* contentComponent,
|
||||
bool deleteComponentWhenNotNeeded,
|
||||
int insertIndex)
|
||||
{
|
||||
contentComponents.insert (insertIndex, WeakReference<Component> (contentComponent));
|
||||
|
||||
|
|
@ -159,22 +159,22 @@ void TabbedComponent::addTab (const String& tabName,
|
|||
resized();
|
||||
}
|
||||
|
||||
void TabbedComponent::setTabName (const int tabIndex, const String& newName)
|
||||
void TabbedComponent::setTabName (int tabIndex, const String& newName)
|
||||
{
|
||||
tabs->setTabName (tabIndex, newName);
|
||||
}
|
||||
|
||||
void TabbedComponent::removeTab (const int tabIndex)
|
||||
void TabbedComponent::removeTab (int tabIndex)
|
||||
{
|
||||
if (isPositiveAndBelow (tabIndex, contentComponents.size()))
|
||||
{
|
||||
TabbedComponentHelpers::deleteIfNecessary (contentComponents.getReference (tabIndex));
|
||||
TabbedComponentHelpers::deleteIfNecessary (contentComponents.getReference (tabIndex).get());
|
||||
contentComponents.remove (tabIndex);
|
||||
tabs->removeTab (tabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void TabbedComponent::moveTab (const int currentIndex, const int newIndex, const bool animate)
|
||||
void TabbedComponent::moveTab (int currentIndex, int newIndex, bool animate)
|
||||
{
|
||||
contentComponents.move (currentIndex, newIndex);
|
||||
tabs->moveTab (currentIndex, newIndex, animate);
|
||||
|
|
@ -190,17 +190,17 @@ StringArray TabbedComponent::getTabNames() const
|
|||
return tabs->getTabNames();
|
||||
}
|
||||
|
||||
Component* TabbedComponent::getTabContentComponent (const int tabIndex) const noexcept
|
||||
Component* TabbedComponent::getTabContentComponent (int tabIndex) const noexcept
|
||||
{
|
||||
return contentComponents [tabIndex];
|
||||
return contentComponents[tabIndex].get();
|
||||
}
|
||||
|
||||
Colour TabbedComponent::getTabBackgroundColour (const int tabIndex) const noexcept
|
||||
Colour TabbedComponent::getTabBackgroundColour (int tabIndex) const noexcept
|
||||
{
|
||||
return tabs->getTabBackgroundColour (tabIndex);
|
||||
}
|
||||
|
||||
void TabbedComponent::setTabBackgroundColour (const int tabIndex, Colour newColour)
|
||||
void TabbedComponent::setTabBackgroundColour (int tabIndex, Colour newColour)
|
||||
{
|
||||
tabs->setTabBackgroundColour (tabIndex, newColour);
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ void TabbedComponent::setTabBackgroundColour (const int tabIndex, Colour newColo
|
|||
repaint();
|
||||
}
|
||||
|
||||
void TabbedComponent::setCurrentTabIndex (const int newTabIndex, const bool sendChangeMessage)
|
||||
void TabbedComponent::setCurrentTabIndex (int newTabIndex, bool sendChangeMessage)
|
||||
{
|
||||
tabs->setCurrentTabIndex (newTabIndex, sendChangeMessage);
|
||||
}
|
||||
|
|
@ -223,14 +223,14 @@ String TabbedComponent::getCurrentTabName() const
|
|||
return tabs->getCurrentTabName();
|
||||
}
|
||||
|
||||
void TabbedComponent::setOutline (const int thickness)
|
||||
void TabbedComponent::setOutline (int thickness)
|
||||
{
|
||||
outlineThickness = thickness;
|
||||
resized();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void TabbedComponent::setIndent (const int indentThickness)
|
||||
void TabbedComponent::setIndent (int indentThickness)
|
||||
{
|
||||
edgeIndent = indentThickness;
|
||||
resized();
|
||||
|
|
@ -266,19 +266,19 @@ void TabbedComponent::resized()
|
|||
tabs->setBounds (TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth));
|
||||
content = BorderSize<int> (edgeIndent).subtractedFrom (outline.subtractedFrom (content));
|
||||
|
||||
for (int i = contentComponents.size(); --i >= 0;)
|
||||
if (Component* c = contentComponents.getReference(i))
|
||||
c->setBounds (content);
|
||||
for (auto& c : contentComponents)
|
||||
if (auto comp = c.get())
|
||||
comp->setBounds (content);
|
||||
}
|
||||
|
||||
void TabbedComponent::lookAndFeelChanged()
|
||||
{
|
||||
for (int i = contentComponents.size(); --i >= 0;)
|
||||
if (Component* c = contentComponents.getReference(i))
|
||||
c->lookAndFeelChanged();
|
||||
for (auto& c : contentComponents)
|
||||
if (auto comp = c.get())
|
||||
comp->lookAndFeelChanged();
|
||||
}
|
||||
|
||||
void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String& newTabName)
|
||||
void TabbedComponent::changeCallback (int newCurrentTabIndex, const String& newTabName)
|
||||
{
|
||||
auto* newPanelComp = getTabContentComponent (getCurrentTabIndex());
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public:
|
|||
/** Returns the current component that's filling the panel.
|
||||
This will return nullptr if there isn't one.
|
||||
*/
|
||||
Component* getCurrentContentComponent() const noexcept { return panelComponent; }
|
||||
Component* getCurrentContentComponent() const noexcept { return panelComponent.get(); }
|
||||
|
||||
//==============================================================================
|
||||
/** Callback method to indicate the selected tab has been changed.
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void Viewport::deleteOrRemoveContentComp()
|
|||
{
|
||||
// This sets the content comp to a null pointer before deleting the old one, in case
|
||||
// anything tries to use the old one while it's in mid-deletion..
|
||||
std::unique_ptr<Component> oldCompDeleter (contentComp);
|
||||
std::unique_ptr<Component> oldCompDeleter (contentComp.get());
|
||||
contentComp = nullptr;
|
||||
}
|
||||
else
|
||||
|
|
@ -124,7 +124,7 @@ Point<int> Viewport::viewportPosToCompPos (Point<int> pos) const
|
|||
{
|
||||
jassert (contentComp != nullptr);
|
||||
|
||||
auto contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds());
|
||||
auto contentBounds = contentHolder.getLocalArea (contentComp.get(), contentComp->getLocalBounds());
|
||||
|
||||
Point<int> p (jmax (jmin (0, contentHolder.getWidth() - contentBounds.getWidth()), jmin (0, -(pos.x))),
|
||||
jmax (jmin (0, contentHolder.getHeight() - contentBounds.getHeight()), jmin (0, -(pos.y))));
|
||||
|
|
@ -398,8 +398,9 @@ void Viewport::updateVisibleArea()
|
|||
}
|
||||
|
||||
Rectangle<int> contentBounds;
|
||||
if (contentComp != nullptr)
|
||||
contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds());
|
||||
|
||||
if (auto cc = contentComp.get())
|
||||
contentBounds = contentHolder.getLocalArea (cc, cc->getLocalBounds());
|
||||
|
||||
auto visibleOrigin = -contentBounds.getPosition();
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
@see setViewedComponent
|
||||
*/
|
||||
Component* getViewedComponent() const noexcept { return contentComp; }
|
||||
Component* getViewedComponent() const noexcept { return contentComp.get(); }
|
||||
|
||||
//==============================================================================
|
||||
/** Changes the position of the viewed component.
|
||||
|
|
|
|||
|
|
@ -1226,7 +1226,7 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
|
|||
g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha));
|
||||
g.setFont (font);
|
||||
|
||||
Rectangle<int> textArea (label.getBorderSize().subtractedFrom (label.getLocalBounds()));
|
||||
auto textArea = label.getBorderSize().subtractedFrom (label.getLocalBounds());
|
||||
|
||||
g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
|
||||
jmax (1, (int) (textArea.getHeight() / font.getHeight())),
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Co
|
|||
|
||||
void LookAndFeel_V3::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header)
|
||||
{
|
||||
Rectangle<int> r (header.getLocalBounds());
|
||||
auto r = header.getLocalBounds();
|
||||
auto outlineColour = header.findColour (TableHeaderComponent::outlineColourId);
|
||||
|
||||
g.setColour (outlineColour);
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ void BubbleComponent::setPosition (Rectangle<int> rectangleToPointTo,
|
|||
const int totalW = content.getWidth() + distanceFromTarget * 2;
|
||||
const int totalH = content.getHeight() + distanceFromTarget * 2;
|
||||
|
||||
const Rectangle<int> availableSpace (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds()
|
||||
: getParentMonitorArea().transformedBy (getTransform().inverted()));
|
||||
auto availableSpace = (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds()
|
||||
: getParentMonitorArea().transformedBy (getTransform().inverted()));
|
||||
|
||||
int spaceAbove = ((allowablePlacements & above) != 0) ? jmax (0, rectangleToPointTo.getY() - availableSpace.getY()) : -1;
|
||||
int spaceBelow = ((allowablePlacements & below) != 0) ? jmax (0, availableSpace.getBottom() - rectangleToPointTo.getBottom()) : -1;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo
|
|||
|
||||
if (componentToDrag != nullptr)
|
||||
{
|
||||
Rectangle<int> bounds (componentToDrag->getBounds());
|
||||
auto bounds = componentToDrag->getBounds();
|
||||
|
||||
// If the component is a window, multiple mouse events can get queued while it's in the same position,
|
||||
// so their coordinates become wrong after the first one moves the window, so in that case, we'll use
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public:
|
|||
comp.internalMouseDrag (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, pressure, orientation, rotation, tiltX, tiltY);
|
||||
}
|
||||
|
||||
void sendMouseUp (Component& comp, Point<float> screenPos, Time time, const ModifierKeys oldMods)
|
||||
void sendMouseUp (Component& comp, Point<float> screenPos, Time time, ModifierKeys oldMods)
|
||||
{
|
||||
JUCE_MOUSE_EVENT_DBG ("up")
|
||||
comp.internalMouseUp (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, oldMods, pressure, orientation, rotation, tiltX, tiltY);
|
||||
|
|
@ -161,7 +161,7 @@ public:
|
|||
comp.internalMouseWheel (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, wheel);
|
||||
}
|
||||
|
||||
void sendMagnifyGesture (Component& comp, Point<float> screenPos, Time time, const float amount)
|
||||
void sendMagnifyGesture (Component& comp, Point<float> screenPos, Time time, float amount)
|
||||
{
|
||||
JUCE_MOUSE_EVENT_DBG ("magnify")
|
||||
comp.internalMagnifyGesture (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, amount);
|
||||
|
|
@ -169,7 +169,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
// (returns true if the button change caused a modal event loop)
|
||||
bool setButtons (Point<float> screenPos, Time time, const ModifierKeys newButtonState)
|
||||
bool setButtons (Point<float> screenPos, Time time, ModifierKeys newButtonState)
|
||||
{
|
||||
if (buttonState == newButtonState)
|
||||
return false;
|
||||
|
|
@ -220,7 +220,7 @@ public:
|
|||
return lastCounter != mouseEventCounter;
|
||||
}
|
||||
|
||||
void setComponentUnderMouse (Component* const newComponent, Point<float> screenPos, Time time)
|
||||
void setComponentUnderMouse (Component* newComponent, Point<float> screenPos, Time time)
|
||||
{
|
||||
auto* current = getComponentUnderMouse();
|
||||
|
||||
|
|
@ -234,16 +234,17 @@ public:
|
|||
WeakReference<Component> safeOldComp (current);
|
||||
setButtons (screenPos, time, ModifierKeys());
|
||||
|
||||
if (safeOldComp != nullptr)
|
||||
if (auto oldComp = safeOldComp.get())
|
||||
{
|
||||
componentUnderMouse = safeNewComp;
|
||||
sendMouseExit (*safeOldComp, screenPos, time);
|
||||
sendMouseExit (*oldComp, screenPos, time);
|
||||
}
|
||||
|
||||
buttonState = originalButtonState;
|
||||
}
|
||||
|
||||
current = componentUnderMouse = safeNewComp;
|
||||
componentUnderMouse = safeNewComp.get();
|
||||
current = safeNewComp.get();
|
||||
|
||||
if (current != nullptr)
|
||||
sendMouseEnter (*current, screenPos, time);
|
||||
|
|
@ -263,7 +264,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void setScreenPos (Point<float> newScreenPos, Time time, const bool forceUpdate)
|
||||
void setScreenPos (Point<float> newScreenPos, Time time, bool forceUpdate)
|
||||
{
|
||||
if (! isDragging())
|
||||
setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time);
|
||||
|
|
@ -368,7 +369,7 @@ public:
|
|||
else
|
||||
screenPos = peer.localToGlobal (positionWithinPeer);
|
||||
|
||||
if (Component* target = lastNonInertialWheelTarget)
|
||||
if (auto target = lastNonInertialWheelTarget.get())
|
||||
sendMouseWheel (*target, screenPos, time, wheel);
|
||||
}
|
||||
|
||||
|
|
@ -737,7 +738,7 @@ struct MouseInputSource::SourceList : public Timer
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void beginDragAutoRepeat (const int interval)
|
||||
void beginDragAutoRepeat (int interval)
|
||||
{
|
||||
if (interval > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
PropertyComponent::PropertyComponent (const String& name, const int preferredHeight_)
|
||||
: Component (name), preferredHeight (preferredHeight_)
|
||||
PropertyComponent::PropertyComponent (const String& name, int height)
|
||||
: Component (name), preferredHeight (height)
|
||||
{
|
||||
jassert (name.isNotEmpty());
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ PropertyComponent::~PropertyComponent() {}
|
|||
|
||||
void PropertyComponent::paint (Graphics& g)
|
||||
{
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
lf.drawPropertyComponentBackground (g, getWidth(), getHeight(), *this);
|
||||
lf.drawPropertyComponentLabel (g, getWidth(), getHeight(), *this);
|
||||
|
|
@ -45,7 +45,7 @@ void PropertyComponent::paint (Graphics& g)
|
|||
|
||||
void PropertyComponent::resized()
|
||||
{
|
||||
if (Component* const c = getChildComponent(0))
|
||||
if (auto c = getChildComponent(0))
|
||||
c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -499,11 +499,11 @@ void TableHeaderComponent::reactToMenuItem (const int menuReturnId, const int /*
|
|||
|
||||
void TableHeaderComponent::paint (Graphics& g)
|
||||
{
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
lf.drawTableHeaderBackground (g, *this);
|
||||
|
||||
const Rectangle<int> clip (g.getClipBounds());
|
||||
auto clip = g.getClipBounds();
|
||||
|
||||
int x = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ public:
|
|||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> r (getLocalBounds().reduced (2, 0));
|
||||
auto r = getLocalBounds().reduced (2, 0);
|
||||
|
||||
for (int i = 0; i < editors.size(); ++i)
|
||||
editors.getUnchecked(i)->setBounds (r.removeFromTop (itemHeight));
|
||||
|
|
|
|||
|
|
@ -219,9 +219,9 @@ void OnlineUnlockForm::resized()
|
|||
|
||||
const int buttonHeight = 22;
|
||||
|
||||
Rectangle<int> r (getLocalBounds().reduced (10, 20));
|
||||
auto r = getLocalBounds().reduced (10, 20);
|
||||
|
||||
Rectangle<int> buttonArea (r.removeFromBottom (buttonHeight));
|
||||
auto buttonArea = r.removeFromBottom (buttonHeight);
|
||||
registerButton.changeWidthToFitText (buttonHeight);
|
||||
cancelButton.changeWidthToFitText (buttonHeight);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue