FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
hflow.cpp
Go to the documentation of this file.
1// Copyright 2020 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#include <stdio.h> // for getchar
5#include <ftxui/dom/elements.hpp> // for operator|, size, Element, text, hcenter, Decorator, Fit, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
6#include <ftxui/screen/screen.hpp> // for Full, Screen
7#include <string> // for allocator, char_traits, operator+, to_string, string
8
9#include "ftxui/dom/node.hpp" // for Render
10#include "ftxui/screen/color.hpp" // for ftxui
11
12int main() {
13 using namespace ftxui;
14 auto make_box = [](int dimx, int dimy) {
15 std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
16 return window(text(title) | hcenter | bold,
17 text("content") | hcenter | dim) |
18 size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
19 };
20
21 auto style = size(WIDTH, GREATER_THAN, 20) | border |
22 size(HEIGHT, GREATER_THAN, 30) | size(WIDTH, LESS_THAN, 50);
23
24 auto document = hflow({
25 make_box(7, 7),
26 make_box(7, 5),
27 make_box(5, 7),
28 make_box(10, 4),
29 make_box(10, 4),
30 make_box(10, 4),
31 make_box(10, 4),
32 make_box(11, 4),
33 make_box(11, 4),
34 make_box(11, 4),
35 make_box(11, 4),
36 make_box(12, 4),
37 make_box(12, 5),
38 make_box(12, 4),
39 make_box(13, 4),
40 make_box(13, 3),
41 make_box(13, 3),
42 make_box(10, 3),
43 }) |
44 style;
45
46 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
47 Render(screen, document);
48 screen.Print();
49 getchar();
50
51 return 0;
52}
Element make_box(int x, int y)
int main()
Definition hflow.cpp:12
The FTXUI ftxui:: namespace.
Definition animation.hpp:10