
using Godot;
using Rokojori;
using System.Collections.Generic;
 
namespace Rokojori
{ 
  [Tool]
  [GlobalClass,Icon("res://addons/rokojori_action_library/Icons/UIImage.svg")]
  public partial class UIImageType:Resource
  { 
    public readonly EventSlot<Null> onChange = new EventSlot<Null>();
    List<UIImage> _images = new List<UIImage>();

    public UIImageType()
    {
      onChange.AddAction( a => ApplyChanges() );
    }

    public void Assign( UIImage image )
    {
      _images.Add( image );
      _Assign( image );
      _ApplyChange( image );
    }

    public void Clear( UIImage image )
    {
      _images.Remove( image );
      _Clear( image );
    }

    public void ApplyChanges()
    {
      _images.ForEach( i => _ApplyChange( i ) );
    } 

    protected virtual void _ApplyChange( UIImage image )
    {

    }     

    protected virtual void _Assign( UIImage image )
    {

    } 

    protected virtual void _Clear( UIImage image )
    {
      
    } 

  }
}