using System.Collections.Generic; namespace Microsoft.Iris.Render.OpenGL { /// /// Shared state machine for animations: play/pause/reset, repeat counting and the /// async-notify event. Target property interpolation is intentionally minimal here /// (see ); full per-frame evaluation is a stage-3 TODO. /// public abstract class GLAnimation : SharedRenderObject, IAnimation { public int RepeatCount { get; set; } public bool IsPlaying { get; private set; } public bool IsActive { get; private set; } public bool AutoReset { get; set; } public AnimationResetBehavior ResetBehavior { get; set; } = AnimationResetBehavior.LeaveCurrent; public event AsyncNotifyHandler? AsyncNotifyEvent; public virtual void Play() { IsPlaying = true; IsActive = true; } public virtual void Pause() => IsPlaying = false; public virtual void Reset() { IsPlaying = false; IsActive = false; } public virtual void InstantAdvance(float advanceTime) { } public virtual void InstantFinish() { IsPlaying = false; IsActive = false; } protected void RaiseAsyncNotify(int cookie) => AsyncNotifyEvent?.Invoke(cookie); /// Advance internal time. Called by the animation system each pulse. internal virtual void Advance(int advanceMs) { } } public sealed class GLAnimationGroup : GLAnimation, IAnimationGroup { private readonly List m_members = new List(); public override void Play() { base.Play(); foreach (var a in m_members) a.Play(); } internal void Add(GLAnimation animation) => m_members.Add(animation); internal override void Advance(int advanceMs) { foreach (var a in m_members) a.Advance(advanceMs); } } }