|
R-Type
Distributed multiplayer game engine in C++
|
Raylib implementation of the ISlider interface. More...
#include <RaylibSlider.hpp>


Public Member Functions | |
| RaylibSlider (Graphics::IGraphics &graphics) | |
| Construct a new RaylibSlider. | |
| ~RaylibSlider () override=default | |
| Destroy the RaylibSlider. | |
| void | Update () override |
| Update the slider internal state (hover, drag). | |
| void | Render () override |
| Render the slider. | |
| void | SetOnValueChanged (std::function< void(float)> callback) override |
| Set callback invoked when value changes. | |
| void | SetPosition (float x, float y) override |
| Set the top-left position of the slider. | |
| void | GetPosition (float &x, float &y) const override |
| Get the current top-left position of the slider. | |
| void | SetSize (float width, float height) override |
| Set the slider size. | |
| void | GetSize (float &width, float &height) const override |
| Get the current size of the slider. | |
| void | SetTrackColor (unsigned int color) override |
| Set the track color (unfilled portion). | |
| void | SetFilledColor (unsigned int color) override |
| Set the filled track color (portion before handle). | |
| void | SetHandleColor (unsigned int color) override |
| Set the handle color. | |
| void | SetHandleHoverColor (unsigned int color) override |
| Set the handle hover color. | |
| void | SetMinValue (float minValue) override |
| Set the minimum value. | |
| void | SetMaxValue (float maxValue) override |
| Set the maximum value. | |
| void | SetValue (float value) override |
| Set the current value. | |
| float | GetValue () const override |
| Get the current value. | |
| void | SetAlign (Align align) override |
| Set alignment mode relative to the window. | |
| Align | GetAlign () const override |
| Get the current alignment mode. | |
| void | ApplyAlignment () override |
| Apply the current alignment mode to the position. | |
| void | SetEnabled (bool enabled) override |
| Enable or disable the slider. | |
| bool | IsEnabled () const override |
| Check if the slider is enabled. | |
Public Member Functions inherited from UI::ISlider | |
| virtual | ~ISlider ()=default |
| Virtual destructor. | |
Private Member Functions | |
| bool | IsMouseOverHandle () const |
| Check whether the mouse cursor is over the handle. | |
| bool | IsMouseOverTrack () const |
| Check whether the mouse cursor is over the track. | |
| void | UpdateValueFromMouse () |
| Update value based on mouse position. | |
| void | ClampValue () |
| Clamp value to [min, max] range. | |
Private Attributes | |
| Graphics::IGraphics & | _graphics |
| std::function< void(float)> | _onValueChanged {} |
| float | _x {0.0F} |
| float | _y {0.0F} |
| float | _width {200.0F} |
| float | _height {10.0F} |
| unsigned int | _trackColor {0xFF505050} |
| unsigned int | _filledColor {0xFF4CAF50} |
| unsigned int | _handleColor {0xFFFFFFFF} |
| unsigned int | _handleHoverColor {0xFFE0E0E0} |
| float | _minValue {0.0F} |
| float | _maxValue {100.0F} |
| float | _value {50.0F} |
| bool | _enabled {true} |
| bool | _isDragging {false} |
| bool | _isHovered {false} |
| Align | _align {Align::NONE} |
Static Private Attributes | |
| static constexpr float | HANDLE_RADIUS = 12.0F |
| static constexpr float | TRACK_HEIGHT_RATIO = 0.4F |
Raylib implementation of the ISlider interface.
Features:
Definition at line 27 of file RaylibSlider.hpp.
|
explicit |
Construct a new RaylibSlider.
| graphics | Graphics wrapper used for input and drawing. |
Definition at line 15 of file RaylibSlider.cpp.
|
overridedefault |
Destroy the RaylibSlider.
|
overridevirtual |
Apply the current alignment mode to the position.
Implements UI::ISlider.
Definition at line 170 of file RaylibSlider.cpp.
References _align, _graphics, _height, _width, _x, _y, UI::CENTER_BOTH, UI::CENTER_HORIZONTAL, UI::CENTER_VERTICAL, Graphics::IGraphics::GetScreenHeight(), Graphics::IGraphics::GetScreenWidth(), and UI::NONE.

|
private |
Clamp value to [min, max] range.
Definition at line 256 of file RaylibSlider.cpp.
References _maxValue, _minValue, and _value.
Referenced by SetMaxValue(), SetMinValue(), and SetValue().
|
overridevirtual |
Get the current alignment mode.
Implements UI::ISlider.
Definition at line 166 of file RaylibSlider.cpp.
References _align.
|
overridevirtual |
Get the current top-left position of the slider.
| x | Output X position in pixels. |
| y | Output Y position in pixels. |
Implements UI::ISlider.
Definition at line 106 of file RaylibSlider.cpp.
|
overridevirtual |
Get the current size of the slider.
| width | Output width in pixels. |
| height | Output height in pixels. |
Implements UI::ISlider.
Definition at line 116 of file RaylibSlider.cpp.
|
overridevirtual |
Get the current value.
Implements UI::ISlider.
Definition at line 158 of file RaylibSlider.cpp.
References _value.
|
overridevirtual |
Check if the slider is enabled.
Implements UI::ISlider.
Definition at line 199 of file RaylibSlider.cpp.
References _enabled.
|
private |
Check whether the mouse cursor is over the handle.
Definition at line 203 of file RaylibSlider.cpp.
References _graphics, _height, _maxValue, _minValue, _value, _width, _x, _y, Graphics::IGraphics::GetMouseX(), Graphics::IGraphics::GetMouseY(), and HANDLE_RADIUS.
Referenced by Update().

|
private |
Check whether the mouse cursor is over the track.
Definition at line 224 of file RaylibSlider.cpp.
References _graphics, _height, _width, _x, _y, Graphics::IGraphics::GetMouseX(), and Graphics::IGraphics::GetMouseY().
Referenced by Update().

|
overridevirtual |
Render the slider.
Implements UI::ISlider.
Definition at line 53 of file RaylibSlider.cpp.
References _filledColor, _graphics, _handleColor, _handleHoverColor, _height, _isDragging, _isHovered, _maxValue, _minValue, _trackColor, _value, _width, _x, _y, Graphics::IGraphics::DrawCircle(), Graphics::IGraphics::DrawCircleFilled(), Graphics::IGraphics::DrawRectangle(), HANDLE_RADIUS, and TRACK_HEIGHT_RATIO.

|
overridevirtual |
Set alignment mode relative to the window.
| align | Alignment mode. |
Implements UI::ISlider.
Definition at line 162 of file RaylibSlider.cpp.
References _align.
|
overridevirtual |
Enable or disable the slider.
| enabled | true to enable, false to disable. |
Implements UI::ISlider.
Definition at line 191 of file RaylibSlider.cpp.
References _enabled, _isDragging, and _isHovered.
|
overridevirtual |
Set the filled track color (portion before handle).
| color | Color in ARGB format (0xAARRGGBB). |
Implements UI::ISlider.
Definition at line 125 of file RaylibSlider.cpp.
References _filledColor.
|
overridevirtual |
Set the handle color.
| color | Color in ARGB format (0xAARRGGBB). |
Implements UI::ISlider.
Definition at line 129 of file RaylibSlider.cpp.
References _handleColor.
|
overridevirtual |
Set the handle hover color.
| color | Color in ARGB format (0xAARRGGBB). |
Implements UI::ISlider.
Definition at line 133 of file RaylibSlider.cpp.
References _handleHoverColor.
|
overridevirtual |
Set the maximum value.
| maxValue | Maximum value. |
Implements UI::ISlider.
Definition at line 142 of file RaylibSlider.cpp.
References _maxValue, and ClampValue().

|
overridevirtual |
Set the minimum value.
| minValue | Minimum value. |
Implements UI::ISlider.
Definition at line 137 of file RaylibSlider.cpp.
References _minValue, and ClampValue().

|
overridevirtual |
Set callback invoked when value changes.
| callback | Function called when the slider value changes. |
Implements UI::ISlider.
Definition at line 97 of file RaylibSlider.cpp.
References _onValueChanged.
|
overridevirtual |
Set the top-left position of the slider.
| x | X position in pixels. |
| y | Y position in pixels. |
Implements UI::ISlider.
Definition at line 101 of file RaylibSlider.cpp.
|
overridevirtual |
Set the slider size.
| width | Width in pixels (track length). |
| height | Height in pixels (track thickness). |
Implements UI::ISlider.
Definition at line 111 of file RaylibSlider.cpp.
|
overridevirtual |
Set the track color (unfilled portion).
| color | Color in ARGB format (0xAARRGGBB). |
Implements UI::ISlider.
Definition at line 121 of file RaylibSlider.cpp.
References _trackColor.
|
overridevirtual |
Set the current value.
| value | Current value (will be clamped to [min, max]). |
Implements UI::ISlider.
Definition at line 147 of file RaylibSlider.cpp.
References _onValueChanged, _value, and ClampValue().

|
overridevirtual |
Update the slider internal state (hover, drag).
Implements UI::ISlider.
Definition at line 17 of file RaylibSlider.cpp.
References _enabled, _graphics, _isDragging, _isHovered, Graphics::IGraphics::IsMouseButtonDown(), Graphics::IGraphics::IsMouseButtonPressed(), IsMouseOverHandle(), IsMouseOverTrack(), and UpdateValueFromMouse().

|
private |
Update value based on mouse position.
Definition at line 232 of file RaylibSlider.cpp.
References _graphics, _maxValue, _minValue, _onValueChanged, _value, _width, _x, and Graphics::IGraphics::GetMouseX().
Referenced by Update().

|
private |
Definition at line 142 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), GetAlign(), and SetAlign().
|
private |
Definition at line 138 of file RaylibSlider.hpp.
Referenced by IsEnabled(), SetEnabled(), and Update().
|
private |
Definition at line 130 of file RaylibSlider.hpp.
Referenced by Render(), and SetFilledColor().
|
private |
Definition at line 121 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), IsMouseOverHandle(), IsMouseOverTrack(), Render(), Update(), and UpdateValueFromMouse().
|
private |
Definition at line 131 of file RaylibSlider.hpp.
Referenced by Render(), and SetHandleColor().
|
private |
Definition at line 132 of file RaylibSlider.hpp.
Referenced by Render(), and SetHandleHoverColor().
|
private |
Definition at line 127 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), GetSize(), IsMouseOverHandle(), IsMouseOverTrack(), Render(), and SetSize().
|
private |
Definition at line 139 of file RaylibSlider.hpp.
Referenced by Render(), SetEnabled(), and Update().
|
private |
Definition at line 140 of file RaylibSlider.hpp.
Referenced by Render(), SetEnabled(), and Update().
|
private |
Definition at line 135 of file RaylibSlider.hpp.
Referenced by ClampValue(), IsMouseOverHandle(), Render(), SetMaxValue(), and UpdateValueFromMouse().
|
private |
Definition at line 134 of file RaylibSlider.hpp.
Referenced by ClampValue(), IsMouseOverHandle(), Render(), SetMinValue(), and UpdateValueFromMouse().
|
private |
Definition at line 122 of file RaylibSlider.hpp.
Referenced by SetOnValueChanged(), SetValue(), and UpdateValueFromMouse().
|
private |
Definition at line 129 of file RaylibSlider.hpp.
Referenced by Render(), and SetTrackColor().
|
private |
Definition at line 136 of file RaylibSlider.hpp.
Referenced by ClampValue(), GetValue(), IsMouseOverHandle(), Render(), SetValue(), and UpdateValueFromMouse().
|
private |
Definition at line 126 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), GetSize(), IsMouseOverHandle(), IsMouseOverTrack(), Render(), SetSize(), and UpdateValueFromMouse().
|
private |
Definition at line 124 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), GetPosition(), IsMouseOverHandle(), IsMouseOverTrack(), Render(), SetPosition(), and UpdateValueFromMouse().
|
private |
Definition at line 125 of file RaylibSlider.hpp.
Referenced by ApplyAlignment(), GetPosition(), IsMouseOverHandle(), IsMouseOverTrack(), Render(), and SetPosition().
|
staticconstexprprivate |
Definition at line 144 of file RaylibSlider.hpp.
Referenced by IsMouseOverHandle(), and Render().
|
staticconstexprprivate |
Definition at line 145 of file RaylibSlider.hpp.
Referenced by Render().