FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
resizable_split_clamp.cpp
Go to the documentation of this file.
1// Copyright 2025 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <memory> // for shared_ptr, allocator, __shared_ptr_access
5
6#include "ftxui/component/app.hpp" // for App
7#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
8#include "ftxui/component/component_base.hpp" // for ComponentBase
9#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
10
11using namespace ftxui;
12
13int main() {
14 auto screen = App::Fullscreen();
15
16 // Estado:
17 int size = 40;
18 int size_min = 10;
19 int size_max = 80;
20
21 // Renderizadores:
22 auto split = ResizableSplit({
23 .main = Renderer([] { return text("Left") | center; }),
24 .back = Renderer([] { return text("Right") | center; }),
26 .main_size = &size,
27 .min = &size_min,
28 .max = &size_max,
29 });
30
31 auto renderer = Renderer(split, [&] {
32 return window(text("Drag the separator with the mouse"),
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}
Component Renderer(Component child, std::function< Element()>)
Devuelve un nuevo Component, similar a |child|, pero usando |render| como el evento Component::Render...
Element window(Element title, Element content, BorderStyle border=ROUNDED)
Dibuja una ventana con un título y un borde alrededor del elemento.
Element text(std::string_view text)
Muestra un fragmento de texto Unicode codificado en UTF8.
Element flex(Element child)
Hace que un elemento hijo se expanda proporcionalmente al espacio restante en un contenedor.
Definition flex.cpp:95
Element center(Element child)
Centra un elemento horizontal y verticalmente.
Element separator()
Dibuja una separación vertical u horizontal entre otros dos elementos.
Element vbox(Elements children)
Un contenedor que muestra elementos verticalmente uno por uno.
Definition vbox.cpp:96
El espacio de nombres ftxui:: de FTXUI.
Definition animation.hpp:11
Direction direction
Definition elements.hpp:83
Component ResizableSplit(ResizableSplitOption options)
Una división entre dos componentes.