VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / layout / juce_ResizableEdgeComponent.h
blobe3fc26de95fe298dd15370e2b28defb3b57ce1dc
1 /*
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
8 licensing.
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
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
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
42 @tags{GUI}
44 class JUCE_API ResizableEdgeComponent : public Component
46 public:
47 //==============================================================================
48 enum Edge
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
60 isn't mandatory.
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,
73 Edge edgeToResize);
75 /** Destructor. */
76 ~ResizableEdgeComponent() override;
78 bool isVertical() const noexcept;
80 protected:
81 //==============================================================================
82 /** @internal */
83 void paint (Graphics&) override;
84 /** @internal */
85 void mouseDown (const MouseEvent&) override;
86 /** @internal */
87 void mouseDrag (const MouseEvent&) override;
88 /** @internal */
89 void mouseUp (const MouseEvent&) override;
91 private:
92 WeakReference<Component> component;
93 ComponentBoundsConstrainer* constrainer;
94 Rectangle<int> originalBounds;
95 const Edge edge;
97 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent)
100 } // namespace juce