|
Zappy GUI
C++ graphic client: renderer, camera, network
|
Self-contained speed slider widget. More...
#include <SpeedSlider.hpp>
Inheritance diagram for SpeedSlider:
Collaboration diagram for SpeedSlider:Public Member Functions | |
| void | syncFromServer (int serverTimeUnit) |
| Snaps to the nearest step index matching serverTimeUnit. No-op if already initialized or serverTimeUnit is 0. | |
| void | reset () |
| Resets slider state. Call on reconnect so it re-syncs from the new server. | |
| bool | handleInput () override |
| Processes mouse input. | |
| std::optional< int > | getPendingSpeedChange () |
| Returns and clears any pending speed change. | |
| void | draw (int scaledFontSize) const override |
| Draws the slider panel at the bottom-left of the screen. | |
| int | currentSpeed () const |
Public Member Functions inherited from IWidget | |
| virtual | ~IWidget ()=default |
Static Public Attributes | |
| static constexpr int | PANEL_WIDTH = 220 |
| static constexpr int | PANEL_HEIGHT = 58 |
| static const std::vector< int > | STEPS |
Static Private Member Functions | |
| static float | _trackX (float panelX) |
| static float | _trackY (float panelY, float panelH) |
| static float | _trackW (float panelW) |
Private Attributes | |
| int | _index = 23 |
| bool | _dragging = false |
| bool | _initialized = false |
| std::optional< int > | _pendingSpeed = std::nullopt |
Self-contained speed slider widget.
Encapsulates all state, input handling, and drawing for the server-speed slider panel displayed at the bottom-left of the screen. Matches the HUD visual style (same rounded panel, colors, and font scaling).
Discrete speed steps: 1, 2, 3, 4, then 5 to 200 in steps of 5.
Definition at line 17 of file SpeedSlider.hpp.
|
staticprivate |
Definition at line 31 of file SpeedSlider.cpp.
Referenced by draw(), and handleInput().
Here is the caller graph for this function:
|
staticprivate |
Definition at line 29 of file SpeedSlider.cpp.
Referenced by draw(), and handleInput().
Here is the caller graph for this function:
|
staticprivate |
Definition at line 30 of file SpeedSlider.cpp.
Referenced by draw(), and handleInput().
Here is the caller graph for this function:
|
inline |
Definition at line 54 of file SpeedSlider.hpp.
|
overridevirtual |
Draws the slider panel at the bottom-left of the screen.
| scaledFontSize | Pre-scaled font size matching the HUD. |
Implements IWidget.
Definition at line 94 of file SpeedSlider.cpp.
References _dragging, _index, _trackW(), _trackX(), _trackY(), ACCENT_COLOR, BG_COLOR, BORDER_COLOR, BORDER_THICKNESS, TextRenderer::draw(), I18n::get(), HANDLE_DRAG_COLOR, HANDLE_RADIUS, PANEL_HEIGHT, PANEL_WIDTH, ROUNDNESS, SEGMENTS, I18n::SPEED_LABEL, STEPS, TRACK_BG_COLOR, TRACK_FILL_COLOR, and TRACK_H.
Referenced by RaylibRenderer::_drawSpeedSlider().
Here is the call graph for this function:
Here is the caller graph for this function:| std::optional< int > SpeedSlider::getPendingSpeedChange | ( | ) |
Returns and clears any pending speed change.
Definition at line 87 of file SpeedSlider.cpp.
References _pendingSpeed.
Referenced by RaylibRenderer::handleInput().
Here is the caller graph for this function:
|
overridevirtual |
Processes mouse input.
Implements IWidget.
Definition at line 50 of file SpeedSlider.cpp.
References _dragging, _index, _pendingSpeed, _trackW(), _trackX(), _trackY(), HANDLE_RADIUS, PANEL_HEIGHT, PANEL_WIDTH, and STEPS.
Referenced by RaylibRenderer::handleInput().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Resets slider state. Call on reconnect so it re-syncs from the new server.
Definition at line 31 of file SpeedSlider.hpp.
References _dragging, and _initialized.
Referenced by RaylibRenderer::init().
Here is the caller graph for this function:| void SpeedSlider::syncFromServer | ( | int | serverTimeUnit | ) |
Snaps to the nearest step index matching serverTimeUnit. No-op if already initialized or serverTimeUnit is 0.
Definition at line 33 of file SpeedSlider.cpp.
References _index, _initialized, and STEPS.
Referenced by RaylibRenderer::_drawSpeedSlider().
Here is the caller graph for this function:
|
private |
Definition at line 58 of file SpeedSlider.hpp.
Referenced by draw(), handleInput(), and reset().
|
private |
Definition at line 57 of file SpeedSlider.hpp.
Referenced by currentSpeed(), draw(), handleInput(), and syncFromServer().
|
private |
Definition at line 59 of file SpeedSlider.hpp.
Referenced by reset(), and syncFromServer().
|
private |
Definition at line 60 of file SpeedSlider.hpp.
Referenced by getPendingSpeedChange(), and handleInput().
|
staticconstexpr |
Definition at line 20 of file SpeedSlider.hpp.
Referenced by draw(), handleInput(), and RaylibRenderer::handleInput().
|
staticconstexpr |
Definition at line 19 of file SpeedSlider.hpp.
Referenced by draw(), handleInput(), and RaylibRenderer::handleInput().
|
static |
Definition at line 11 of file SpeedSlider.hpp.
Referenced by currentSpeed(), draw(), handleInput(), and syncFromServer().