FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/renderer.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/captured_mouse.hpp" // for ftxui
6#include "ftxui/component/component.hpp" // for Renderer, Button, Vertical
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 operator|, Element, text, bold, border, center, color
10#include "ftxui/screen/color.hpp" // for Color, Color::Red
11
12int main() {
13 using namespace ftxui;
14 auto screen = ScreenInteractive::FitComponent();
15
16 // Renderer()は、自身の描画のためにラムダ関数をパラメータとして使用するコンポーネントです。
17
18 // 1. フォーカス可能なRendererの例:
19 auto renderer_focusable = Renderer([](bool focused) {
20 if (focused) {
21 return text("FOCUSABLE RENDERER()") | center | bold | border;
22 } else {
23 return text(" Focusable renderer() ") | center | border;
24 }
25 });
26
27 // 2. フォーカス不可能なRendererの例。
28 auto renderer_non_focusable = Renderer([&] {
29 return text("~~~~~ Non Focusable renderer() ~~~~~"); //
30 });
31
32 // 3. Rendererは他のコンポーネントをラップして、そのRender()関数を再定義できます。
33 auto button = Button("Wrapped quit button", screen.ExitLoopClosure());
34 auto renderer_wrap = Renderer(button, [&] {
35 if (button->Focused()) {
36 return button->Render() | bold | color(Color::Red);
37 } else {
38 return button->Render();
39 }
40 });
41
42 // すべてをレンダリングしましょう:
43 screen.Loop(Container::Vertical({
44 renderer_focusable,
45 renderer_non_focusable,
46 renderer_wrap,
47 }));
48}
Element border(Element child)
要素の周囲にボーダーを描画します。
FTXUI ftxui:: 名前空間
Definition animation.hpp:9