25#ifndef TGUI_SPIN_CONTROL_HPP
26#define TGUI_SPIN_CONTROL_HPP
28#include <TGUI/SubwidgetContainer.hpp>
29#include <TGUI/Widgets/SpinButton.hpp>
30#include <TGUI/Widgets/EditBox.hpp>
34TGUI_MODULE_EXPORT
namespace tgui
43 using Ptr = std::shared_ptr<SpinControl>;
44 using ConstPtr = std::shared_ptr<const SpinControl>;
46 static constexpr const char StaticWidgetType[] =
"SpinControl";
55 SpinControl(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
88 TGUI_NODISCARD
static SpinControl::Ptr create(
float min = 0.0f,
float max = 10.0f,
float value = 0.0f,
unsigned int decimal = 0,
float step = 1.0f);
118 TGUI_NODISCARD
const EditBoxRenderer* getSpinTextSharedRenderer()
const;
133 using SubwidgetContainer::setSize;
260 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
265 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
278 bool inRange(
const float value)
const;
283 void setString(
const String& str);
293 unsigned int m_decimalPlaces = 0;
294 bool m_useWideArrows =
false;
Definition EditBoxRenderer.hpp:35
std::shared_ptr< EditBox > Ptr
Shared widget pointer.
Definition EditBox.hpp:51
Class to store the position or size of a widget.
Definition Layout.hpp:313
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Spin control widget.
Definition SpinControl.hpp:40
void setMaximum(float maximum)
Sets a maximum value.
TGUI_NODISCARD float getValue() const
Returns the current value.
SpinControl(const SpinControl ©)
Copy constructor.
std::shared_ptr< const SpinControl > ConstPtr
Shared constant widget pointer.
Definition SpinControl.hpp:44
static TGUI_NODISCARD SpinControl::Ptr create(float min=0.0f, float max=10.0f, float value=0.0f, unsigned int decimal=0, float step=1.0f)
Creates a new spin button widget.
TGUI_NODISCARD float getStep() const
Returns the number of positions the thumb advances with each move.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
SpinControl(SpinControl &©) noexcept
Move constructor.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
TGUI_NODISCARD unsigned int getDecimalPlaces() const
Returns the number of decimal places to display.
void setUseWideArrows(bool useWideArrows)
Changes whether the spin button width equals the heigh or the widget or only half of the height (defa...
void setSize(const Layout2d &size) override
Changes the size of the spin control.
static TGUI_NODISCARD SpinControl::Ptr copy(const SpinControl::ConstPtr &SpinCtrl)
Makes a copy of another spin control.
void setMinimum(float minimum)
Sets a minimum value.
TGUI_NODISCARD SpinButtonRenderer * getSpinButtonRenderer()
Returns the renderer of spin buttons part of widget.
TGUI_NODISCARD float getMinimum() const
Returns the minimum value.
void setStep(float step)
Changes how much the value changes on each arrow press.
std::shared_ptr< SpinControl > Ptr
Shared widget pointer.
Definition SpinControl.hpp:43
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.
void setDecimalPlaces(unsigned int decimalPlaces)
Changes the number of decimal places to display.
bool setValue(float value)
Changes the current value.
TGUI_NODISCARD SpinButtonRenderer * getSpinButtonSharedRenderer()
Returns the renderer of spin buttons part of widget.
TGUI_NODISCARD EditBoxRenderer * getSpinTextRenderer()
Returns the renderer of edit box part of widget.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
TGUI_NODISCARD float getMaximum() const
Returns the maximum value.
TGUI_NODISCARD bool getUseWideArrows() const
Returns whether the spin button width equals the heigh or the widget or only half of the height (defa...
TGUI_NODISCARD EditBoxRenderer * getSpinTextSharedRenderer()
Returns the renderer of edit box part of widget.
Wrapper class to store strings.
Definition String.hpp:96
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38