LMMS
Loading...
Searching...
No Matches
juce_ResizableBorderComponent.h
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
29//==============================================================================
48{
49public:
50 //==============================================================================
68 ResizableBorderComponent (Component* componentToResize,
70
73
74
75 //==============================================================================
80 void setBorderThickness (BorderSize<int> newBorderSize);
81
87
88
89 //==============================================================================
93 class Zone
94 {
95 public:
96 //==============================================================================
97 enum Zones
98 {
99 centre = 0,
100 left = 1,
101 top = 2,
102 right = 4,
104 };
105
106 //==============================================================================
108 explicit Zone (int zoneFlags) noexcept;
109
110 Zone() noexcept;
112 Zone& operator= (const Zone&) noexcept;
113
114 bool operator== (const Zone&) const noexcept;
115 bool operator!= (const Zone&) const noexcept;
116
117 //==============================================================================
121 static Zone fromPositionOnBorder (Rectangle<int> totalSize,
122 BorderSize<int> border,
123 Point<int> position);
124
127
131 bool isDraggingLeftEdge() const noexcept { return (zone & left) != 0; }
133 bool isDraggingRightEdge() const noexcept { return (zone & right) != 0; }
135 bool isDraggingTopEdge() const noexcept { return (zone & top) != 0; }
137 bool isDraggingBottomEdge() const noexcept { return (zone & bottom) != 0; }
138
142 template <typename ValueType>
144 const Point<ValueType>& distance) const noexcept
145 {
147 return original + distance;
148
149 if (isDraggingLeftEdge()) original.setLeft (jmin (original.getRight(), original.getX() + distance.x));
150 if (isDraggingRightEdge()) original.setWidth (jmax (ValueType(), original.getWidth() + distance.x));
151 if (isDraggingTopEdge()) original.setTop (jmin (original.getBottom(), original.getY() + distance.y));
152 if (isDraggingBottomEdge()) original.setHeight (jmax (ValueType(), original.getHeight() + distance.y));
153
154 return original;
155 }
156
158 int getZoneFlags() const noexcept { return zone; }
159
160 private:
161 //==============================================================================
163 };
164
167
168protected:
170 void paint (Graphics&) override;
172 void mouseEnter (const MouseEvent&) override;
174 void mouseMove (const MouseEvent&) override;
176 void mouseDown (const MouseEvent&) override;
178 void mouseDrag (const MouseEvent&) override;
180 void mouseUp (const MouseEvent&) override;
182 bool hitTest (int x, int y) override;
183
184private:
190
191 void updateMouseZone (const MouseEvent&);
192
194};
195
196} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_BorderSize.h:42
Definition juce_ComponentBoundsConstrainer.h:44
virtual MouseCursor getMouseCursor()
Definition juce_Component.cpp:1870
Component() noexcept
Definition juce_Component.cpp:517
Definition juce_GraphicsContext.h:45
Definition juce_MouseCursor.h:39
Definition juce_MouseEvent.h:39
Definition juce_Point.h:42
Definition juce_Rectangle.h:67
Definition juce_ResizableBorderComponent.h:94
bool isDraggingWholeObject() const noexcept
Definition juce_ResizableBorderComponent.h:129
bool isDraggingBottomEdge() const noexcept
Definition juce_ResizableBorderComponent.h:137
Rectangle< ValueType > resizeRectangleBy(Rectangle< ValueType > original, const Point< ValueType > &distance) const noexcept
Definition juce_ResizableBorderComponent.h:143
bool isDraggingLeftEdge() const noexcept
Definition juce_ResizableBorderComponent.h:131
Zones
Definition juce_ResizableBorderComponent.h:98
@ right
Definition juce_ResizableBorderComponent.h:102
@ bottom
Definition juce_ResizableBorderComponent.h:103
@ centre
Definition juce_ResizableBorderComponent.h:99
@ top
Definition juce_ResizableBorderComponent.h:101
@ left
Definition juce_ResizableBorderComponent.h:100
bool isDraggingTopEdge() const noexcept
Definition juce_ResizableBorderComponent.h:135
int zone
Definition juce_ResizableBorderComponent.h:162
bool isDraggingRightEdge() const noexcept
Definition juce_ResizableBorderComponent.h:133
Zone(int zoneFlags) noexcept
Definition juce_ResizableBorderComponent.cpp:30
int getZoneFlags() const noexcept
Definition juce_ResizableBorderComponent.h:158
ComponentBoundsConstrainer * constrainer
Definition juce_ResizableBorderComponent.h:186
Zone getCurrentZone() const noexcept
Definition juce_ResizableBorderComponent.h:166
WeakReference< Component > component
Definition juce_ResizableBorderComponent.h:185
void updateMouseZone(const MouseEvent &)
Definition juce_ResizableBorderComponent.cpp:184
BorderSize< int > borderSize
Definition juce_ResizableBorderComponent.h:187
Zone mouseZone
Definition juce_ResizableBorderComponent.h:189
void setBorderThickness(BorderSize< int > newBorderSize)
Definition juce_ResizableBorderComponent.cpp:170
Rectangle< int > originalBounds
Definition juce_ResizableBorderComponent.h:188
BorderSize< int > getBorderThickness() const
Definition juce_ResizableBorderComponent.cpp:179
ResizableBorderComponent(Component *componentToResize, ComponentBoundsConstrainer *constrainer)
Definition juce_ResizableBorderComponent.cpp:90
Definition juce_WeakReference.h:78
int y
Definition inflate.c:1588
static ZCONST unsigned border[]
Definition inflate.c:749
unsigned x[BMAX+1]
Definition inflate.c:1586
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
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
#define const
Definition zconf.h:137