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. Todos los derechos reservados.
2// El uso de este código fuente se rige por la licencia MIT que se puede encontrar en
3// el archivo LICENSE.
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
14using namespace ftxui;
15
16int 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,
48 Button("Animated 5", action,
50 Button("Animated 6", action,
52 }),
53 }),
54 }) |
55 border;
56
58 screen.Loop(buttons);
59 return 0;
60}
int main()
auto screen
static ScreenInteractive FitComponent()
static ButtonOption Simple()
Crea una ButtonOption, invertida cuando está enfocada.
static ButtonOption Ascii()
Crea una ButtonOption, resaltada usando los caracteres [].
static ButtonOption Animated()
Component Button(ButtonOption options)
Dibuja un botón. Ejecuta una función al hacer clic.
Component Renderer(Component child, std::function< Element()>)
Retorna un nuevo Componente, similar a |child|, pero usando |render| como el evento Component::Render...
Element text(std::wstring text)
Muestra un fragmento de texto Unicode.
Definition text.cpp:160
Element separator()
Dibuja una separación vertical u horizontal entre otros dos elementos.
El espacio de nombres ftxui:: de FTXUI.
Definition animation.hpp:10