|
Gin
|
A discrete value that can't blend, like a text or an icon: on a change the previous value fades out while the new one fades in, over a Transition found exactly like Animated's (layout "transition" by property name, preset, inline spec). More...
#include <gin_animated.h>
Public Member Functions | |
| Crossfade (juce::Component &owner, const juce::String &property={}, T initial=T()) | |
| const T & | getCurrent () const |
| The incoming value, the only one once the fade ends. | |
| const T & | getPrevious () const |
| The outgoing value; equals getCurrent() when no fade runs. | |
| float | getProgress () const |
| 0 shows only the previous value, 1 only the current one | |
| template<typename PaintFn> | |
| void | draw (PaintFn &&paintOne) const |
| Paints both sides of the fade with your own drawing: calls paintOne (value, opacity) for the previous value at 1 - progress and the current one at progress, skipping a side at opacity 0. | |
| void | setValue (T newValue) |
| Jumps to the value, stopping any fade. | |
| void | updateTarget (T newValue) |
| Changes the incoming value without restarting a running fade, e.g. | |
| void | setTarget (T newTarget) |
| Fades to the value with the owner's transition for the property. | |
| void | setTarget (T newTarget, const juce::String &nameOrSpec) |
| Fades to the value with a preset name (looked up from the owner up), an inline spec like "150 inOutQuad" or "none". | |
| void | setTarget (T newTarget, const Transition &t) |
| Fades to the value with an explicit Transition. | |
| Public Member Functions inherited from AnimatedBase | |
| AnimatedBase (juce::Component &owner, const juce::String &property) | |
| virtual | ~AnimatedBase () |
| bool | isAnimating () const |
| True while a transition runs. | |
| juce::Component * | getOwner () const |
| The owning component, nullptr once it was deleted. | |
| const juce::String & | getProperty () const |
| The name the layout's "transition" entries know this value by. | |
| Transition | getTransition () const |
| The transition setTarget (value) uses: the owner's for the property, see Transition::forProperty. | |
Additional Inherited Members | |
| Public Attributes inherited from AnimatedBase | |
| std::function< void()> | onChange |
| Called on every change of the current value (each animation step, and jumps), after the owner was asked to repaint. | |
| Protected Member Functions inherited from AnimatedBase | |
| bool | start (const Transition &t) |
| Returns false when the change has to apply at once: an instant transition or an owner not on screen. | |
| void | stop () |
| void | changed () |
| virtual void | valueChanged () |
| For subclasses that apply the value somewhere: called on every change, before onChange. | |
| float | getLastProgress () const |
| The eased progress of the latest step of the running transition. | |
A discrete value that can't blend, like a text or an icon: on a change the previous value fades out while the new one fades in, over a Transition found exactly like Animated's (layout "transition" by property name, preset, inline spec).
Painting draws getPrevious() at an opacity of 1 - getProgress() and getCurrent() at getProgress(), or uses the drawText / drawIcon helpers which do just that. T needs copy assignment and operator==; juce::String and juce::Path are the usual ones.
A new target while a fade runs restarts it from 0, with the value that showed more so far as the one fading out. updateTarget() changes the incoming value without a restart.
| Crossfade< T >::Crossfade | ( | juce::Component & | owner, |
| const juce::String & | property = {}, | ||
| T | initial = T() ) |
| owner | The component that repaints on every step and whose layout transitions apply |
| property | The name the layout's "transition" object knows this value by |
| initial | The starting value, shown alone |
| const T & Crossfade< T >::getCurrent | ( | ) | const |
The incoming value, the only one once the fade ends.
| const T & Crossfade< T >::getPrevious | ( | ) | const |
The outgoing value; equals getCurrent() when no fade runs.
| float Crossfade< T >::getProgress | ( | ) | const |
0 shows only the previous value, 1 only the current one
| void Crossfade< T >::draw | ( | PaintFn && | paintOne | ) | const |
Paints both sides of the fade with your own drawing: calls paintOne (value, opacity) for the previous value at 1 - progress and the current one at progress, skipping a side at opacity 0.
Multiply your colours' alpha by the opacity.
| void Crossfade< T >::setValue | ( | T | newValue | ) |
Jumps to the value, stopping any fade.
References AnimatedBase::changed(), and AnimatedBase::stop().
Referenced by setTarget(), setTarget(), and updateTarget().
| void Crossfade< T >::updateTarget | ( | T | newValue | ) |
Changes the incoming value without restarting a running fade, e.g.
a counter that keeps changing while it fades in. Without a fade it jumps.
References AnimatedBase::changed(), AnimatedBase::isAnimating(), and setValue().
| void Crossfade< T >::setTarget | ( | T | newTarget | ) |
Fades to the value with the owner's transition for the property.
References AnimatedBase::getTransition(), and setTarget().
Referenced by setTarget(), and setTarget().
| void Crossfade< T >::setTarget | ( | T | newTarget, |
| const juce::String & | nameOrSpec ) |
Fades to the value with a preset name (looked up from the owner up), an inline spec like "150 inOutQuad" or "none".
References AnimatedBase::getOwner(), Transition::resolve(), setTarget(), and setValue().
| void Crossfade< T >::setTarget | ( | T | newTarget, |
| const Transition & | t ) |
Fades to the value with an explicit Transition.
References AnimatedBase::changed(), setValue(), and AnimatedBase::start().