26#ifndef TGUI_SLIDER_HPP
27#define TGUI_SLIDER_HPP
30#include <TGUI/Widget.hpp>
31#include <TGUI/Renderers/SliderRenderer.hpp>
35TGUI_MODULE_EXPORT
namespace tgui
44 using Ptr = std::shared_ptr<Slider>;
45 using ConstPtr = std::shared_ptr<const Slider>;
47 static constexpr const char StaticWidgetType[] =
"Slider";
57 Slider(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
88 TGUI_NODISCARD
const SliderRenderer* getSharedRenderer()
const override;
106 using Widget::setSize;
281 bool leftMousePressed(
Vector2f pos)
override;
286 void leftMouseReleased(
Vector2f pos)
override;
291 void mouseMoved(
Vector2f pos)
override;
296 bool scrolled(
float delta,
Vector2f pos,
bool touch)
override;
301 void leftMouseButtonNoLongerDown()
override;
341 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
347 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
353 TGUI_NODISCARD
Vector2f getInnerSize()
const;
359 void updateThumbPosition();
380 bool m_mouseDownOnThumb =
false;
384 float m_maximum = 10;
388 bool m_invertedDirection =
false;
389 bool m_verticalScroll =
false;
390 bool m_verticalImage =
false;
391 bool m_changeValueOnScroll =
true;
394 Sprite m_spriteTrackHover;
396 Sprite m_spriteThumbHover;
400 Color m_borderColorCached;
401 Color m_borderColorHoverCached;
402 Color m_thumbColorCached;
403 Color m_thumbColorHoverCached;
404 Color m_trackColorCached;
405 Color m_trackColorHoverCached;
406 bool m_thumbWithinTrackCached =
false;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Wrapper for colors.
Definition Color.hpp:72
Class to store the position or size of a widget.
Definition Layout.hpp:289
Definition Outline.hpp:39
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Definition SliderRenderer.hpp:37
Slider widget.
Definition Slider.hpp:41
TGUI_NODISCARD Vector2f getWidgetOffset() const override
Returns the distance between the position where the widget is drawn and where the widget is placed.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
TGUI_NODISCARD float getStep() const
Returns the number of positions the thumb advances with each move.
TGUI_NODISCARD float getMaximum() const
Returns the maximum value.
TGUI_NODISCARD bool getInvertedDirection() const
Returns whether the side of the slider that is the minimum and maximum is inverted.
TGUI_NODISCARD float getMinimum() const
Returns the minimum value.
TGUI_NODISCARD SliderRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void setVerticalScroll(bool vertical)
Changes whether the slider lies horizontally or vertically.
void setMinimum(float minimum)
Sets a minimum value.
TGUI_NODISCARD Vector2f getFullSize() const override
Returns the full size of the slider.
void setStep(float step)
Changes the number of positions the thumb advances with each move.
std::shared_ptr< Slider > Ptr
Shared widget pointer.
Definition Slider.hpp:44
TGUI_NODISCARD bool getChangeValueOnScroll() const
Returns whether the mouse wheel can be used to change the value of the slider.
void setChangeValueOnScroll(bool changeValueOnScroll)
Changes whether the mouse wheel can be used to change the value of the slider.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void setSize(const Layout2d &size) override
Changes the size of the slider.
TGUI_NODISCARD SliderRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TGUI_NODISCARD float getValue() const
Returns the current value.
void setValue(float value)
Changes the current value.
TGUI_NODISCARD bool getVerticalScroll() const
Returns whether the slider lies horizontally or vertically.
static TGUI_NODISCARD Slider::Ptr copy(const Slider::ConstPtr &slider)
Makes a copy of another slider.
std::shared_ptr< const Slider > ConstPtr
Shared constant widget pointer.
Definition Slider.hpp:45
void setInvertedDirection(bool invertedDirection)
Changes whether the side of the slider that is the minimum and maximum should be inverted.
static TGUI_NODISCARD Slider::Ptr create(float minimum=0, float maximum=10)
Creates a new slider widget.
void setMaximum(float maximum)
Sets a maximum value.
TGUI_NODISCARD std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
Wrapper class to store strings.
Definition String.hpp:101
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
States used for drawing.
Definition RenderStates.hpp:39