26 : entries_(entries), selected_(selected) {
29 auto prefix =
text(s.state ?
"↓ " :
"→ ");
30 auto t =
text(s.label);
37 return hbox({prefix, t});
39 checkbox_ =
Checkbox(&title_, &show_, option);
40 radiobox_ =
Radiobox(entries_, selected_);
44 Maybe(radiobox_, &show_),
49 *selected_ =
util::clamp(*selected_, 0,
int(entries_.size()) - 1);
50 title_ = entries_[
static_cast<size_t>(*selected_)];
52 const int max_height = 12;
63 checkbox_->Render() |
border,
70 const bool show_old = show_;
71 const int selected_old = *selected_;
74 if (!show_old && show_) {
75 radiobox_->TakeFocus();
78 if (selected_old != *selected_) {
79 checkbox_->TakeFocus();
95 return Make<Impl>(entries, selected);
It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ft...
virtual bool OnEvent(Event)
Called in response to an event.
An adapter. Reference a list of strings.
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
Element vscroll_indicator(Element)
Display a vertical scrollbar to the right. colors.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Component Maybe(Component, const bool *show)
Decorate a component |child|. It is shown only when |show| is true.
Component Checkbox(CheckboxOption options)
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
Element bold(Element)
Use a bold font, for elements with more emphasis.
Component Radiobox(RadioboxOption options)
A list of element, where only one can be selected.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Element text(std::wstring text)
Display a piece of unicode text.
Component Dropdown(ConstStringListRef entries, int *selected)
A dropdown menu.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element filler()
An element that will take expand proportionnally to the space left in a container.
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Element border(Element)
Draw a border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.
arguments for |ButtonOption::transform|, |CheckboxOption::transform|, |Radiobox::transform|,...
Option for the Checkbox component.
std::function< Element(const EntryState &)> transform
Represent an event. It can be key press event, a terminal resize, or more ...