FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
button_style.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,該條款可在 LICENSE 檔案中找到。
3#include <string> // for operator+, to_string
4
5#include "ftxui/component/captured_mouse.hpp" // for ftxui
6#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer, Horizontal, operator|
7#include "ftxui/component/component_base.hpp" // for Component
8#include "ftxui/component/component_options.hpp" // for ButtonOption
9#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
10#include "ftxui/dom/elements.hpp" // for Element, separator, text, border
11#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Green, Color::Red
12
13using namespace ftxui;
14
15int main() {
16 int value = 0;
17 auto action = [&] { value++; };
18 auto action_renderer =
19 Renderer([&] { return text("count = " + std::to_string(value)); });
20
21 auto buttons =
22 Container::Vertical({
23 action_renderer,
24 Renderer([] { return separator(); }),
25 Container::Horizontal({
26 Container::Vertical({
27 Button("Ascii 1", action, ButtonOption::Ascii()),
28 Button("Ascii 2", action, ButtonOption::Ascii()),
29 Button("Ascii 3", action, ButtonOption::Ascii()),
30 }),
31 Renderer([] { return separator(); }),
32 Container::Vertical({
33 Button("Simple 1", action, ButtonOption::Simple()),
34 Button("Simple 2", action, ButtonOption::Simple()),
35 Button("Simple 3", action, ButtonOption::Simple()),
36 }),
37 Renderer([] { return separator(); }),
38 Container::Vertical({
39 Button("Animated 1", action, ButtonOption::Animated()),
40 Button("Animated 2", action, ButtonOption::Animated()),
41 Button("Animated 3", action, ButtonOption::Animated()),
42 }),
43 Renderer([] { return separator(); }),
44 Container::Vertical({
45 Button("Animated 4", action,
47 Button("Animated 5", action,
49 Button("Animated 6", action,
51 }),
52 }),
53 }) |
54 border;
55
56 auto screen = ScreenInteractive::FitComponent();
57 screen.Loop(buttons);
58 return 0;
59}
int main()
static ButtonOption Animated()
創建一個 ButtonOption,使用動畫顏色。
static ScreenInteractive FitComponent()
static ButtonOption Simple()
創建一個 ButtonOption,在聚焦時反轉。
static ButtonOption Ascii()
創建一個 ButtonOption,使用 [] 字元突出顯示。
Component Button(ButtonOption options)
繪製一個按鈕。點擊時執行一個函數。
Component Renderer(Component child, std::function< Element()>)
回傳一個新的元件,類似於 |child|,但使用 |render| 作為 Component::Render() 事件。
Element text(std::wstring text)
顯示一段 Unicode 文字。
Definition text.cpp:160
Element separator()
在兩個元素之間繪製垂直或水平分隔線。
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10