8
8
9
9
#include < elements/view.hpp>
10
10
#include < elements/element/composite.hpp>
11
+ #include < elements/element/margin.hpp>
11
12
#include < memory>
12
13
13
14
namespace cycfi ::elements
@@ -32,7 +33,7 @@ namespace cycfi::elements
32
33
33
34
using vtile_composite = vector_composite<vtile_element>;
34
35
35
- template <typename ... E>
36
+ template <concepts::Element ... E>
36
37
inline auto vtile (E&&... elements)
37
38
{
38
39
using composite = array_composite<sizeof ...(elements), vtile_element>;
@@ -42,6 +43,23 @@ namespace cycfi::elements
42
43
return r;
43
44
}
44
45
46
+ template <concepts::Element FE, concepts::Element... E>
47
+ inline auto vtile_spaced (float space, FE&& first, E&&... rest)
48
+ {
49
+ using composite = array_composite<1 +(sizeof ...(rest)), vtile_element>;
50
+ composite r{};
51
+
52
+ std::size_t i = 0 ;
53
+ r[i] = share (std::forward<FE>(first));
54
+ auto fill_interleaved = [&, i = 1 ](auto && e) mutable
55
+ {
56
+ r[i++] = share (margin_top (space, std::forward<decltype (e)>(e)));
57
+ };
58
+
59
+ (fill_interleaved (rest), ...);
60
+ return r;
61
+ }
62
+
45
63
// //////////////////////////////////////////////////////////////////////////
46
64
// Horizontal Tiles
47
65
// //////////////////////////////////////////////////////////////////////////
@@ -62,7 +80,7 @@ namespace cycfi::elements
62
80
63
81
using htile_composite = vector_composite<htile_element>;
64
82
65
- template <typename ... E>
83
+ template <concepts::Element ... E>
66
84
inline auto htile (E&&... elements)
67
85
{
68
86
using composite = array_composite<sizeof ...(elements), htile_element>;
@@ -71,6 +89,23 @@ namespace cycfi::elements
71
89
r = container{{share (std::forward<E>(elements))...}};
72
90
return r;
73
91
}
92
+
93
+ template <concepts::Element FE, concepts::Element... E>
94
+ inline auto htile_spaced (float space, FE&& first, E&&... rest)
95
+ {
96
+ using composite = array_composite<1 +(sizeof ...(rest)), htile_element>;
97
+ composite r{};
98
+
99
+ std::size_t i = 0 ;
100
+ r[i] = share (std::forward<FE>(first));
101
+ auto fill_interleaved = [&, i = 1 ](auto && e) mutable
102
+ {
103
+ r[i++] = share (margin_left (space, std::forward<decltype (e)>(e)));
104
+ };
105
+
106
+ (fill_interleaved (rest), ...);
107
+ return r;
108
+ }
74
109
}
75
110
76
111
#endif
0 commit comments