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 // 状態:
17 int size = 40;
18 int size_min = 10;
19 int size_max = 80;
20
21 // レンダラー:
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()>)
|child| に似た、|render| をComponent::Render()イベントとして 使用する新しいComponentを返します。
Element window(Element title, Element content, BorderStyle border=ROUNDED)
要素の周囲にタイトルとボーダーを持つウィンドウを描画します。
Element text(std::string_view text)
UTF8エンコードされたユニコードテキストを表示します。
Element flex(Element child)
子要素をコンテナに残されたスペースに比例して拡大させます。
Definition flex.cpp:93
Element center(Element child)
要素を水平方向および垂直方向に中央揃えします。
Element vbox(Elements children)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:95
FTXUI ftxui::名前空間
Definition animation.hpp:11
Direction direction
Definition elements.hpp:80
Component ResizableSplit(ResizableSplitOption options)
2つのコンポーネント間の分割。