A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5
6namespace osu.Framework.Bindables
7{
8 public interface IBindableNumber<T> : IBindable<T>
9 where T : struct, IComparable<T>, IEquatable<T>
10 {
11 /// <summary>
12 /// An event which is raised when <see cref="Precision"/> has changed.
13 /// </summary>
14 event Action<T> PrecisionChanged;
15
16 /// <summary>
17 /// An event which is raised when <see cref="MinValue"/> has changed.
18 /// </summary>
19 event Action<T> MinValueChanged;
20
21 /// <summary>
22 /// An event which is raised when <see cref="MaxValue"/> has changed.
23 /// </summary>
24 event Action<T> MaxValueChanged;
25
26 /// <summary>
27 /// The precision up to which the value of this bindable should be rounded.
28 /// </summary>
29 T Precision { get; }
30
31 /// <summary>
32 /// The minimum value of this bindable. <see cref="IBindable{T}.Value">Value</see> will never go below this value.
33 /// </summary>
34 T MinValue { get; }
35
36 /// <summary>
37 /// The maximum value of this bindable. <see cref="IBindable{T}.Value">Value</see> will never go above this value.
38 /// </summary>
39 T MaxValue { get; }
40
41 /// <summary>
42 /// Whether <typeparamref name="T"/> is an integer.
43 /// </summary>
44 bool IsInteger { get; }
45
46 /// <summary>
47 /// Retrieve a new bindable instance weakly bound to the configuration backing.
48 /// If you are further binding to events of a bindable retrieved using this method, ensure to hold
49 /// a local reference.
50 /// </summary>
51 /// <returns>A weakly bound copy of the specified bindable.</returns>
52 new IBindableNumber<T> GetBoundCopy();
53 }
54}