43 Maybe(radiobox_, checkbox.checked),
49 util::clamp(radiobox.selected(), 0,
int(radiobox.entries.size()) - 1);
50 title_ = radiobox.entries[selected_()];
52 return transform(*open_, checkbox_->Render(), radiobox_->Render());
57 const bool open_old = open_();
58 const int selected_old = selected_();
62 if (!open_old && open_()) {
63 radiobox_->TakeFocus();
68 if (open_old && open_()) {
69 const bool should_close = (selected_() != selected_old) ||
75 checkbox_->TakeFocus();
85 open_ = checkbox.checked;
86 selected_ = radiobox.selected;
87 checkbox.checked = &*open_;
88 radiobox.selected = &*selected_;
89 checkbox.label = &title_;
91 if (!checkbox.transform) {
93 auto prefix =
text(s.state ?
"↓ " :
"→ ");
94 auto t =
text(s.label);
101 return hbox({prefix, t});
106 transform = [](
bool is_open,
Element checkbox_element,
109 const int max_height = 12;
111 std::move(checkbox_element),
131 return Make<Impl>(option);
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.
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 proportionally 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.
Component Checkbox(CheckboxOption options)
Draw checkable element.
Element border(Element)
Draw a border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.
Option for the Dropdown component.A dropdown menu is a checkbox opening/closing a radiobox.
arguments for |ButtonOption::transform|, |CheckboxOption::transform|, |Radiobox::transform|,...
Represent an event. It can be key press event, a terminal resize, or more ...
static const Event Escape
static Event Character(std::string)
An event corresponding to a given typed character.
static const Event Return
ConstStringListRef entries