LMMS
Loading...
Searching...
No Matches
juce_ResizableEdgeComponent.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
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.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
40
42
43//==============================================================================
48
50{
51 getLookAndFeel().drawStretchableLayoutResizerBar (g, getWidth(), getHeight(), isVertical(),
53}
54
56{
57 if (component == nullptr)
58 {
59 jassertfalse; // You've deleted the component that this resizer was supposed to be using!
60 return;
61 }
62
63 originalBounds = component->getBounds();
64
65 if (constrainer != nullptr)
66 constrainer->resizeStart();
67}
68
70{
71 if (component == nullptr)
72 {
73 jassertfalse; // You've deleted the component that this resizer was supposed to be using!
74 return;
75 }
76
77 auto newBounds = originalBounds;
78
79 switch (edge)
80 {
81 case leftEdge: newBounds.setLeft (jmin (newBounds.getRight(), newBounds.getX() + e.getDistanceFromDragStartX())); break;
82 case rightEdge: newBounds.setWidth (jmax (0, newBounds.getWidth() + e.getDistanceFromDragStartX())); break;
83 case topEdge: newBounds.setTop (jmin (newBounds.getBottom(), newBounds.getY() + e.getDistanceFromDragStartY())); break;
84 case bottomEdge: newBounds.setHeight (jmax (0, newBounds.getHeight() + e.getDistanceFromDragStartY())); break;
85 default: jassertfalse; break;
86 }
87
88 if (constrainer != nullptr)
89 {
90 constrainer->setBoundsForComponent (component, newBounds,
91 edge == topEdge,
92 edge == leftEdge,
94 edge == rightEdge);
95 }
96 else
97 {
98 if (auto* p = component->getPositioner())
99 p->applyNewBounds (newBounds);
100 else
101 component->setBounds (newBounds);
102 }
103}
104
106{
107 if (constrainer != nullptr)
108 constrainer->resizeEnd();
109}
110
111} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_ComponentBoundsConstrainer.h:44
bool isMouseButtonDown(bool includeChildren=false) const
Definition juce_Component.cpp:3177
void setRepaintsOnMouseActivity(bool shouldRepaint) noexcept
Definition juce_Component.cpp:1881
int getHeight() const noexcept
Definition juce_Component.h:274
void setMouseCursor(const MouseCursor &cursorType)
Definition juce_Component.cpp:1859
Component() noexcept
Definition juce_Component.cpp:517
bool isMouseOver(bool includeChildren=false) const
Definition juce_Component.cpp:3159
int getWidth() const noexcept
Definition juce_Component.h:271
LookAndFeel & getLookAndFeel() const noexcept
Definition juce_Component.cpp:2173
Definition juce_GraphicsContext.h:45
@ LeftRightResizeCursor
Definition juce_MouseCursor.h:59
@ UpDownResizeCursor
Definition juce_MouseCursor.h:60
Definition juce_MouseEvent.h:39
WeakReference< Component > component
Definition juce_ResizableEdgeComponent.h:92
void mouseDown(const MouseEvent &) override
Definition juce_ResizableEdgeComponent.cpp:55
bool isVertical() const noexcept
Definition juce_ResizableEdgeComponent.cpp:44
const Edge edge
Definition juce_ResizableEdgeComponent.h:95
ResizableEdgeComponent(Component *componentToResize, ComponentBoundsConstrainer *constrainer, Edge edgeToResize)
Definition juce_ResizableEdgeComponent.cpp:29
void paint(Graphics &) override
Definition juce_ResizableEdgeComponent.cpp:49
void mouseDrag(const MouseEvent &) override
Definition juce_ResizableEdgeComponent.cpp:69
void mouseUp(const MouseEvent &) override
Definition juce_ResizableEdgeComponent.cpp:105
Rectangle< int > originalBounds
Definition juce_ResizableEdgeComponent.h:94
ComponentBoundsConstrainer * constrainer
Definition juce_ResizableEdgeComponent.h:93
Edge
Definition juce_ResizableEdgeComponent.h:49
@ rightEdge
Definition juce_ResizableEdgeComponent.h:51
@ topEdge
Definition juce_ResizableEdgeComponent.h:52
@ bottomEdge
Definition juce_ResizableEdgeComponent.h:53
@ leftEdge
Definition juce_ResizableEdgeComponent.h:50
* e
Definition inflate.c:1404
int g
Definition inflate.c:1573
#define jassertfalse
Definition carla_juce.cpp:31
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
constexpr Type jmax(Type a, Type b)
Definition juce_MathsFunctions.h:94
uch * p
Definition crypt.c:594
#define const
Definition zconf.h:137