# FTXUI: collapsible.cpp Source File

Loading...
Searching...
No Matches
examples/component/collapsible.cpp
Go to the documentation of this file.
// 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);
}
captured_mouse.hpp
component.hpp
component_base.hpp
elements.hpp
Inner
Component Inner(std::vector< Component > children)
Definition examples/component/collapsible.cpp:18
Empty
Component Empty()
Definition examples/component/collapsible.cpp:28
main
int main()
Definition examples/component/collapsible.cpp:32
ftxui::ComponentBase::Render
Element Render()
Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::...
Definition component.cpp:103
ftxui::ScreenInteractive::FitComponent
static ScreenInteractive FitComponent()
Definition screen_interactive.cpp:346
ftxui::ScreenInteractive::Loop
void Loop(Component)
Execute the main loop.
Definition screen_interactive.cpp:417
ftxui::Renderer
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition src/ftxui/component/renderer.cpp:61
ftxui::Container::Vertical
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Definition container.cpp:317
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
ftxui::Collapsible
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
A collapsible component. It displays a checkbox with an arrow. Once activated, the child is displayed...
Definition src/ftxui/component/collapsible.cpp:33
ftxui::Component
std::shared_ptr< ComponentBase > Component
Definition component_base.hpp:24
screen_interactive.hpp