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_DropShadowEffect.h 3.8KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_DROPSHADOWEFFECT_H_INCLUDED
  18. #define JUCE_DROPSHADOWEFFECT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Defines a drop-shadow effect.
  22. */
  23. struct JUCE_API DropShadow
  24. {
  25. /** Creates a default drop-shadow effect. */
  26. DropShadow() noexcept;
  27. /** Creates a drop-shadow object with the given parameters. */
  28. DropShadow (Colour shadowColour, int radius, Point<int> offset) noexcept;
  29. /** Renders a drop-shadow based on the alpha-channel of the given image. */
  30. void drawForImage (Graphics& g, const Image& srcImage) const;
  31. /** Renders a drop-shadow based on the shape of a path. */
  32. void drawForPath (Graphics& g, const Path& path) const;
  33. /** Renders a drop-shadow for a rectangle.
  34. Note that for speed, this approximates the shadow using gradients.
  35. */
  36. void drawForRectangle (Graphics& g, const Rectangle<int>& area) const;
  37. /** The colour with which to render the shadow.
  38. In most cases you'll probably want to leave this as black with an alpha
  39. value of around 0.5
  40. */
  41. Colour colour;
  42. /** The approximate spread of the shadow. */
  43. int radius;
  44. /** The offset of the shadow. */
  45. Point<int> offset;
  46. };
  47. //==============================================================================
  48. /**
  49. An effect filter that adds a drop-shadow behind the image's content.
  50. (This will only work on images/components that aren't opaque, of course).
  51. When added to a component, this effect will draw a soft-edged
  52. shadow based on what gets drawn inside it. The shadow will also
  53. be applied to the component's children.
  54. For speed, this doesn't use a proper gaussian blur, but cheats by
  55. using a simple bilinear filter. If you need a really high-quality
  56. shadow, check out ImageConvolutionKernel::createGaussianBlur()
  57. @see Component::setComponentEffect
  58. */
  59. class JUCE_API DropShadowEffect : public ImageEffectFilter
  60. {
  61. public:
  62. //==============================================================================
  63. /** Creates a default drop-shadow effect.
  64. To customise the shadow's appearance, use the setShadowProperties() method.
  65. */
  66. DropShadowEffect();
  67. /** Destructor. */
  68. ~DropShadowEffect();
  69. //==============================================================================
  70. /** Sets up parameters affecting the shadow's appearance. */
  71. void setShadowProperties (const DropShadow& newShadow);
  72. //==============================================================================
  73. /** @internal */
  74. void applyEffect (Image& sourceImage, Graphics& destContext, float scaleFactor, float alpha);
  75. private:
  76. //==============================================================================
  77. DropShadow shadow;
  78. JUCE_LEAK_DETECTOR (DropShadowEffect)
  79. };
  80. #endif // JUCE_DROPSHADOWEFFECT_H_INCLUDED