FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
flexbox_config.hpp
Go to the documentation of this file.
1// Copyright 2021 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_DOM_FLEXBOX_CONFIG_HPP
5#define FTXUI_DOM_FLEXBOX_CONFIG_HPP
6
7/*
8 This replicate the CSS flexbox model.
9 See guide for documentation:
10 https://css-tricks.com/snippets/css/a-guide-to-flexbox/
11*/
12
13namespace ftxui {
14
15
16/// @brief FlexboxConfig is a configuration structure that defines the layout
17/// properties for a flexbox container.
18//
19/// It allows you to specify the direction of the flex items, whether they
20/// should wrap, how they should be justified along the main axis, and how
21/// they should be aligned along the cross axis.
22/// It also includes properties for gaps between flex items in both the
23/// main and cross axes.
24/// This structure is used to configure the layout behavior of flexbox
25/// containers in a terminal user interface.
26///
27/// @ingroup dom
29 /// This establishes the main-axis, thus defining the direction flex items are
30 /// placed in the flex container. Flexbox is (aside wrapping) single-direction
31 /// layout concept. Think of flex items as primarily laying out either in
32 /// horizontal rows or vertical columns.
33 enum class Direction {
34 Row, ///< Flex items are laid out in a row.
35 RowInversed, ///< Flex items are laid out in a row, but in reverse order.
36 Column, ///< Flex items are laid out in a column.
37 ColumnInversed ///< Flex items are laid out in a column, but in reverse
38 ///< order.
39 };
41
42 /// By default, flex items will all try to fit onto one line. You can change
43 /// that and allow the items to wrap as needed with this property.
44 enum class Wrap {
45 NoWrap, ///< Flex items will all try to fit onto one line.
46 Wrap, ///< Flex items will wrap onto multiple lines.
47 WrapInversed, ///< Flex items will wrap onto multiple lines, but in reverse
48 ///< order.
49 };
51
52 /// This defines the alignment along the main axis. It helps distribute extra
53 /// free space leftover when either all the flex items on a line are
54 /// inflexible, or are flexible but have reached their maximum size. It also
55 /// exerts some control over the alignment of items when they overflow the
56 /// line.
57 enum class JustifyContent {
58 /// Items are aligned to the start of flexbox's direction.
60 /// Items are aligned to the end of flexbox's direction.
61 FlexEnd,
62 /// Items are centered along the line.
63 Center,
64 /// Items are stretched to fill the line.
65 Stretch,
66 /// Items are evenly distributed in the line; first item is on the start
67 // line, last item on the end line
69 /// Items are evenly distributed in the line with equal space around them.
70 /// Note that visually the spaces aren’t equal, since all the items have
71 /// equal space on both sides. The first item will have one unit of space
72 /// against the container edge, but two units of space between the next item
73 /// because that next item has its own spacing that applies.
75 /// Items are distributed so that the spacing between any two items (and the
76 /// space to the edges) is equal.
78 };
80
81 /// This defines the default behavior for how flex items are laid out along
82 /// the cross axis on the current line. Think of it as the justify-content
83 /// version for the cross-axis (perpendicular to the main-axis).
84 enum class AlignItems {
85 FlexStart, ///< items are placed at the start of the cross axis.
86 FlexEnd, ///< items are placed at the end of the cross axis.
87 Center, ///< items are centered along the cross axis.
88 Stretch, ///< items are stretched to fill the cross axis.
89 };
91
92 // This aligns a flex container’s lines within when there is extra space in
93 // the cross-axis, similar to how justify-content aligns individual items
94 // within the main-axis.
95 enum class AlignContent {
96 FlexStart, ///< items are placed at the start of the cross axis.
97 FlexEnd, ///< items are placed at the end of the cross axis.
98 Center, ///< items are centered along the cross axis.
99 Stretch, ///< items are stretched to fill the cross axis.
100 SpaceBetween, ///< items are evenly distributed in the cross axis.
101 SpaceAround, ///< tems evenly distributed with equal space around each
102 ///< line.
103 SpaceEvenly, ///< items are evenly distributed in the cross axis with equal
104 ///< space around them.
105 };
107
108 int gap_x = 0;
109 int gap_y = 0;
110
111 // Constructor pattern. For chained use like:
112 // ```
113 // FlexboxConfig()
114 // .Set(FlexboxConfig::Direction::Row)
115 // .Set(FlexboxConfig::Wrap::Wrap);
116 // ```
122 FlexboxConfig& SetGap(int gap_x, int gap_y);
123};
124
125} // namespace ftxui
126
127#endif // FTXUI_DOM_FLEXBOX_CONFIG_HPP
@ FlexStart
items are placed at the start of 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.
@ FlexStart
items are placed at the start of the cross axis.
FlexboxConfig & SetGap(int gap_x, int gap_y)
Set the flexbox flex direction.
JustifyContent justify_content
@ 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.
FlexboxConfig & Set(FlexboxConfig::Direction)
Set the flexbox direction.
FlexboxConfig is a configuration structure that defines the layout properties for a flexbox container...
The FTXUI ftxui:: namespace.
Definition animation.hpp:10