LMMS
Loading...
Searching...
No Matches
juce_ResizableCornerComponent.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
37
39
40//==============================================================================
47
49{
50 if (component == nullptr)
51 {
52 jassertfalse; // You've deleted the component that this resizer is supposed to be controlling!
53 return;
54 }
55
56 originalBounds = component->getBounds();
57
58 if (constrainer != nullptr)
59 constrainer->resizeStart();
60}
61
63{
64 if (component == nullptr)
65 {
66 jassertfalse; // You've deleted the component that this resizer is supposed to be controlling!
67 return;
68 }
69
70 auto r = originalBounds.withSize (originalBounds.getWidth() + e.getDistanceFromDragStartX(),
71 originalBounds.getHeight() + e.getDistanceFromDragStartY());
72
73 if (constrainer != nullptr)
74 constrainer->setBoundsForComponent (component, r, false, false, true, true);
75 else if (auto pos = component->getPositioner())
76 pos->applyNewBounds (r);
77 else
78 component->setBounds (r);
79}
80
82{
83 if (constrainer != nullptr)
84 constrainer->resizeEnd();
85}
86
88{
89 if (getWidth() <= 0)
90 return false;
91
92 auto yAtX = getHeight() - (getHeight() * x / getWidth());
93 return y >= yAtX - getHeight() / 4;
94}
95
96} // namespace juce
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
bool isMouseOverOrDragging(bool includeChildren=false) const
Definition juce_Component.cpp:3191
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
int getWidth() const noexcept
Definition juce_Component.h:271
LookAndFeel & getLookAndFeel() const noexcept
Definition juce_Component.cpp:2173
Definition juce_GraphicsContext.h:45
@ BottomRightCornerResizeCursor
Definition juce_MouseCursor.h:70
Definition juce_MouseEvent.h:39
void paint(Graphics &) override
Definition juce_ResizableCornerComponent.cpp:41
ComponentBoundsConstrainer * constrainer
Definition juce_ResizableCornerComponent.h:86
void mouseDrag(const MouseEvent &) override
Definition juce_ResizableCornerComponent.cpp:62
void mouseUp(const MouseEvent &) override
Definition juce_ResizableCornerComponent.cpp:81
bool hitTest(int x, int y) override
Definition juce_ResizableCornerComponent.cpp:87
void mouseDown(const MouseEvent &) override
Definition juce_ResizableCornerComponent.cpp:48
ResizableCornerComponent(Component *componentToResize, ComponentBoundsConstrainer *constrainer)
Definition juce_ResizableCornerComponent.cpp:29
WeakReference< Component > component
Definition juce_ResizableCornerComponent.h:85
Rectangle< int > originalBounds
Definition juce_ResizableCornerComponent.h:87
* e
Definition inflate.c:1404
int y
Definition inflate.c:1588
int g
Definition inflate.c:1573
unsigned x[BMAX+1]
Definition inflate.c:1586
#define jassertfalse
Definition carla_juce.cpp:31
int r
Definition crypt.c:458