mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Tidied up a couple of minor analyser warnings and comments
This commit is contained in:
parent
411071f3b1
commit
dace37288b
4 changed files with 95 additions and 94 deletions
|
|
@ -256,7 +256,7 @@ public:
|
|||
|
||||
case linearGradient:
|
||||
case radialGradient:
|
||||
return gradCol1.isOpaque() && gradCol1.isOpaque();
|
||||
return gradCol1.isOpaque() && gradCol2.isOpaque();
|
||||
|
||||
case imageBrush:
|
||||
return image.isValid()
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
RelativePositionedRectangle newState, oldState;
|
||||
};
|
||||
|
||||
|
|
@ -236,32 +235,35 @@ void PaintElement::drawExtraEditorGraphics (Graphics&, const Rectangle<int>& /*r
|
|||
|
||||
void PaintElement::paint (Graphics& g)
|
||||
{
|
||||
Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
|
||||
|
||||
g.saveState();
|
||||
g.setOrigin (area.getPosition() - Component::getPosition());
|
||||
area.setPosition (0, 0);
|
||||
|
||||
g.saveState();
|
||||
g.reduceClipRegion (0, 0, area.getWidth(), area.getHeight());
|
||||
|
||||
draw (g, getDocument()->getComponentLayout(), area);
|
||||
|
||||
g.restoreState();
|
||||
|
||||
drawExtraEditorGraphics (g, area);
|
||||
g.restoreState();
|
||||
|
||||
if (selected)
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
{
|
||||
const BorderSize<int> borderSize (border->getBorderThickness());
|
||||
auto area = pe->getComponentArea();
|
||||
|
||||
drawResizableBorder (g, getWidth(), getHeight(), borderSize,
|
||||
(isMouseOverOrDragging() || border->isMouseOverOrDragging()));
|
||||
}
|
||||
else if (isMouseOverOrDragging())
|
||||
{
|
||||
drawMouseOverCorners (g, getWidth(), getHeight());
|
||||
g.saveState();
|
||||
g.setOrigin (area.getPosition() - Component::getPosition());
|
||||
area.setPosition (0, 0);
|
||||
|
||||
g.saveState();
|
||||
g.reduceClipRegion (0, 0, area.getWidth(), area.getHeight());
|
||||
|
||||
draw (g, getDocument()->getComponentLayout(), area);
|
||||
|
||||
g.restoreState();
|
||||
|
||||
drawExtraEditorGraphics (g, area);
|
||||
g.restoreState();
|
||||
|
||||
if (selected)
|
||||
{
|
||||
const BorderSize<int> borderSize (border->getBorderThickness());
|
||||
|
||||
drawResizableBorder (g, getWidth(), getHeight(), borderSize,
|
||||
(isMouseOverOrDragging() || border->isMouseOverOrDragging()));
|
||||
}
|
||||
else if (isMouseOverOrDragging())
|
||||
{
|
||||
drawMouseOverCorners (g, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -291,31 +293,36 @@ void PaintElement::mouseDrag (const MouseEvent& e)
|
|||
{
|
||||
if (! e.mods.isPopupMenu())
|
||||
{
|
||||
jassert (dynamic_cast<PaintRoutineEditor*> (getParentComponent()) != nullptr);
|
||||
const Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
|
||||
|
||||
if (selected && ! dragging)
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
{
|
||||
dragging = e.mouseWasDraggedSinceMouseDown();
|
||||
auto area = pe->getComponentArea();
|
||||
|
||||
if (selected && ! dragging)
|
||||
{
|
||||
dragging = e.mouseWasDraggedSinceMouseDown();
|
||||
|
||||
if (dragging)
|
||||
owner->startDragging (area);
|
||||
}
|
||||
|
||||
if (dragging)
|
||||
owner->startDragging (area);
|
||||
owner->dragSelectedComps (e.getDistanceFromDragStartX(),
|
||||
e.getDistanceFromDragStartY(),
|
||||
area);
|
||||
}
|
||||
|
||||
if (dragging)
|
||||
owner->dragSelectedComps (e.getDistanceFromDragStartX(),
|
||||
e.getDistanceFromDragStartY(),
|
||||
area);
|
||||
}
|
||||
}
|
||||
|
||||
void PaintElement::mouseUp (const MouseEvent& e)
|
||||
{
|
||||
if (dragging)
|
||||
owner->endDragging();
|
||||
|
||||
if (owner != nullptr)
|
||||
owner->getSelectedElements().addToSelectionOnMouseUp (this, e.mods, dragging, mouseDownSelectStatus);
|
||||
{
|
||||
if (dragging)
|
||||
owner->endDragging();
|
||||
|
||||
if (owner != nullptr)
|
||||
owner->getSelectedElements().addToSelectionOnMouseUp (this, e.mods, dragging, mouseDownSelectStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void PaintElement::resizeStart()
|
||||
|
|
@ -345,44 +352,47 @@ void PaintElement::checkBounds (Rectangle<int>& b,
|
|||
|
||||
ComponentBoundsConstrainer::checkBounds (b, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
|
||||
|
||||
JucerDocument* document = getDocument();
|
||||
|
||||
if (document != nullptr && document->isSnapActive (true))
|
||||
if (auto* document = getDocument())
|
||||
{
|
||||
jassert (getParentComponent() != nullptr);
|
||||
const Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
|
||||
if (document->isSnapActive (true))
|
||||
{
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
{
|
||||
auto area = pe->getComponentArea();
|
||||
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int w = b.getWidth();
|
||||
int h = b.getHeight();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int w = b.getWidth();
|
||||
int h = b.getHeight();
|
||||
|
||||
x += borderThickness - area.getX();
|
||||
y += borderThickness - area.getY();
|
||||
w -= borderThickness * 2;
|
||||
h -= borderThickness * 2;
|
||||
x += borderThickness - area.getX();
|
||||
y += borderThickness - area.getY();
|
||||
w -= borderThickness * 2;
|
||||
h -= borderThickness * 2;
|
||||
|
||||
int right = x + w;
|
||||
int bottom = y + h;
|
||||
int right = x + w;
|
||||
int bottom = y + h;
|
||||
|
||||
if (isStretchingRight)
|
||||
right = document->snapPosition (right);
|
||||
if (isStretchingRight)
|
||||
right = document->snapPosition (right);
|
||||
|
||||
if (isStretchingBottom)
|
||||
bottom = document->snapPosition (bottom);
|
||||
if (isStretchingBottom)
|
||||
bottom = document->snapPosition (bottom);
|
||||
|
||||
if (isStretchingLeft)
|
||||
x = document->snapPosition (x);
|
||||
if (isStretchingLeft)
|
||||
x = document->snapPosition (x);
|
||||
|
||||
if (isStretchingTop)
|
||||
y = document->snapPosition (y);
|
||||
if (isStretchingTop)
|
||||
y = document->snapPosition (y);
|
||||
|
||||
w = (right - x) + borderThickness * 2;
|
||||
h = (bottom - y) + borderThickness * 2;
|
||||
x -= borderThickness - area.getX();
|
||||
y -= borderThickness - area.getY();
|
||||
w = (right - x) + borderThickness * 2;
|
||||
h = (bottom - y) + borderThickness * 2;
|
||||
x -= borderThickness - area.getX();
|
||||
y -= borderThickness - area.getY();
|
||||
|
||||
b = Rectangle<int> (x, y, w, h);
|
||||
b = { x, y, w, h };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -392,28 +402,24 @@ void PaintElement::applyBoundsToComponent (Component*, const Rectangle<int>& new
|
|||
{
|
||||
getDocument()->getUndoManager().undoCurrentTransactionOnly();
|
||||
|
||||
jassert (dynamic_cast<PaintRoutineEditor*> (getParentComponent()) != nullptr);
|
||||
|
||||
setCurrentBounds (newBounds.expanded (-borderThickness, -borderThickness),
|
||||
((PaintRoutineEditor*) getParentComponent())->getComponentArea(),
|
||||
true);
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
setCurrentBounds (newBounds.expanded (-borderThickness, -borderThickness),
|
||||
pe->getComponentArea(), true);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle<int> PaintElement::getCurrentAbsoluteBounds() const
|
||||
{
|
||||
jassert (dynamic_cast<PaintRoutineEditor*> (getParentComponent()) != nullptr);
|
||||
const Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
return position.getRectangle (pe->getComponentArea(), getDocument()->getComponentLayout());
|
||||
|
||||
return position.getRectangle (area, getDocument()->getComponentLayout());
|
||||
return {};
|
||||
}
|
||||
|
||||
void PaintElement::getCurrentAbsoluteBoundsDouble (double& x, double& y, double& w, double& h) const
|
||||
{
|
||||
jassert (dynamic_cast<PaintRoutineEditor*> (getParentComponent()) != nullptr);
|
||||
const Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
|
||||
|
||||
position.getRectangleDouble (x, y, w, h, area, getDocument()->getComponentLayout());
|
||||
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
|
||||
position.getRectangleDouble (x, y, w, h, pe->getComponentArea(), getDocument()->getComponentLayout());
|
||||
}
|
||||
|
||||
void PaintElement::changeListenerCallback (ChangeBroadcaster*)
|
||||
|
|
@ -465,7 +471,7 @@ void PaintElement::updateSiblingComps()
|
|||
|
||||
void PaintElement::showPopupMenu()
|
||||
{
|
||||
ApplicationCommandManager* commandManager = &ProjucerApplication::getCommandManager();
|
||||
auto* commandManager = &ProjucerApplication::getCommandManager();
|
||||
|
||||
PopupMenu m;
|
||||
|
||||
|
|
|
|||
|
|
@ -99,10 +99,6 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Changes the font to use for subsequent text-drawing functions.
|
||||
|
||||
Note there's also a setFont (float, int) method to quickly change the size and
|
||||
style of the current font.
|
||||
|
||||
@see drawSingleLineText, drawMultiLineText, drawText, drawFittedText
|
||||
*/
|
||||
void setFont (const Font& newFont);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
static uint32 lastUniquePeerID = 1;
|
||||
|
||||
//==============================================================================
|
||||
ComponentPeer::ComponentPeer (Component& comp, const int flags)
|
||||
ComponentPeer::ComponentPeer (Component& comp, int flags)
|
||||
: component (comp),
|
||||
styleFlags (flags),
|
||||
uniqueID (lastUniquePeerID += 2) // increment by 2 so that this can never hit 0
|
||||
|
|
@ -154,7 +154,7 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo)
|
|||
|
||||
Component* ComponentPeer::getTargetForKeyPress()
|
||||
{
|
||||
Component* c = Component::getCurrentlyFocusedComponent();
|
||||
auto* c = Component::getCurrentlyFocusedComponent();
|
||||
|
||||
if (c == nullptr)
|
||||
c = &component;
|
||||
|
|
@ -180,7 +180,7 @@ bool ComponentPeer::handleKeyPress (const KeyPress& keyInfo)
|
|||
{
|
||||
bool keyWasUsed = false;
|
||||
|
||||
for (Component* target = getTargetForKeyPress(); target != nullptr; target = target->getParentComponent())
|
||||
for (auto* target = getTargetForKeyPress(); target != nullptr; target = target->getParentComponent())
|
||||
{
|
||||
const WeakReference<Component> deletionChecker (target);
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown)
|
|||
ModifierKeys::updateCurrentModifiers();
|
||||
bool keyWasUsed = false;
|
||||
|
||||
for (Component* target = getTargetForKeyPress(); target != nullptr; target = target->getParentComponent())
|
||||
for (auto* target = getTargetForKeyPress(); target != nullptr; target = target->getParentComponent())
|
||||
{
|
||||
const WeakReference<Component> deletionChecker (target);
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown)
|
|||
if (keyWasUsed || deletionChecker == nullptr)
|
||||
break;
|
||||
|
||||
if (const Array<KeyListener*>* const keyListeners = target->keyListeners)
|
||||
if (auto* keyListeners = target->keyListeners.get())
|
||||
{
|
||||
for (int i = keyListeners->size(); --i >= 0;)
|
||||
{
|
||||
|
|
@ -264,8 +264,7 @@ void ComponentPeer::handleModifierKeysChange()
|
|||
if (target == nullptr)
|
||||
target = &component;
|
||||
|
||||
if (target != nullptr)
|
||||
target->internalModifierKeysChanged();
|
||||
target->internalModifierKeysChanged();
|
||||
}
|
||||
|
||||
TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
|
||||
|
|
@ -273,7 +272,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
|
|||
auto* c = Component::getCurrentlyFocusedComponent();
|
||||
|
||||
if (c == &component || component.isParentOf (c))
|
||||
if (TextInputTarget* const ti = dynamic_cast<TextInputTarget*> (c))
|
||||
if (auto* ti = dynamic_cast<TextInputTarget*> (c))
|
||||
if (ti->isTextInputActive())
|
||||
return ti;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue