28#include <TGUI/Widget.hpp>
29#include <TGUI/Renderers/KnobRenderer.hpp>
33TGUI_MODULE_EXPORT
namespace tgui
42 using Ptr = std::shared_ptr<Knob>;
45 static constexpr const char StaticWidgetType[] =
"Knob";
54 Knob(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
77 TGUI_NODISCARD
const KnobRenderer* getSharedRenderer()
const override;
92 using Widget::setSize;
228 void mouseMoved(
Vector2f pos)
override;
262 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
267 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
272 TGUI_NODISCARD
Vector2f getInnerSize()
const;
277 void recalculateRotation();
292 bool m_clockwiseTurning =
true;
293 float m_startRotation = 270;
294 float m_endRotation = 270;
298 float m_maximum = 360;
302 Sprite m_spriteBackground;
303 Sprite m_spriteForeground;
307 Color m_borderColorCached;
308 Color m_backgroundColorCached;
309 Color m_thumbColorCached;
310 float m_imageRotationCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Wrapper for colors.
Definition Color.hpp:73
Definition KnobRenderer.hpp:35
Knob widget.
Definition Knob.hpp:39
static Knob::Ptr create()
Creates a new knob widget.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
float getMinimum() const
Returns the value when the knob would be rotated in the direction of StartRotation.
void setValue(float value)
Changes the current value.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
KnobRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
float getEndRotation() const
Sets the end rotation, which is the place where the value should be maximal.
float getStartRotation() const
Returns the start rotation, which is the place where the value should be minimal.
bool leftMousePressed(Vector2f pos) override
Called by the parent when the left mouse button goes down on top of the widget.
void setEndRotation(float endRotation)
Sets the end rotation, which is the place where the value should be maximal.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
float getMaximum() const
Returns the value when the knob would be rotated in the direction of EndRotation.
float getValue() const
Returns the current value.
void setClockwiseTurning(bool clockwise)
Should the value increase when turning the knob clockwise?
KnobRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
bool getClockwiseTurning() const
Returns whether the value increases when turning the knob clockwise?
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
static Knob::Ptr copy(const Knob::ConstPtr &knob)
Makes a copy of another knob.
void setSize(const Layout2d &size) override
Changes the size of the knob.
std::shared_ptr< const Knob > ConstPtr
Shared constant widget pointer.
Definition Knob.hpp:43
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 setStartRotation(float startRotation)
Sets the start rotation, which is the place where the value should be minimal.
void setMinimum(float minimum)
Sets the value for when the knob would be rotated in the direction of StartRotation.
void setMaximum(float maximum)
Sets the value for when the knob would be rotated in the direction of EndRotation.
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
std::shared_ptr< Knob > Ptr
Shared widget pointer.
Definition Knob.hpp:42
Class to store the position or size of a widget.
Definition Layout.hpp:323
Definition Outline.hpp:38
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
States used for drawing.
Definition RenderStates.hpp:38