#pragma once
#include <string>
#include <functional>
#include "nodes.h"

namespace enginend::nodes::twod {
	struct node2d :public node {
		Vector2 pos;
		node2d();
		node2d(float x,float y);
	};
	struct rect :virtual public node2d{
		Vector2 size;
		rect();
		rect(float x,float y,float w,float h);
	};
	struct textured :virtual public rect{
		Texture2D* texture;
		textured();
		textured(Texture2D* texture,float x,float y,float w,float h);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct animated : virtual public textured {
		Image animimage;
		int frames;
		int currentframe;
		int framedelay;
		int framecounter;
		unsigned int nextframeoffset;
		int prevframe;
		const char*path;
		animated();
		animated(const char* gifpath, Vector2 position, Vector2 size, int delay = 6);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct colored :virtual public rect{
		Color c;
		colored();
		colored(Color color,float x,float y,float w,float h);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct tinted :virtual public colored,virtual public textured{
		tinted();
		tinted(Texture2D* texture,Color color,float x,float y,float w,float h);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct text :public tinted {
	protected:
		std::string result;
	public:
		float fs;
		Color txc;
		std::string content;
		text();
		text(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct button :virtual public tinted{
		std::function<void()> func;
		bool pressed;
		bool hover;
		const bool isboolean;
		bool boolean=false;
		button();
		button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f);
		button(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,std::function<void()> f,bool isboolean);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct labeledbutton :virtual public button {
		std::string label;
		int fs;
		Color txc;
		labeledbutton(std::string name,Texture2D* texture,enginend::theme* theme,
			float x,float y,float w,float h,std::function<void()> f,int size);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct slider :virtual public tinted{
		float val;
		float minv;
		float maxv;
		slider();
		slider(Texture2D* texture,Color color,float x,float y,float w,float h,float min,float max,float v);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct textfield :public text{
		textfield();
		textfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize,std::string txt);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct textinput :public text{
		bool active;
		int cpos;
		textinput();
		textinput(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
	struct textinputfield :public textfield{
		bool active;
		int cpos;
		textinputfield();
		textinputfield(Texture2D* texture,enginend::theme* theme,float x,float y,float w,float h,float fsize);
		void boot()override;
		void tick()override;
		void draw()override;
		void exit()override;
	};
}
