2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
23 ==============================================================================
29 //==============================================================================
31 A component that resizes its parent component when dragged.
33 This component forms a bar along one edge of a component, allowing it to
34 be dragged by that edges to resize it.
36 To use it, just add it to your component, positioning it along the appropriate
37 edge. Make sure you reposition the resizer component each time the parent's size
38 changes, to keep it in the correct position.
40 @see ResizableBorderComponent, ResizableCornerComponent
44 class JUCE_API ResizableEdgeComponent
: public Component
47 //==============================================================================
50 leftEdge
, /**< Indicates a vertical bar that can be dragged left/right to move the component's left-hand edge. */
51 rightEdge
, /**< Indicates a vertical bar that can be dragged left/right to move the component's right-hand edge. */
52 topEdge
, /**< Indicates a horizontal bar that can be dragged up/down to move the top of the component. */
53 bottomEdge
/**< Indicates a horizontal bar that can be dragged up/down to move the bottom of the component. */
56 /** Creates a resizer bar.
58 Pass in the target component which you want to be resized when this one is
59 dragged. The target component will usually be this component's parent, but this
62 Remember that when the target component is resized, it'll need to move and
63 resize this component to keep it in place, as this won't happen automatically.
65 If the constrainer parameter is not a nullptr, then this object will be used to
66 enforce limits on the size and position that the component can be stretched to.
67 Make sure that the constrainer isn't deleted while still in use by this object.
69 @see ComponentBoundsConstrainer
71 ResizableEdgeComponent (Component
* componentToResize
,
72 ComponentBoundsConstrainer
* constrainer
,
76 ~ResizableEdgeComponent() override
;
78 bool isVertical() const noexcept
;
81 //==============================================================================
83 void paint (Graphics
&) override
;
85 void mouseDown (const MouseEvent
&) override
;
87 void mouseDrag (const MouseEvent
&) override
;
89 void mouseUp (const MouseEvent
&) override
;
92 WeakReference
<Component
> component
;
93 ComponentBoundsConstrainer
* constrainer
;
94 Rectangle
<int> originalBounds
;
97 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent
)