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_DropShadower.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Adds a drop-shadow to a component.
  23. This object creates and manages a set of components which sit around a
  24. component, creating a gaussian shadow around it. The components will track
  25. the position of the component and if it's brought to the front they'll also
  26. follow this.
  27. For desktop windows you don't need to use this class directly - just
  28. set the Component::windowHasDropShadow flag when calling
  29. Component::addToDesktop(), and the system will create one of these if it's
  30. needed (which it obviously isn't on the Mac, for example).
  31. @tags{GUI}
  32. */
  33. class JUCE_API DropShadower : private ComponentListener
  34. {
  35. public:
  36. //==============================================================================
  37. /** Creates a DropShadower. */
  38. DropShadower (const DropShadow& shadowType);
  39. /** Destructor. */
  40. ~DropShadower() override;
  41. /** Attaches the DropShadower to the component you want to shadow. */
  42. void setOwner (Component* componentToFollow);
  43. private:
  44. //==============================================================================
  45. void componentMovedOrResized (Component&, bool, bool) override;
  46. void componentBroughtToFront (Component&) override;
  47. void componentChildrenChanged (Component&) override;
  48. void componentParentHierarchyChanged (Component&) override;
  49. void componentVisibilityChanged (Component&) override;
  50. void updateParent();
  51. void updateShadows();
  52. class ShadowWindow;
  53. WeakReference<Component> owner;
  54. OwnedArray<Component> shadowWindows;
  55. DropShadow shadow;
  56. bool reentrant = false;
  57. WeakReference<Component> lastParentComp;
  58. class ParentVisibilityChangedListener;
  59. std::unique_ptr<ParentVisibilityChangedListener> visibilityChangedListener;
  60. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DropShadower)
  61. JUCE_DECLARE_WEAK_REFERENCEABLE (DropShadower)
  62. };
  63. } // namespace juce