SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
Slider.h
1#ifndef Slider_H
2#define Slider_H
3
4#include "AzulCore.h"
5#include "UIComponent.h"
6
8class UICommand;
9
30class Slider : public UIComponent
31{
32public:
36 Slider() = default;
37 Slider(const Slider&) = delete;
38 Slider& operator=(const Slider&) = delete;
39 ~Slider();
40
46 Slider(std::string sliderKnobKey, std::string sliderBarKey);
47
53 void SetOrigin(float x, float y);
54
60 void SetPosition(float x, float y);
61
66 void SetAngleRadians(float rad);
67
72 void SetAngleDegrees(float deg);
73
79 void SetScaleFactor(float x, float y);
80
86 void SetScalePixel(float x, float y);
87
92 float GetWidth() const;
93
98 float GetHeight() const;
99
104 float GetAngle() const;
105
110 float GetScaleX() const;
111
116 float GetScaleY() const;
117
122 void SetLayer(int layer) override;
123
128 void SetOnPressCommand(UICommand* cmd);
129
134 void SetValue(float value);
135
140 float GetValue() const;
141
142private:
145 Matrix trans;
146 Matrix rot;
147 Matrix scale;
148 float posX;
149 float posY;
150 float angle;
151 float scaleX;
152 float scaleY;
153 float value;
155
159 void Render() override;
160
164 void OnPress() override;
165
172 bool IsMouseOver(float xPos, float yPos) override;
173
177 void UpdateWorld();
178};
179
180#endif
Represents a sprite in the SUNENGINE.
Definition Sprites/SUNENGINESprite.h:16
float GetAngle() const
Gets the angle of the slider in radians.
Definition Slider.cpp:80
SUNENGINESprite * pKnobSprite
Sprite for the slider knob.
Definition Slider.h:143
void SetLayer(int layer) override
Sets the rendering layer of the slider.
Definition Slider.cpp:141
void SetAngleRadians(float rad)
Sets the angle of the slider in radians.
Definition Slider.cpp:48
void Render() override
Renders the slider (bar and knob).
Definition Slider.cpp:134
Matrix trans
Transformation matrix.
Definition Slider.h:145
float GetWidth() const
Gets the width of the slider (bar) in pixels.
Definition Slider.cpp:70
void SetAngleDegrees(float deg)
Sets the angle of the slider in degrees.
Definition Slider.cpp:53
bool IsMouseOver(float xPos, float yPos) override
Checks if the mouse is over the slider.
Definition Slider.cpp:155
UICommand * pOnPressCommand
Command to execute when the slider is pressed.
Definition Slider.h:154
float GetValue() const
Gets the current value of the slider (0.0 to 1.0).
Definition Slider.cpp:101
void UpdateWorld()
Updates the world matrix of the slider.
Definition Slider.cpp:183
float posY
Y position of the slider center.
Definition Slider.h:149
float GetScaleX() const
Gets the x-scale factor of the slider.
Definition Slider.cpp:85
float angle
Angle of the slider in radians.
Definition Slider.h:150
void SetOrigin(float x, float y)
Sets the origin of the slider (for transformations).
Definition Slider.cpp:35
Matrix rot
Rotation matrix.
Definition Slider.h:146
Matrix scale
Scale matrix.
Definition Slider.h:147
void OnPress() override
Handles press events (mouse interaction) for the slider.
Definition Slider.cpp:106
float scaleX
X scale factor.
Definition Slider.h:151
SUNENGINESprite * pBarSprite
Sprite for the slider bar.
Definition Slider.h:144
float GetHeight() const
Gets the height of the slider (bar) in pixels.
Definition Slider.cpp:75
float posX
X position of the slider center.
Definition Slider.h:148
float GetScaleY() const
Gets the y-scale factor of the slider.
Definition Slider.cpp:90
void SetPosition(float x, float y)
Sets the position of the slider.
Definition Slider.cpp:42
void SetOnPressCommand(UICommand *cmd)
Sets the command to be executed when the slider is pressed.
Definition Slider.cpp:146
void SetScaleFactor(float x, float y)
Sets the scale factor of the slider.
Definition Slider.cpp:58
void SetValue(float value)
Sets the value of the slider (0.0 to 1.0).
Definition Slider.cpp:95
void SetScalePixel(float x, float y)
Sets the scale of the slider in pixels.
Definition Slider.cpp:64
float value
Current value of the slider (0.0 to 1.0).
Definition Slider.h:153
Slider()=default
Default constructor.
float scaleY
Y scale factor.
Definition Slider.h:152
Abstract base class for UI-related command objects.
Definition UICommand.h:32
Abstract base class for all UI components.
Definition UIComponent.h:32