FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
examples/component/collapsible.cpp
Aller à la documentation de ce fichier.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Utilisation de ce code source soumise à la licence MIT, que l'on peut trouver dans le fichier
3// LICENSE.
4#include <memory> // for allocator, make_shared, __shared_ptr_access
5#include <utility> // for move
6#include <vector> // for vector
7
8#include "ftxui/component/captured_mouse.hpp" // for ftxui
9#include "ftxui/component/component.hpp" // for Collapsible, Renderer, Vertical
10#include "ftxui/component/component_base.hpp" // for ComponentBase
11#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
12#include "ftxui/dom/elements.hpp" // for text, hbox, Element
13
14using namespace ftxui;
15
16// Prend une liste de composants, les affiche verticalement, chaque colonne décalée vers la
17// droite.
18Component Inner(std::vector<Component> children) {
19 Component vlist = Container::Vertical(std::move(children));
20 return Renderer(vlist, [vlist] {
21 return hbox({
22 text(" "),
23 vlist->Render(),
24 });
25 });
26}
27
29 return std::make_shared<ComponentBase>();
30}
31
32int main() {
33 auto component =
34 Collapsible("Réductible 1",
35 Inner({
36 Collapsible("Réductible 1.1",
37 Inner({
38 Collapsible("Réductible 1.1.1", Empty()),
39 Collapsible("Réductible 1.1.2", Empty()),
40 Collapsible("Réductible 1.1.3", Empty()),
41 })),
42 Collapsible("Réductible 1.2",
43 Inner({
44 Collapsible("Réductible 1.2.1", Empty()),
45 Collapsible("Réductible 1.2.2", Empty()),
46 Collapsible("Réductible 1.2.3", Empty()),
47 })),
48 Collapsible("Réductible 1.3",
49 Inner({
50 Collapsible("Réductible 1.3.1", Empty()),
51 Collapsible("Réductible 1.3.2", Empty()),
52 Collapsible("Réductible 1.3.3", Empty()),
53 })),
54 }));
55
57}
Component Inner(std::vector< Component > children)
Component Empty()
Element Render()
Dessine le composant. Construit un ftxui::Element à dessiner sur l'écran ftxui::Screen représentant c...
static ScreenInteractive FitComponent()
void Loop(Component)
Exécute la boucle principale.
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
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10
Element hbox(Elements)
Un conteneur affichant les éléments horizontalement un par un.
Definition hbox.cpp:94
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
Un composant repliable. Il affiche une case à cocher avec une flèche. Une fois activé,...
std::shared_ptr< ComponentBase > Component