18 std::swap(
c.gap_x,
c.gap_y);
19 switch (
c.direction) {
36 switch (
c.direction) {
63 std::swap(
g.size_x,
g.size_y);
64 for (
auto&
b :
g.blocks) {
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);
75 for (
auto&
b :
g.blocks) {
76 b.x =
g.size_x -
b.x -
b.dim_x;
82 for (
auto&
b :
g.blocks) {
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) {
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) {
149 switch (
g.config.align_content) {
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);
213 switch (
g.config.align_items) {
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();
246 switch (
g.config.justify_content) {
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 = line.blocks.size();
336 line.blocks.push_back(&
block);
339 if (!line.blocks.empty()) {
340 lines.push_back(std::move(line));
void Compute(std::vector< Element > *elements, int target_size)
void Compute(Global &global)
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Component Slider(SliderOption< T > options)
A slider in any direction.
@ Center
items are centered along the cross axis.
@ FlexStart
items are placed at the start of the cross axis.
@ FlexEnd
items are placed at the end of the cross axis.
@ SpaceBetween
items are evenly distributed in the cross axis.
@ Stretch
items are stretched to fill the cross axis.
@ Column
Flex items are laid out in a column.
@ Row
Flex items are laid out in a row.
@ RowInversed
Flex items are laid out in a row, but in reverse order.
@ NoWrap
Flex items will all try to fit onto one line.
@ Wrap
Flex items will wrap onto multiple lines.
@ Center
items are centered along the cross axis.
@ FlexStart
items are placed at the start of the cross axis.
@ FlexEnd
items are placed at the end of the cross axis.
@ Stretch
items are stretched to fill the cross axis.
@ Center
Items are centered along the line.
@ FlexStart
Items are aligned to the start of flexbox's direction.
@ FlexEnd
Items are aligned to the end of flexbox's direction.
@ SpaceBetween
Items are evenly distributed in the line; first item is on the start.
@ Stretch
Items are stretched to fill the line.