// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; namespace osu.Framework.Graphics.UserInterface { /// /// A drawable object that supports counting to values. /// public class Counter : CompositeDrawable { private double count; /// /// The current count. /// protected double Count { get => count; private set { if (count == value) return; count = value; OnCountChanged(count); } } /// /// Invoked when has changed. /// protected virtual void OnCountChanged(double count) { } public TransformSequence CountTo(double endCount, double duration = 0, Easing easing = Easing.None) => this.TransformTo(nameof(Count), endCount, duration, easing); } public static class CounterTransformSequenceExtensions { public static TransformSequence CountTo(this TransformSequence t, double endCount, double duration = 0, Easing easing = Easing.None) => t.Append(o => o.CountTo(endCount, duration, easing)); } }