class Impl : public ComponentBase {
private:
float scroll_x = 0.1;
float scroll_y = 0.1;
public:
Impl() {
const std::string lorem =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
"do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation "
"ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis "
"aute irure dolor in reprehenderit in voluptate velit esse "
"cillum dolore eu fugiat nulla pariatur. Excepteur sint "
"occaecat cupidatat non proident, sunt in culpa qui officia "
"deserunt mollit anim id est laborum.";
text(lorem.substr(0, -1)),
text(lorem.substr(5, -1)),
text(
""),
text(lorem.substr(10, -1)),
text(lorem.substr(15, -1)),
text(
""),
text(lorem.substr(20, -1)),
text(lorem.substr(25, -1)),
text(
""),
text(lorem.substr(30, -1)),
text(lorem.substr(35, -1)),
text(
""),
text(lorem.substr(40, -1)),
text(lorem.substr(45, -1)),
text(
""),
text(lorem.substr(50, -1)),
text(lorem.substr(55, -1)),
text(
""),
text(lorem.substr(60, -1)),
text(lorem.substr(65, -1)),
text(
""),
text(lorem.substr(70, -1)),
text(lorem.substr(75, -1)),
text(
""),
text(lorem.substr(80, -1)),
text(lorem.substr(85, -1)),
text(
""),
text(lorem.substr(90, -1)),
text(lorem.substr(95, -1)),
text(
""),
text(lorem.substr(100, -1)),
text(lorem.substr(105, -1)),
text(
""),
text(lorem.substr(110, -1)),
text(lorem.substr(115, -1)),
text(
""),
text(lorem.substr(120, -1)),
text(lorem.substr(125, -1)),
text(
""),
text(lorem.substr(130, -1)),
text(lorem.substr(135, -1)),
text(
""),
text(lorem.substr(140, -1)),
});
});
auto scrollable_content =
Renderer(content, [&, content] {
});
SliderOption<float> option_x;
option_x.value = &scroll_x;
option_x.min = 0.f;
option_x.max = 1.f;
option_x.increment = 0.1f;
auto scrollbar_x =
Slider(option_x);
SliderOption<float> option_y;
option_y.value = &scroll_y;
option_y.min = 0.f;
option_y.max = 1.f;
option_y.increment = 0.1f;
auto scrollbar_y =
Slider(option_y);
scrollable_content,
scrollbar_y,
scrollbar_x,
}),
}));
}
};
return Make<Impl>();
}
int main() {
.inner = DummyWindowContent(),
.title = "First window",
.width = 80,
.height = 30,
});
.inner = DummyWindowContent(),
.title = "My window",
.left = 40,
.top = 20,
.width = 80,
.height = 30,
});
window_1,
window_2,
});
screen.Loop(window_container);
return EXIT_SUCCESS;
}
static ScreenInteractive Fullscreen()
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Component Stacked(Components children)
A list of components to be stacked on top of each other. Events are propagated to the first component...
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< ComponentBase > Component
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Component Window(WindowOptions option)
A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stac...
Element text(std::wstring text)
Display a piece of unicode text.
Component Slider(SliderOption< T > options)
A slider in any direction.
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.