mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 20:12:23 +00:00
* started refactoring for gui windows * a bit more work on gui windows * fixed some bugs and broken build stuff * fixed some bugs in gui controls * a little code cleanup * got gui dialogs positioning and experimenting with named styles by type * apply control styles directly in the constructor of controls * got everything compiling again * all gui controls have skinnable constructors * rework uniform grid desired size calculations * turns out gui layouts are complicated * include pdb files in nuget packages * fixed a bug in find nearest glyph * custom control styling * added a range constructor overload that takes one value * rethinking control desired size behaviour * made particle emitters more editable at runtime * moved the auto trigger code to the particle effect instead of the emitters * tweaks * changed the particle modifer interface to an abstract base with an optional name * changed the particle modifer interface to an abstract base with an optional name * an attempt at creating a gui combo box * rolled back the nested control experiment * pretty good (but not perfect) combo boxes * tweaks * name property bindings on lists * removed and cleaned up the hacks from the gui combo box * minor combo box styling tweaks * minor bug fix in gui combo box * experiments with data binding * fixed a mistake on the texture region service interface * working on the ability to serialize particles * finished particle serialization * more robust range deserialization * added editor browable attributes * fixed some broken demos * made the particle modifiers editable at runtime * fixed some issues with particle serialization * fixed some issues with interpolators
98 lines
2.4 KiB
C#
98 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using MonoGame.Extended.Gui.Controls;
|
|
|
|
namespace MonoGame.Extended.Gui
|
|
{
|
|
public abstract class GuiElementCollection<TChild, TParent> : IList<TChild>
|
|
where TParent : class, IRectangular
|
|
where TChild : GuiElement<TParent>
|
|
{
|
|
private readonly TParent _parent;
|
|
private readonly List<TChild> _list = new List<TChild>();
|
|
|
|
public Action<TChild> ItemAdded { get; set; }
|
|
public Action<TChild> ItemRemoved { get; set; }
|
|
|
|
protected GuiElementCollection(TParent parent)
|
|
{
|
|
_parent = parent;
|
|
}
|
|
|
|
public IEnumerator<TChild> GetEnumerator()
|
|
{
|
|
return _list.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return ((IEnumerable)_list).GetEnumerator();
|
|
}
|
|
|
|
public void Add(TChild item)
|
|
{
|
|
item.Parent = _parent;
|
|
_list.Add(item);
|
|
ItemAdded?.Invoke(item);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
foreach (var child in _list)
|
|
{
|
|
child.Parent = null;
|
|
ItemRemoved?.Invoke(child);
|
|
}
|
|
|
|
_list.Clear();
|
|
}
|
|
|
|
public bool Contains(TChild item)
|
|
{
|
|
return _list.Contains(item);
|
|
}
|
|
|
|
public void CopyTo(TChild[] array, int arrayIndex)
|
|
{
|
|
_list.CopyTo(array, arrayIndex);
|
|
}
|
|
|
|
public bool Remove(TChild item)
|
|
{
|
|
item.Parent = null;
|
|
ItemRemoved?.Invoke(item);
|
|
return _list.Remove(item);
|
|
}
|
|
|
|
public int Count => _list.Count;
|
|
|
|
public bool IsReadOnly => ((ICollection<GuiControl>)_list).IsReadOnly;
|
|
|
|
public int IndexOf(TChild item)
|
|
{
|
|
return _list.IndexOf(item);
|
|
}
|
|
|
|
public void Insert(int index, TChild item)
|
|
{
|
|
item.Parent = _parent;
|
|
_list.Insert(index, item);
|
|
ItemAdded?.Invoke(item);
|
|
}
|
|
|
|
public void RemoveAt(int index)
|
|
{
|
|
var child = _list[index];
|
|
child.Parent = null;
|
|
_list.RemoveAt(index);
|
|
ItemRemoved?.Invoke(child);
|
|
}
|
|
|
|
public TChild this[int index]
|
|
{
|
|
get { return _list[index]; }
|
|
set { _list[index] = value; }
|
|
}
|
|
}
|
|
} |