This controller can be used to animate between two visual states using one or two timelines.
Provides an interface for co-ordinating two visual states with animations between them. One or two timelines can be provided in SetTimelines(), and this controller will manage playing the appropriate timeline in the appropriate direction when the CYIAnimationToggleController::State is changed.
#include <animation/YiAnimationToggleController.h>
Public Types | |
enum | State { State::Off = 0, State::On } |
Public Member Functions | |
CYIAnimationToggleController () | |
CYIAnimationToggleController (CYIAnimationToggleController &&other) | |
virtual | ~CYIAnimationToggleController () |
void | SetTimelines (CYIAbstractTimeline *pTimelineOn, CYIAbstractTimeline *pTimelineOff=nullptr) |
void | SetTimelines (std::unique_ptr< CYIAbstractTimeline > pTimelineOn, std::unique_ptr< CYIAbstractTimeline > pTimelineOff) |
State | GetState () const |
bool | IsAnimating () const |
void | ToggleOn () |
void | ToggleOff () |
void | ToggleToState (State state) |
bool | IsToggledOn () const |
bool | IsToggledOff () const |
void | Toggle () |
void | ResetToState (State state) |
![]() | |
CYISignalHandler () | |
CYISignalHandler (const CYISignalHandler &rSignalHandler) | |
virtual | ~CYISignalHandler () |
CYISignalHandler & | operator= (const CYISignalHandler &rSignalHandler) |
void | MoveToThread (CYIThread *pThread) |
This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More... | |
CYIThreadHandle | GetThreadAffinity () const |
void | SetThreadAffinity (const CYIThreadHandle &rThreadAffinity) |
virtual bool | IsConnected () const |
virtual bool | IsConnected (const CYISignalBase &rSignal) const |
void | Disconnect (CYISignalBase &rSignal) |
void | DisconnectFromAllSignals () |
![]() | |
Listener () | |
virtual | ~Listener () |
virtual void | OnThreadStarted (CYIThread *) |
virtual void | OnThreadTerminated (CYIThread *) |
virtual void | OnThreadFinished (CYIThread *) |
Public Attributes | |
CYISignal< State > | StateChanged |
CYISignal< State > | AnimationEnded |
|
strong |
Enumerator | |
---|---|
Off | |
On |
CYIAnimationToggleController::CYIAnimationToggleController | ( | ) |
CYIAnimationToggleController::CYIAnimationToggleController | ( | CYIAnimationToggleController && | other | ) |
|
virtual |
State CYIAnimationToggleController::GetState | ( | ) | const |
Returns the current state. The initial state is CYIAnimationToggleController::State::Off for a newly constructed object.
bool CYIAnimationToggleController::IsAnimating | ( | ) | const |
Returns true if one of the timelines is playing.
bool CYIAnimationToggleController::IsToggledOff | ( | ) | const |
Returns true if this controller is in the CYIAnimationToggleController::State::Off state.
bool CYIAnimationToggleController::IsToggledOn | ( | ) | const |
Returns true if this controller is in the CYIAnimationToggleController::State::On state.
void CYIAnimationToggleController::ResetToState | ( | State | state | ) |
Immediately transitions this controller to state without playing any timelines or emitting the CYIAnimationToggleController::StateChanged signal. The CYIAnimationToggleController::AnimationEnded signal will be emitted immediately.
void CYIAnimationToggleController::SetTimelines | ( | CYIAbstractTimeline * | pTimelineOn, |
CYIAbstractTimeline * | pTimelineOff = nullptr |
||
) |
Specifies the timelines to be controlled. pTimelineOn is mandatory and pTimelineOff is optional. Pass nullptr to indicate there is no 'off' timeline.
If both timelines are specified:
If only pTimelineOn is specified:
ResetToState() will be called with the current CYIAnimationToggleController::State so the new timelines provided take effect immediately.
This function does not take ownership of the provided timelines.
void CYIAnimationToggleController::SetTimelines | ( | std::unique_ptr< CYIAbstractTimeline > | pTimelineOn, |
std::unique_ptr< CYIAbstractTimeline > | pTimelineOff | ||
) |
Specifies the timelines to be controlled. pTimelineOn is mandatory and pTimelineOff is optional. Pass nullptr to indicate there is no 'off' timeline.
If both timelines are specified:
If only pTimelineOn is specified:
ResetToState() will be called with the current CYIAnimationToggleController::State so the new timelines provided take effect immediately.
void CYIAnimationToggleController::Toggle | ( | ) |
Immediately transitions this controller to the opposite state, then plays the appropriate timeline.
void CYIAnimationToggleController::ToggleOff | ( | ) |
Immediately transitions this controller to the CYIAnimationToggleController::State::Off state, then plays the appropriate timeline.
void CYIAnimationToggleController::ToggleOn | ( | ) |
Immediately transitions this controller to the CYIAnimationToggleController::State::On state, then plays the appropriate timeline.
Emitted when the animation to the new state ends.
Emitted when the controller's state has changed.