JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_RectanglePlacement.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//==============================================================================
39class JUCE_API RectanglePlacement
40{
41public:
42 //==============================================================================
44 inline RectanglePlacement (int placementFlags) noexcept : flags (placementFlags) {}
45
47 inline RectanglePlacement() = default;
48
51
53 RectanglePlacement& operator= (const RectanglePlacement&) = default;
54
55 bool operator== (const RectanglePlacement&) const noexcept;
56 bool operator!= (const RectanglePlacement&) const noexcept;
57
58 //==============================================================================
60 enum Flags
61 {
62 //==============================================================================
64 xLeft = 1,
65
67 xRight = 2,
68
71 xMid = 4,
72
73 //==============================================================================
76 yTop = 8,
77
80 yBottom = 16,
81
84 yMid = 32,
85
86 //==============================================================================
90 stretchToFit = 64,
91
92 //==============================================================================
101 fillDestination = 128,
102
106 onlyReduceInSize = 256,
107
111 onlyIncreaseInSize = 512,
112
115 doNotResize = (onlyIncreaseInSize | onlyReduceInSize),
116
117 //==============================================================================
119 centred = 4 + 32
120 };
121
122 //==============================================================================
124 inline int getFlags() const noexcept { return flags; }
125
130 inline bool testFlags (int flagsToTest) const noexcept { return (flags & flagsToTest) != 0; }
131
132
133 //==============================================================================
139 void applyTo (double& sourceX,
140 double& sourceY,
141 double& sourceW,
142 double& sourceH,
143 double destinationX,
144 double destinationY,
145 double destinationW,
146 double destinationH) const noexcept;
147
151 template <typename ValueType>
153 const Rectangle<ValueType>& destination) const noexcept
154 {
155 double x = source.getX(), y = source.getY(), w = source.getWidth(), h = source.getHeight();
156 applyTo (x, y, w, h, static_cast<double> (destination.getX()), static_cast<double> (destination.getY()),
157 static_cast<double> (destination.getWidth()), static_cast<double> (destination.getHeight()));
158 return Rectangle<ValueType> (static_cast<ValueType> (x), static_cast<ValueType> (y),
159 static_cast<ValueType> (w), static_cast<ValueType> (h));
160 }
161
165 AffineTransform getTransformToFit (const Rectangle<float>& source,
166 const Rectangle<float>& destination) const noexcept;
167
168
169private:
170 //==============================================================================
171 int flags { centred };
172};
173
174} // namespace juce
Represents a 2D affine-transformation matrix.
Defines the method used to position some kind of rectangular object within a rectangular viewport.
int getFlags() const noexcept
Returns the raw flags that are set for this object.
bool testFlags(int flagsToTest) const noexcept
Tests a set of flags for this object.
RectanglePlacement()=default
Creates a default RectanglePlacement object, which is equivalent to using the 'centred' flag.
RectanglePlacement(const RectanglePlacement &)=default
Creates a copy of another RectanglePlacement object.
RectanglePlacement(int placementFlags) noexcept
Creates a RectanglePlacement object using a combination of flags from the Flags enum.
Rectangle< ValueType > appliedTo(const Rectangle< ValueType > &source, const Rectangle< ValueType > &destination) const noexcept
Returns the rectangle that should be used to fit the given source rectangle into the destination rect...
Flags
Flag values that can be combined and used in the constructor.
Manages a rectangle and allows geometric operations to be performed on it.
JUCE Namespace.