#include <memory>
#include <string>
auto option = ButtonOption::Animated();
auto element = text(s.label);
if (s.focused) {
element |= bold;
}
return element | center | borderEmpty | flex;
};
return option;
}
int main() {
int value = 50;
auto btn_dec_01 = Button("-1", [&] { value -= 1; }, Style());
auto btn_inc_01 =
Button(
"+1", [&] { value += 1; }, Style());
auto btn_dec_10 =
Button(
"-10", [&] { value -= 10; }, Style());
auto btn_inc_10 =
Button(
"+10", [&] { value += 10; }, Style());
int row = 0;
auto buttons = Container::Vertical({
Container::Horizontal({btn_dec_01, btn_inc_01}, &row) | flex,
Container::Horizontal({btn_dec_10, btn_inc_10}, &row) | flex,
});
auto component =
Renderer(buttons, [&] {
text(
"value = " + std::to_string(value)),
buttons->Render() |
flex,
}) |
flex | border;
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(component);
return 0;
}
Element flex(Element)
Make a child element to expand proportionally to the space left in a container.
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 text(std::wstring text)
Display a piece of unicode text.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element vbox(Elements)
A container displaying elements vertically one by one.
arguments for |ButtonOption::transform|, |CheckboxOption::transform|, |Radiobox::transform|,...