diff --git a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h index 56ec491775..fb72c98ced 100644 --- a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h +++ b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_FillType.h @@ -256,7 +256,7 @@ public: case linearGradient: case radialGradient: - return gradCol1.isOpaque() && gradCol1.isOpaque(); + return gradCol1.isOpaque() && gradCol2.isOpaque(); case imageBrush: return image.isValid() diff --git a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp index 96cfbe8e80..a408119aa1 100644 --- a/extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp +++ b/extras/Projucer/Source/ComponentEditor/paintelements/jucer_PaintElement.cpp @@ -113,7 +113,6 @@ public: return true; } -private: RelativePositionedRectangle newState, oldState; }; @@ -236,32 +235,35 @@ void PaintElement::drawExtraEditorGraphics (Graphics&, const Rectangle& /*r void PaintElement::paint (Graphics& g) { - Rectangle 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 (getParentComponent())) { - const BorderSize 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 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 (getParentComponent()) != nullptr); - const Rectangle area (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); - - if (selected && ! dragging) + if (auto* pe = dynamic_cast (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& 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 area (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); + if (document->isSnapActive (true)) + { + if (auto* pe = dynamic_cast (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 (x, y, w, h); + b = { x, y, w, h }; + } + } } } @@ -392,28 +402,24 @@ void PaintElement::applyBoundsToComponent (Component*, const Rectangle& new { getDocument()->getUndoManager().undoCurrentTransactionOnly(); - jassert (dynamic_cast (getParentComponent()) != nullptr); - - setCurrentBounds (newBounds.expanded (-borderThickness, -borderThickness), - ((PaintRoutineEditor*) getParentComponent())->getComponentArea(), - true); + if (auto* pe = dynamic_cast (getParentComponent())) + setCurrentBounds (newBounds.expanded (-borderThickness, -borderThickness), + pe->getComponentArea(), true); } } Rectangle PaintElement::getCurrentAbsoluteBounds() const { - jassert (dynamic_cast (getParentComponent()) != nullptr); - const Rectangle area (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); + if (auto* pe = dynamic_cast (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 (getParentComponent()) != nullptr); - const Rectangle area (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); - - position.getRectangleDouble (x, y, w, h, area, getDocument()->getComponentLayout()); + if (auto* pe = dynamic_cast (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; diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index a6f5e239b1..156aef9764 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -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); diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index c9615f8da2..c276c1482d 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -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 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 deletionChecker (target); @@ -235,7 +235,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown) if (keyWasUsed || deletionChecker == nullptr) break; - if (const Array* 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 (c)) + if (auto* ti = dynamic_cast (c)) if (ti->isTextInputActive()) return ti;