2023-08-19 13:56:36 +02:00
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|
2021-06-21 23:08:39 +02:00
|
|
|
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
|
|
|
|
|
|
|
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
|
|
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
2021-05-27 15:22:53 +02:00
|
|
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
2021-08-09 00:27:37 +02:00
|
|
|
#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
|
2021-05-27 15:22:53 +02:00
|
|
|
|
|
|
|
using namespace ftxui;
|
|
|
|
|
2023-06-03 13:59:39 +02:00
|
|
|
int main() {
|
2021-05-27 15:22:53 +02:00
|
|
|
auto screen = ScreenInteractive::Fullscreen();
|
|
|
|
|
2025-10-18 11:17:59 +02:00
|
|
|
// State:
|
2021-05-27 15:22:53 +02:00
|
|
|
int left_size = 20;
|
|
|
|
int right_size = 20;
|
|
|
|
int top_size = 10;
|
|
|
|
int bottom_size = 10;
|
|
|
|
|
2025-10-18 11:17:59 +02:00
|
|
|
// Renderers:
|
|
|
|
auto RendererInfo = [](const std::string& name, int* size) {
|
|
|
|
return Renderer([name, size] {
|
|
|
|
return text(name + ": " + std::to_string(*size)) | center;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
auto middle = Renderer([] { return text("Middle") | center; });
|
|
|
|
auto left = RendererInfo("Left", &left_size);
|
|
|
|
auto right = RendererInfo("Right", &right_size);
|
|
|
|
auto top = RendererInfo("Top", &top_size);
|
|
|
|
auto bottom = RendererInfo("Bottom", &bottom_size);
|
|
|
|
|
2021-05-27 15:22:53 +02:00
|
|
|
auto container = middle;
|
2021-05-27 15:46:23 +02:00
|
|
|
container = ResizableSplitLeft(left, container, &left_size);
|
|
|
|
container = ResizableSplitRight(right, container, &right_size);
|
|
|
|
container = ResizableSplitTop(top, container, &top_size);
|
|
|
|
container = ResizableSplitBottom(bottom, container, &bottom_size);
|
2021-05-27 15:22:53 +02:00
|
|
|
|
|
|
|
auto renderer =
|
|
|
|
Renderer(container, [&] { return container->Render() | border; });
|
|
|
|
|
|
|
|
screen.Loop(renderer);
|
|
|
|
}
|