Loading...
Searching...
No Matches
juce::DrawableShape Class Reference

Detailed Description

A base class implementing common functionality for Drawable classes which consist of some kind of filled and stroked outline.

See also
DrawablePath, DrawableRectangle

The documentation for this class was generated from the following file:
Inheritance diagram for juce::DrawableShape:

Public Member Functions

void setFill (const FillType &newFill)
 Sets a fill type for the path.
const FillTypegetFill () const noexcept
 Returns the current fill type.
void setStrokeFill (const FillType &newStrokeFill)
 Sets the fill type with which the outline will be drawn.
const FillTypegetStrokeFill () const noexcept
 Returns the current stroke fill.
void setStrokeType (const PathStrokeType &newStrokeType)
 Changes the properties of the outline that will be drawn around the path.
void setStrokeThickness (float newThickness)
 Changes the stroke thickness.
PathStrokeType getStrokeType () const noexcept
 Returns the current outline style.
void setDashLengths (Span< const float > newDashLengths)
 Provides a set of dash lengths to use for stroking the path.
void setDashOffset (float dashOffset)
 Provides an offset on the rendering of the associated dash array.
Span< const float > getDashLengths () const &
 Returns the set of dash lengths that the path is using.
Span< const float > getDashLengths () const &&=delete
Rectangle< float > getDrawableBoundsUntransformed () const override
 Returns the area that this drawable covers in its original coordinate system.
bool hitTest (Point< float >) const override
 Tests whether a given point is inside the Drawable.
bool replaceColour (Colour originalColour, Colour replacementColour) override
 Recursively replaces a colour that might be used for filling or stroking.
Path getOutlineAsPath () const override
 Creates a path that describes the outline of this drawable.
Public Member Functions inherited from juce::Drawable
 Drawable ()=default
 Constructor.
 Drawable (const Drawable &other)
 Copy constructor.
virtual ~Drawable ()=default
 Destructor.
virtual std::unique_ptr< DrawablecreateCopy () const =0
 Creates a deep copy of this Drawable object.
void draw (Graphics &g, float opacity, const AffineTransform &transform=AffineTransform()) const
 Renders this Drawable object.
void drawAt (Graphics &g, float x, float y, float opacity) const
 Renders the Drawable at a given offset within the Graphics context.
void drawWithin (Graphics &g, Rectangle< float > destArea, RectanglePlacement placement, float opacity) const
 Renders the Drawable within a rectangle, scaling it to fit neatly inside without changing its aspect-ratio.
void setClipPath (std::unique_ptr< Drawable > drawableClipPath)
 Sets a the clipping region of this drawable using another drawable.
Rectangle< float > getDrawableBounds () const
 Returns the area that this drawable covers.
int getWidth () const
 Returns the width of the drawable bounds rounded up to the nearest integer.
int getHeight () const
 Returns the height of the drawable bounds rounded up to the nearest integer.
void setDrawableTransform (const AffineTransform &transform)
 Sets a transformation that applies to the same coordinate system in which the rest of the draw calls are made.
void setDrawableTransformToFit (const Rectangle< float > &area, RectanglePlacement placement)
 Calls setDrawableTransform() with a transform that will position this Drawable within the specified area in the untransformed coordinate system of the Drawable.
AffineTransform getDrawableTransform () const
 Returns the transform that is currently being applied to this drawable.
const StringgetName () const
 Returns the name of this Drawable object.
void setName (const String &newName)
 Sets the name of this drawable object.
void addListener (Listener *newListener)
 Adds a listener.
void removeListener (Listener *listenerToRemove)
 Removes a listener.
virtual bool isImage () const
virtual std::optional< StringgetContainedText () const
virtual bool requiresBlendBuffer () const

Protected Member Functions

 DrawableShape ()=default
 DrawableShape (const DrawableShape &)=default
void pathChanged ()
 Called when the cached path should be updated.
void strokeChanged ()
 Called when the cached stroke should be updated.
bool isStrokeVisible () const noexcept
 True if there's a stroke with a non-zero thickness and non-transparent colour.
Protected Member Functions inherited from juce::Drawable
virtual AffineTransform getTransform () const
void callListeners ()

Protected Attributes

StrokeOptions strokeOptions = StrokeOptions{}.withWidth (0.0f)
Path path
Path strokePath

Additional Inherited Members

Static Public Member Functions inherited from juce::Drawable
static std::unique_ptr< DrawablecreateFromImageData (const void *data, size_t numBytes)
 Tries to turn some kind of image file into a drawable.
static std::unique_ptr< DrawablecreateFromImageDataStream (InputStream &dataSource)
 Tries to turn a stream containing some kind of image data into a drawable.
static std::unique_ptr< DrawablecreateFromImageFile (const File &file)
 Tries to turn a file containing some kind of image data into a drawable.
static std::unique_ptr< DrawablecreateFromSVGFile (const File &svgFile)
 Attempts to parse an SVG (Scalable Vector Graphics) document from a file, and to turn this into a Drawable tree.
static std::unique_ptr< DrawableCompositecreateFromSVGString (const String &svgString)
 Attempts to parse an SVG (Scalable Vector Graphics) document from a string, and to turn this into a Drawable tree.
static Path parseSVGPath (const String &svgPath)
 Parses an SVG path string and returns it.

Constructors and Destructors

◆ DrawableShape() [1/2]

juce::DrawableShape::DrawableShape ( )
protecteddefault

Referenced by DrawableShape().

◆ DrawableShape() [2/2]

juce::DrawableShape::DrawableShape ( const DrawableShape & )
protecteddefault

References DrawableShape().

Member Functions

◆ setFill()

void juce::DrawableShape::setFill ( const FillType & newFill)

Sets a fill type for the path.

This colour is used to fill the path - if you don't want the path to be filled (e.g. if you're just drawing an outline), set this to a transparent colour.

See also
setPath, setStrokeFill

◆ getFill()

const FillType & juce::DrawableShape::getFill ( ) const
inlinenoexcept

Returns the current fill type.

See also
setFill

◆ setStrokeFill()

void juce::DrawableShape::setStrokeFill ( const FillType & newStrokeFill)

Sets the fill type with which the outline will be drawn.

See also
setFill

◆ getStrokeFill()

const FillType & juce::DrawableShape::getStrokeFill ( ) const
inlinenoexcept

Returns the current stroke fill.

See also
setStrokeFill

◆ setStrokeType()

void juce::DrawableShape::setStrokeType ( const PathStrokeType & newStrokeType)

Changes the properties of the outline that will be drawn around the path.

If the stroke has 0 thickness, no stroke will be drawn.

See also
setStrokeThickness, setStrokeColour

◆ setStrokeThickness()

void juce::DrawableShape::setStrokeThickness ( float newThickness)

Changes the stroke thickness.

This is a shortcut for calling setStrokeType.

◆ getStrokeType()

PathStrokeType juce::DrawableShape::getStrokeType ( ) const
inlinenoexcept

Returns the current outline style.

References strokeOptions.

◆ setDashLengths()

void juce::DrawableShape::setDashLengths ( Span< const float > newDashLengths)

Provides a set of dash lengths to use for stroking the path.

◆ setDashOffset()

void juce::DrawableShape::setDashOffset ( float dashOffset)

Provides an offset on the rendering of the associated dash array.

◆ getDashLengths() [1/2]

Span< const float > juce::DrawableShape::getDashLengths ( ) const &
inline

Returns the set of dash lengths that the path is using.

References strokeOptions.

◆ getDashLengths() [2/2]

Span< const float > juce::DrawableShape::getDashLengths ( ) const &&
delete

◆ getDrawableBoundsUntransformed()

Rectangle< float > juce::DrawableShape::getDrawableBoundsUntransformed ( ) const
overridevirtual

Returns the area that this drawable covers in its original coordinate system.

These bounds are not affected by setDrawableTransform().

See also
getDrawableBounds

Implements juce::Drawable.

References getDrawableBoundsUntransformed().

Referenced by getDrawableBoundsUntransformed().

◆ hitTest()

bool juce::DrawableShape::hitTest ( Point< float > ) const
overridevirtual

Tests whether a given point is inside the Drawable.

Implements juce::Drawable.

References hitTest().

Referenced by hitTest().

◆ replaceColour()

bool juce::DrawableShape::replaceColour ( Colour originalColour,
Colour replacementColour )
overridevirtual

Recursively replaces a colour that might be used for filling or stroking.

return true if any instances of this colour were found.

Reimplemented from juce::Drawable.

References replaceColour().

Referenced by replaceColour().

◆ getOutlineAsPath()

Path juce::DrawableShape::getOutlineAsPath ( ) const
overridevirtual

Creates a path that describes the outline of this drawable.

Implements juce::Drawable.

References getOutlineAsPath().

Referenced by getOutlineAsPath().

◆ pathChanged()

void juce::DrawableShape::pathChanged ( )
protected

Called when the cached path should be updated.

References pathChanged().

Referenced by pathChanged().

◆ strokeChanged()

void juce::DrawableShape::strokeChanged ( )
protected

Called when the cached stroke should be updated.

References strokeChanged().

Referenced by strokeChanged().

◆ isStrokeVisible()

bool juce::DrawableShape::isStrokeVisible ( ) const
protectednoexcept

True if there's a stroke with a non-zero thickness and non-transparent colour.

References isStrokeVisible().

Referenced by isStrokeVisible().

Member Data Documentation

◆ strokeOptions

StrokeOptions juce::DrawableShape::strokeOptions = StrokeOptions{}.withWidth (0.0f)
protected

Referenced by getDashLengths(), and getStrokeType().

◆ path

Path juce::DrawableShape::path
protected

◆ strokePath

Path juce::DrawableShape::strokePath
protected
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram