FTXUI  0.8.1
C++ functional terminal UI.
composite_decorator.cpp
Go to the documentation of this file.
1 
2 #include <utility> // for move
3 
4 #include "ftxui/dom/elements.hpp" // for Element, filler, operator|, hbox, flex_grow, vbox, xflex_grow, yflex_grow, align_right, center, hcenter, vcenter
5 
6 namespace ftxui {
7 
8 /// @brief Center an element horizontally.
9 /// @param child The decorated element.
10 /// @return The centered element.
11 /// @ingroup dom
13  return hbox(filler(), std::move(child), filler()) | xflex_grow;
14 }
15 
16 /// @brief Center an element vertically.
17 /// @param child The decorated element.
18 /// @return The centered element.
19 /// @ingroup dom
21  return vbox(filler(), std::move(child), filler()) | yflex_grow;
22 }
23 
24 /// @brief Center an element horizontally and vertically.
25 /// @param child The decorated element.
26 /// @return The centered element.
27 /// @ingroup dom
29  return hcenter(vcenter(std::move(child))) | flex_grow;
30 }
31 
32 /// @brief Align an element on the right side.
33 /// @param child The decorated element.
34 /// @return The right aligned element.
35 /// @ingroup dom
37  return hbox(filler(), std::move(child)) | flex_grow;
38 }
39 
40 } // namespace ftxui
41 
42 // Copyright 2020 Arthur Sonzogni. All rights reserved.
43 // Use of this source code is governed by the MIT license that can be found in
44 // the LICENSE file.
ftxui::flex_grow
Element flex_grow(Element)
Expand if possible.
Definition: flex.cpp:137
ftxui::center
Element center(Element)
Center an element horizontally and vertically.
Definition: composite_decorator.cpp:28
ftxui::align_right
Element align_right(Element)
Align an element on the right side.
Definition: composite_decorator.cpp:36
ftxui
Definition: captured_mouse.hpp:6
ftxui::vcenter
Element vcenter(Element)
Center an element vertically.
Definition: composite_decorator.cpp:20
ftxui::filler
Element filler()
An element that will take expand proportionnally to the space left in a container.
Definition: flex.cpp:94
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:75
elements.hpp
ftxui::Element
std::shared_ptr< Node > Element
Definition: elements.hpp:15
ftxui::xflex_grow
Element xflex_grow(Element)
Expand if possible on the X axis.
Definition: flex.cpp:143
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition: vbox.cpp:76
ftxui::hcenter
Element hcenter(Element)
Center an element horizontally.
Definition: composite_decorator.cpp:12
ftxui::yflex_grow
Element yflex_grow(Element)
Expand if possible on the Y axis.
Definition: flex.cpp:149