diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 4f3df52454..ef9c738649 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -365,8 +365,8 @@ void Graphics::fillRectList (const RectangleList& rectangles) const void Graphics::fillRectList (const RectangleList& rects) const { - for (const Rectangle* r = rects.begin(), * const e = rects.end(); r != e; ++r) - context.fillRect (*r, false); + for (auto& r : rects) + context.fillRect (r, false); } void Graphics::setPixel (int x, int y) const diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index 3b7c1cf72f..47628ac038 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -200,7 +200,7 @@ void LowLevelGraphicsPostScriptRenderer::writeClip() int itemsOnLine = 0; - for (const Rectangle* i = stateStack.getLast()->clip.begin(), * const e = stateStack.getLast()->clip.end(); i != e; ++i) + for (auto& i : stateStack.getLast()->clip) { if (++itemsOnLine == 6) { @@ -208,8 +208,8 @@ void LowLevelGraphicsPostScriptRenderer::writeClip() out << '\n'; } - out << i->getX() << ' ' << -i->getY() << ' ' - << i->getWidth() << ' ' << -i->getHeight() << " pr "; + out << i.getX() << ' ' << -i.getY() << ' ' + << i.getWidth() << ' ' << -i.getHeight() << " pr "; } out << "endclip\n"; @@ -482,7 +482,7 @@ void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, co out << "newpath "; int itemsOnLine = 0; - for (const Rectangle* i = imageClip.begin(), * const e = imageClip.end(); i != e; ++i) + for (auto& i : imageClip) { if (++itemsOnLine == 6) { @@ -490,7 +490,7 @@ void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, co itemsOnLine = 0; } - out << i->getX() << ' ' << i->getY() << ' ' << i->getWidth() << ' ' << i->getHeight() << " pr "; + out << i.getX() << ' ' << i.getY() << ' ' << i.getWidth() << ' ' << i.getHeight() << " pr "; } out << " clip newpath\n"; diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/modules/juce_graphics/geometry/juce_EdgeTable.cpp index edefa73c64..10559996b5 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -133,13 +133,13 @@ EdgeTable::EdgeTable (const RectangleList& rectanglesToAdd) allocate(); clearLineSizes(); - for (const Rectangle* r = rectanglesToAdd.begin(), * const e = rectanglesToAdd.end(); r != e; ++r) + for (auto& r : rectanglesToAdd) { - const int x1 = r->getX() << 8; - const int x2 = r->getRight() << 8; - int y = r->getY() - bounds.getY(); + const int x1 = r.getX() << 8; + const int x2 = r.getRight() << 8; + int y = r.getY() - bounds.getY(); - for (int j = r->getHeight(); --j >= 0;) + for (int j = r.getHeight(); --j >= 0;) addEdgePointPair (x1, x2, y++, 255); } @@ -156,13 +156,13 @@ EdgeTable::EdgeTable (const RectangleList& rectanglesToAdd) allocate(); clearLineSizes(); - for (const Rectangle* r = rectanglesToAdd.begin(), * const e = rectanglesToAdd.end(); r != e; ++r) + for (auto& r : rectanglesToAdd) { - const int x1 = roundToInt (r->getX() * 256.0f); - const int x2 = roundToInt (r->getRight() * 256.0f); + const int x1 = roundToInt (r.getX() * 256.0f); + const int x2 = roundToInt (r.getRight() * 256.0f); - const int y1 = roundToInt (r->getY() * 256.0f) - (bounds.getY() << 8); - const int y2 = roundToInt (r->getBottom() * 256.0f) - (bounds.getY() << 8); + const int y1 = roundToInt (r.getY() * 256.0f) - (bounds.getY() << 8); + const int y2 = roundToInt (r.getBottom() * 256.0f) - (bounds.getY() << 8); if (x2 <= x1 || y2 <= y1) continue; diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index 3d1273df62..dcd2141244 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -352,11 +352,11 @@ public: for (int j = 0; j < rects.size(); ++j) { - const RectangleType& rect = rects.getReference (j); + auto& rect = rects.getReference (j); - for (const Rectangle* r = other.begin(), * const e = other.end(); r != e; ++r) + for (auto& r : other) { - RectangleType clipped (r->template toType()); + auto clipped = r.template toType(); if (rect.intersectRectangle (clipped)) result.rects.add (clipped); @@ -386,7 +386,7 @@ public: { for (int i = rects.size(); --i >= 0;) { - RectangleType r (rects.getReference (i)); + auto r = rects.getReference (i); if (rect.intersectRectangle (r)) destRegion.rects.add (r); diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index 8bb520c365..61026306fd 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -1605,8 +1605,8 @@ struct ClipRegions RectangleList inverse (edgeTable.getMaximumBounds()); if (inverse.subtract (r)) - for (const Rectangle* i = inverse.begin(), * const e = inverse.end(); i != e; ++i) - edgeTable.excludeRectangle (*i); + for (auto& i : inverse) + edgeTable.excludeRectangle (i); return edgeTable.isEmpty() ? nullptr : this; } @@ -1845,14 +1845,14 @@ struct ClipRegions template void iterate (Renderer& r) const noexcept { - for (const Rectangle* i = clip.begin(), * const e = clip.end(); i != e; ++i) + for (auto& i : clip) { - const int x = i->getX(); - const int w = i->getWidth(); + const int x = i.getX(); + const int w = i.getWidth(); jassert (w > 0); - const int bottom = i->getBottom(); + const int bottom = i.getBottom(); - for (int y = i->getY(); y < bottom; ++y) + for (int y = i.getY(); y < bottom; ++y) { r.setEdgeTableYPos (y); r.handleEdgeTableLineFull (x, w); @@ -1872,9 +1872,9 @@ struct ClipRegions template void iterate (Renderer& r) const noexcept { - for (const Rectangle* i = clip.begin(), * const e = clip.end(); i != e; ++i) + for (auto& i : clip) { - const Rectangle rect (i->getIntersection (area)); + auto rect = i.getIntersection (area); if (! rect.isEmpty()) { @@ -1912,12 +1912,12 @@ struct ClipRegions { const RenderingHelpers::FloatRectangleRasterisingInfo f (area); - for (const Rectangle* i = clip.begin(), * const e = clip.end(); i != e; ++i) + for (auto& i : clip) { - const int clipLeft = i->getX(); - const int clipRight = i->getRight(); - const int clipTop = i->getY(); - const int clipBottom = i->getBottom(); + const int clipLeft = i.getX(); + const int clipRight = i.getRight(); + const int clipTop = i.getY(); + const int clipBottom = i.getBottom(); if (f.totalBottom > clipTop && f.totalTop < clipBottom && f.totalRight > clipLeft && f.totalLeft < clipRight) @@ -2066,8 +2066,8 @@ public: cloneClipIfMultiplyReferenced(); RectangleList scaledList; - for (const Rectangle* i = r.begin(), * const e = r.end(); i != e; ++i) - scaledList.add (transform.transformed (*i)); + for (auto& i : r) + scaledList.add (transform.transformed (i)); clip = clip->clipToRectangleList (scaledList); } diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index 93fdaf6f0c..c48eaa623e 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -249,8 +249,8 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList rects (numRects); int i = 0; - for (const Rectangle* r = clipRegion.begin(), * const e = clipRegion.end(); r != e; ++r) - rects[i++] = CGRectMake (r->getX(), flipHeight - r->getBottom(), r->getWidth(), r->getHeight()); + for (auto& r : clipRegion) + rects[i++] = CGRectMake (r.getX(), flipHeight - r.getBottom(), r.getWidth(), r.getHeight()); CGContextClipToRects (context, rects, numRects); lastClipRectIsValid = false; @@ -559,8 +559,9 @@ void CoreGraphicsContext::fillRectList (const RectangleList& list) HeapBlock rects ((size_t) list.getNumRectangles()); size_t num = 0; - for (const Rectangle* r = list.begin(), * const e = list.end(); r != e; ++r) - rects[num++] = CGRectMake (r->getX(), flipHeight - r->getBottom(), r->getWidth(), r->getHeight()); + + for (auto& r : list) + rects[num++] = CGRectMake (r.getX(), flipHeight - r.getBottom(), r.getWidth(), r.getHeight()); if (state->fillType.isColour()) { diff --git a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp index b364092360..083c6d4269 100644 --- a/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp +++ b/modules/juce_graphics/native/juce_win32_Direct2DGraphicsContext.cpp @@ -191,8 +191,8 @@ public: void fillRectList (const RectangleList& list) { - for (const Rectangle* r = list.begin(), * const e = list.end(); r != e; ++r) - fillRect (*r); + for (auto& r : list) + fillRect (r); } void fillPath (const Path& p, const AffineTransform& transform) diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index b35cb9a1c5..5d695c2760 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -777,8 +777,8 @@ public: void paint (Graphics& g) override { scale = g.getInternalContext().getPhysicalPixelScaleFactor(); - const Rectangle compBounds (owner.getLocalBounds()); - const Rectangle imageBounds (compBounds * scale); + auto compBounds = owner.getLocalBounds(); + auto imageBounds = compBounds * scale; if (image.isNull() || image.getBounds() != imageBounds) { @@ -794,12 +794,12 @@ public: if (! validArea.containsRectangle (compBounds)) { Graphics imG (image); - LowLevelGraphicsContext& lg = imG.getInternalContext(); + auto& lg = imG.getInternalContext(); lg.addTransform (AffineTransform::scale (scale)); - for (const Rectangle* i = validArea.begin(), * const e = validArea.end(); i != e; ++i) - lg.excludeClipRectangle (*i); + for (auto& i : validArea) + lg.excludeClipRectangle (i); if (! owner.isOpaque()) { diff --git a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp index e7b059d591..3bc1ba9ecc 100644 --- a/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp @@ -2699,8 +2699,8 @@ private: adjustedList.offsetAll (-totalArea.getX(), -totalArea.getY()); if (peer.depth == 32) - for (const Rectangle* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i) - image.clear (*i - totalArea.getPosition()); + for (auto& i : originalRepaintRegion) + image.clear (i - totalArea.getPosition()); { ScopedPointer context (peer.getComponent().getLookAndFeel() @@ -2709,9 +2709,10 @@ private: peer.handlePaint (*context); } - for (const Rectangle* i = originalRepaintRegion.begin(), * const e = originalRepaintRegion.end(); i != e; ++i) + for (auto& i : originalRepaintRegion) { - XBitmapImage* xbitmap = static_cast (image.getPixelData()); + auto* xbitmap = static_cast (image.getPixelData()); + #if JUCE_USE_XSHM if (xbitmap->isUsingXShm()) ++shmPaintsPending; @@ -2719,10 +2720,10 @@ private: xbitmap->blitToWindow (peer.windowH, - i->getX(), i->getY(), - (unsigned int) i->getWidth(), - (unsigned int) i->getHeight(), - i->getX() - totalArea.getX(), i->getY() - totalArea.getY()); + i.getX(), i.getY(), + (unsigned int) i.getWidth(), + (unsigned int) i.getHeight(), + i.getX() - totalArea.getX(), i.getY() - totalArea.getY()); } } diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index f56ac28fae..52fe4ee276 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -933,8 +933,8 @@ public: void setNeedsDisplayRectangles() { - for (const Rectangle* i = deferredRepaints.begin(), *e = deferredRepaints.end(); i != e; ++i) - [view setNeedsDisplayInRect: makeNSRect (*i)]; + for (auto& i : deferredRepaints) + [view setNeedsDisplayInRect: makeNSRect (i)]; lastRepaintTime = Time::getMillisecondCounter(); deferredRepaints.clear(); diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 89b04b2722..3d1efb1aed 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -199,9 +199,9 @@ public: cachedImageFrameBuffer.makeCurrentRenderingTarget(); const int imageH = cachedImageFrameBuffer.getHeight(); - for (const Rectangle* i = list.begin(), * const e = list.end(); i != e; ++i) + for (auto& r : list) { - glScissor (i->getX(), imageH - i->getBottom(), i->getWidth(), i->getHeight()); + glScissor (r.getX(), imageH - r.getBottom(), r.getWidth(), r.getHeight()); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 5a8c1f5b9d..6cbade0c49 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1200,15 +1200,15 @@ struct StateHelpers void add (const RectangleList& list, const PixelARGB colour) noexcept { - for (const Rectangle* i = list.begin(), * const e = list.end(); i != e; ++i) - add (*i, colour); + for (auto& i : list) + add (i, colour); } void add (const RectangleList& list, const Rectangle& clip, const PixelARGB colour) noexcept { - for (const Rectangle* i = list.begin(), * const e = list.end(); i != e; ++i) + for (auto& i : list) { - const Rectangle r (i->getIntersection (clip)); + auto r = i.getIntersection (clip); if (! r.isEmpty()) add (r, colour);