Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_DrawableImage.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A drawable object which is a bitmap image.
  23. @see Drawable
  24. @tags{GUI}
  25. */
  26. class JUCE_API DrawableImage : public Drawable
  27. {
  28. public:
  29. //==============================================================================
  30. DrawableImage();
  31. DrawableImage (const DrawableImage&);
  32. /** Destructor. */
  33. ~DrawableImage() override;
  34. //==============================================================================
  35. /** Sets the image that this drawable will render. */
  36. void setImage (const Image& imageToUse);
  37. /** Returns the current image. */
  38. const Image& getImage() const noexcept { return image; }
  39. /** Sets the opacity to use when drawing the image. */
  40. void setOpacity (float newOpacity);
  41. /** Returns the image's opacity. */
  42. float getOpacity() const noexcept { return opacity; }
  43. /** Sets a colour to draw over the image's alpha channel.
  44. By default this is transparent so isn't drawn, but if you set a non-transparent
  45. colour here, then it will be overlaid on the image, using the image's alpha
  46. channel as a mask.
  47. This is handy for doing things like darkening or lightening an image by overlaying
  48. it with semi-transparent black or white.
  49. */
  50. void setOverlayColour (Colour newOverlayColour);
  51. /** Returns the overlay colour. */
  52. Colour getOverlayColour() const noexcept { return overlayColour; }
  53. /** Sets the bounding box within which the image should be displayed. */
  54. void setBoundingBox (Parallelogram<float> newBounds);
  55. /** Sets the bounding box within which the image should be displayed. */
  56. void setBoundingBox (Rectangle<float> newBounds);
  57. /** Returns the position to which the image's top-left corner should be remapped in the target
  58. coordinate space when rendering this object.
  59. @see setTransform
  60. */
  61. Parallelogram<float> getBoundingBox() const noexcept { return bounds; }
  62. //==============================================================================
  63. /** @internal */
  64. void paint (Graphics&) override;
  65. /** @internal */
  66. bool hitTest (int x, int y) override;
  67. /** @internal */
  68. std::unique_ptr<Drawable> createCopy() const override;
  69. /** @internal */
  70. Rectangle<float> getDrawableBounds() const override;
  71. /** @internal */
  72. Path getOutlineAsPath() const override;
  73. private:
  74. //==============================================================================
  75. Image image;
  76. float opacity = 1.0f;
  77. Colour overlayColour { 0 };
  78. Parallelogram<float> bounds;
  79. DrawableImage& operator= (const DrawableImage&);
  80. JUCE_LEAK_DETECTOR (DrawableImage)
  81. };
  82. } // namespace juce