45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143 | auto c = planet::ui::expandable_row{
0,
std::tuple{
planet::debug::fixed_element{log, {4, 3}},
planet::debug::fixed_element{log, {4, 3}}},
2.0f};
c.reflow({.screen = screen}, screen);
c.move_to({.screen = screen}, full);
check(c.position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{10, 3}};
check(std::get<0>(c.items).position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{4, 3}};
check(std::get<1>(c.items).position())
== planet::affine::rectangle2d{
{21, 20}, planet::affine::extents2d{4, 3}};
});
auto const taken =
suite.test("the offer is taken", [](auto check, auto &log) {
auto c = planet::ui::expandable_row{
0,
std::tuple{
filling_element{3},
planet::debug::fixed_element{log, {4, 3}}},
2.0f};
c.reflow({.screen = screen}, screen);
c.move_to({.screen = screen}, full);
check(c.position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{100, 3}};
check(std::get<0>(c.items).position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{94, 3}};
check(std::get<1>(c.items).position())
== planet::affine::rectangle2d{
{111, 20}, planet::affine::extents2d{4, 3}};
});
auto const middle =
suite.test("expanding in the middle", [](auto check, auto &log) {
auto c = planet::ui::expandable_row{
1,
std::tuple{
planet::debug::fixed_element{log, {4, 3}},
filling_element{3},
planet::debug::fixed_element{log, {4, 3}}},
2.0f};
c.reflow({.screen = screen}, screen);
c.move_to({.screen = screen}, full);
check(c.position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{100, 3}};
check(std::get<0>(c.items).position())
== planet::affine::rectangle2d{
{15, 20}, planet::affine::extents2d{4, 3}};
check(std::get<1>(c.items).position())
== planet::affine::rectangle2d{
{21, 20}, planet::affine::extents2d{88, 3}};
check(std::get<2>(c.items).position())
== planet::affine::rectangle2d{
{111, 20}, planet::affine::extents2d{4, 3}};
});
auto const constraints = suite.test(
"the expanding item is offered the left over width during reflow",
[](auto check, auto &log) {
auto c = planet::ui::expandable_row{
1,
std::tuple{
planet::debug::fixed_element{log, {4, 3}},
filling_element{3}},
2.0f};
c.reflow({.screen = screen}, screen);
check(c.constraints().extents())
== planet::affine::extents2d{100, 3};
});
auto const range = suite.test(
"the expanding index must be an item", [](auto check, auto &log) {
auto c = planet::ui::expandable_row{
1,
std::tuple{planet::debug::fixed_element{log, {4, 3}}}};
check([&]() {
c.reflow({.screen = screen}, screen);
}).template throws_type<felspar::stdexcept::logic_error>();
});
}
|