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_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 //==============================================================================
46
48 Justification (const Justification&) = default;
49
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
66 int getOnlyVerticalFlags() const noexcept { return flags & (top | bottom | verticallyCentred); }
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
178 bottomRight = 18
179 };
180
181
182private:
183 //==============================================================================
184 int flags;
185};
186
187} // namespace juce
Represents a type of justification to be used when positioning graphical items.
Flags
Flag values that can be combined and used in the constructor.
@ centredRight
Indicates that the item should be centred vertically but placed on the right hand side.
@ horizontallyJustified
Indicates that lines of text should be spread out to fill the maximum width available,...
@ centredBottom
Indicates that the item should be centred horizontally and placed at the bottom.
@ centred
Indicates that the item should be centred vertically and horizontally.
@ left
Indicates that the item should be aligned against the left edge of the available space.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
@ horizontallyCentred
Indicates that the item should be placed in the centre between the left and right sides of the availa...
@ centredTop
Indicates that the item should be centred horizontally and placed at the top.
@ bottom
Indicates that the item should be aligned against the bottom edge of the available space.
@ verticallyCentred
Indicates that the item should be placed in the centre between the top and bottom sides of the availa...
@ top
Indicates that the item should be aligned against the top edge of the available space.
@ right
Indicates that the item should be aligned against the right edge of the available space.
@ bottomLeft
Indicates that the item should be placed in the bottom-left corner.
@ bottomRight
Indicates that the item should be placed in the bottom-left corner.
@ topLeft
Indicates that the item should be placed in the top-left corner.
@ topRight
Indicates that the item should be placed in the top-right corner.
const Rectangle< ValueType > appliedToRectangle(const Rectangle< ValueType > &areaToAdjust, const Rectangle< ValueType > &targetSpace) const noexcept
Returns the new position of a rectangle that has been justified to fit within a given space.
void applyToRectangle(ValueType &x, ValueType &y, ValueType w, ValueType h, ValueType spaceX, ValueType spaceY, ValueType spaceW, ValueType spaceH) const noexcept
Adjusts the position of a rectangle to fit it into a space.
int getOnlyVerticalFlags() const noexcept
Returns just the flags from this object that deal with vertical layout.
Justification(const Justification &)=default
Creates a copy of another Justification object.
int getOnlyHorizontalFlags() const noexcept
Returns just the flags from this object that deal with horizontal layout.
Justification & operator=(const Justification &)=default
Copies another Justification object.
int getFlags() const noexcept
Returns the raw flags that are set for this Justification object.
Justification(int justificationFlags) noexcept
Creates a Justification object using a combination of flags from the Flags enum.
bool testFlags(int flagsToTest) const noexcept
Tests a set of flags for this object.
Manages a rectangle and allows geometric operations to be performed on it.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88