FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
button_style.cpp
Aller à la documentation de ce fichier.
1// Copyright 2020 Arthur Sonzogni. Tous droits réservés.
2// L'utilisation de ce code source est régie par la licence MIT que l'on peut trouver dans
3// le fichier 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 ButtonOption Animated()
Crée une ButtonOption, utilisant des couleurs animées.
static ScreenInteractive FitComponent()
static ButtonOption Simple()
Crée une ButtonOption, inversée lorsqu'elle est sélectionnée.
static ButtonOption Ascii()
Crée une ButtonOption, mise en évidence à l'aide des caractères [].
Component Button(ButtonOption options)
Dessine un bouton. Exécute une fonction lors d'un clic.
Component Renderer(Component child, std::function< Element()>)
Renvoie un nouveau composant, similaire à |child|, mais utilisant |render| comme événement Component:...
Element text(std::wstring text)
Affiche un morceau de texte unicode.
Definition text.cpp:160
Element separator()
Dessine une séparation verticale ou horizontale entre deux autres éléments.
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10