FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
resizable_split_clamp.cpp
Aller à la documentation de ce fichier.
1// Copyright 2025 Arthur Sonzogni. Tous droits réservés.
2// L'utilisation de ce code source est régie par la licence MIT qui se trouve dans
3// le fichier LICENSE.
4#include <memory> // pour shared_ptr, allocator, __shared_ptr_access
5
6#include "ftxui/component/component.hpp" // pour Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
7#include "ftxui/component/component_base.hpp" // pour ComponentBase
8#include "ftxui/component/screen_interactive.hpp" // pour ScreenInteractive
9#include "ftxui/dom/elements.hpp" // pour Element, operator|, text, center, border
10
11using namespace ftxui;
12
13int main() {
15
16 // État :
17 int size = 40;
18 int size_min = 10;
19 int size_max = 80;
20
21 // Rendu :
22 auto split = ResizableSplit({
23 .main = Renderer([] { return text("Left") | center; }),
24 .back = Renderer([] { return text("Right") | center; }),
25 .direction = Direction::Left,
26 .main_size = &size,
27 .min = &size_min,
28 .max = &size_max,
29 });
30
31 auto renderer = Renderer(split, [&] {
32 return window(text("Faites glisser le séparateur avec la souris"),
33 vbox({
34 text("Min: " + std::to_string(size_min)),
35 text("Max: " + std::to_string(size_max)),
36 text("Size: " + std::to_string(size)),
37 separator(),
38 split->Render() | flex,
39 }));
40 });
41
42 screen.Loop(renderer);
43}
auto screen
static ScreenInteractive Fullscreen()
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 window(Element title, Element content, BorderStyle border=ROUNDED)
Dessine une fenêtre avec un titre et une bordure autour de l'élément.
Element flex(Element)
Permet à un élément enfant de s'étendre proportionnellement à l'espace restant dans un conteneur.
Definition flex.cpp:123
Element center(Element)
Centre un élément horizontalement et verticalement.
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
Component ResizableSplit(ResizableSplitOption options)
Une séparation entre deux composants.