FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/resizable_split.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
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 shared_ptr, allocator, __shared_ptr_access
5
6#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
7#include "ftxui/component/component_base.hpp" // for ComponentBase
8#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
9#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
10
11using namespace ftxui;
12
13int main() {
15
16 // Estado:
17 int left_size = 20;
18 int right_size = 20;
19 int top_size = 10;
20 int bottom_size = 10;
21
22 // Renderizadores:
23 auto RendererInfo = [](const std::string& name, int* size) {
24 return Renderer([name, size] {
25 return text(name + ": " + std::to_string(*size)) | center;
26 });
27 };
28 auto middle = Renderer([] { return text("Middle") | center; });
29 auto left = RendererInfo("Left", &left_size);
30 auto right = RendererInfo("Right", &right_size);
31 auto top = RendererInfo("Top", &top_size);
32 auto bottom = RendererInfo("Bottom", &bottom_size);
33
34 auto container = middle;
35 container = ResizableSplitLeft(left, container, &left_size);
36 container = ResizableSplitRight(right, container, &right_size);
37 container = ResizableSplitTop(top, container, &top_size);
38 container = ResizableSplitBottom(bottom, container, &bottom_size);
39
40 auto renderer =
41 Renderer(container, [&] { return container->Render() | border; });
42
43 screen.Loop(renderer);
44}
auto screen
static ScreenInteractive Fullscreen()
Component ResizableSplitTop(Component main, Component back, int *main_size)
Una división vertical entre dos componentes, configurable usando el ratón.
Component Renderer(Component child, std::function< Element()>)
Retorna un nuevo Componente, similar a |child|, pero usando |render| como el evento Component::Render...
Component ResizableSplitRight(Component main, Component back, int *main_size)
Una división horizontal entre dos componentes, configurable usando el ratón.
Component ResizableSplitBottom(Component main, Component back, int *main_size)
Una división vertical entre dos componentes, configurable usando el ratón.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
Una división horizontal entre dos componentes, configurable usando el ratón.
Decorator size(WidthOrHeight, Constraint, int value)
Aplica una restricción al tamaño de un elemento.
Element center(Element)
Centra un elemento horizontal y verticalmente.
Element text(std::wstring text)
Muestra un fragmento de texto Unicode.
Definition text.cpp:160
Element border(Element)
Draw a border around the element.
El espacio de nombres ftxui:: de FTXUI.
Definition animation.hpp:10
std::uint8_t top
Definition screen.cpp:131
std::uint8_t left
Definition screen.cpp:130
std::uint8_t right
Definition screen.cpp:132