#include <memory>
#include <string>
#include <vector>
std::string title = "(" + std::to_string(x) + ", " + std::to_string(y) + ")";
return text(title) | center | size(WIDTH, EQUAL, 18) |
size(HEIGHT, EQUAL, 9) | border |
bgcolor(Color::HSV(x * 255 / 15, 255, y * 255 / 15));
};
std::vector<Elements> rows;
for (int i = 0; i < 15; i++) {
std::vector<Element> cols;
for (int j = 0; j < 15; j++) {
cols.push_back(make_box(i, j));
}
rows.push_back(cols);
}
};
int main() {
float focus_x = 0.5f;
float focus_y = 0.5f;
auto slider_x =
Slider(
"x", &focus_x, 0.f, 1.f, 0.01f);
auto slider_y =
Slider(
"y", &focus_y, 0.f, 1.f, 0.01f);
Container::Vertical({
slider_x,
slider_y,
}),
[&] {
auto title = "focusPositionRelative(" +
std::to_string(focus_x) + ", " +
std::to_string(focus_y) + ")";
slider_x->Render(),
slider_y->Render(),
}) |
border;
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(renderer);
return 0;
}
Decorator focusPositionRelative(float x, float y)
Used inside a frame, this force the view to be scrolled toward a a given position....
Element flex(Element)
Make a child element to expand proportionally to the space left in a container.
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 text(std::wstring text)
Display a piece of unicode text.
Component Slider(SliderOption< T > options)
A slider in any direction.
Element gridbox(std::vector< Elements > lines)
A container displaying a grid of elements.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
Element vbox(Elements)
A container displaying elements vertically one by one.