mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-30 15:36:53 +08:00
7daeac25c0
Take selector at the end to get more pleasing results with clang-format.
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
#include <memory> // for allocator, __shared_ptr_access, shared_ptr
|
|
#include <string> // for wstring, basic_string
|
|
#include <vector> // for vector
|
|
|
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
|
#include "ftxui/component/component.hpp" // for Radiobox, Horizontal, Menu, Renderer, Tab
|
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
|
#include "ftxui/dom/elements.hpp" // for Element, separator, hbox, operator|, border
|
|
|
|
using namespace ftxui;
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
std::vector<std::wstring> tab_values{
|
|
L"tab_1",
|
|
L"tab_2",
|
|
L"tab_3",
|
|
};
|
|
int tab_selected = 0;
|
|
auto tab_menu = Menu(&tab_values, &tab_selected);
|
|
|
|
std::vector<std::wstring> tab_1_entries{
|
|
L"Forest",
|
|
L"Water",
|
|
L"I don't know",
|
|
};
|
|
int tab_1_selected = 0;
|
|
|
|
std::vector<std::wstring> tab_2_entries{
|
|
L"Hello",
|
|
L"Hi",
|
|
L"Hay",
|
|
};
|
|
int tab_2_selected = 0;
|
|
|
|
std::vector<std::wstring> tab_3_entries{
|
|
L"Table",
|
|
L"Nothing",
|
|
L"Is",
|
|
L"Empty",
|
|
};
|
|
int tab_3_selected = 0;
|
|
auto tab_container = Container::Tab(
|
|
{
|
|
Radiobox(&tab_1_entries, &tab_1_selected),
|
|
Radiobox(&tab_2_entries, &tab_2_selected),
|
|
Radiobox(&tab_3_entries, &tab_3_selected),
|
|
},
|
|
&tab_selected);
|
|
|
|
auto container = Container::Horizontal({
|
|
tab_menu,
|
|
tab_container,
|
|
});
|
|
|
|
auto renderer = Renderer(container, [&] {
|
|
return hbox({
|
|
tab_menu->Render(),
|
|
separator(),
|
|
tab_container->Render(),
|
|
}) |
|
|
border;
|
|
});
|
|
|
|
auto screen = ScreenInteractive::TerminalOutput();
|
|
screen.Loop(renderer);
|
|
}
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
// the LICENSE file.
|