Carousel
carousel · Containers · interactive
A strip of slides, one screenful at a time.
Import
cpp
#include "gbui/widgets/carousel.hpp"Example
cpp
CarouselResult carousel(Ui& ui, const Interaction& input, std::string_view id, std::size_t count, CarouselState& state, float delta, const std::function<void(Ui&, std::size_t)>& slide, const CarouselOptions& options = {});Draws count slides and shows the ones around state.first. slide is called for every index, not only the visible ones: a carousel is a handful of things and the whole strip has to exist for the movement between them to be a movement rather than a cut. A list long enough for that to matter is a virtualList, not a carousel. delta is the frame's own seconds, and only autoplay reads it.
API
CarouselOptions
| Option | Type | Default | What it does |
|---|---|---|---|
orientation | CarouselOrientationHorizontal · Vertical | CarouselOrientation::Horizontal | Which way the strip runs, and therefore which pair of arrow keys moves it. |
slidesPerPage | float | 1.0f | How many slides are on screen at once, and a fraction is allowed. 2.5 shows two and half of the next, which is not decoration: a strip cut cleanly at the edge looks like it ends there, and half a slide is the only thing that says there is more without spending a control on saying it. |
gap | float | 12.0f | Between two slides. Taken out of the room they share, so the arithmetic stays exact however many are showing. |
loop | bool | false | Past the last slide is the first. Off, because a strip that silently starts over is a strip a reader cannot tell they have finished. |
autoplay | double | 0.0 | Seconds between automatic advances. Zero — the default — never moves. On, it also draws a pause button, and that is not optional: see the note at the top of this header. |
indicators | bool | true | The row of dots, which is also how a reader jumps straight to one. |
navigators | bool | true | The two arrows. Off for a strip driven entirely by its indicators or by the keyboard. |
name | std::string_view | What the strip is of — "Screenshots", "Recent commits". | |
height | float | 220.0f | |
width | float | kAuto | |
grow | float | 0.0f |