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_GridItem.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
35class JUCE_API GridItem
36{
37public:
38 enum class Keyword { autoValue };
39
40 //==============================================================================
42 struct Span
43 {
44 explicit Span (int numberToUse) noexcept : number (numberToUse)
45 {
46 /* Span must be at least one and positive */
47 jassert (numberToUse > 0);
48 }
49
50 explicit Span (int numberToUse, const String& nameToUse) : Span (numberToUse)
51 {
52 /* Name must not be empty */
53 jassert (nameToUse.isNotEmpty());
54 name = nameToUse;
55 }
56
57 explicit Span (const String& nameToUse) : name (nameToUse)
58 {
59 /* Name must not be empty */
60 jassert (nameToUse.isNotEmpty());
61 }
62
63 int number = 1;
64 String name;
65 };
66
67 //==============================================================================
69 struct Property
70 {
71 Property() noexcept;
72
73 Property (Keyword keyword) noexcept;
74
75 Property (const char* lineNameToUse) noexcept;
76
77 Property (const String& lineNameToUse) noexcept;
78
79 Property (int numberToUse) noexcept;
80
81 Property (int numberToUse, const String& lineNameToUse) noexcept;
82
83 Property (Span spanToUse) noexcept;
84
85 bool hasSpan() const noexcept { return isSpan && ! isAuto; }
86 bool hasAbsolute() const noexcept { return ! (isSpan || isAuto); }
87 bool hasAuto() const noexcept { return isAuto; }
88 bool hasName() const noexcept { return name.isNotEmpty(); }
89 const String& getName() const noexcept { return name; }
90 int getNumber() const noexcept { return number; }
91
92 private:
93 String name;
94 int number = 1;
95 bool isSpan = false;
96 bool isAuto = false;
97 };
98
99 //==============================================================================
101 struct StartAndEndProperty { Property start, end; };
102
103 //==============================================================================
105 enum class JustifySelf : int
106 {
107 start = 0,
108 end,
109 center,
110 stretch,
111 autoValue
112 };
113
115 enum class AlignSelf : int
116 {
117 start = 0,
118 end,
119 center,
120 stretch,
121 autoValue
122 };
123
125 GridItem() noexcept;
127 GridItem (Component& componentToUse) noexcept;
129 GridItem (Component* componentToUse) noexcept;
130
131 //==============================================================================
133 Component* associatedComponent = nullptr;
134
135 //==============================================================================
137 int order = 0;
138
142 JustifySelf justifySelf = JustifySelf::autoValue;
143
147 AlignSelf alignSelf = AlignSelf::autoValue;
148
150 StartAndEndProperty column = { Keyword::autoValue, Keyword::autoValue };
151
153 StartAndEndProperty row = { Keyword::autoValue, Keyword::autoValue };
154
156 String area;
157
158 //==============================================================================
159 enum
160 {
161 useDefaultValue = -2, /* TODO: useDefaultValue should be named useAuto */
162 notAssigned = -1
163 };
164
165 /* TODO: move all of this into a common class that is shared with the FlexItem */
166 float width = notAssigned;
167 float minWidth = 0.0f;
168 float maxWidth = notAssigned;
169
170 float height = notAssigned;
171 float minHeight = 0.0f;
172 float maxHeight = notAssigned;
173
175 struct Margin
176 {
177 Margin() noexcept;
178 Margin (int size) noexcept;
179 Margin (float size) noexcept;
180 Margin (float top, float right, float bottom, float left) noexcept;
182 float left;
183 float right;
184 float top;
185 float bottom;
186 };
187
190
193
195 void setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd);
196
198 void setArea (Property rowStart, Property columnStart);
199
201 void setArea (const String& areaName);
202
204 GridItem withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept;
205
207 GridItem withArea (Property rowStart, Property columnStart) const noexcept;
208
210 GridItem withArea (const String& areaName) const noexcept;
211
213 GridItem withRow (StartAndEndProperty row) const noexcept;
214
216 GridItem withColumn (StartAndEndProperty column) const noexcept;
217
219 GridItem withAlignSelf (AlignSelf newAlignSelf) const noexcept;
220
222 GridItem withJustifySelf (JustifySelf newJustifySelf) const noexcept;
223
225 GridItem withWidth (float newWidth) const noexcept;
226
228 GridItem withHeight (float newHeight) const noexcept;
229
231 GridItem withSize (float newWidth, float newHeight) const noexcept;
232
234 GridItem withMargin (Margin newMargin) const noexcept;
235
237 GridItem withOrder (int newOrder) const noexcept;
238};
239
240} // namespace juce
The base class for all JUCE user-interface objects.
Defines an item in a Grid.
Rectangle< float > currentBounds
The item's current bounds.
AlignSelf
Possible values for the alignSelf property.
GridItem() noexcept
Creates an item with default parameters.
Margin margin
The margin to leave around this item.
JustifySelf
Possible values for the justifySelf property.
Represents start and end properties.
Manages a rectangle and allows geometric operations to be performed on it.
The JUCE String class!
Definition juce_String.h:53
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
Represents a margin.
Represents a property.
Represents a span.