using System.Threading.Tasks;
using Mox.Shared.UI;
using Mox.Shared.Math;

namespace Mox.Shared.Renderer
{
	public abstract class RendererBase
	{
		public abstract Task<ImageBase> CreateImage(string _sPath);
		public abstract void FillRect(Rect _rect, Color _color);
		public abstract void DrawImage(ImageBase _image, Rect _source, Rect _target);
		public abstract void BeginDraw();
		public abstract void EndDraw();

		public abstract void Clear(Color _color);
		public abstract void SetTextColor(Color _color);
		public abstract void SetTextStyle(string _sFont, int _iSize);
		public abstract void DrawText(string _sText, int _iX, int _iY);
		public abstract Rect MeasureText(string _sText);

		public void Render(Control _uiControl)
		{
			if (_uiControl.Visibility == EVisibility.Visible)
			{
				_uiControl.Render();

				foreach (var child in _uiControl.Children)
				{
					Render(child);
				}
			}
		}

		public Atlas Atlas { get; set; }
		public static RendererBase Instance { get; protected set; }

		public abstract void Dispose();
	}
}
