diff --git a/examples/Demo/Source/Demos/GraphicsDemo.cpp b/examples/Demo/Source/Demos/GraphicsDemo.cpp index 2c6bde8ea0..84d43977cf 100644 --- a/examples/Demo/Source/Demos/GraphicsDemo.cpp +++ b/examples/Demo/Source/Demos/GraphicsDemo.cpp @@ -573,7 +573,7 @@ public: void paint (Graphics& g) override { - g.fillCheckerBoard (getLocalBounds(), 48, 48, + g.fillCheckerBoard (getLocalBounds().toFloat(), 48.0f, 48.0f, Colours::lightgrey, Colours::white); } diff --git a/examples/Demo/Source/Demos/OpenGLDemo2D.cpp b/examples/Demo/Source/Demos/OpenGLDemo2D.cpp index b4c5ddef1d..201cf78ea5 100644 --- a/examples/Demo/Source/Demos/OpenGLDemo2D.cpp +++ b/examples/Demo/Source/Demos/OpenGLDemo2D.cpp @@ -74,7 +74,7 @@ public: void paint (Graphics& g) override { - g.fillCheckerBoard (getLocalBounds(), 48, 48, Colours::lightgrey, Colours::white); + g.fillCheckerBoard (getLocalBounds().toFloat(), 48.0f, 48.0f, Colours::lightgrey, Colours::white); if (shader == nullptr || shader->getFragmentShaderCode() != fragmentCode) { diff --git a/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h b/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h index 7594cad9ea..6f5e0765bc 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h +++ b/extras/Projucer/Source/CodeEditor/jucer_ItemPreviewComponent.h @@ -60,8 +60,7 @@ public: p.addRectangle (area); DropShadow (Colours::black.withAlpha (0.5f), 6, Point (0, 1)).drawForPath (g, p); - g.fillCheckerBoard (area.getSmallestIntegerContainer(), 24, 24, - Colour (0xffffffff), Colour (0xffeeeeee)); + g.fillCheckerBoard (area, 24.0f, 24.0f, Colour (0xffffffff), Colour (0xffeeeeee)); drawable->draw (g, 1.0f, RectanglePlacement (RectanglePlacement::stretchToFit) .getTransformToFit (contentBounds, area.toFloat())); diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h index fc0095324c..3271f49668 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h @@ -356,7 +356,7 @@ private: void paint (Graphics& g) override { if (jucerComp == nullptr) - g.fillCheckerBoard (getLocalBounds(), 50, 50, + g.fillCheckerBoard (getLocalBounds().toFloat(), 50.0f, 50.0f, Colour::greyLevel (0.9f).withAlpha (0.4f), Colour::greyLevel (0.8f).withAlpha (0.4f)); } diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_ViewportHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_ViewportHandler.h index e955de6f03..3ac593c508 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_ViewportHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_ViewportHandler.h @@ -285,7 +285,7 @@ private: void paint (Graphics& g) override { - g.fillCheckerBoard (getLocalBounds(), 50, 50, + g.fillCheckerBoard (getLocalBounds().toFloat(), 50.0f, 50.0f, Colours::lightgrey.withAlpha (0.5f), Colours::darkgrey.withAlpha (0.5f)); } diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h index 24b5971e4c..c4168f0cc6 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h @@ -407,8 +407,8 @@ private: image = Image (Image::RGB, 100, 100, true); Graphics g (image); - g.fillCheckerBoard (image.getBounds(), - image.getWidth() / 2, image.getHeight() / 2, + g.fillCheckerBoard (image.getBounds().toFloat(), + image.getWidth() * 0.5f, image.getHeight() * 0.5f, Colours::white, Colours::lightgrey); g.setFont (12.0f); diff --git a/extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h b/extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h index 4fa20a3250..f1ce94666e 100644 --- a/extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h +++ b/extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h @@ -61,8 +61,8 @@ public: { g.fillAll (Colours::grey); - g.fillCheckerBoard (getLocalBounds().reduced (2, 2), - 10, 10, + g.fillCheckerBoard (getLocalBounds().reduced (2, 2).toFloat(), + 10.0f, 10.0f, Colour (0xffdddddd).overlaidWith (colour), Colour (0xffffffff).overlaidWith (colour)); diff --git a/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp b/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp index 81dac7d8d1..4aeced4e2b 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_PaintRoutine.cpp @@ -525,8 +525,9 @@ void PaintRoutine::fillWithBackground (Graphics& g, const bool drawOpaqueBackgro { if ((! backgroundColour.isOpaque()) && drawOpaqueBackground) { - g.fillCheckerBoard (Rectangle (0, 0, g.getClipBounds().getRight(), g.getClipBounds().getBottom()), - 50, 50, + g.fillCheckerBoard (Rectangle ((float) g.getClipBounds().getRight(), + (float) g.getClipBounds().getBottom()), + 50.0f, 50.0f, Colour (0xffdddddd).overlaidWith (backgroundColour), Colour (0xffffffff).overlaidWith (backgroundColour)); } diff --git a/extras/Projucer/Source/Utility/UI/PropertyComponents/jucer_ColourPropertyComponent.h b/extras/Projucer/Source/Utility/UI/PropertyComponents/jucer_ColourPropertyComponent.h index c60392530d..a855c573d1 100644 --- a/extras/Projucer/Source/Utility/UI/PropertyComponents/jucer_ColourPropertyComponent.h +++ b/extras/Projucer/Source/Utility/UI/PropertyComponents/jucer_ColourPropertyComponent.h @@ -66,8 +66,8 @@ private: const Colour colour (getColour()); g.fillAll (Colours::grey); - g.fillCheckerBoard (getLocalBounds().reduced (2), - 10, 10, + g.fillCheckerBoard (getLocalBounds().reduced (2).toFloat(), + 10.0f, 10.0f, Colour (0xffdddddd).overlaidWith (colour), Colour (0xffffffff).overlaidWith (colour)); diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 9bdbf057ca..5f1ae7e11d 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -512,8 +512,7 @@ void Graphics::drawArrow (Line line, float lineThickness, float arrowhead fillPath (p); } -void Graphics::fillCheckerBoard (Rectangle area, - const int checkWidth, const int checkHeight, +void Graphics::fillCheckerBoard (Rectangle area, float checkWidth, float checkHeight, Colour colour1, Colour colour2) const { jassert (checkWidth > 0 && checkHeight > 0); // can't be zero or less! @@ -525,31 +524,33 @@ void Graphics::fillCheckerBoard (Rectangle area, if (colour1 == colour2) { context.setFill (colour1); - context.fillRect (area, false); + context.fillRect (area); } else { - auto clipped = context.getClipBounds().getIntersection (area); + auto clipped = context.getClipBounds().getIntersection (area.getSmallestIntegerContainer()); if (! clipped.isEmpty()) { - context.clipToRectangle (clipped); - - const int checkNumX = (clipped.getX() - area.getX()) / checkWidth; - const int checkNumY = (clipped.getY() - area.getY()) / checkHeight; - const int startX = area.getX() + checkNumX * checkWidth; - const int startY = area.getY() + checkNumY * checkHeight; - const int right = clipped.getRight(); - const int bottom = clipped.getBottom(); + const int checkNumX = (int) ((clipped.getX() - area.getX()) / checkWidth); + const int checkNumY = (int) ((clipped.getY() - area.getY()) / checkHeight); + const float startX = area.getX() + checkNumX * checkWidth; + const float startY = area.getY() + checkNumY * checkHeight; + const float right = clipped.getRight(); + const float bottom = clipped.getBottom(); for (int i = 0; i < 2; ++i) { - context.setFill (i == ((checkNumX ^ checkNumY) & 1) ? colour1 : colour2); - int cy = i; - for (int y = startY; y < bottom; y += checkHeight) - for (int x = startX + (cy++ & 1) * checkWidth; x < right; x += checkWidth * 2) - context.fillRect (Rectangle (x, y, checkWidth, checkHeight), false); + RectangleList checks; + + for (float y = startY; y < bottom; y += checkHeight) + for (float x = startX + (cy++ & 1) * checkWidth; x < right; x += checkWidth * 2.0f) + checks.addWithoutMerging ({ x, y, checkWidth, checkHeight }); + + checks.clipTo (area); + context.setFill (i == ((checkNumX ^ checkNumY) & 1) ? colour1 : colour2); + context.fillRectList (checks); } } } diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index 86260657bb..0142561ca4 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -300,8 +300,8 @@ public: float cornerSize) const; /** Fills a rectangle with a checkerboard pattern, alternating between two colours. */ - void fillCheckerBoard (Rectangle area, - int checkWidth, int checkHeight, + void fillCheckerBoard (Rectangle area, + float checkWidth, float checkHeight, Colour colour1, Colour colour2) const; /** Draws a rectangular outline, using the current colour or brush. diff --git a/modules/juce_graphics/geometry/juce_RectangleList.h b/modules/juce_graphics/geometry/juce_RectangleList.h index 21ae5195f8..893005aaeb 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.h +++ b/modules/juce_graphics/geometry/juce_RectangleList.h @@ -53,7 +53,7 @@ public: } /** Creates a list containing just one rectangle. */ - RectangleList (const RectangleType& rect) + RectangleList (RectangleType rect) { addWithoutMerging (rect); } @@ -106,7 +106,7 @@ public: The rectangle can have any size and may be empty, but if it's floating point then it's expected to not contain any INF values. */ - void add (const RectangleType& rect) + void add (RectangleType rect) { jassert (rect.isFinite()); // You must provide a valid rectangle to this method! @@ -176,7 +176,7 @@ public: The rectangle can have any size and may be empty, but if it's floating point then it's expected to not contain any INF values. */ - void addWithoutMerging (const RectangleType& rect) + void addWithoutMerging (RectangleType rect) { jassert (rect.isFinite()); // You must provide a valid rectangle to this method! @@ -200,7 +200,7 @@ public: Any rectangles in the list which overlap this will be clipped and subdivided if necessary. */ - void subtract (const RectangleType& rect) + void subtract (RectangleType rect) { if (auto numRects = rects.size()) { @@ -310,7 +310,7 @@ public: @see getIntersectionWith */ - bool clipTo (const RectangleType& rect) + bool clipTo (RectangleType rect) { jassert (rect.isFinite()); // You must provide a valid rectangle to this method! @@ -377,7 +377,7 @@ public: @see clipTo */ - bool getIntersectionWith (const RectangleType& rect, RectangleList& destRegion) const + bool getIntersectionWith (RectangleType rect, RectangleList& destRegion) const { jassert (rect.isFinite()); // You must provide a valid rectangle to this method! @@ -428,7 +428,7 @@ public: defined by this object @see intersectsRectangle, containsPoint */ - bool containsRectangle (const RectangleType& rectangleToCheck) const + bool containsRectangle (RectangleType rectangleToCheck) const { if (rects.size() > 1) { @@ -456,7 +456,7 @@ public: defined by this object @see containsRectangle */ - bool intersectsRectangle (const RectangleType& rectangleToCheck) const noexcept + bool intersectsRectangle (RectangleType rectangleToCheck) const noexcept { for (auto& r : rects) if (r.intersects (rectangleToCheck)) @@ -466,7 +466,6 @@ public: } /** Checks whether this region intersects any part of another one. - @see intersectsRectangle */ bool intersects (const RectangleList& other) const noexcept diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index ca3af1f372..e715d6633e 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -553,7 +553,7 @@ struct TextEditor::Iterator Graphics::ScopedSaveState state (g); g.reduceClipRegion ({ startX, baselineY, endX - startX, 1 }); - g.fillCheckerBoard ({ endX, baselineY + 1 }, 3, 1, colour, Colours::transparentBlack); + g.fillCheckerBoard ({ (float) endX, baselineY + 1.0f }, 3.0f, 1.0f, colour, Colours::transparentBlack); } void drawSelectedText (Graphics& g, Range selected, Colour selectedTextColour) const diff --git a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp index f41c64f849..a5676d7593 100644 --- a/modules/juce_gui_extra/misc/juce_ColourSelector.cpp +++ b/modules/juce_gui_extra/misc/juce_ColourSelector.cpp @@ -261,7 +261,7 @@ public: { const Colour c (owner.getSwatchColour (index)); - g.fillCheckerBoard (getLocalBounds(), 6, 6, + g.fillCheckerBoard (getLocalBounds().toFloat(), 6.0f, 6.0f, Colour (0xffdddddd).overlaidWith (c), Colour (0xffffffff).overlaidWith (c)); } @@ -430,9 +430,9 @@ void ColourSelector::paint (Graphics& g) if ((flags & showColourAtTop) != 0) { - const Colour currentColour (getCurrentColour()); + auto currentColour = getCurrentColour(); - g.fillCheckerBoard (previewArea, 10, 10, + g.fillCheckerBoard (previewArea.toFloat(), 10.0f, 10.0f, Colour (0xffdddddd).overlaidWith (currentColour), Colour (0xffffffff).overlaidWith (currentColour)); diff --git a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp index e287c226be..fd3258ae1a 100644 --- a/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp +++ b/modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp @@ -410,7 +410,7 @@ struct ColourEditorComp : public Component, void paint (Graphics& g) override { - g.fillCheckerBoard (getLocalBounds(), 6, 6, + g.fillCheckerBoard (getLocalBounds().toFloat(), 6.0f, 6.0f, Colour (0xffdddddd).overlaidWith (getColour()), Colour (0xffffffff).overlaidWith (getColour())); }