A draggable UI slider component.
More...
#include <Slider.h>
|
|
| Slider ()=default |
| | Default constructor.
|
| |
|
| Slider (const Slider &)=delete |
| |
|
Slider & | operator= (const Slider &)=delete |
| |
| | Slider (std::string sliderKnobKey, std::string sliderBarKey) |
| | Constructs a Slider with specified knob and bar texture keys.
|
| |
| void | SetOrigin (float x, float y) |
| | Sets the origin of the slider (for transformations).
|
| |
| void | SetPosition (float x, float y) |
| | Sets the position of the slider.
|
| |
| void | SetAngleRadians (float rad) |
| | Sets the angle of the slider in radians.
|
| |
| void | SetAngleDegrees (float deg) |
| | Sets the angle of the slider in degrees.
|
| |
| void | SetScaleFactor (float x, float y) |
| | Sets the scale factor of the slider.
|
| |
| void | SetScalePixel (float x, float y) |
| | Sets the scale of the slider in pixels.
|
| |
| float | GetWidth () const |
| | Gets the width of the slider (bar) in pixels.
|
| |
| float | GetHeight () const |
| | Gets the height of the slider (bar) in pixels.
|
| |
| float | GetAngle () const |
| | Gets the angle of the slider in radians.
|
| |
| float | GetScaleX () const |
| | Gets the x-scale factor of the slider.
|
| |
| float | GetScaleY () const |
| | Gets the y-scale factor of the slider.
|
| |
| void | SetLayer (int layer) override |
| | Sets the rendering layer of the slider.
|
| |
| void | SetOnPressCommand (UICommand *cmd) |
| | Sets the command to be executed when the slider is pressed.
|
| |
| void | SetValue (float value) |
| | Sets the value of the slider (0.0 to 1.0).
|
| |
| float | GetValue () const |
| | Gets the current value of the slider (0.0 to 1.0).
|
| |
|
virtual | ~UIComponent ()=default |
| | Virtual destructor.
|
| |
| int | GetLayer () const |
| | Gets the rendering layer of the component.
|
| |
| UIComponentType | GetType () const |
| | Gets the type of the UI component.
|
| |
| bool | IsEnabled () const |
| | Returns whether the component is enabled or not.
|
| |
| void | SetEnabled (bool enabled) |
| | Sets the enabled state of the component.
|
| |
| void | SetOwningCanvas (Canvas *canvas) |
| | Gets the owning canvas of the component.
|
| |
|
| void | Render () override |
| | Renders the slider (bar and knob).
|
| |
| void | OnPress () override |
| | Handles press events (mouse interaction) for the slider.
|
| |
| bool | IsMouseOver (float xPos, float yPos) override |
| | Checks if the mouse is over the slider.
|
| |
|
void | UpdateWorld () |
| | Updates the world matrix of the slider.
|
| |
|
|
SUNENGINESprite * | pKnobSprite |
| | Sprite for the slider knob.
|
| |
|
SUNENGINESprite * | pBarSprite |
| | Sprite for the slider bar.
|
| |
|
Matrix | trans |
| | Transformation matrix.
|
| |
|
Matrix | rot |
| | Rotation matrix.
|
| |
|
Matrix | scale |
| | Scale matrix.
|
| |
|
float | posX |
| | X position of the slider center.
|
| |
|
float | posY |
| | Y position of the slider center.
|
| |
|
float | angle |
| | Angle of the slider in radians.
|
| |
|
float | scaleX |
| | X scale factor.
|
| |
|
float | scaleY |
| | Y scale factor.
|
| |
|
float | value |
| | Current value of the slider (0.0 to 1.0).
|
| |
|
UICommand * | pOnPressCommand |
| | Command to execute when the slider is pressed.
|
| |
|
|
bool | Enabled = true |
| | Indicates if the component is enabled or not.
|
| |
|
int | Layer = 0 |
| | Rendering layer in.
|
| |
|
UIComponentType | Type = UIComponentType::None |
| | Type of the UI component.
|
| |
|
Canvas * | pOwningCanvas = nullptr |
| | Pointer to the owning canvas, if any.
|
| |
A draggable UI slider component.
The Slider class represents a UI slider that allows users to select a value by dragging a knob along a bar. It supports custom sprites for the knob and bar, and can be positioned, rotated, and scaled. The slider can execute a command when pressed, and its value can be set or queried programmatically.
Example usage:
Slider* slider =
new Slider(
"KnobTextureKey",
"BarTextureKey");
canvas->AddComponent(slider);
void SetOrigin(float x, float y)
Sets the origin of the slider (for transformations).
Definition Slider.cpp:35
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
Slider()=default
Default constructor.
- See also
- Canvas, UICommand, SUNENGINESprite
◆ Slider()
| Slider::Slider |
( |
std::string | sliderKnobKey, |
|
|
std::string | sliderBarKey ) |
Constructs a Slider with specified knob and bar texture keys.
- Parameters
-
| sliderKnobKey | The texture key for the slider knob. |
| sliderBarKey | The texture key for the slider bar. |
◆ GetAngle()
| float Slider::GetAngle |
( |
| ) |
const |
Gets the angle of the slider in radians.
- Returns
- The angle in radians.
◆ GetHeight()
| float Slider::GetHeight |
( |
| ) |
const |
Gets the height of the slider (bar) in pixels.
- Returns
- The height of the slider.
◆ GetScaleX()
| float Slider::GetScaleX |
( |
| ) |
const |
Gets the x-scale factor of the slider.
- Returns
- The x-scale factor.
◆ GetScaleY()
| float Slider::GetScaleY |
( |
| ) |
const |
Gets the y-scale factor of the slider.
- Returns
- The y-scale factor.
◆ GetValue()
| float Slider::GetValue |
( |
| ) |
const |
Gets the current value of the slider (0.0 to 1.0).
- Returns
- The current slider value.
◆ GetWidth()
| float Slider::GetWidth |
( |
| ) |
const |
Gets the width of the slider (bar) in pixels.
- Returns
- The width of the slider.
◆ IsMouseOver()
| bool Slider::IsMouseOver |
( |
float | xPos, |
|
|
float | yPos ) |
|
overrideprivatevirtual |
Checks if the mouse is over the slider.
- Parameters
-
| xPos | The x-coordinate of the mouse position. |
| yPos | The y-coordinate of the mouse position. |
- Returns
- True if the mouse is over the slider, false otherwise.
Implements UIComponent.
◆ OnPress()
Handles press events (mouse interaction) for the slider.
Implements UIComponent.
◆ Render()
Renders the slider (bar and knob).
Implements UIComponent.
◆ SetAngleDegrees()
| void Slider::SetAngleDegrees |
( |
float | deg | ) |
|
Sets the angle of the slider in degrees.
- Parameters
-
◆ SetAngleRadians()
| void Slider::SetAngleRadians |
( |
float | rad | ) |
|
Sets the angle of the slider in radians.
- Parameters
-
◆ SetLayer()
| void Slider::SetLayer |
( |
int | layer | ) |
|
|
overridevirtual |
Sets the rendering layer of the slider.
- Parameters
-
Reimplemented from UIComponent.
◆ SetOnPressCommand()
| void Slider::SetOnPressCommand |
( |
UICommand * | cmd | ) |
|
Sets the command to be executed when the slider is pressed.
- Parameters
-
| cmd | The command to execute. |
◆ SetOrigin()
| void Slider::SetOrigin |
( |
float | x, |
|
|
float | y ) |
Sets the origin of the slider (for transformations).
- Parameters
-
| x | The x-coordinate of the origin (0.0 to 1.0). |
| y | The y-coordinate of the origin (0.0 to 1.0). |
◆ SetPosition()
| void Slider::SetPosition |
( |
float | x, |
|
|
float | y ) |
Sets the position of the slider.
- Parameters
-
| x | The x-coordinate of the slider's center. |
| y | The y-coordinate of the slider's center. |
◆ SetScaleFactor()
| void Slider::SetScaleFactor |
( |
float | x, |
|
|
float | y ) |
Sets the scale factor of the slider.
- Parameters
-
| x | The x-scale factor. |
| y | The y-scale factor. |
◆ SetScalePixel()
| void Slider::SetScalePixel |
( |
float | x, |
|
|
float | y ) |
Sets the scale of the slider in pixels.
- Parameters
-
| x | The width in pixels. |
| y | The height in pixels. |
◆ SetValue()
| void Slider::SetValue |
( |
float | value | ) |
|
Sets the value of the slider (0.0 to 1.0).
- Parameters
-
| value | The new value for the slider. |
The documentation for this class was generated from the following files: