LMMS
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//==============================================================================
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 //==============================================================================
91
92 //==============================================================================
102
107
112
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
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_AffineTransform.h:43
Definition juce_Rectangle.h:67
int getFlags() const noexcept
Definition juce_RectanglePlacement.h:124
bool testFlags(int flagsToTest) const noexcept
Definition juce_RectanglePlacement.h:130
RectanglePlacement(const RectanglePlacement &)=default
void applyTo(double &sourceX, double &sourceY, double &sourceW, double &sourceH, double destinationX, double destinationY, double destinationW, double destinationH) const noexcept
Definition juce_RectanglePlacement.cpp:39
RectanglePlacement(int placementFlags) noexcept
Definition juce_RectanglePlacement.h:44
Rectangle< ValueType > appliedTo(const Rectangle< ValueType > &source, const Rectangle< ValueType > &destination) const noexcept
Definition juce_RectanglePlacement.h:152
Flags
Definition juce_RectanglePlacement.h:61
@ onlyReduceInSize
Definition juce_RectanglePlacement.h:106
@ doNotResize
Definition juce_RectanglePlacement.h:115
@ fillDestination
Definition juce_RectanglePlacement.h:101
@ onlyIncreaseInSize
Definition juce_RectanglePlacement.h:111
@ yMid
Definition juce_RectanglePlacement.h:84
@ yTop
Definition juce_RectanglePlacement.h:76
@ xMid
Definition juce_RectanglePlacement.h:71
@ xRight
Definition juce_RectanglePlacement.h:67
@ centred
Definition juce_RectanglePlacement.h:119
@ stretchToFit
Definition juce_RectanglePlacement.h:90
@ yBottom
Definition juce_RectanglePlacement.h:80
@ xLeft
Definition juce_RectanglePlacement.h:64
int flags
Definition juce_RectanglePlacement.h:171
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
unsigned x[BMAX+1]
Definition inflate.c:1586
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
void Rectangle(HDC ctx, int l, int t, int r, int b)
Definition swell-gdi-generic.cpp:279
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
#define const
Definition zconf.h:137