FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
button_in_frame.cpp
Go to the documentation of this file.
1// Copyright 2022 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
5#include <string> // for to_string, operator+
6
7#include "ftxui/component/captured_mouse.hpp" // for ftxui
8#include "ftxui/component/component.hpp" // for Button, Renderer, Vertical
9#include "ftxui/component/component_base.hpp" // for ComponentBase
10#include "ftxui/component/component_options.hpp" // for ButtonOption
11#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
12#include "ftxui/dom/elements.hpp" // for operator|, text, Element, hbox, separator, size, vbox, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
13#include "ftxui/screen/color.hpp" // for Color, Color::Default, Color::GrayDark, Color::White
14
15using namespace ftxui;
16
17int main() {
18 int counter = 0;
19 auto on_click = [&] { counter++; };
20
23
24 auto container = Container::Vertical({});
25 for (int i = 0; i < 30; ++i) {
26 auto button = Button("Button " + std::to_string(i), on_click, style);
27 container->Add(button);
28 }
29
30 auto renderer = Renderer(container, [&] {
31 return vbox({
32 hbox({
33 text("Counter:"),
34 text(std::to_string(counter)),
35 }),
36 separator(),
37 container->Render() | vscroll_indicator | frame |
38 size(HEIGHT, LESS_THAN, 20),
39 }) |
40 border;
41 });
42
44 screen.Loop(renderer);
45
46 return 0;
47}
int main()
auto screen
static ScreenInteractive FitComponent()
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...
virtual void Render(Screen &screen)
Muestra un elemento en un ftxui::Screen.
Definition node.cpp:59
Decorator size(WidthOrHeight, Constraint, int value)
Aplica una restricción al tamaño de un elemento.
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
Element hbox(Elements)
Un contenedor que muestra elementos horizontalmente uno por uno.
Definition hbox.cpp:94
Element vbox(Elements)
@ LESS_THAN
Definition elements.hpp:162