LMMS
Loading...
Searching...
No Matches
juce_Grid.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
40{
41public:
42 //==============================================================================
44 struct Px final
45 {
46 explicit Px (float p) : pixels (static_cast<long double>(p)) { /*sta (p >= 0.0f);*/ }
47 explicit Px (int p) : pixels (static_cast<long double>(p)) { /*sta (p >= 0.0f);*/ }
48 explicit constexpr Px (long double p) : pixels (p) {}
49 explicit constexpr Px (unsigned long long p) : pixels (static_cast<long double>(p)) {}
50
51 long double pixels;
52 };
53
55 struct Fr final
56 {
57 explicit Fr (int f) : fraction (static_cast<unsigned long long> (f)) {}
58 explicit constexpr Fr (unsigned long long p) : fraction (p) {}
59
60 unsigned long long fraction;
61 };
62
63 //==============================================================================
66 {
68 TrackInfo() noexcept;
69
70 TrackInfo (Px sizeInPixels) noexcept;
71 TrackInfo (Fr fractionOfFreeSpace) noexcept;
72
73 TrackInfo (Px sizeInPixels, const String& endLineNameToUse) noexcept;
74 TrackInfo (Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept;
75
76 TrackInfo (const String& startLineNameToUse, Px sizeInPixels) noexcept;
77 TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace) noexcept;
78
79 TrackInfo (const String& startLineNameToUse, Px sizeInPixels, const String& endLineNameToUse) noexcept;
80 TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept;
81
82 bool isAuto() const noexcept { return hasKeyword; }
84 bool isPixels() const noexcept { return ! isFraction; }
87
89 float getSize() const noexcept { return size; }
90
91 private:
92 friend class Grid;
93 float getAbsoluteSize (float relativeFractionalUnit) const;
94
95 float size = 0; // Either a fraction or an absolute size in pixels
96 bool isFraction = false;
97 bool hasKeyword = false;
98
100 };
101
102 //==============================================================================
104 enum class JustifyItems : int
105 {
106 start = 0,
108 center,
109 stretch
110 };
111
113 enum class AlignItems : int
114 {
115 start = 0,
117 center,
118 stretch
119 };
120
122 enum class JustifyContent
123 {
126 center,
127 stretch,
128 spaceAround,
129 spaceBetween,
130 spaceEvenly
131 };
132
134 enum class AlignContent
135 {
138 center,
139 stretch,
140 spaceAround,
141 spaceBetween,
142 spaceEvenly
143 };
144
146 enum class AutoFlow
147 {
150 rowDense,
151 columnDense
152 };
153
154
155 //==============================================================================
157 Grid() = default;
158
160 ~Grid() noexcept = default;
161
162 //==============================================================================
165
168
171
174
177
178
179 //==============================================================================
182
185
188
191
194
198 Px rowGap { 0 };
199
201 void setGap (Px sizeInPixels) noexcept { rowGap = columnGap = sizeInPixels; }
202
203 //==============================================================================
206
207 //==============================================================================
210
211 //==============================================================================
216
217private:
218 //==============================================================================
219 struct SizeCalculation;
220 struct PlacementHelpers;
221 struct AutoPlacement;
222 struct BoxAlignment;
223};
224
225constexpr Grid::Px operator"" _px (long double px) { return Grid::Px { px }; }
226constexpr Grid::Px operator"" _px (unsigned long long px) { return Grid::Px { px }; }
227constexpr Grid::Fr operator"" _fr (unsigned long long fr) { return Grid::Fr { fr }; }
228
229} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
#define final
Definition DistrhoDefines.h:74
Definition juce_Array.h:56
TrackInfo autoColumns
Definition juce_Grid.h:193
void performLayout(Rectangle< int >)
Definition juce_Grid.cpp:1018
AutoFlow autoFlow
Definition juce_Grid.h:176
JustifyItems justifyItems
Definition juce_Grid.h:164
Grid()=default
JustifyItems
Definition juce_Grid.h:105
TrackInfo autoRows
Definition juce_Grid.h:190
Array< TrackInfo > templateRows
Definition juce_Grid.h:184
void setGap(Px sizeInPixels) noexcept
Definition juce_Grid.h:201
Px columnGap
Definition juce_Grid.h:196
JustifyContent justifyContent
Definition juce_Grid.h:170
JustifyContent
Definition juce_Grid.h:123
int getNumberOfColumns() const noexcept
Definition juce_Grid.h:213
StringArray templateAreas
Definition juce_Grid.h:187
AlignContent
Definition juce_Grid.h:135
Array< TrackInfo > templateColumns
Definition juce_Grid.h:181
AlignContent alignContent
Definition juce_Grid.h:173
AlignItems alignItems
Definition juce_Grid.h:167
Px rowGap
Definition juce_Grid.h:198
AlignItems
Definition juce_Grid.h:114
~Grid() noexcept=default
AutoFlow
Definition juce_Grid.h:147
Array< GridItem > items
Definition juce_Grid.h:205
int getNumberOfRows() const noexcept
Definition juce_Grid.h:215
Definition juce_Rectangle.h:67
Definition juce_StringArray.h:35
Definition juce_String.h:53
unsigned f
Definition inflate.c:1572
virtual ASIOError start()=0
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Definition juce_RangedDirectoryIterator.h:184
@ column
Definition juce_AccessibilityRole.h:52
@ row
Definition juce_AccessibilityRole.h:53
Definition juce_Grid.h:56
constexpr Fr(unsigned long long p)
Definition juce_Grid.h:58
Fr(int f)
Definition juce_Grid.h:57
unsigned long long fraction
Definition juce_Grid.h:60
Definition juce_Grid.h:45
Px(int p)
Definition juce_Grid.h:47
long double pixels
Definition juce_Grid.h:51
Px(float p)
Definition juce_Grid.h:46
constexpr Px(unsigned long long p)
Definition juce_Grid.h:49
constexpr Px(long double p)
Definition juce_Grid.h:48
Definition juce_Grid.h:66
const String & getStartLineName() const noexcept
Definition juce_Grid.h:85
bool isFraction
Definition juce_Grid.h:96
bool hasKeyword
Definition juce_Grid.h:97
String endLineName
Definition juce_Grid.h:99
const String & getEndLineName() const noexcept
Definition juce_Grid.h:86
float getAbsoluteSize(float relativeFractionalUnit) const
Definition juce_Grid.cpp:1012
friend class Grid
Definition juce_Grid.h:92
bool isAuto() const noexcept
Definition juce_Grid.h:82
TrackInfo() noexcept
Definition juce_Grid.cpp:968
bool isPixels() const noexcept
Definition juce_Grid.h:84
bool isFractional() const noexcept
Definition juce_Grid.h:83
float getSize() const noexcept
Definition juce_Grid.h:89
float size
Definition juce_Grid.h:95
String startLineName
Definition juce_Grid.h:99
uch * p
Definition crypt.c:594
#define const
Definition zconf.h:137