FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
tab_horizontal.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSE ファイルにあるMITライセンスによって管理されています。
3#include <memory> // for allocator, __shared_ptr_access, shared_ptr
4#include <string> // for string, basic_string
5#include <vector> // for vector
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for Radiobox, Renderer, Tab, Toggle, Vertical
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for Element, separator, operator|, vbox, border
12
13using namespace ftxui;
14
15int main() {
16 std::vector<std::string> tab_values{
17 "tab_1",
18 "tab_2",
19 "tab_3",
20 };
21 int tab_selected = 0;
22 auto tab_toggle = Toggle(&tab_values, &tab_selected);
23
24 std::vector<std::string> tab_1_entries{
25 "Forest",
26 "Water",
27 "I don't know",
28 };
29 int tab_1_selected = 0;
30
31 std::vector<std::string> tab_2_entries{
32 "Hello",
33 "Hi",
34 "Hay",
35 };
36 int tab_2_selected = 0;
37
38 std::vector<std::string> tab_3_entries{
39 "Table",
40 "Nothing",
41 "Is",
42 "Empty",
43 };
44 int tab_3_selected = 0;
45 auto tab_container = Container::Tab(
46 {
47 Radiobox(&tab_1_entries, &tab_1_selected),
48 Radiobox(&tab_2_entries, &tab_2_selected),
49 Radiobox(&tab_3_entries, &tab_3_selected),
50 },
51 &tab_selected);
52
53 auto container = Container::Vertical({
54 tab_toggle,
55 tab_container,
56 });
57
58 auto renderer = Renderer(container, [&] {
59 return vbox({
60 tab_toggle->Render(),
61 separator(),
62 tab_container->Render(),
63 }) |
64 border;
65 });
66
68 screen.Loop(renderer);
69}
static ScreenInteractive TerminalOutput()
ターミナル出力の幅に一致し、描画されるコンポーネントの高さに一致するScreenInteractiveを作成します。
Component Toggle(ConstStringListRef entries, int *selected)
要素の水平リスト。ユーザーはこれらを操作できます。
Component Radiobox(RadioboxOption options)
1つだけ選択できる要素のリスト。
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
virtual void Render(Screen &screen)
要素をftxui::Screenに表示します。
Definition node.cpp:59
Element vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element separator()
int main()