FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
nested_screen.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 <memory> // pour allocator, shared_ptr, __shared_ptr_access
5#include <string> // pour operator+, string, char_traits, basic_string
6
7#include "ftxui/component/captured_mouse.hpp" // pour ftxui
8#include "ftxui/component/component.hpp" // pour Button, Vertical, Renderer
9#include "ftxui/component/component_base.hpp" // pour ComponentBase
10#include "ftxui/component/screen_interactive.hpp" // pour ScreenInteractive
11#include "ftxui/dom/elements.hpp" // pour separator, text, Element, operator|, vbox, border
12
13using namespace ftxui;
14
15void Nested(std::string path) {
17 auto back_button = Button("Retour", screen.ExitLoopClosure());
18 auto goto_1 = Button("Aller à /1", [path] { Nested(path + "/1"); });
19 auto goto_2 = Button("Aller à /2", [path] { Nested(path + "/2"); });
20 auto goto_3 = Button("Aller à /3", [path] { Nested(path + "/3"); });
21 auto layout = Container::Vertical({
22 back_button,
23 goto_1,
24 goto_2,
25 goto_3,
26 });
27 auto renderer = Renderer(layout, [&] {
28 return vbox({
29 text("chemin: " + path),
30 separator(),
31 back_button->Render(),
32 goto_1->Render(),
33 goto_2->Render(),
34 goto_3->Render(),
35 }) |
36 border;
37 });
38 screen.Loop(renderer);
39}
40
41int main() {
43 auto button_quit = Button("Quitter", screen.ExitLoopClosure());
44 auto button_nested = Button("Imbriqué", [] { Nested(""); });
45 screen.Loop(Container::Vertical({
46 button_quit,
47 button_nested,
48 }));
49 return 0;
50}
auto screen
static ScreenInteractive FitComponent()
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:...
virtual void Render(Screen &screen)
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.
Element vbox(Elements)
Un conteneur affichant les éléments verticalement un par un.
Definition vbox.cpp:96
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10
void Nested(std::string path)
int main()