![]() |
PRooFPS-dd Dev Doc 1.0
PRooFPS-dd Developer Documentation
|
In/Out Slider GUI Element for PRooFPS-dd. More...
In/Out Slider GUI Element for PRooFPS-dd.
This class has the slide animation control logic only, does not know about the actual GUI element. The idea is that this can be used as a base for a more specific class that encapsulates the actual GUI element. Therefore, this class can be used for sliding not only PureObject3D instances but also Dear ImGui elements or anything else that can have 2D-coordinates.
See the animation logic described at enum AnimState.
Definition at line 30 of file InOutSlider.h.
#include <InOutSlider.h>
Inheritance diagram for proofps_dd::InOutSlider:Public Types | |
| enum class | AnimState { Finished , SlidingIn , WaitingForTimeout , SlidingOut } |
| Initially, the animation is sitting in Finished state. More... | |
Public Member Functions | |
| CConsole & | getConsole () const |
| InOutSlider ()=default | |
| virtual | ~InOutSlider () |
| InOutSlider (const InOutSlider &)=default | |
| InOutSlider & | operator= (const InOutSlider &)=default |
| InOutSlider (InOutSlider &&)=default | |
| InOutSlider & | operator= (InOutSlider &&)=default |
| TXY & | getScreenStartPos () |
| The user shall use this function to set the initial position of the slide-in animation. | |
| const TXY & | getScreenStartPos () const |
| TXY & | getScreenFinishPos () |
| The user shall use this function to set the ending position of the slide-in animation. | |
| const TXY & | getScreenFinishPos () const |
| const TXY & | getScreenCurrentPos () const |
| const AnimState & | getState () const |
| const std::chrono::milliseconds::rep & | getTimeoutInWaitingState () const |
| void | setTimeoutInWaitingState (std::chrono::milliseconds::rep millisecs) |
| Sets the duration for waiting in WaitingForTimeout state before transitioning to SlidingOut state. | |
| void | loadSoundForSlidingIn (pge_audio::PgeAudio &audio, const char *szFilename) |
| void | show (pge_audio::PgeAudio &audio) |
| Starts or resumes the slide-in animation from the Current position towards the Finish position. | |
| void | hide (pge_audio::PgeAudio &audio, bool forceStopAudio) |
| Starts or resumes the slide-out animation from the Current position towards the Start position. | |
| virtual void | update (pge_audio::PgeAudio &audio) |
| Steps the slide animation between the Start and Finish positions. | |
| virtual void | clear () |
| Frees up any loaded resource, like the sound that can be optionally loaded by loadSoundForSlidingIn(). | |
Static Public Member Functions | |
| static const char * | getLoggerModuleName () |
Protected Member Functions | |
| virtual void | stateEntered (const AnimState &, const AnimState &) |
| Invoked by stateEnter() after a successful state transition. | |
Private Member Functions | |
| bool | stateEnter (pge_audio::PgeAudio &audio, const AnimState &newState, bool forceStopAudio) |
| Expected to be invoked only for events, such as explicit call to show(), hide(), or when update() detects an event. | |
| void | stateUpdate (pge_audio::PgeAudio &audio) |
| Expected to be invoked periodically. | |
Private Attributes | |
| TXY | m_posScreenStart {} |
| TXY | m_posScreenFinish {} |
| TXY | m_posScreenTarget {} |
| TXY | m_posScreenCurrent {} |
| AnimState | m_state { AnimState::Finished } |
| std::chrono::milliseconds::rep | m_durationTimeoutMillisecsInWaitingState { 0 } |
| std::chrono::time_point< std::chrono::steady_clock > | m_timeEnteredWaitingState |
| SoLoud::Wav * | m_sndPlayedInSlidingInState { nullptr } |
|
strong |
Initially, the animation is sitting in Finished state.
The animation can be triggered at the beginning using show().
The animation is transitioning through states by periodic calls to update().
The animation can be instructed to go back to Finished state using hide(), but it will follow the state machine flow to do that gradually.
If a TimeOut is set, then between the SlidingIn and SlidingOut states, the animation will stay in WaitingForTimeout state for the TimeOut duration, otherwise the animation will stay in WaitingForTimeout until an explicit call to hide().
Summary: Therefore, the recommended way of controlling the animation is to always do periodical calls to update(), no need to explicitly check for states. The only additional explicit call that is needed only once is show(). If a TimeOut is set, no need to explicitly call hide().
hide()
>--------------------->------------------------------>
| ¡
| update(): update(): timeout, | update():
show() ^ FinishPos reached hide() ¡ FinishPos reached
o--->-> Finished -------> SlidingIn ------------> WaitingForTimeout -------> SlidingOut ---------------> ^ ^ ¡ ^ ¡ ^ ^ ¡ ^ ¡ ¡ ¡ | |hide()| |show()| | |show()| |hide()| | | | ^---—< ^---—< | ^---—< ^---—< | | | | show() | | | ^-----------—<--------------—<--------------—< | | | ^-------—<------------—<------------—<--------------—<-----------------—<--------------—<
| Enumerator | |
|---|---|
| Finished | |
| SlidingIn | |
| WaitingForTimeout | |
| SlidingOut | |
Definition at line 66 of file InOutSlider.h.
|
default |
|
inlinevirtual |
Definition at line 88 of file InOutSlider.h.
|
default |
|
default |
|
inlinevirtual |
Frees up any loaded resource, like the sound that can be optionally loaded by loadSoundForSlidingIn().
Derived classes must extend this method by freeing up their loaded resources as well.
Reimplemented in proofps_dd::PureObject3dInOutSlider.
Definition at line 270 of file InOutSlider.h.
|
inline |
Definition at line 81 of file InOutSlider.h.
|
inlinestatic |
Definition at line 74 of file InOutSlider.h.
|
inline |
Definition at line 145 of file InOutSlider.h.
|
inline |
The user shall use this function to set the ending position of the slide-in animation.
This Finish position is the initial position in WaitingForTimeout and SlidingOut states. This Finish position is the initial position of the slide-out animation.
Definition at line 129 of file InOutSlider.h.
|
inline |
Definition at line 137 of file InOutSlider.h.
|
inline |
The user shall use this function to set the initial position of the slide-in animation.
This Start position is the initial position in Finished and SlidingIn states. This Start position is the ending position of the slide-out animation.
Definition at line 109 of file InOutSlider.h.
|
inline |
Definition at line 117 of file InOutSlider.h.
|
inline |
Definition at line 153 of file InOutSlider.h.
|
inline |
Definition at line 161 of file InOutSlider.h.
|
inline |
Starts or resumes the slide-out animation from the Current position towards the Start position.
No visible effect if the animation is already in SlidingOut or Finished state.
A periodical call to update() is required to eventually reach the Start position. It is advised to call hide() only when you want to start the slide-out animation.
If current state is WaitingForTimeout, we are transitioning to SlidingOut even if a non-zero timeout duration is not yet elapsed.
| forceStopAudio | Set it to true to immediately stop the optionally playing audio that was previously loaded by loadSoundForSlidingIn(). |
Definition at line 239 of file InOutSlider.h.
|
inline |
Definition at line 184 of file InOutSlider.h.
|
default |
|
default |
|
inline |
Sets the duration for waiting in WaitingForTimeout state before transitioning to SlidingOut state.
Setting 0 means waiting in WaitingForTimeout state without time limit, until an explicit call to hide().
| millisecs | The duration expressed in milliseconds for waiting in WaitingForTimeout state. |
Definition at line 173 of file InOutSlider.h.
|
inline |
Starts or resumes the slide-in animation from the Current position towards the Finish position.
No visible effect if the animation is already in SlidingIn or WaitingForTimeout state.
A periodical call to update() is required to eventually reach the Finish position. It is advised to call show() only when you want to start the slide-in animation.
Definition at line 209 of file InOutSlider.h.
|
inlineprivate |
Expected to be invoked only for events, such as explicit call to show(), hide(), or when update() detects an event.
Definition at line 303 of file InOutSlider.h.
|
inlineprotectedvirtual |
Invoked by stateEnter() after a successful state transition.
Reimplemented in proofps_dd::PureObject3dInOutSlider.
Definition at line 284 of file InOutSlider.h.
|
inlineprivate |
Expected to be invoked periodically.
Definition at line 377 of file InOutSlider.h.
|
inlinevirtual |
Steps the slide animation between the Start and Finish positions.
Direction and speed depends on the Current position and the SlidingIn state. Derived class may extend this function by using the updated Current position.
Reimplemented in proofps_dd::PureObject3dInOutSlider.
Definition at line 261 of file InOutSlider.h.
|
private |
Definition at line 294 of file InOutSlider.h.
|
private |
Definition at line 292 of file InOutSlider.h.
|
private |
Definition at line 290 of file InOutSlider.h.
|
private |
Definition at line 289 of file InOutSlider.h.
|
private |
Definition at line 291 of file InOutSlider.h.
|
private |
Definition at line 296 of file InOutSlider.h.
|
private |
Definition at line 293 of file InOutSlider.h.
|
private |
Definition at line 295 of file InOutSlider.h.