FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
tab_vertical.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,該條款可在 LICENSE 檔案中找到。
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, Horizontal, Menu, Renderer, Tab
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, hbox, operator|, 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_menu = Menu(&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::Horizontal({
54 tab_menu,
55 tab_container,
56 });
57
58 auto renderer = Renderer(container, [&] {
59 return hbox({
60 tab_menu->Render(),
61 separator(),
62 tab_container->Render(),
63 }) |
64 border;
65 });
66
68 screen.Loop(renderer);
69}
static ScreenInteractive TerminalOutput()
Component Menu(MenuOption options)
文字列表。選定的元素會被聚焦。
Component Radiobox(RadioboxOption options)
元素清單,只能選擇一個。
Component Renderer(Component child, std::function< Element()>)
回傳一個新的元件,類似於 |child|,但使用 |render| 作為 Component::Render() 事件。
virtual void Render(Screen &screen)
Element separator()
在兩個元素之間繪製垂直或水平分隔線。
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
Element hbox(Elements)
一個逐一水平顯示元素的容器。
Definition hbox.cpp:94
int main()