/* ============================================================================== This file is part of the JUCE 6 technical preview. Copyright (c) 2020 - Raw Material Software Limited You may use this code under the terms of the GPL v3 (see www.gnu.org/licenses). For this technical preview, this file is not subject to commercial licensing. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { //============================================================================== /** A drawable object which is a bitmap image. @see Drawable @tags{GUI} */ class JUCE_API DrawableImage : public Drawable { public: //============================================================================== DrawableImage(); DrawableImage (const DrawableImage&); /** Destructor. */ ~DrawableImage() override; //============================================================================== /** Sets the image that this drawable will render. */ void setImage (const Image& imageToUse); /** Returns the current image. */ const Image& getImage() const noexcept { return image; } /** Sets the opacity to use when drawing the image. */ void setOpacity (float newOpacity); /** Returns the image's opacity. */ float getOpacity() const noexcept { return opacity; } /** Sets a colour to draw over the image's alpha channel. By default this is transparent so isn't drawn, but if you set a non-transparent colour here, then it will be overlaid on the image, using the image's alpha channel as a mask. This is handy for doing things like darkening or lightening an image by overlaying it with semi-transparent black or white. */ void setOverlayColour (Colour newOverlayColour); /** Returns the overlay colour. */ Colour getOverlayColour() const noexcept { return overlayColour; } /** Sets the bounding box within which the image should be displayed. */ void setBoundingBox (Parallelogram newBounds); /** Sets the bounding box within which the image should be displayed. */ void setBoundingBox (Rectangle newBounds); /** Returns the position to which the image's top-left corner should be remapped in the target coordinate space when rendering this object. @see setTransform */ Parallelogram getBoundingBox() const noexcept { return bounds; } //============================================================================== /** @internal */ void paint (Graphics&) override; /** @internal */ bool hitTest (int x, int y) override; /** @internal */ std::unique_ptr createCopy() const override; /** @internal */ Rectangle getDrawableBounds() const override; /** @internal */ Path getOutlineAsPath() const override; private: //============================================================================== Image image; float opacity = 1.0f; Colour overlayColour { 0 }; Parallelogram bounds; DrawableImage& operator= (const DrawableImage&); JUCE_LEAK_DETECTOR (DrawableImage) }; } // namespace juce