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/// @brief FlexboxConfig is a configuration structure that defines the layout
16/// properties for a flexbox container.
17//
18/// It allows you to specify the direction of the flex items, whether they
19/// should wrap, how they should be justified along the main axis, and how
20/// they should be aligned along the cross axis.
21/// It also includes properties for gaps between flex items in both the
22/// main and cross axes.
23/// This structure is used to configure the layout behavior of flexbox
24/// containers in a terminal user interface.
25///
26/// @ingroup dom
28 /// This establishes the main-axis, thus defining the direction flex items are
29 /// placed in the flex container. Flexbox is (aside wrapping) single-direction
30 /// layout concept. Think of flex items as primarily laying out either in
31 /// horizontal rows or vertical columns.
32 enum class Direction {
33 Row, ///< Flex items are laid out in a row.
34 RowInversed, ///< Flex items are laid out in a row, but in reverse order.
35 Column, ///< Flex items are laid out in a column.
36 ColumnInversed ///< Flex items are laid out in a column, but in reverse
37 ///< order.
38 };
40
41 /// By default, flex items will all try to fit onto one line. You can change
42 /// that and allow the items to wrap as needed with this property.
43 enum class Wrap {
44 NoWrap, ///< Flex items will all try to fit onto one line.
45 Wrap, ///< Flex items will wrap onto multiple lines.
46 WrapInversed, ///< Flex items will wrap onto multiple lines, but in reverse
47 ///< order.
48 };
50
51 /// This defines the alignment along the main axis. It helps distribute extra
52 /// free space leftover when either all the flex items on a line are
53 /// inflexible, or are flexible but have reached their maximum size. It also
54 /// exerts some control over the alignment of items when they overflow the
55 /// line.
56 enum class JustifyContent {
57 /// Items are aligned to the start of flexbox's direction.
59 /// Items are aligned to the end of flexbox's direction.
60 FlexEnd,
61 /// Items are centered along the line.
62 Center,
63 /// Items are stretched to fill the line.
64 Stretch,
65 /// Items are evenly distributed in the line; first item is on the start
66 // line, last item on the end line
68 /// Items are evenly distributed in the line with equal space around them.
69 /// Note that visually the spaces aren’t equal, since all the items have
70 /// equal space on both sides. The first item will have one unit of space
71 /// against the container edge, but two units of space between the next item
72 /// because that next item has its own spacing that applies.
74 /// Items are distributed so that the spacing between any two items (and the
75 /// space to the edges) is equal.
77 };
79
80 /// This defines the default behavior for how flex items are laid out along
81 /// the cross axis on the current line. Think of it as the justify-content
82 /// version for the cross-axis (perpendicular to the main-axis).
83 enum class AlignItems {
84 FlexStart, ///< items are placed at the start of the cross axis.
85 FlexEnd, ///< items are placed at the end of the cross axis.
86 Center, ///< items are centered along the cross axis.
87 Stretch, ///< items are stretched to fill the cross axis.
88 };
90
91 // This aligns a flex container’s lines within when there is extra space in
92 // the cross-axis, similar to how justify-content aligns individual items
93 // within the main-axis.
94 enum class AlignContent {
95 FlexStart, ///< items are placed at the start of the cross axis.
96 FlexEnd, ///< items are placed at the end of the cross axis.
97 Center, ///< items are centered along the cross axis.
98 Stretch, ///< items are stretched to fill the cross axis.
99 SpaceBetween, ///< items are evenly distributed in the cross axis.
100 SpaceAround, ///< tems evenly distributed with equal space around each
101 ///< line.
102 SpaceEvenly, ///< items are evenly distributed in the cross axis with equal
103 ///< space around them.
104 };
106
107 int gap_x = 0;
108 int gap_y = 0;
109
110 // Constructor pattern. For chained use like:
111 // ```
112 // FlexboxConfig()
113 // .Set(FlexboxConfig::Direction::Row)
114 // .Set(FlexboxConfig::Wrap::Wrap);
115 // ```
121 FlexboxConfig& SetGap(int gap_x, int gap_y);
122};
123
124} // namespace ftxui
125
126#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