FTXUI  0.9.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
elements.hpp
Go to the documentation of this file.
1#ifndef FTXUI_DOM_ELEMENTS_HPP
2#define FTXUI_DOM_ELEMENTS_HPP
3
4#include <functional>
5#include <memory>
6
7#include "ftxui/dom/node.hpp"
12
13namespace ftxui {
14class Node;
15using Element = std::shared_ptr<Node>;
16using Elements = std::vector<Element>;
17using Decorator = std::function<Element(Element)>;
18using GraphFunction = std::function<std::vector<int>(int, int)>;
19
21
22// Pipe elements into decorator togethers.
23// For instance the next lines are equivalents:
24// -> text("ftxui") | bold | underlined
25// -> underlined(bold(text("FTXUI")))
29
30// --- Widget ---
31Element text(std::string text);
32Element vtext(std::string text);
33Element separator(void);
39Element gauge(float ratio);
47Element window(Element title, Element content);
48Element spinner(int charset_index, size_t image_index);
49Elements paragraph(std::string text); // Use inside hflow(). Split by space.
51
52// -- Decorator ---
62
63// --- Layout is
64// Horizontal, Vertical or stacked set of elements.
68Element gridbox(std::vector<Elements> lines);
70
71// -- Flexibility ---
72// Define how to share the remaining space when not all of it is used inside a
73// container.
74Element flex(Element); // Expand/Minimize if possible/needed.
75Element flex_grow(Element); // Expand element if possible.
76Element flex_shrink(Element); // Minimize element if needed.
77
78Element xflex(Element); // Expand/Minimize if possible/needed on X axis.
79Element xflex_grow(Element); // Expand element if possible on X axis.
80Element xflex_shrink(Element); // Minimize element if needed on X axis.
81
82Element yflex(Element); // Expand/Minimize if possible/needed on Y axis.
83Element yflex_grow(Element); // Expand element if possible on Y axis.
84Element yflex_shrink(Element); // Minimize element if needed on Y axis.
85
86Element notflex(Element); // Reset the flex attribute.
87Element filler(); // A blank expandable element.
88
89// -- Size override;
93
94// --
95Decorator reflect(Box& box);
96
97// --- Frame ---
98// A frame is a scrollable area. The internal area is potentially larger than
99// the external one. The internal area is scrolled in order to make visible the
100// focused element.
106
107// --- Util --------------------------------------------------------------------
112Element nothing(Element element);
113
114// Before drawing the |element| clear the pixel below. This is useful in
115// combinaison with dbox.
117
118namespace Dimension {
120} // namespace Dimension
121
122} // namespace ftxui
123
124// Make container able to take any number of children as input.
125#include "ftxui/dom/take_any_args.hpp"
126
127// Include old definitions using wstring.
129#endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */
130
131// Copyright 2020 Arthur Sonzogni. All rights reserved.
132// Use of this source code is governed by the MIT license that can be found in
133// the LICENSE file.
A class representing terminal colors.
Definition color.hpp:17
Dimensions Fit(Element &)
Decorator bgcolor(Color)
Decorate using a background color.
Definition color.cpp:100
Element borderDouble(Element)
Draw a double border around the element.
Definition border.cpp:265
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Definition flex.cpp:125
Element xflex_grow(Element)
Expand if possible on the X axis.
Definition flex.cpp:143
std::function< Element(Element)> Decorator
Definition elements.hpp:17
Element nothing(Element element)
A decoration doing absolutely nothing.
Definition util.cpp:25
@ HEIGHT
Definition elements.hpp:90
@ WIDTH
Definition elements.hpp:90
Element clear_under(Element element)
Before drawing |child|, clear the pixels below. This is useful in.
Element flex(Element)
Make a child element to expand proportionnally to the space left in a container.
Definition flex.cpp:119
Element xframe(Element)
Definition frame.cpp:142
std::shared_ptr< Node > Element
Definition elements.hpp:15
Element hflow(Elements)
A container displaying elements horizontally one by one.
Definition hflow.cpp:75
Decorator borderWith(Pixel)
Same as border but with a constant Pixel around the element.
Definition border.cpp:155
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition bold.cpp:28
Element separatorLight()
Definition separator.cpp:69
Element spinner(int charset_index, size_t image_index)
Useful to represent the effect of time and/or events. This display an ASCII art "video".
Definition spinner.cpp:255
Elements paragraph(std::wstring text)
Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflo...
Definition paragraph.cpp:14
Element borderRounded(Element)
Draw a rounded border around the element.
Definition border.cpp:298
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Definition flex.cpp:131
Element window(Element title, Element content)
Draw window with a title and a border around the element.
Definition border.cpp:323
Element flex_shrink(Element)
Minimize if needed.
Definition flex.cpp:155
Element separator(void)
Definition separator.cpp:61
Element focus(Element)
Definition frame.cpp:79
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:76
Element underlined(Element)
Make the underlined element to be underlined.
Element center(Element)
Center an element horizontally and vertically.
std::vector< Element > Elements
Definition elements.hpp:16
Element borderHeavy(Element)
Draw a heavy border around the element.
Definition border.cpp:232
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition inverted.cpp:29
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:106
Element align_right(Element)
Align an element on the right side.
Element operator|(Element, Decorator)
From an element, apply a decorator.
Definition util.cpp:64
Element yflex_grow(Element)
Expand if possible on the Y axis.
Definition flex.cpp:149
Element flex_grow(Element)
Expand if possible.
Definition flex.cpp:137
Element yframe(Element)
Definition frame.cpp:146
Element notflex(Element)
Make the element not flexible.
Definition flex.cpp:173
Element dbox(Elements)
Stack several element on top of each other.
Definition dbox.cpp:50
Element xflex_shrink(Element)
Minimize if needed on the X axis.
Definition flex.cpp:161
Element vtext(std::wstring text)
Display a piece unicode text vertically.
Definition text.cpp:166
Element borderLight(Element)
Draw a light border around the element.
Definition border.cpp:199
Decorator reflect(Box &box)
Definition reflect.cpp:39
std::function< std::vector< int >(int, int)> GraphFunction
Definition elements.hpp:18
Decorator borderStyled(BorderStyle)
Same as border but with different styles.
Definition border.cpp:164
Element gridbox(std::vector< Elements > lines)
A container displaying a grid of elements.
Definition gridbox.cpp:154
Element filler()
An element that will take expand proportionnally to the space left in a container.
Definition flex.cpp:94
Element dim(Element)
Use a light font, for elements with less emphasis.
Definition dim.cpp:28
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
Definition frame.cpp:138
Element blink(Element)
The text drawn alternates in between visible and hidden.
Definition blink.cpp:28
Element vcenter(Element)
Center an element vertically.
Decorator size(Direction, Constraint, int value)
Apply a constraint on the size of an element.
Definition size.cpp:86
Element separatorDouble()
Definition separator.cpp:75
@ LESS_THAN
Definition elements.hpp:91
@ EQUAL
Definition elements.hpp:91
@ GREATER_THAN
Definition elements.hpp:91
Element gauge(float ratio)
Draw a high definition progress bar.
Definition gauge.cpp:75
Element graph(GraphFunction)
Draw a graph using a GraphFunction.
Definition graph.cpp:59
Element border(Element)
Draw a border around the element.
Definition border.cpp:148
Element separatorHeavy()
Definition separator.cpp:72
Element select(Element)
Definition frame.cpp:38
Element separatorStyled(BorderStyle)
Definition separator.cpp:65
Decorator color(Color)
Decorate using a foreground color.
Definition color.cpp:86
Element yflex_shrink(Element)
Minimize if needed on the Y axis.
Definition flex.cpp:167
Element hcenter(Element)
Center an element horizontally.
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition vbox.cpp:77
BorderStyle
Definition elements.hpp:20
@ DOUBLE
Definition elements.hpp:20
@ HEAVY
Definition elements.hpp:20
@ ROUNDED
Definition elements.hpp:20
@ LIGHT
Definition elements.hpp:20
A unicode character and its associated style.
Definition screen.hpp:16