46 if (
auto* clipPath = other.drawableClipPath.get())
54void Drawable::applyDrawableClipPath (
Graphics& g)
56 if (drawableClipPath !=
nullptr)
58 auto clipPath = drawableClipPath->getOutlineAsPath();
60 if (! clipPath.isEmpty())
61 g.getInternalContext().clipToPath (clipPath, {});
68 const_cast<Drawable*
> (
this)->nonConstDraw (g, opacity, transform);
76 (
float) -(originRelativeToComponent.
y))
78 .followedBy (transform));
80 applyDrawableClipPath (g);
116 if (drawableClipPath != clipPath)
118 drawableClipPath = std::move (clipPath);
123void Drawable::transformContextToCorrectOrigin (
Graphics& g)
138 parentOrigin = parent->originRelativeToComponent;
141 auto newBounds = smallestIntegerContainer + parentOrigin;
142 originRelativeToComponent = -smallestIntegerContainer.getPosition();
149 bool changed =
false;
152 if (
auto* d =
dynamic_cast<Drawable*
> (c))
153 changed = d->replaceColour (original, replacement) || changed;
160 drawableTransform = transform;
164void Drawable::updateTransform()
169 const auto transformationOrigin = originRelativeToComponent +
getPosition();
171 .followedBy (drawableTransform)
Represents a colour, also including a transparency value.
The base class for all JUCE user-interface objects.
void paintEntireComponent(Graphics &context, bool ignoreAlphaLevel)
Draws this component and all its subcomponents onto the specified graphics context.
AffineTransform getTransform() const
Returns the transform that is currently being applied to this component.
void setTransform(const AffineTransform &transform)
Sets a transform matrix to be applied to this component.
void setComponentID(const String &newID)
Sets the component's ID string.
void setAccessible(bool shouldBeAccessible)
Sets whether this component and its children are visible to accessibility clients.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Point< int > getPosition() const noexcept
Returns the component's top-left position as a Point.
void setPaintingIsUnclipped(bool shouldPaintWithoutClipping) noexcept
This allows you to indicate that this component doesn't require its graphics context to be clipped wh...
void repaint()
Marks the whole component as needing to be redrawn.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
String getComponentID() const noexcept
Returns the ID string that was set by setComponentID().
const Array< Component * > & getChildren() const noexcept
Provides access to the underlying array of child components.
A drawable object which acts as a container for a set of other Drawables.
The base class for objects which can draw themselves, e.g.
void draw(Graphics &g, float opacity, const AffineTransform &transform=AffineTransform()) const
Renders this Drawable object.
static std::unique_ptr< Drawable > createFromImageData(const void *data, size_t numBytes)
Tries to turn some kind of image file into a drawable.
void drawAt(Graphics &g, float x, float y, float opacity) const
Renders the Drawable at a given offset within the Graphics context.
static std::unique_ptr< Drawable > createFromSVG(const XmlElement &svgDocument)
Attempts to parse an SVG (Scalable Vector Graphics) document, and to turn this into a Drawable tree.
DrawableComposite * getParent() const
Returns the DrawableComposite that contains this object, if there is one.
void parentHierarchyChanged() override
Called to indicate that the component's parents have changed.
Drawable()
The base class can't be instantiated directly.
static std::unique_ptr< Drawable > createFromImageFile(const File &file)
Tries to turn a file containing some kind of image data into a drawable.
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-...
void setOriginWithOriginalSize(Point< float > originWithinParent)
Resets any transformations on this drawable, and positions its origin within its parent component.
static std::unique_ptr< Drawable > createFromImageDataStream(InputStream &dataSource)
Tries to turn a stream containing some kind of image data into a drawable.
void setClipPath(std::unique_ptr< Drawable > drawableClipPath)
Sets a the clipping region of this drawable using another drawable.
void setTransformToFit(const Rectangle< float > &areaInParent, RectanglePlacement placement)
Sets a transform for this drawable that will position it within the specified area of its parent comp...
void setDrawableTransform(const AffineTransform &transform)
Sets a transformation that applies to the same coordinate system in which the rest of the draw calls ...
virtual bool replaceColour(Colour originalColour, Colour replacementColour)
Recursively replaces a colour that might be used for filling or stroking.
~Drawable() override
Destructor.
virtual Rectangle< float > getDrawableBounds() const =0
Returns the area that this drawable covers.
Represents a local file or directory.
Uses RAII to save and restore the state of a graphics context.
A graphics context, used for drawing a component or image.
bool isClipEmpty() const
Returns true if no drawing can be done because the clip region is zero.
void endTransparencyLayer()
Completes a drawing operation to a temporary semi-transparent buffer.
void addTransform(const AffineTransform &transform)
Adds a transformation which will be performed on all the graphics operations that the context subsequ...
void beginTransparencyLayer(float layerOpacity)
Begins rendering to an off-screen bitmap which will later be flattened onto the current context with ...
void setOrigin(Point< int > newOrigin)
Moves the position of the context's origin.
Writes data to an internal memory buffer, which grows as required.
const void * getData() const noexcept
Returns a pointer to the data that has been written to the stream.
size_t getDataSize() const noexcept
Returns the number of bytes of data that have been written to the stream.
A pair of (x, y) coordinates.
ValueType y
The point's Y coordinate.
ValueType x
The point's X coordinate.
Defines the method used to position some kind of rectangular object within a rectangular viewport.
AffineTransform getTransformToFit(const Rectangle< float > &source, const Rectangle< float > &destination) const noexcept
Returns the transform that should be applied to these source coordinates to fit them into the destina...
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle< int > getSmallestIntegerContainer() const noexcept
Returns the smallest integer-aligned rectangle that completely contains this one.
bool isEmpty() const noexcept
Returns true if the rectangle's width or height are zero or less.
static String createStringFromData(const void *data, int size)
Creates a string from data in an unknown format.
std::unique_ptr< XmlElement > parseXMLIfTagMatches(const String &textToParse, StringRef requiredTag)
Does an inexpensive check to see whether the top-level element has the given tag name,...