
#ifndef SPECTRE_SYSTEM_EVENT_H
#define SPECTRE_SYSTEM_EVENT_H

#include <Spectre/Input/Mouse.h>
#include <Spectre/Input/Keyboard.h>

namespace sp {

class Display;

struct Event
{
public :

	enum Type {
		None,
		Quit,
		Size,
		Key,
		MouseButton,
		MouseMove
	};

	struct KeyEvent {
		Keyboard::Key	code;
		bool			pressed; /* true if pressed, false if released. */

		std::string	getKeyName() const; /* Get the key name */
	};

	struct MouseButtonEvent {
		Mouse::Button button;
		bool		  pressed; /* true if pressed, false if released. */

		std::string	  getName() const;
	};

	struct MouseMoveEvent {
		unsigned int x;
		unsigned int y;
	};

	struct SizeEvent
	{
		Display *display;
		int width;
		int height;
	};

	Type type;
	union {
		struct SizeEvent 		size;
		struct KeyEvent			key;
		struct MouseMoveEvent	mouseMove;
		struct MouseButtonEvent	mouseButton;
	};

	Event(Type type = None);

	std::string toString() const;

	// Helper methods

	static Event createSize(Display *display, int width, int height);

	static Event createKey(Keyboard::Key code, bool pressed);

	static Event createMouseButton(Mouse::Button button, bool pressed);

	static Event createMouseMove(unsigned int x, unsigned int y);
};

} // namespace sp

#endif /* SPECTRE_SYSTEM_EVENT_H */
