65 std::swap(b.min_size_x, b.min_size_y);
66 std::swap(b.flex_grow_x, b.flex_grow_y);
67 std::swap(b.flex_shrink_x, b.flex_shrink_y);
69 std::swap(b.dim_x, b.dim_y);
76 b.x = g.
size_x - b.x - b.dim_x;
83 b.y = g.
size_y - b.y - b.dim_y;
88 std::vector<Block*> blocks;
92 for (
auto& line :
lines) {
93 std::vector<box_helper::Element>
elements;
94 elements.reserve(line.blocks.size());
95 for (
auto*
block : line.blocks) {
99 block->flex_grow_x != 0 ||
global.config.justify_content ==
109 global.size_x -
global.config.gap_x * (
int(line.blocks.size()) - 1));
112 for (
size_t i = 0; i < line.blocks.size(); ++i) {
113 line.blocks[i]->dim_x =
elements[i].size;
114 line.blocks[i]->x = x;
123 std::vector<box_helper::Element>
elements;
125 for (
auto& line :
lines) {
127 element.
flex_shrink = line.blocks.front()->flex_shrink_y;
128 element.
flex_grow = line.blocks.front()->flex_grow_y;
129 for (
auto*
block : line.blocks) {
143 for (
size_t i = 0; i <
elements.size(); ++i) {
155 for (
size_t i = 0; i <
ys.size(); ++i) {
162 for (
size_t i = 0; i <
ys.size(); ++i) {
169 for (
int i =
static_cast<int>(
ys.size()) - 1; i >= 0; --i) {
180 for (
int i =
static_cast<int>(
ys.size()) - 1; i >= 1; --i) {
188 for (
int i =
static_cast<int>(
ys.size()) - 1; i >= 0; --i) {
196 for (
int i =
static_cast<int>(
ys.size()) - 1; i >= 0; --i) {
205 for (
size_t i = 0; i <
lines.size(); ++i) {
209 block->flex_grow_y != 0 ||
212 stretch ? element.size : std::min(element.size,
block->min_size_y);
234 block->dim_y = element.size;
242void JustifyContent(
Global& g, std::vector<Line>
lines) {
243 for (
auto& line :
lines) {
244 Block* last = line.blocks.back();
252 for (
auto*
block : line.blocks) {
259 for (
auto*
block : line.blocks) {
266 for (
int i = (
int)line.blocks.size() - 1; i >= 1; --i) {
274 for (
int i = (
int)line.blocks.size() - 1; i >= 0; --i) {
282 for (
int i = (
int)line.blocks.size() - 1; i >= 0; --i) {
318 std::vector<Line>
lines;
322 line.blocks.reserve(
global.blocks.size());
328 if (!line.blocks.empty()) {
329 lines.push_back(std::move(line));
335 block.line_position =
static_cast<int>(line.blocks.size());
336 line.blocks.push_back(&
block);
339 if (!line.blocks.empty()) {
340 lines.push_back(std::move(line));