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.

93 lines
3.5KB

  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. An effect filter that adds a drop-shadow behind the image's content.
  24. (This will only work on images/components that aren't opaque, of course).
  25. When added to a component, this effect will draw a soft-edged
  26. shadow based on what gets drawn inside it. The shadow will also
  27. be applied to the component's children.
  28. For speed, this doesn't use a proper gaussian blur, but cheats by
  29. using a simple bilinear filter. If you need a really high-quality
  30. shadow, check out ImageConvolutionKernel::createGaussianBlur()
  31. @see Component::setComponentEffect
  32. */
  33. class JUCE_API DropShadowEffect : public ImageEffectFilter
  34. {
  35. public:
  36. //==============================================================================
  37. /** Creates a default drop-shadow effect.
  38. To customise the shadow's appearance, use the setShadowProperties()
  39. method.
  40. */
  41. DropShadowEffect();
  42. /** Destructor. */
  43. ~DropShadowEffect();
  44. //==============================================================================
  45. /** Sets up parameters affecting the shadow's appearance.
  46. @param newRadius the (approximate) radius of the blur used
  47. @param newOpacity the opacity with which the shadow is rendered
  48. @param newShadowOffsetX allows the shadow to be shifted in relation to the
  49. component's contents
  50. @param newShadowOffsetY allows the shadow to be shifted in relation to the
  51. component's contents
  52. */
  53. void setShadowProperties (float newRadius,
  54. float newOpacity,
  55. int newShadowOffsetX,
  56. int newShadowOffsetY);
  57. //==============================================================================
  58. /** @internal */
  59. void applyEffect (Image& sourceImage, Graphics& destContext, float alpha);
  60. private:
  61. //==============================================================================
  62. int offsetX, offsetY;
  63. float radius, opacity;
  64. JUCE_LEAK_DETECTOR (DropShadowEffect);
  65. };
  66. #endif // __JUCE_DROPSHADOWEFFECT_JUCEHEADER__