FTXUI  0.10.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
maybe.cpp
Go to the documentation of this file.
4
5namespace ftxui {
6
7Component Maybe(Component child, bool* show) {
8 class Impl : public ComponentBase {
9 public:
10 Impl(bool* show): show_(show) {}
11
12 private:
13 Element Render() override {
14 return *show_ ? ComponentBase::Render() : std::make_unique<Node>();
15 }
16 bool Focusable() const override {
17 return *show_ && ComponentBase::Focusable();
18 }
19 bool OnEvent(Event event) override {
20 return *show_ && ComponentBase::OnEvent(event);
21 }
22
23 bool* show_;
24 };
25
26 auto maybe = Make<Impl>(show);
27 maybe->Add(std::move(child));
28 return maybe;
29}
30
31} // namespace ftxui
It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ft...
std::shared_ptr< T > Make(Args &&... args)
Definition component.hpp:25
std::shared_ptr< Node > Element
Definition elements.hpp:15
Component Maybe(Component, bool *show)
Definition maybe.cpp:7
void Render(Screen &screen, const Element &node)
Display an element on a ftxui::Screen.
Definition node.cpp:34
std::shared_ptr< ComponentBase > Component
Represent an event. It can be key press event, a terminal resize, or more ...
Definition event.hpp:25