#include <functional>
#include <memory>
#include <string>
#include <vector>
return Renderer(component, [name, component] {
component->Render() |
xflex,
}) |
});
}
int main() {
auto screen = ScreenInteractive::FitComponent();
const std::vector<std::string> menu_entries = {
"Menu 1",
"Menu 2",
"Menu 3",
"Menu 4",
};
int menu_selected = 0;
auto menu =
Menu(&menu_entries, &menu_selected);
menu = Wrap("Menu", menu);
int toggle_selected = 0;
std::vector<std::string> toggle_entries = {
"Toggle_1",
"Toggle_2",
};
auto toggle =
Toggle(&toggle_entries, &toggle_selected);
toggle = Wrap("Toggle", toggle);
bool checkbox_1_selected = false;
bool checkbox_2_selected = false;
bool checkbox_3_selected = false;
bool checkbox_4_selected = false;
Checkbox(
"checkbox1", &checkbox_1_selected),
Checkbox(
"checkbox2", &checkbox_2_selected),
Checkbox(
"checkbox3", &checkbox_3_selected),
Checkbox(
"checkbox4", &checkbox_4_selected),
});
checkboxes = Wrap("Checkbox", checkboxes);
int radiobox_selected = 0;
std::vector<std::string> radiobox_entries = {
"Radiobox 1",
"Radiobox 2",
"Radiobox 3",
"Radiobox 4",
};
auto radiobox =
Radiobox(&radiobox_entries, &radiobox_selected);
radiobox = Wrap("Radiobox", radiobox);
std::string input_label;
auto input =
Input(&input_label,
"placeholder");
input = Wrap("Input", input);
std::string button_label = "Quit";
std::function<void()> on_button_clicked_;
auto button =
Button(&button_label, screen.ExitLoopClosure());
button = Wrap("Button", button);
int slider_value_1 = 12;
int slider_value_2 = 56;
int slider_value_3 = 128;
Slider(
"R:", &slider_value_1, 0, 256, 1),
Slider(
"G:", &slider_value_2, 0, 256, 1),
Slider(
"B:", &slider_value_3, 0, 256, 1),
});
sliders = Wrap("Slider", sliders);
menu,
toggle,
checkboxes,
radiobox,
input,
sliders,
button,
});
menu->Render(),
toggle->Render(),
checkboxes->Render(),
radiobox->Render(),
input->Render(),
sliders->Render(),
button->Render(),
}) |
});
screen.Loop(component);
return 0;
}
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Component Checkbox(CheckboxOption options)
Component Menu(MenuOption options)
A list of text. The focused element is selected.
std::shared_ptr< ComponentBase > Component
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
Component Radiobox(RadioboxOption options)
A list of element, where only one can be selected.
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Element text(std::wstring text)
Display a piece of unicode text.
Component Input(InputOption options={})
An input box for editing text.
Component Slider(SliderOption< T > options)
A slider in any direction.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element border(Element)
Draw a border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.