Add remaining files
[juce-lv2.git] / juce / source / src / gui / components / layout / juce_ResizableEdgeComponent.h
blob0010d53744ea0547988cdd348f78204148b15886
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__
27 #define __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__
29 #include "juce_ComponentBoundsConstrainer.h"
32 //==============================================================================
33 /**
34 A component that resizes its parent component when dragged.
36 This component forms a bar along one edge of a component, allowing it to
37 be dragged by that edges to resize it.
39 To use it, just add it to your component, positioning it along the appropriate
40 edge. Make sure you reposition the resizer component each time the parent's size
41 changes, to keep it in the correct position.
43 @see ResizbleBorderComponent, ResizableCornerComponent
45 class JUCE_API ResizableEdgeComponent : public Component
47 public:
48 //==============================================================================
49 enum Edge
51 leftEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's left-hand edge. */
52 rightEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's right-hand edge. */
53 topEdge, /**< Indicates a horizontal bar that can be dragged up/down to move the top of the component. */
54 bottomEdge /**< Indicates a horizontal bar that can be dragged up/down to move the bottom of the component. */
57 /** Creates a resizer bar.
59 Pass in the target component which you want to be resized when this one is
60 dragged. The target component will usually be this component's parent, but this
61 isn't mandatory.
63 Remember that when the target component is resized, it'll need to move and
64 resize this component to keep it in place, as this won't happen automatically.
66 If the constrainer parameter is non-zero, then this object will be used to enforce
67 limits on the size and position that the component can be stretched to. Make sure
68 that the constrainer isn't deleted while still in use by this object.
70 @see ComponentBoundsConstrainer
72 ResizableEdgeComponent (Component* componentToResize,
73 ComponentBoundsConstrainer* constrainer,
74 Edge edgeToResize);
76 /** Destructor. */
77 ~ResizableEdgeComponent();
79 bool isVertical() const noexcept;
81 protected:
82 //==============================================================================
83 /** @internal */
84 void paint (Graphics& g);
85 /** @internal */
86 void mouseDown (const MouseEvent& e);
87 /** @internal */
88 void mouseDrag (const MouseEvent& e);
89 /** @internal */
90 void mouseUp (const MouseEvent& e);
92 private:
93 WeakReference<Component> component;
94 ComponentBoundsConstrainer* constrainer;
95 Rectangle<int> originalBounds;
96 const Edge edge;
98 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent);
102 #endif // __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__