A game framework written with osu! in mind.
at master 41 lines 2.2 kB view raw
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.Collections.Generic; 5using System.Collections.Specialized; 6 7namespace osu.Framework.Bindables 8{ 9 /// <summary> 10 /// A readonly interface which can be bound to other <see cref="IBindableList{T}"/>s in order to watch for state and content changes. 11 /// </summary> 12 /// <typeparam name="T">The type of value encapsulated by this <see cref="IBindableList{T}"/>.</typeparam> 13 public interface IBindableList<T> : IReadOnlyList<T>, ICanBeDisabled, IHasDefaultValue, IUnbindable, IHasDescription, INotifyCollectionChanged 14 { 15 /// <summary> 16 /// Binds self to another bindable such that we receive any values and value limitations of the bindable we bind width. 17 /// </summary> 18 /// <param name="them">The foreign bindable. This should always be the most permanent end of the bind (ie. a ConfigManager)</param> 19 void BindTo(IBindableList<T> them); 20 21 /// <summary> 22 /// Bind an action to <see cref="INotifyCollectionChanged.CollectionChanged"/> with the option of running the bound action once immediately 23 /// with an <see cref="NotifyCollectionChangedAction.Add"/> event for the entire contents of this <see cref="BindableList{T}"/>. 24 /// </summary> 25 /// <param name="onChange">The action to perform when this <see cref="BindableList{T}"/> changes.</param> 26 /// <param name="runOnceImmediately">Whether the action provided in <paramref name="onChange"/> should be run once immediately.</param> 27 void BindCollectionChanged(NotifyCollectionChangedEventHandler onChange, bool runOnceImmediately = false); 28 29 /// <summary> 30 /// An alias of <see cref="BindTo"/> provided for use in object initializer scenarios. 31 /// Passes the provided value as the foreign (more permanent) bindable. 32 /// </summary> 33 sealed IBindableList<T> BindTarget 34 { 35 set => BindTo(value); 36 } 37 38 /// <inheritdoc cref="IBindable.GetBoundCopy"/> 39 IBindableList<T> GetBoundCopy(); 40 } 41}