mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00

Dom - `vscroll_indicator`. Show a scrollback indicator on the right. Component - `Maybe`: Display an component conditionnally based on a boolean. - `Dropdown`: A dropdown select list. This address: https://github.com/ArthurSonzogni/FTXUI/issues/204
27 lines
654 B
C++
27 lines
654 B
C++
#include "ftxui/component/component_base.hpp"
|
|
|
|
Component Maybe(Component child, bool* show) {
|
|
class Impl : public ComponentBase {
|
|
public:
|
|
Impl(Component child, bool* show) : ComponentBase(child), show_(show) {}
|
|
|
|
private:
|
|
Element Render() override {
|
|
if (*show_)
|
|
return ComponentBase::Render();
|
|
else
|
|
return text("");
|
|
}
|
|
bool Focusable() const override {
|
|
return *show_ && ComponentBase::Focusable();
|
|
}
|
|
bool OnEvent(Event event) override {
|
|
if (*show_)
|
|
return false return ComponentBase::OnEvent(event);
|
|
}
|
|
|
|
bool* show_;
|
|
};
|
|
return Make<Impl>(std::move(child), show);
|
|
}
|