From b416ab66511aa447857d6c93e484f5bf6af28d29 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 13 Oct 2012 11:17:21 +0100 Subject: [PATCH] Added a couple of methods to Graphics. --- .../sources/juce_BufferingAudioSource.h | 1 - .../contexts/juce_GraphicsContext.cpp | 19 +++++++++++++++---- .../contexts/juce_GraphicsContext.h | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 834cb0dd91..f83d634328 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -103,7 +103,6 @@ private: double volatile sampleRate; bool wasSourceLooping, isPrepared; - friend class SharedBufferingAudioSourceThread; bool readNextBufferChunk(); void readBufferSection (int64 start, int length, int bufferOffset); int useTimeSlice(); diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index f696cceccf..8e1a783aad 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -343,14 +343,19 @@ void Graphics::fillRect (const Rectangle& r) const context.fillRect (r, false); } +void Graphics::fillRect (const Rectangle& rectangle) const +{ + Path p; + p.addRectangle (rectangle); + fillPath (p); +} + void Graphics::fillRect (const float x, const float y, const float width, const float height) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); - Path p; - p.addRectangle (x, y, width, height); - fillPath (p); + fillRect (Rectangle (x, y, width, height)); } void Graphics::setPixel (int x, int y) const @@ -406,7 +411,8 @@ void Graphics::drawRect (const int x, const int y, const int width, const int he context.fillRect (Rectangle (x, y + height - lineThickness, width, lineThickness), false); } -void Graphics::drawRect (const float x, const float y, const float width, const float height, const float lineThickness) const +void Graphics::drawRect (const float x, const float y, const float width, const float height, + const float lineThickness) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (x, y, width, height)); @@ -424,6 +430,11 @@ void Graphics::drawRect (const Rectangle& r, const int lineThickness) const drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness); } +void Graphics::drawRect (const Rectangle& r, const float lineThickness) const +{ + drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness); +} + //============================================================================== void Graphics::fillEllipse (const Rectangle& area) const { diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index b2166295ae..2af1fc886f 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -273,6 +273,9 @@ public: /** Fills a rectangle with the current colour or brush. */ void fillRect (const Rectangle& rectangle) const; + /** Fills a rectangle with the current colour or brush. */ + void fillRect (const Rectangle& rectangle) const; + /** Fills a rectangle with the current colour or brush. This uses sub-pixel positioning so is slower than the fillRect method which @@ -327,8 +330,16 @@ public: @see fillRect */ - void drawRect (const Rectangle& rectangle, - int lineThickness = 1) const; + void drawRect (const Rectangle& rectangle, int lineThickness = 1) const; + + /** Draws four lines to form a rectangular outline, using the current colour or brush. + + The lines are drawn inside the given rectangle, and greater line thicknesses + extend inwards. + + @see fillRect + */ + void drawRect (const Rectangle& rectangle, float lineThickness = 1.0f) const; /** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.