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// このソースコードの使用は、LICENSEファイルにあるMITライセンスによって管理されています。
3#include <memory> // for shared_ptr, allocator, __shared_ptr_access
4
5#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
6#include "ftxui/component/component_base.hpp" // for ComponentBase
7#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
8#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
9
10using namespace ftxui;
11
12int main() {
13 auto screen = ScreenInteractive::Fullscreen();
14
15 // State:
16 int left_size = 20;
17 int right_size = 20;
18 int top_size = 10;
19 int bottom_size = 10;
20
21 // Renderers:
22 auto RendererInfo = [](const std::string& name, int* size) {
23 return Renderer([name, size] {
24 return text(name + ": " + std::to_string(*size)) | center;
25 });
26 };
27 auto middle = Renderer([] { return text("Middle") | center; });
28 auto left = RendererInfo("Left", &left_size);
29 auto right = RendererInfo("Right", &right_size);
30 auto top = RendererInfo("Top", &top_size);
31 auto bottom = RendererInfo("Bottom", &bottom_size);
32
33 auto container = middle;
34 container = ResizableSplitLeft(left, container, &left_size);
35 container = ResizableSplitRight(right, container, &right_size);
36 container = ResizableSplitTop(top, container, &top_size);
37 container = ResizableSplitBottom(bottom, container, &bottom_size);
38
39 auto renderer =
40 Renderer(container, [&] { return container->Render() | border; });
41
42 screen.Loop(renderer);
43}
static ScreenInteractive Fullscreen()
Component ResizableSplitTop(Component main, Component back, int *main_size)
2つのコンポーネント間の垂直分割。マウスで設定可能。
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
Component ResizableSplitRight(Component main, Component back, int *main_size)
2つのコンポーネント間の水平分割。マウスで設定可能。
Component ResizableSplitBottom(Component main, Component back, int *main_size)
2つのコンポーネント間の垂直分割。マウスで設定可能。
Component ResizableSplitLeft(Component main, Component back, int *main_size)
2つのコンポーネント間の水平分割。マウスで設定可能。
Element center(Element)
要素を水平方向および垂直方向に中央揃えします。
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element border(Element)
std::uint8_t top
Definition screen.cpp:130
std::uint8_t left
Definition screen.cpp:129
std::uint8_t right
Definition screen.cpp:131
return size
Definition string.cpp:1516