#include <memory>
#include <string>
Element ColorTile(
int red,
int green,
int blue) {
return text("") | size(WIDTH, GREATER_THAN, 14) |
size(HEIGHT, GREATER_THAN, 7) | bgcolor(Color::RGB(red, green, blue));
}
Element ColorString(
int red,
int green,
int blue) {
return text("RGB = (" +
std::to_string(red) + "," +
std::to_string(green) + "," +
std::to_string(blue) + ")"
);
}
int main() {
int red = 128;
int green = 25;
int blue = 100;
auto slider_red =
Slider(
"Red :", &red, 0, 255, 1);
auto slider_green =
Slider(
"Green:", &green, 0, 255, 1);
auto slider_blue =
Slider(
"Blue :", &blue, 0, 255, 1);
auto container = Container::Vertical({
slider_red,
slider_green,
slider_blue,
});
auto renderer =
Renderer(container, [&] {
ColorTile(red, green, blue),
slider_red->Render(),
slider_green->Render(),
slider_blue->Render(),
ColorString(red, green, blue),
}) | xflex,
}) |
border |
size(WIDTH, LESS_THAN, 80);
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
std::shared_ptr< Node > Element
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.
Component Slider(SliderOption< T > options)
A slider in any direction.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element vbox(Elements)
A container displaying elements vertically one by one.