Browse Source

Tidied up a couple of minor analyser warnings and comments

tags/2021-05-28
jules 8 years ago
parent
commit
dace37288b
4 changed files with 90 additions and 89 deletions
  1. +1
    -1
      extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h
  2. +82
    -76
      extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp
  3. +0
    -4
      modules/juce_graphics/contexts/juce_GraphicsContext.h
  4. +7
    -8
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp

+ 1
- 1
extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h View File

@@ -256,7 +256,7 @@ public:
case linearGradient: case linearGradient:
case radialGradient: case radialGradient:
return gradCol1.isOpaque() && gradCol1.isOpaque();
return gradCol1.isOpaque() && gradCol2.isOpaque();
case imageBrush: case imageBrush:
return image.isValid() return image.isValid()


+ 82
- 76
extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp View File

@@ -113,7 +113,6 @@ public:
return true; return true;
} }
private:
RelativePositionedRectangle newState, oldState; RelativePositionedRectangle newState, oldState;
}; };
@@ -236,32 +235,35 @@ void PaintElement::drawExtraEditorGraphics (Graphics&, const Rectangle<int>& /*r
void PaintElement::paint (Graphics& g) void PaintElement::paint (Graphics& g)
{ {
Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea());
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (getParentComponent()))
{
auto area = pe->getComponentArea();
g.saveState();
g.setOrigin (area.getPosition() - Component::getPosition());
area.setPosition (0, 0);
g.saveState();
g.setOrigin (area.getPosition() - Component::getPosition());
area.setPosition (0, 0);
g.saveState();
g.reduceClipRegion (0, 0, area.getWidth(), area.getHeight());
g.saveState();
g.reduceClipRegion (0, 0, area.getWidth(), area.getHeight());
draw (g, getDocument()->getComponentLayout(), area);
draw (g, getDocument()->getComponentLayout(), area);
g.restoreState();
g.restoreState();
drawExtraEditorGraphics (g, area);
g.restoreState();
drawExtraEditorGraphics (g, area);
g.restoreState();
if (selected)
{
const BorderSize<int> borderSize (border->getBorderThickness());
if (selected)
{
const BorderSize<int> borderSize (border->getBorderThickness());
drawResizableBorder (g, getWidth(), getHeight(), borderSize,
(isMouseOverOrDragging() || border->isMouseOverOrDragging()));
}
else if (isMouseOverOrDragging())
{
drawMouseOverCorners (g, getWidth(), getHeight());
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()) 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) 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) void PaintElement::mouseUp (const MouseEvent& e)
{ {
if (dragging)
owner->endDragging();
if (owner != nullptr) 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() void PaintElement::resizeStart()
@@ -345,44 +352,47 @@ void PaintElement::checkBounds (Rectangle<int>& b,
ComponentBoundsConstrainer::checkBounds (b, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); 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(); 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 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 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*) void PaintElement::changeListenerCallback (ChangeBroadcaster*)
@@ -465,7 +471,7 @@ void PaintElement::updateSiblingComps()
void PaintElement::showPopupMenu() void PaintElement::showPopupMenu()
{ {
ApplicationCommandManager* commandManager = &ProjucerApplication::getCommandManager();
auto* commandManager = &ProjucerApplication::getCommandManager();
PopupMenu m; PopupMenu m;


+ 0
- 4
modules/juce_graphics/contexts/juce_GraphicsContext.h View File

@@ -99,10 +99,6 @@ public:
//============================================================================== //==============================================================================
/** Changes the font to use for subsequent text-drawing functions. /** 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 @see drawSingleLineText, drawMultiLineText, drawText, drawFittedText
*/ */
void setFont (const Font& newFont); void setFont (const Font& newFont);


+ 7
- 8
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -25,7 +25,7 @@
static uint32 lastUniquePeerID = 1; static uint32 lastUniquePeerID = 1;
//============================================================================== //==============================================================================
ComponentPeer::ComponentPeer (Component& comp, const int flags)
ComponentPeer::ComponentPeer (Component& comp, int flags)
: component (comp), : component (comp),
styleFlags (flags), styleFlags (flags),
uniqueID (lastUniquePeerID += 2) // increment by 2 so that this can never hit 0 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* ComponentPeer::getTargetForKeyPress()
{ {
Component* c = Component::getCurrentlyFocusedComponent();
auto* c = Component::getCurrentlyFocusedComponent();
if (c == nullptr) if (c == nullptr)
c = &component; c = &component;
@@ -180,7 +180,7 @@ bool ComponentPeer::handleKeyPress (const KeyPress& keyInfo)
{ {
bool keyWasUsed = false; 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); const WeakReference<Component> deletionChecker (target);
@@ -226,7 +226,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown)
ModifierKeys::updateCurrentModifiers(); ModifierKeys::updateCurrentModifiers();
bool keyWasUsed = false; 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); const WeakReference<Component> deletionChecker (target);
@@ -235,7 +235,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown)
if (keyWasUsed || deletionChecker == nullptr) if (keyWasUsed || deletionChecker == nullptr)
break; break;
if (const Array<KeyListener*>* const keyListeners = target->keyListeners)
if (auto* keyListeners = target->keyListeners.get())
{ {
for (int i = keyListeners->size(); --i >= 0;) for (int i = keyListeners->size(); --i >= 0;)
{ {
@@ -264,8 +264,7 @@ void ComponentPeer::handleModifierKeysChange()
if (target == nullptr) if (target == nullptr)
target = &component; target = &component;
if (target != nullptr)
target->internalModifierKeysChanged();
target->internalModifierKeysChanged();
} }
TextInputTarget* ComponentPeer::findCurrentTextInputTarget() TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
@@ -273,7 +272,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
auto* c = Component::getCurrentlyFocusedComponent(); auto* c = Component::getCurrentlyFocusedComponent();
if (c == &component || component.isParentOf (c)) if (c == &component || component.isParentOf (c))
if (TextInputTarget* const ti = dynamic_cast<TextInputTarget*> (c))
if (auto* ti = dynamic_cast<TextInputTarget*> (c))
if (ti->isTextInputActive()) if (ti->isTextInputActive())
return ti; return ti;


Loading…
Cancel
Save