Phosphor::Transition(S, M)
Abstract base for animated screen transitions between two Screen
instances — the animated alternative to Cmd::Push/Cmd::Pop/
Cmd::Replace's instant swap.
Generic over S, the same application state type Screen(S, M) and
Widget(S, M) use — a Transition only ever runs between two screens
that share the same S. Also generic over M, the app's own Msg
type, for the same reason.
See TASKS.md § "Phase 25: Animated screen transitions" for the full rationale.
Instance methods
Returns an iterator of compositing Procs, one per animation frame, for a transition from from to to, rendering with state.
Each yielded Proc(Buffer, Void) receives the frame's shared
Buffer and paints the in-progress transition state into it —
Procs rather than raw Frames, since a transition needs to blend
from's and to's own renders (e.g. a slide needs both screens'
content in the same buffer, offset against each other), which this
lets a concrete Transition do without needing Buffer's
constructor exposed publicly.
state is passed through to Screen#render for both from and
to — AppState is shared across the screen stack (see Phase 19),
so a single value renders either screen correctly. Neither from
nor to caches its own state, so a Transition can't render them
without it.
App#run consumes this iterator one Proc per render tick during a
transition; once it's exhausted, to becomes the fully active
screen. An iterator with no elements (see NoTransition) means the
swap happens on the very next render, with no animation at all.