LMMS
Loading...
Searching...
No Matches
juce_Justification.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//==============================================================================
41{
42public:
43 //==============================================================================
45 Justification (int justificationFlags) noexcept : flags (justificationFlags) {}
46
48 Justification (const Justification&) = default;
49
51 Justification& operator= (const Justification&) = default;
52
53 bool operator== (const Justification& other) const noexcept { return flags == other.flags; }
54 bool operator!= (const Justification& other) const noexcept { return flags != other.flags; }
55
56 //==============================================================================
58 inline int getFlags() const noexcept { return flags; }
59
63 inline bool testFlags (int flagsToTest) const noexcept { return (flags & flagsToTest) != 0; }
64
67
70
71 //==============================================================================
77 template <typename ValueType>
78 void applyToRectangle (ValueType& x, ValueType& y, ValueType w, ValueType h,
79 ValueType spaceX, ValueType spaceY, ValueType spaceW, ValueType spaceH) const noexcept
80 {
81 x = spaceX;
82 if ((flags & horizontallyCentred) != 0) x += (spaceW - w) / (ValueType) 2;
83 else if ((flags & right) != 0) x += spaceW - w;
84
85 y = spaceY;
86 if ((flags & verticallyCentred) != 0) y += (spaceH - h) / (ValueType) 2;
87 else if ((flags & bottom) != 0) y += spaceH - h;
88 }
89
92 template <typename ValueType>
94 const Rectangle<ValueType>& targetSpace) const noexcept
95 {
96 ValueType x = areaToAdjust.getX(), y = areaToAdjust.getY();
97 applyToRectangle (x, y, areaToAdjust.getWidth(), areaToAdjust.getHeight(),
98 targetSpace.getX(), targetSpace.getY(), targetSpace.getWidth(), targetSpace.getHeight());
99 return areaToAdjust.withPosition (x, y);
100 }
101
102 //==============================================================================
104 enum Flags
105 {
106 //==============================================================================
108 left = 1,
109
111 right = 2,
112
116
117 //==============================================================================
119 top = 8,
120
122 bottom = 16,
123
127
128 //==============================================================================
133
134 //==============================================================================
139
144
149
154
159
164
169
174
179 };
180
181
182private:
183 //==============================================================================
184 int flags;
185};
186
187} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Flags
Definition juce_Justification.h:105
@ centredRight
Definition juce_Justification.h:148
@ horizontallyJustified
Definition juce_Justification.h:132
@ centredBottom
Definition juce_Justification.h:158
@ centred
Definition juce_Justification.h:138
@ left
Definition juce_Justification.h:108
@ centredLeft
Definition juce_Justification.h:143
@ horizontallyCentred
Definition juce_Justification.h:115
@ centredTop
Definition juce_Justification.h:153
@ bottom
Definition juce_Justification.h:122
@ verticallyCentred
Definition juce_Justification.h:126
@ top
Definition juce_Justification.h:119
@ right
Definition juce_Justification.h:111
@ bottomLeft
Definition juce_Justification.h:173
@ bottomRight
Definition juce_Justification.h:178
@ topLeft
Definition juce_Justification.h:163
@ topRight
Definition juce_Justification.h:168
const Rectangle< ValueType > appliedToRectangle(const Rectangle< ValueType > &areaToAdjust, const Rectangle< ValueType > &targetSpace) const noexcept
Definition juce_Justification.h:93
void applyToRectangle(ValueType &x, ValueType &y, ValueType w, ValueType h, ValueType spaceX, ValueType spaceY, ValueType spaceW, ValueType spaceH) const noexcept
Definition juce_Justification.h:78
int getOnlyVerticalFlags() const noexcept
Definition juce_Justification.h:66
Justification(const Justification &)=default
int getOnlyHorizontalFlags() const noexcept
Definition juce_Justification.h:69
int getFlags() const noexcept
Definition juce_Justification.h:58
int flags
Definition juce_Justification.h:184
Justification(int justificationFlags) noexcept
Definition juce_Justification.h:45
bool testFlags(int flagsToTest) const noexcept
Definition juce_Justification.h:63
Definition juce_Rectangle.h:67
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
unsigned x[BMAX+1]
Definition inflate.c:1586
Definition carla_juce.cpp:31
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
#define const
Definition zconf.h:137