30#include <TGUI/Widget.hpp>
31#include <TGUI/Renderers/KnobRenderer.hpp>
35TGUI_MODULE_EXPORT
namespace tgui
44 using Ptr = std::shared_ptr<Knob>;
47 static constexpr const char StaticWidgetType[] =
"Knob";
57 Knob(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
85 TGUI_NODISCARD
const KnobRenderer* getSharedRenderer()
const override;
102 using Widget::setSize;
264 void mouseMoved(
Vector2f pos)
override;
304 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
310 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
316 TGUI_NODISCARD
Vector2f getInnerSize()
const;
322 void recalculateRotation();
340 bool m_clockwiseTurning =
true;
341 float m_startRotation = 270;
342 float m_endRotation = 270;
346 float m_maximum = 360;
350 Sprite m_spriteBackground;
351 Sprite m_spriteForeground;
355 Color m_borderColorCached;
356 Color m_backgroundColorCached;
357 Color m_thumbColorCached;
358 float m_imageRotationCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Wrapper for colors.
Definition Color.hpp:72
Definition KnobRenderer.hpp:37
Knob widget.
Definition Knob.hpp:41
TGUI_NODISCARD float getMinimum() const
Returns the value when the knob would be rotated in the direction of StartRotation.
TGUI_NODISCARD bool getClockwiseTurning() const
Returns whether the value increases when turning the knob clockwise?
static TGUI_NODISCARD Knob::Ptr copy(const Knob::ConstPtr &knob)
Makes a copy of another knob.
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.
TGUI_NODISCARD KnobRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TGUI_NODISCARD float getEndRotation() const
Sets the end rotation, which is the place where the value should be maximal.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
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.
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 draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
TGUI_NODISCARD KnobRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setClockwiseTurning(bool clockwise)
Should the value increase when turning the knob clockwise?
static TGUI_NODISCARD Knob::Ptr create()
Creates a new knob widget.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
TGUI_NODISCARD float getValue() const
Returns the current value.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
TGUI_NODISCARD float getStartRotation() const
Returns the start rotation, which is the place where the value should be minimal.
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:45
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.
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 getMaximum() const
Returns the value when the knob would be rotated in the direction of EndRotation.
std::shared_ptr< Knob > Ptr
Shared widget pointer.
Definition Knob.hpp:44
Class to store the position or size of a widget.
Definition Layout.hpp:305
Definition Outline.hpp:39
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
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