A scrollable container that presents a collection of Core objects.
More...
#include <Carousel.h>
Public Types | |
| using | ArrowPlacement = CarouselManifest::ArrowPlacement |
Convenience alias for CarouselManifest::ArrowPlacement. | |
| using | ArrowSide = CarouselManifest::ArrowSide |
Convenience alias for CarouselManifest::ArrowSide. | |
| using | Flag = CarouselManifest::Flag |
Convenience alias for CarouselManifest::Flag. | |
| using | State = CarouselManifest::State |
Convenience alias for CarouselManifest::State. | |
| using | Style = CarouselManifest::Style |
Convenience alias for CarouselManifest::Style. | |
Public Member Functions | |
| Carousel () | |
| void | add (ml::Core &component) |
Add a Core object to the carousel. | |
| void | clearArrowPosition (ArrowSide side) |
| Revert an arrow to its placement-preset position. | |
| sf::FloatRect | getGlobalBounds () const override |
| sf::Vector2f | getPosition () const override |
| int | getPreviewCount () const |
| Return the current visible item count. | |
| sf::RenderStates | getRenderStates () const override |
| ShaderLibrary::Params & | getShaderParams () |
| Return a mutable reference to the current shader parameters. | |
| float | getSpacing () const |
| Return the current item spacing in pixels. | |
| float | getSpeed () const |
| Return the current scroll speed. | |
| Style | getStyle () const |
| Return the currently active built-in style. | |
| void | next () |
| Scroll to the next item (right). | |
| void | previous () |
| Scroll to the previous item (left). | |
| void | remove (ml::Core &component) |
Remove a Core object from the carousel. | |
| void | setArrowColor (sf::Color color) |
| Set the default fill color of the navigation arrows. | |
| void | setArrowHoverColor (sf::Color color) |
| Set the fill color of a navigation arrow on hover. | |
| void | setArrowPlacement (ArrowPlacement placement) |
| Set the layout strategy for navigation arrows. | |
| void | setArrowPosition (ArrowSide side, sf::Vector2f position) |
| Override the auto-computed position of one arrow. | |
| void | setArrowSize (float size) |
| Set the size of both navigation arrows. | |
| void | setArrowTexture (ArrowSide side, sf::Texture texture) |
| Replace the default arrow rectangle with a custom texture. | |
| void | setPosition (const sf::Vector2f &position) override |
| void | setPreviewCount (int count) |
| Set how many items are visible in the carousel window at once. | |
| void | setShader (sf::Shader *shader, std::function< void(sf::Shader &)> uniformSetter) |
| Set a custom GLSL shader with a per-frame uniform setter. | |
| void | setShaderParams (const ShaderLibrary::Params ¶ms) |
Set parameters forwarded to the active ShaderLibrary style. | |
| void | setSpacing (float spacing) |
| Set the pixel gap between items. | |
| void | setSpeed (float speed) |
| Set the scroll animation speed. | |
| void | setStyle (Style style) |
Set a built-in shader style from ShaderLibrary. | |
| void | showArrows (bool show) |
| Show or hide the navigation arrows. | |
Protected Member Functions | |
| void | draw (sf::RenderTarget &target, sf::RenderStates states) const override |
A scrollable container that presents a collection of Core objects.
Carousel renders its child components into an internal sf::RenderTexture and displays a windowed view of them, supporting smooth animated scrolling, optional navigation arrows, and GLSL shader effects via ShaderLibrary.
Definition at line 111 of file Carousel.h.
Convenience alias for CarouselManifest::ArrowPlacement.
Definition at line 121 of file Carousel.h.
Convenience alias for CarouselManifest::ArrowSide.
Definition at line 123 of file Carousel.h.
Convenience alias for CarouselManifest::Flag.
Definition at line 115 of file Carousel.h.
Convenience alias for CarouselManifest::State.
Definition at line 117 of file Carousel.h.
Convenience alias for CarouselManifest::Style.
Definition at line 119 of file Carousel.h.
| ml::Carousel::Carousel | ( | ) |
| void ml::Carousel::add | ( | ml::Core & | component | ) |
Add a Core object to the carousel.
Items are displayed in insertion order. The carousel takes a non-owning pointer; the caller is responsible for the item's lifetime.
| component | The component to add. |
| void ml::Carousel::clearArrowPosition | ( | ArrowSide | side | ) |
Revert an arrow to its placement-preset position.
| side | Which arrow to reset. |
|
overrideprotected |
|
override |
|
override |
| int ml::Carousel::getPreviewCount | ( | ) | const |
Return the current visible item count.
|
override |
| ShaderLibrary::Params & ml::Carousel::getShaderParams | ( | ) |
Return a mutable reference to the current shader parameters.
ShaderLibrary::Params. | float ml::Carousel::getSpacing | ( | ) | const |
Return the current item spacing in pixels.
| float ml::Carousel::getSpeed | ( | ) | const |
Return the current scroll speed.
| Style ml::Carousel::getStyle | ( | ) | const |
Return the currently active built-in style.
| void ml::Carousel::next | ( | ) |
Scroll to the next item (right).
Animates the view toward the next item at the current speed. Sets Flag::SCROLLING and State::SCROLL_RIGHT while animating.
| void ml::Carousel::previous | ( | ) |
Scroll to the previous item (left).
Animates the view toward the previous item at the current speed. Sets Flag::SCROLLING and State::SCROLL_LEFT while animating.
| void ml::Carousel::remove | ( | ml::Core & | component | ) |
Remove a Core object from the carousel.
| component | The component to remove. Safe to call even if component is not currently in the carousel. |
| void ml::Carousel::setArrowColor | ( | sf::Color | color | ) |
Set the default fill color of the navigation arrows.
| color | Fill color when the mouse is not hovering. |
| void ml::Carousel::setArrowHoverColor | ( | sf::Color | color | ) |
Set the fill color of a navigation arrow on hover.
| color | Fill color when the mouse is hovering over an arrow. |
| void ml::Carousel::setArrowPlacement | ( | ArrowPlacement | placement | ) |
Set the layout strategy for navigation arrows.
| placement | One of SIDES, TOP, or OVERLAY. |
| void ml::Carousel::setArrowPosition | ( | ArrowSide | side, |
| sf::Vector2f | position ) |
Override the auto-computed position of one arrow.
Bypasses the ArrowPlacement preset for the specified side. Call clearArrowPosition to revert.
| side | Which arrow to reposition. |
| position | Absolute world-space position for the arrow. |
| void ml::Carousel::setArrowSize | ( | float | size | ) |
Set the size of both navigation arrows.
| size | Arrow width/height in pixels. |
| void ml::Carousel::setArrowTexture | ( | ArrowSide | side, |
| sf::Texture | texture ) |
Replace the default arrow rectangle with a custom texture.
| side | Which arrow to replace (LEFT or RIGHT). |
| texture | The sf::Texture to use. |
|
override |
| void ml::Carousel::setPreviewCount | ( | int | count | ) |
Set how many items are visible in the carousel window at once.
| count | Number of visible items. Defaults to 5. |
| void ml::Carousel::setShader | ( | sf::Shader * | shader, |
| std::function< void(sf::Shader &)> | uniformSetter ) |
Set a custom GLSL shader with a per-frame uniform setter.
The uniformSetter is called once per frame before rendering so you can update time-dependent or state-dependent uniforms.
| shader | Pointer to the sf::Shader to use. Must remain valid for the lifetime of the carousel. |
| uniformSetter | Callback invoked each frame with the shader reference, used to push uniform values. |
| void ml::Carousel::setShaderParams | ( | const ShaderLibrary::Params & | params | ) |
Set parameters forwarded to the active ShaderLibrary style.
| params | Parameter struct with style-specific fields. |
| void ml::Carousel::setSpacing | ( | float | spacing | ) |
Set the pixel gap between items.
| spacing | Gap in pixels. Defaults to 10. |
| void ml::Carousel::setSpeed | ( | float | speed | ) |
Set the scroll animation speed.
| speed | Pixels per frame (or per tick). Defaults to 1. |
| void ml::Carousel::setStyle | ( | Style | style | ) |
Set a built-in shader style from ShaderLibrary.
Loads and activates one of the pre-built GLSL shaders. Replaces any previously set custom shader.
| style | The ShaderLibrary::Style to apply. |
| void ml::Carousel::showArrows | ( | bool | show | ) |
Show or hide the navigation arrows.
| show | true to show arrows, false to hide. |