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

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_RESIZABLEEDGECOMPONENT_H_INCLUDED
  18. #define JUCE_RESIZABLEEDGECOMPONENT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A component that resizes its parent component when dragged.
  22. This component forms a bar along one edge of a component, allowing it to
  23. be dragged by that edges to resize it.
  24. To use it, just add it to your component, positioning it along the appropriate
  25. edge. Make sure you reposition the resizer component each time the parent's size
  26. changes, to keep it in the correct position.
  27. @see ResizbleBorderComponent, ResizableCornerComponent
  28. */
  29. class JUCE_API ResizableEdgeComponent : public Component
  30. {
  31. public:
  32. //==============================================================================
  33. enum Edge
  34. {
  35. leftEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's left-hand edge. */
  36. rightEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's right-hand edge. */
  37. topEdge, /**< Indicates a horizontal bar that can be dragged up/down to move the top of the component. */
  38. bottomEdge /**< Indicates a horizontal bar that can be dragged up/down to move the bottom of the component. */
  39. };
  40. /** Creates a resizer bar.
  41. Pass in the target component which you want to be resized when this one is
  42. dragged. The target component will usually be this component's parent, but this
  43. isn't mandatory.
  44. Remember that when the target component is resized, it'll need to move and
  45. resize this component to keep it in place, as this won't happen automatically.
  46. If the constrainer parameter is non-zero, then this object will be used to enforce
  47. limits on the size and position that the component can be stretched to. Make sure
  48. that the constrainer isn't deleted while still in use by this object.
  49. @see ComponentBoundsConstrainer
  50. */
  51. ResizableEdgeComponent (Component* componentToResize,
  52. ComponentBoundsConstrainer* constrainer,
  53. Edge edgeToResize);
  54. /** Destructor. */
  55. ~ResizableEdgeComponent();
  56. bool isVertical() const noexcept;
  57. protected:
  58. //==============================================================================
  59. /** @internal */
  60. void paint (Graphics&) override;
  61. /** @internal */
  62. void mouseDown (const MouseEvent&) override;
  63. /** @internal */
  64. void mouseDrag (const MouseEvent&) override;
  65. /** @internal */
  66. void mouseUp (const MouseEvent&) override;
  67. private:
  68. WeakReference<Component> component;
  69. ComponentBoundsConstrainer* constrainer;
  70. Rectangle<int> originalBounds;
  71. const Edge edge;
  72. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent)
  73. };
  74. #endif // JUCE_RESIZABLEEDGECOMPONENT_H_INCLUDED