FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
button_style.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <string> // for operator+, to_string
5
6#include "ftxui/component/captured_mouse.hpp" // for ftxui
7#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer, Horizontal, operator|
8#include "ftxui/component/component_base.hpp" // for Component
9#include "ftxui/component/component_options.hpp" // for ButtonOption
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for Element, separator, text, border
12#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Green, Color::Red
13
14 using namespace ftxui;
15
16 int main() {
17 int value = 0;
18 auto action = [&] { value++; };
19 auto action_renderer =
20 Renderer([&] { return text("count = " + std::to_string(value)); });
21
22 auto buttons =
23 Container::Vertical({
24 action_renderer,
25 Renderer([] { return separator(); }),
26 Container::Horizontal({
27 Container::Vertical({
28 Button("Ascii 1", action, ButtonOption::Ascii()),
29 Button("Ascii 2", action, ButtonOption::Ascii()),
30 Button("Ascii 3", action, ButtonOption::Ascii()),
31 }),
32 Renderer([] { return separator(); }),
33 Container::Vertical({
34 Button("Simple 1", action, ButtonOption::Simple()),
35 Button("Simple 2", action, ButtonOption::Simple()),
36 Button("Simple 3", action, ButtonOption::Simple()),
37 }),
38 Renderer([] { return separator(); }),
39 Container::Vertical({
40 Button("Animated 1", action, ButtonOption::Animated()),
41 Button("Animated 2", action, ButtonOption::Animated()),
42 Button("Animated 3", action, ButtonOption::Animated()),
43 }),
44 Renderer([] { return separator(); }),
45 Container::Vertical({
46 Button("Animated 4", action,
47 ButtonOption::Animated(Color::Red)),
48 Button("Animated 5", action,
49 ButtonOption::Animated(Color::Green)),
50 Button("Animated 6", action,
51 ButtonOption::Animated(Color::Blue)),
52 }),
53 }),
54 }) |
55 border;
56
57 auto screen = ScreenInteractive::FitComponent();
58 screen.Loop(buttons);
59 return 0;
60}
main
int main()
Definition button_style.cpp:16
captured_mouse.hpp
color.hpp
component.hpp
component_base.hpp
component_options.hpp
elements.hpp
ftxui::ButtonOption::Animated
static ButtonOption Animated()
Create a ButtonOption, using animated colors.
Definition component_options.cpp:196
ftxui::ScreenInteractive::FitComponent
static ScreenInteractive FitComponent()
Definition screen_interactive.cpp:423
ftxui::ButtonOption::Simple
static ButtonOption Simple()
Create a ButtonOption, inverted when focused.
Definition component_options.cpp:165
ftxui::ButtonOption::Ascii
static ButtonOption Ascii()
Create a ButtonOption, highlighted using [] characters.
Definition component_options.cpp:153
ftxui::Button
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Definition src/ftxui/component/button.cpp:175
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition src/ftxui/component/renderer.cpp:61
ftxui::Container::Vertical
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Definition container.cpp:317
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
ftxui::separator
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Definition src/ftxui/dom/separator.cpp:134
ftxui::Color::Green
@ Green
Definition color.hpp:56
ftxui::Color::Red
@ Red
Definition color.hpp:55
ftxui::Color::Blue
@ Blue
Definition color.hpp:58
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
screen_interactive.hpp