FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
menu_entries_animated.cpp
Go to the documentation of this file.
1// Copyright 2020 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 <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
5#include <memory> // for shared_ptr, __shared_ptr_access
6#include <string> // for to_string, allocator
7
8#include "ftxui/component/captured_mouse.hpp" // for ftxui
9#include "ftxui/component/component.hpp" // for MenuEntryAnimated, Renderer, Vertical
10#include "ftxui/component/component_base.hpp" // for ComponentBase
11#include "ftxui/component/component_options.hpp" // for MenuEntryAnimated
12#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
13#include "ftxui/dom/elements.hpp" // for operator|, separator, Element, Decorator, color, text, hbox, size, bold, frame, inverted, vbox, HEIGHT, LESS_THAN, border
14#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::Green, Color::Red, Color::Yellow
15
16using namespace ftxui;
17
18// Define un estilo especial para alguna entrada del menú.
29
30int main() {
32
33 int selected = 0;
34 auto menu = Container::Vertical(
35 {
36 MenuEntry(" 1. rear", Colored(Color::Red)),
37 MenuEntry(" 2. drown", Colored(Color::Yellow)),
38 MenuEntry(" 3. nail", Colored(Color::Green)),
39 MenuEntry(" 4. quit", Colored(Color::Cyan)),
40 MenuEntry(" 5. decorative", Colored(Color::Blue)),
41 MenuEntry(" 7. costume"),
42 MenuEntry(" 8. pick"),
43 MenuEntry(" 9. oral"),
44 MenuEntry("11. minister"),
45 MenuEntry("12. football"),
46 MenuEntry("13. welcome"),
47 MenuEntry("14. copper"),
48 MenuEntry("15. inhabitant"),
49 },
50 &selected);
51
52 // Muestra el menú junto con un borde
53 auto renderer = Renderer(menu, [&] {
54 return vbox({
55 hbox(text("selected = "), text(std::to_string(selected))),
56 separator(),
57 menu->Render() | frame,
58 }) |
59 border | bgcolor(Color::Black);
60 });
61
62 screen.Loop(renderer);
63
64 std::cout << "Selected element = " << selected << std::endl;
65}
auto screen
static ScreenInteractive TerminalOutput()
AnimatedColorsOption animated_colors
Component MenuEntry(MenuEntryOption options)
Una entrada de menú específica. Se pueden colocar en un Container::Vertical para formar un menú.
Component Renderer(Component child, std::function< Element()>)
Retorna un nuevo Componente, similar a |child|, pero usando |render| como el evento Component::Render...
Opción para el componente MenuEntry.
virtual void Render(Screen &screen)
Muestra un elemento en un ftxui::Screen.
Definition node.cpp:59
Decorator bgcolor(Color)
Decora usando un color de fondo.
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.
Color es una clase que representa un color en la interfaz de usuario de la terminal.
Definition color.hpp:21
MenuEntryOption Colored(ftxui::Color c)
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)
Element frame(Element)
Permite que un elemento se muestre dentro de un área 'virtual'. Su tamaño puede ser mayor que su cont...
Definition frame.cpp:118