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 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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. /** Sets the image that this drawable will render. */
  33. explicit DrawableImage (const Image& imageToUse);
  34. /** Destructor. */
  35. ~DrawableImage() override;
  36. //==============================================================================
  37. /** Sets the image that this drawable will render. */
  38. void setImage (const Image& imageToUse);
  39. /** Returns the current image. */
  40. const Image& getImage() const noexcept { return image; }
  41. /** Sets the opacity to use when drawing the image. */
  42. void setOpacity (float newOpacity);
  43. /** Returns the image's opacity. */
  44. float getOpacity() const noexcept { return opacity; }
  45. /** Sets a colour to draw over the image's alpha channel.
  46. By default this is transparent so isn't drawn, but if you set a non-transparent
  47. colour here, then it will be overlaid on the image, using the image's alpha
  48. channel as a mask.
  49. This is handy for doing things like darkening or lightening an image by overlaying
  50. it with semi-transparent black or white.
  51. */
  52. void setOverlayColour (Colour newOverlayColour);
  53. /** Returns the overlay colour. */
  54. Colour getOverlayColour() const noexcept { return overlayColour; }
  55. /** Sets the bounding box within which the image should be displayed. */
  56. void setBoundingBox (Parallelogram<float> newBounds);
  57. /** Sets the bounding box within which the image should be displayed. */
  58. void setBoundingBox (Rectangle<float> newBounds);
  59. /** Returns the position to which the image's top-left corner should be remapped in the target
  60. coordinate space when rendering this object.
  61. @see setTransform
  62. */
  63. Parallelogram<float> getBoundingBox() const noexcept { return bounds; }
  64. //==============================================================================
  65. /** @internal */
  66. void paint (Graphics&) override;
  67. /** @internal */
  68. bool hitTest (int x, int y) override;
  69. /** @internal */
  70. std::unique_ptr<Drawable> createCopy() const override;
  71. /** @internal */
  72. Rectangle<float> getDrawableBounds() const override;
  73. /** @internal */
  74. Path getOutlineAsPath() const override;
  75. private:
  76. //==============================================================================
  77. std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
  78. bool setImageInternal (const Image&);
  79. //==============================================================================
  80. Image image;
  81. float opacity = 1.0f;
  82. Colour overlayColour { 0 };
  83. Parallelogram<float> bounds;
  84. DrawableImage& operator= (const DrawableImage&);
  85. JUCE_LEAK_DETECTOR (DrawableImage)
  86. };
  87. } // namespace juce