mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-27 21:58:29 +08:00
58 lines
2.3 KiB
C++
58 lines
2.3 KiB
C++
// 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.
|
|
#include <memory> // for allocator, make_shared, __shared_ptr_access
|
|
#include <utility> // for move
|
|
#include <vector> // for vector
|
|
|
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
|
#include "ftxui/component/component.hpp" // for Collapsible, Renderer, Vertical
|
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
|
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
|
#include "ftxui/dom/elements.hpp" // for text, hbox, Element
|
|
|
|
using namespace ftxui;
|
|
|
|
// Take a list of component, display them vertically, one column shifted to the
|
|
// right.
|
|
Component Inner(std::vector<Component> children) {
|
|
Component vlist = Container::Vertical(std::move(children));
|
|
return Renderer(vlist, [vlist] {
|
|
return hbox({
|
|
text(" "),
|
|
vlist->Render(),
|
|
});
|
|
});
|
|
}
|
|
|
|
Component Empty() {
|
|
return std::make_shared<ComponentBase>();
|
|
}
|
|
|
|
int main() {
|
|
auto component =
|
|
Collapsible("Collapsible 1",
|
|
Inner({
|
|
Collapsible("Collapsible 1.1",
|
|
Inner({
|
|
Collapsible("Collapsible 1.1.1", Empty()),
|
|
Collapsible("Collapsible 1.1.2", Empty()),
|
|
Collapsible("Collapsible 1.1.3", Empty()),
|
|
})),
|
|
Collapsible("Collapsible 1.2",
|
|
Inner({
|
|
Collapsible("Collapsible 1.2.1", Empty()),
|
|
Collapsible("Collapsible 1.2.2", Empty()),
|
|
Collapsible("Collapsible 1.2.3", Empty()),
|
|
})),
|
|
Collapsible("Collapsible 1.3",
|
|
Inner({
|
|
Collapsible("Collapsible 1.3.1", Empty()),
|
|
Collapsible("Collapsible 1.3.2", Empty()),
|
|
Collapsible("Collapsible 1.3.3", Empty()),
|
|
})),
|
|
}));
|
|
|
|
ScreenInteractive::FitComponent().Loop(component);
|
|
}
|