8#ifndef MALENA_CAROUSEL_H
9#define MALENA_CAROUSEL_H
43 enum class Flag { SCROLLING, SHOW_ARROWS };
54 enum class State { SCROLL_IDLE, SCROLL_LEFT, SCROLL_RIGHT };
130 std::list<ml::Core*> _components;
138 std::unique_ptr<sf::Shader> _ownedShader;
139 std::function<void(
sf::Shader&)> _shaderUniformSetter;
140 float _shaderTime = 0.f;
144 float _spacing = 10.f;
147 float _targetViewX = 0.f;
148 int _previewCount = 5;
157 ArrowPlacement _arrowPlacement = ArrowPlacement::SIDES;
158 float _arrowSize = 40.f;
161 std::optional<sf::Texture> _leftArrowTexture;
162 std::optional<sf::Texture> _rightArrowTexture;
163 std::optional<sf::Vector2f> _leftArrowManualPos;
164 std::optional<sf::Vector2f> _rightArrowManualPos;
167 void wrapComponents();
168 void updateRenderTextureSize();
169 void updateArrowPositions();
171 void loadShaderForStyle(Style style);
void setArrowSize(float size)
Set the size of both navigation arrows.
void setShader(sf::Shader *shader, std::function< void(sf::Shader &)> uniformSetter)
Set a custom GLSL shader with a per-frame uniform setter.
void remove(ml::Core &component)
Remove a Core object from the carousel.
Carousel(const Carousel &)=delete
float getSpacing() const
Return the current item spacing in pixels.
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
sf::FloatRect getGlobalBounds() const override
void showArrows(bool show)
Show or hide the navigation arrows.
CarouselManifest::ArrowPlacement ArrowPlacement
Convenience alias for CarouselManifest::ArrowPlacement.
sf::RenderStates getRenderStates() const override
void setSpacing(float spacing)
Set the pixel gap between items.
void setShaderParams(const ShaderLibrary::Params ¶ms)
Set parameters forwarded to the active ShaderLibrary style.
void setPosition(const sf::Vector2f &position) override
CarouselManifest::ArrowSide ArrowSide
Convenience alias for CarouselManifest::ArrowSide.
Carousel & operator=(const Carousel &)=delete
CarouselManifest::State State
Convenience alias for CarouselManifest::State.
void setPreviewCount(int count)
Set how many items are visible in the carousel window at once.
Style getStyle() const
Return the currently active built-in style.
ShaderLibrary::Params & getShaderParams()
Return a mutable reference to the current shader parameters.
void previous()
Scroll to the previous item (left).
void setSpeed(float speed)
Set the scroll animation speed.
CarouselManifest::Flag Flag
Convenience alias for CarouselManifest::Flag.
int getPreviewCount() const
Return the current visible item count.
sf::Vector2f getPosition() const override
void setArrowColor(sf::Color color)
Set the default fill color of the navigation arrows.
void clearArrowPosition(ArrowSide side)
Revert an arrow to its placement-preset position.
float getSpeed() const
Return the current scroll speed.
void add(ml::Core &component)
Add a Core object to the carousel.
CarouselManifest::Style Style
Convenience alias for CarouselManifest::Style.
void setArrowTexture(ArrowSide side, sf::Texture texture)
Replace the default arrow rectangle with a custom texture.
void setArrowHoverColor(sf::Color color)
Set the fill color of a navigation arrow on hover.
void next()
Scroll to the next item (right).
void setStyle(Style style)
Set a built-in shader style from ShaderLibrary.
void setArrowPosition(ArrowSide side, sf::Vector2f position)
Override the auto-computed position of one arrow.
void setArrowPlacement(ArrowPlacement placement)
Set the layout strategy for navigation arrows.
Manifest for the Carousel component.
ShaderLibrary::Style Style
Shader visual style — aliases ShaderLibrary::Style.
ArrowSide
Identifies which navigation arrow to target in setter calls.
State
Scroll animation states.
Flag
Runtime boolean flags for the carousel.
ArrowPlacement
Controls where navigation arrows are placed relative to the content.
Virtual base class for all Malena framework objects.
Base class for all Malena manifests.
A framework-integrated rectangle with optional rounded corners.
Style
Available built-in visual styles.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
All uniform parameters shared across the built-in shaders.