FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
menu_entries_animated.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. 全著作権所有。
2// このソースコードの使用は、LICENSEファイルにあるMITライセンスに準拠しています。
3#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
4#include <memory> // for shared_ptr, __shared_ptr_access
5#include <string> // for to_string, allocator
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for MenuEntryAnimated, Renderer, Vertical
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/component/component_options.hpp" // for MenuEntryAnimated
11#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
12#include "ftxui/dom/elements.hpp" // for operator|, separator, Element, Decorator, color, text, hbox, size, bold, frame, inverted, vbox, HEIGHT, LESS_THAN, border
13#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::Green, Color::Red, Color::Yellow
14
15using namespace ftxui;
16
17// 特定のメニューエントリに特別なスタイルを定義します。
28
29int main() {
31
32 int selected = 0;
33 auto menu = Container::Vertical(
34 {
35 MenuEntry(" 1. rear", Colored(Color::Red)),
36 MenuEntry(" 2. drown", Colored(Color::Yellow)),
37 MenuEntry(" 3. nail", Colored(Color::Green)),
38 MenuEntry(" 4. quit", Colored(Color::Cyan)),
39 MenuEntry(" 5. decorative", Colored(Color::Blue)),
40 MenuEntry(" 7. costume"),
41 MenuEntry(" 8. pick"),
42 MenuEntry(" 9. oral"),
43 MenuEntry("11. minister"),
44 MenuEntry("12. football"),
45 MenuEntry("13. welcome"),
46 MenuEntry("14. copper"),
47 MenuEntry("15. inhabitant"),
48 },
49 &selected);
50
51 // Display together the menu with a border
52 auto renderer = Renderer(menu, [&] {
53 return vbox({
54 hbox(text("selected = "), text(std::to_string(selected))),
55 separator(),
56 menu->Render() | frame,
57 }) |
58 border | bgcolor(Color::Black);
59 });
60
61 screen.Loop(renderer);
62
63 std::cout << "Selected element = " << selected << std::endl;
64}
static ScreenInteractive TerminalOutput()
ターミナル出力の幅に一致し、描画されるコンポーネントの高さに一致するScreenInteractiveを作成します。
AnimatedColorsOption animated_colors
Component MenuEntry(MenuEntryOption options)
特定のメニューエントリ。これらはContainer::Verticalに入れてメニューを形成できます。
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
MenuEntryコンポーネントのオプション。
virtual void Render(Screen &screen)
要素をftxui::Screenに表示します。
Definition node.cpp:59
Decorator bgcolor(Color)
背景色を使用して装飾します。
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
Element vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
Colorは、ターミナルユーザーインターフェースにおける色を表すクラスです。
Definition color.hpp:25
MenuEntryOption Colored(ftxui::Color c)
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element hbox(Elements)
要素を水平方向に1つずつ表示するコンテナ。
Definition hbox.cpp:93
Element separator()
Element frame(Element)
要素を「仮想」領域内に表示できるようにします。そのサイズはコンテナよりも大きくすることができます。 この場合、より小さい部分のみが表示されます。フォーカスされた要素を表示するためにビューはスクロール可能...
Definition frame.cpp:117