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.

103 lines
3.5KB

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