11
11
12
12
namespace cycfi ::elements
13
13
{
14
- // //////////////////////////////////////////////////////////////////////////
15
- // grid_base: Base class for vertical and horizontal grids, supplies grid
16
- // coordinates in the form of a float const*
17
- // //////////////////////////////////////////////////////////////////////////
14
+ /* *
15
+ * \struct grid_base
16
+ *
17
+ * \brief
18
+ * Base class for vertical and horizontal grids in a grid layout.
19
+ * Provides supplies grid coordinates.
20
+ *
21
+ * `grid_base` provides the core functionality shared by all grid-like
22
+ * structures, such as being able to determine their size, map index to
23
+ * a coordinate, and get a number of spans.
24
+ */
18
25
struct grid_base : public composite_base
19
26
{
20
27
virtual std::size_t grid_size () const = 0;
21
28
virtual float grid_coord (std::size_t i) const = 0;
22
29
virtual std::size_t num_spans () const = 0;
23
30
};
24
31
32
+ /* *
33
+ * \class equal_grid
34
+ *
35
+ * \brief
36
+ * A specialized grid where grid columns (or rows) have equal size.
37
+ *
38
+ * \tparam Base
39
+ * The base class on which `equal_grid` is derived from.
40
+ */
25
41
template <typename Base>
26
42
class equal_grid : public Base
27
43
{
@@ -34,6 +50,17 @@ namespace cycfi::elements
34
50
{ return float (i+1 ) / this ->num_spans (); }
35
51
};
36
52
53
+ /* *
54
+ * \class range_grid
55
+ *
56
+ * \brief
57
+ * A specialized grid that lays out cells based on a supplied array of
58
+ * coordinates in the form of a pointer to a float array (`float
59
+ * const*`).
60
+ *
61
+ * \tparam Base
62
+ * The base class on which `range_grid` derived from.
63
+ */
37
64
template <typename Base>
38
65
class range_grid : public Base
39
66
{
@@ -62,6 +89,26 @@ namespace cycfi::elements
62
89
};
63
90
}
64
91
92
+ /* *
93
+ * \class container_grid
94
+ *
95
+ * \brief
96
+ * A specialized grid that lays out cells based on coordinates provided
97
+ * by a container.
98
+ *
99
+ * `container_grid` is a grid where the size and coordinates of cells
100
+ * are defined by the elements of a container that is given at
101
+ * construction time. `container_grid` does not manage and does not own
102
+ * the container.
103
+ *
104
+ * \tparam Container
105
+ * The type of container which provides data for the grid coordinates.
106
+ * The Container should satisfy the `GridContainer` concept.
107
+ *
108
+ * \tparam Base
109
+ * The base class on which `container_grid` is derived from. The base
110
+ * class should satisfy the `Composite` concept.
111
+ */
65
112
template <concepts::GridContainer Container, concepts::Composite Base>
66
113
class container_grid : public Base
67
114
{
@@ -79,9 +126,13 @@ namespace cycfi::elements
79
126
Container const & _container;
80
127
};
81
128
82
- // //////////////////////////////////////////////////////////////////////////
83
- // Vertical Grids
84
- // //////////////////////////////////////////////////////////////////////////
129
+ /* *
130
+ * \class vgrid_element
131
+ *
132
+ * \brief
133
+ * A specialized grid class that provides layout features for a
134
+ * vertical grid structure.
135
+ */
85
136
class vgrid_element : public grid_base
86
137
{
87
138
public:
@@ -101,6 +152,29 @@ namespace cycfi::elements
101
152
container_grid<std::vector<float >, vgrid_element>
102
153
>;
103
154
155
+ /* *
156
+ * \brief
157
+ * Create vertical grid layout, given row coordinates as a C-style
158
+ * array.
159
+ *
160
+ * \tparam N
161
+ * The number of rows.
162
+ *
163
+ * \tparam E
164
+ * A parameter pack representing a variadic template parameter. It
165
+ * consists of the elements put into grid cells.
166
+ *
167
+ * \param coords
168
+ * C-style array with coordinates for grid cells.
169
+ *
170
+ * \param elements
171
+ * Elements intended to place in grid cells.
172
+ *
173
+ * \returns
174
+ * A vertical grid element represented as an instance of
175
+ * `array_composite` that is derived from `range_grid<vgrid_element>`.
176
+ * The row coordinates are provided by the `coords` parameter.
177
+ */
104
178
template <std::size_t N, typename ... E>
105
179
inline auto vgrid (float const (&coords)[N], E&&... elements)
106
180
{
@@ -111,13 +185,53 @@ namespace cycfi::elements
111
185
return r;
112
186
}
113
187
188
+ /* *
189
+ * \brief
190
+ * Create a vertical grid layout, given row coordinates as an
191
+ * `std::array`.
192
+ *
193
+ * \tparam N
194
+ * The number of rows.
195
+ *
196
+ * \tparam E
197
+ * A parameter pack representing a variadic template parameter. It
198
+ * consists of the elements put into grid cells.
199
+ *
200
+ * \param coords
201
+ * `std::array` with coordinates for grid cells.
202
+ *
203
+ * \param elements
204
+ * Elements intended to place in grid cells.
205
+ *
206
+ * \returns
207
+ * A vertical grid element represented as an instance of
208
+ * `array_composite` that is derived from `range_grid<vgrid_element>`.
209
+ * The row coordinates are provided by the `coords` parameter.
210
+ */
114
211
template <std::size_t N, typename ... E>
115
212
inline auto vgrid (std::array<float , N> const & coords, E&&... elements)
116
213
{
117
214
using plain_array = float const (&)[N];
118
215
return vgrid (plain_array (*coords.data ()), std::forward<E>(elements)...);
119
216
}
120
217
218
+ /* *
219
+ * \brief
220
+ * Create a vertical grid layout, given the elements to place in
221
+ * equally sized rows.
222
+ *
223
+ * \tparam E
224
+ * A parameter pack representing a variadic template parameter. It
225
+ * consists of the elements put into grid cells.
226
+ *
227
+ * \param elements
228
+ * Elements intended to place in grid cells.
229
+ *
230
+ * \returns
231
+ * A vertical grid element represented as an instance of
232
+ * `array_composite` that is derived from `equal_grid<vgrid_element>.
233
+ * The rows are equally spaced.
234
+ */
121
235
template <typename ... E>
122
236
inline auto vgrid (E&&... elements)
123
237
{
@@ -128,9 +242,13 @@ namespace cycfi::elements
128
242
return r;
129
243
}
130
244
131
- // //////////////////////////////////////////////////////////////////////////
132
- // Horizontal Grids
133
- // //////////////////////////////////////////////////////////////////////////
245
+ /* *
246
+ * \class hgrid_element
247
+ *
248
+ * \brief
249
+ * A specialized grid class that provides layout features for a
250
+ * horizontal grid structure.
251
+ */
134
252
class hgrid_element : public grid_base
135
253
{
136
254
public:
@@ -150,6 +268,29 @@ namespace cycfi::elements
150
268
container_grid<std::vector<float >, hgrid_element>
151
269
>;
152
270
271
+ /* *
272
+ * \brief
273
+ * Create horizontal grid layout, given column coordinates as a C-style
274
+ * array.
275
+ *
276
+ * \tparam N
277
+ * The number of columns.
278
+ *
279
+ * \tparam E
280
+ * A parameter pack representing a variadic template parameter. It
281
+ * consists of the elements put into grid cells.
282
+ *
283
+ * \param coords
284
+ * C-style array with coordinates for grid cells.
285
+ *
286
+ * \param elements
287
+ * Elements intended to place in grid cells.
288
+ *
289
+ * \returns
290
+ * A horizontal grid element represented as an instance of
291
+ * `array_composite` that is derived from `range_grid<hgrid_element>`.
292
+ * The column coordinates are provided by the `coords` parameter.
293
+ */
153
294
template <std::size_t N, typename ... E>
154
295
inline auto hgrid (float const (&coords)[N], E&&... elements)
155
296
{
@@ -160,13 +301,53 @@ namespace cycfi::elements
160
301
return r;
161
302
}
162
303
304
+ /* *
305
+ * \brief
306
+ * Create a horizontal grid layout, given column coordinates as an
307
+ * `std::array`.
308
+ *
309
+ * \tparam N
310
+ * The number of columns.
311
+ *
312
+ * \tparam E
313
+ * A parameter pack representing a variadic template parameter. It
314
+ * consists of the elements put into grid cells.
315
+ *
316
+ * \param coords
317
+ * `std::array` with coordinates for grid cells.
318
+ *
319
+ * \param elements
320
+ * Elements intended to place in grid cells.
321
+ *
322
+ * \returns
323
+ * A horizontal grid element represented as an instance of
324
+ * `array_composite` that is derived from `range_grid<hgrid_element>`.
325
+ * The column coordinates are provided by the `coords` parameter.
326
+ */
163
327
template <std::size_t N, typename ... E>
164
328
inline auto hgrid (std::array<float , N> const & coords, E&&... elements)
165
329
{
166
330
using plain_array = float const (&)[N];
167
331
return hgrid (plain_array (*coords.data ()), std::forward<E>(elements)...);
168
332
}
169
333
334
+ /* *
335
+ * \brief
336
+ * Create a horizontal grid layout, given the elements to place in
337
+ * equally sized grid cells.
338
+ *
339
+ * \tparam E
340
+ * A parameter pack representing a variadic template parameter. It
341
+ * consists of the elements put into grid cells.
342
+ *
343
+ * \param elements
344
+ * Elements intended to place in grid cells.
345
+ *
346
+ * \returns
347
+ * A horizontal grid element represented as an instance of
348
+ * `array_composite` that is derived from `equal_grid<hgrid_element>.
349
+ * The columns are equally spaced.
350
+ */
170
351
template <typename ... E>
171
352
inline auto hgrid (E&&... elements)
172
353
{
0 commit comments