The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

109 lines
3.9KB

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