FTXUI 7.0.3
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// 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 left_size = 20;
18 int right_size = 20;
19 int top_size = 10;
20 int bottom_size = 10;
21
22 // レンダラー:
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}
Component ResizableSplitTop(Component main, Component back, int *main_size)
マウスで設定可能な、2つのコンポーネント間の垂直分割。
Component Renderer(Component child, std::function< Element()>)
|child| に似た、|render| をComponent::Render()イベントとして 使用する新しいComponentを返します。
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 text(std::string_view text)
UTF8エンコードされたユニコードテキストを表示します。
Decorator size(WidthOrHeight direction, Constraint constraint, int value)
要素のサイズに制約を適用する。
Element center(Element child)
要素を水平方向および垂直方向に中央揃えします。
Element border(Element child)
要素の周囲にボーダーを描画します。
FTXUI ftxui::名前空間
Definition animation.hpp:11
std::uint8_t top
Definition screen.cpp:148
std::uint8_t left
Definition screen.cpp:147
std::uint8_t right
Definition screen.cpp:149